PERFORCE change 127291 for review

Kip Macy kmacy at FreeBSD.org
Sun Oct 7 14:54:51 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=127291

Change 127291 by kmacy at kmacy_home:ethng on 2007/10/07 21:54:41

	mark deleted rtentry as expired so that any inpcbs referencing it
	will free their reference and look it up again

Affected files ...

.. //depot/projects/ethng/src/sys/net/route.c#7 edit
.. //depot/projects/ethng/src/sys/netinet/tcp_output.c#4 edit
.. //depot/projects/ethng/src/sys/netinet/udp_usrreq.c#5 edit

Differences ...

==== //depot/projects/ethng/src/sys/net/route.c#7 (text+ko) ====

@@ -861,7 +861,12 @@
 		 * when RTFREE(rt) is eventually called.
 		 */
 		rttrash++;
-
+		/*
+		 * If inpcbs hold a reference to this route
+		 * they need to be notified that it is no longer valid
+		 */
+		rt->rt_rmx.rmx_expire = time_uptime;
+		
 		/*
 		 * If the caller wants it, then it can have it,
 		 * but it's up to it to free the rtentry as we won't be

==== //depot/projects/ethng/src/sys/netinet/tcp_output.c#4 (text+ko) ====

@@ -43,6 +43,7 @@
 #include <sys/lock.h>
 #include <sys/mbuf.h>
 #include <sys/mutex.h>
+#include <sys/rwlock.h>
 #include <sys/protosw.h>
 #include <sys/socket.h>
 #include <sys/socketvar.h>
@@ -141,6 +142,7 @@
 	struct sackhole *p;
 	int tso = 0;
 	struct tcpopt to;
+	struct rtentry *rt;
 #if 0
 	int maxburst = TCP_MAXBURST;
 #endif
@@ -1123,9 +1125,10 @@
 	if (path_mtu_discovery)
 		ip->ip_off |= IP_DF;
 	/*
-	 * XXX need to validate
-	 */ 
-	if (inp->inp_route.ro_rt == NULL) {
+	 * XXX timer wrap?
+	 */
+	rt = inp->inp_route.ro_rt;
+	if (rt == NULL || (rt && rt->rt_rmx.rmx_expire && (rt->rt_rmx.rmx_expire <= time_uptime))) {
 		struct sockaddr_in *dst =  (struct sockaddr_in *)&inp->inp_route.ro_dst;
 		struct ip *ip = mtod(m, struct ip *);
 		
@@ -1133,7 +1136,10 @@
 		dst->sin_family = AF_INET;
 		dst->sin_len = sizeof(*dst);
 		dst->sin_addr = ip->ip_dst;
-		
+		if (rt) {
+			RTFREE(rt);
+			inp->inp_route.ro_rt = NULL;
+		}
 		rtalloc_ign(&inp->inp_route, 0);
 	}
 

==== //depot/projects/ethng/src/sys/netinet/udp_usrreq.c#5 (text+ko) ====

@@ -767,7 +767,8 @@
 	int ipflags;
 	u_short fport, lport;
 	int unlock_udbinfo;
-
+	struct rtentry *rt;
+	
 	/*
 	 * udp_output() may need to temporarily bind or connect the current
 	 * inpcb.  As such, we don't know up front whether we will need the
@@ -969,9 +970,10 @@
 		INP_INFO_WUNLOCK(&udbinfo);
 
 	/*
-	 * XXX need to validate
+	 * XXX timer wrap?
 	 */
-	if (inp->inp_route.ro_rt == NULL) {
+	rt = inp->inp_route.ro_rt;
+	if (rt == NULL || (rt && rt->rt_rmx.rmx_expire && (rt->rt_rmx.rmx_expire <= time_uptime))) {
 		struct sockaddr_in *dst =  (struct sockaddr_in *)&inp->inp_route.ro_dst;
 		struct ip *ip = mtod(m, struct ip *);
 		
@@ -979,9 +981,15 @@
 		dst->sin_family = AF_INET;
 		dst->sin_len = sizeof(*dst);
 		dst->sin_addr = ip->ip_dst;
-		
+		if (rt) {
+			RTFREE(rt);
+			inp->inp_route.ro_rt = NULL;
+		}
 		rtalloc_ign(&inp->inp_route, 0);
-	}
+	} 
+
+	
+	
 	m->m_pkthdr.rss_hash = inp->inp_rss_hash;
 	error = ip_output(m, inp->inp_options, &inp->inp_route, ipflags,
 	    inp->inp_moptions, inp);


More information about the p4-projects mailing list