Subject: Re: PMTUD: notification on PMTUD route timeout
To: None <tech-net@netbsd.org>
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
List: tech-net
Date: 05/28/2002 17:48:27
	i think this should do the trick (RTF_UP will be cleared on RTM_DELETE
	on PMTUD route).  any opinions?

itojun



Index: netinet/in_pcb.c
===================================================================
RCS file: /cvsroot/syssrc/sys/netinet/in_pcb.c,v
retrieving revision 1.75
diff -u -r1.75 in_pcb.c
--- netinet/in_pcb.c	2002/03/08 20:48:43	1.75
+++ netinet/in_pcb.c	2002/05/28 08:47:48
@@ -833,11 +833,15 @@
 
 	ro = &inp->inp_route;
 
-	if (ro->ro_rt == NULL) {
+	if (ro->ro_rt == NULL || (ro->ro_rt->rt_flags & RTF_UP) == 0) {
 		/*
 		 * No route yet, so try to acquire one.
 		 */
 		if (!in_nullhost(inp->inp_faddr)) {
+			if (ro->ro_rt) {
+				RTFREE(ro->ro_rt);
+				ro->ro_rt = (struct rtentry *)NULL;
+			}
 			bzero(&ro->ro_dst, sizeof(struct sockaddr_in));
 			ro->ro_dst.sa_family = AF_INET;
 			ro->ro_dst.sa_len = sizeof(ro->ro_dst);
Index: netinet6/in6_pcb.c
===================================================================
RCS file: /cvsroot/syssrc/sys/netinet6/in6_pcb.c,v
retrieving revision 1.46
diff -u -r1.46 in6_pcb.c
--- netinet6/in6_pcb.c	2002/03/21 02:11:39	1.46
+++ netinet6/in6_pcb.c	2002/05/28 08:47:49
@@ -834,11 +834,16 @@
 	ro = &in6p->in6p_route;
 	dst6 = (struct sockaddr_in6 *)&ro->ro_dst;
 
-	if (ro->ro_rt == NULL) {
+	if (ro->ro_rt == NULL || (ro->ro_rt->rt_flags & RTF_UP) == 0 ||
+	    dst6->sin6_family != AF_INET6) {
 		/*
 		 * No route yet, so try to acquire one.
 		 */
 		if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
+			if (ro->ro_rt) {
+				RTFREE(ro->ro_rt);
+				ro->ro_rt = (struct rtentry *)NULL;
+			}
 			bzero(dst6, sizeof(*dst6));
 			dst6->sin6_family = AF_INET6;
 			dst6->sin6_len = sizeof(struct sockaddr_in6);