Date: Tue, 30 Oct 2007 01:51:28 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 128316 for review Message-ID: <200710300151.l9U1pSrh087621@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=128316 Change 128316 by kmacy@kmacy:storage:toestack on 2007/10/30 01:50:45 add eventhandlers for pmtu changes and redirects Affected files ... .. //depot/projects/toestack/sys/net/route.c#5 edit .. //depot/projects/toestack/sys/net/route.h#5 edit .. //depot/projects/toestack/sys/netinet/ip_icmp.c#4 edit Differences ... ==== //depot/projects/toestack/sys/net/route.c#5 (text+ko) ==== @@ -496,9 +496,11 @@ info.rti_ifa = ifa; info.rti_flags = flags; rt = NULL; + error = rtrequest1(RTM_ADD, &info, &rt); if (rt != NULL) { RT_LOCK(rt); + EVENTHANDLER_INVOKE(route_event, RTEVENT_REDIRECT_UPDATE, rt); flags = rt->rt_flags; } stat = &rtstat.rts_dynamic; @@ -514,6 +516,7 @@ * add the key and gateway (in one malloc'd chunk). */ rt_setgate(rt, rt_key(rt), gateway); + EVENTHANDLER_INVOKE(route_event, RTEVENT_REDIRECT_UPDATE, rt); } } else error = EHOSTUNREACH; ==== //depot/projects/toestack/sys/net/route.h#5 (text+ko) ==== @@ -367,7 +367,9 @@ #include <sys/eventhandler.h> -#define RTEVENT_ARP_UPDATE 1 +#define RTEVENT_ARP_UPDATE 1 +#define RTEVENT_PMTU_UPDATE 2 +#define RTEVENT_REDIRECT_UPDATE 3 typedef void (*rtevent_fn)(void *, int, struct rtentry *); EVENTHANDLER_DECLARE(route_event, rtevent_fn); ==== //depot/projects/toestack/sys/netinet/ip_icmp.c#4 (text+ko) ==== @@ -136,6 +136,33 @@ extern struct protosw inetsw[]; +static void +rt_mtu_update(struct sockaddr *icmpsrc, struct icmp *icp) +{ + struct rtentry *rt; + int mtu; + + rt = rtalloc1(icmpsrc, 0, RTF_CLONING); + if (rt && (rt->rt_flags & RTF_HOST)) { + mtu = ntohs(icp->icmp_nextmtu); + if (!mtu) + mtu = ip_next_mtu(rt->rt_rmx.rmx_mtu, + 1); +#ifdef DEBUG_MTUDISC + printf("MTU for %s reduced to %d\n", + inet_ntoa(icmpsrc.sin_addr), mtu); +#endif + if (mtu >= 296 && rt->rt_rmx.rmx_mtu > mtu) { + rt->rt_rmx.rmx_mtu = mtu; + EVENTHANDLER_INVOKE(route_event, RTEVENT_PMTU_UPDATE, rt); + } + } + if (rt) + RTFREE(rt); +} + + + /* * Generate an error packet of type error * in response to bad packet ip. @@ -442,6 +469,11 @@ #endif icmpsrc.sin_addr = icp->icmp_ip.ip_dst; /* + * Update the route directly for use by protocol offload + */ + if (code == PRC_MSGSIZE) + rt_mtu_update((struct sockaddr *)&icmpsrc, icp); + /* * XXX if the packet contains [IPv4 AH TCP], we can't make a * notification to TCP layer. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200710300151.l9U1pSrh087621>