cvs commit: src/sys/netinet in_gif.c

Ruslan Ermilov ru at freebsd.org
Mon Dec 6 14:43:43 PST 2004


On Mon, Dec 06, 2004 at 07:02:43PM +0000, Gleb Smirnoff wrote:
> glebius     2004-12-06 19:02:43 UTC
> 
>   FreeBSD src repository
> 
>   Modified files:
>     sys/netinet          in_gif.c 
>   Log:
>   - Make route cacheing optional, configurable via IFF_LINK0 flag.
>   - Turn it off by default.
>   
>   Requested by:   many
>   Reviewed by:    andre
>   Approved by:    julian (mentor)
>   MFC after:      3 days
>   
>   Revision  Changes    Path
>   1.27      +6 -0      src/sys/netinet/in_gif.c
> 
This looks suboptimal.  In the !IFF_LINK0 case, I suggest
not messing with sc->gif_ro at all and passing ip_output()
a NULL route pointer.  Loop detection here is incomplete,
and the correct detection is already done in if_gif.c.
Other route checks just duplicate existing functionality.

By the way, I have a WIP (attached) that adds versioning
to the routing table.  Whenever a routing table is altered,
the version is bumped.  The primary intent is for cached
routes, and it was invented specifically to address this
gif(4) problem, but also the remnants of PR kern/10778.


Cheers,
-- 
Ruslan Ermilov
ru at FreeBSD.org
FreeBSD committer
-------------- next part --------------
Index: radix.c
===================================================================
RCS file: /home/ncvs/src/sys/net/radix.c,v
retrieving revision 1.36
diff -u -p -r1.36 radix.c
--- radix.c	21 Apr 2004 15:27:36 -0000	1.36
+++ radix.c	30 Nov 2004 11:54:36 -0000
@@ -714,8 +714,10 @@ rn_addroute(v_arg, n_arg, head, treenode
 	}
 on2:
 	/* Add new route to highest possible ancestor's list */
-	if ((netmask == 0) || (b > t->rn_bit ))
+	if ((netmask == 0) || (b > t->rn_bit )) {
+		head->version++;
 		return tt; /* can't lift at all */
+	}
 	b_leaf = tt->rn_bit;
 	do {
 		x = t;
@@ -737,6 +739,7 @@ on2:
 			if (tt->rn_flags & RNF_NORMAL) {
 			    log(LOG_ERR,
 			        "Non-unique normal route, mask not entered\n");
+				head->version++;
 				return tt;
 			}
 		} else
@@ -744,6 +747,7 @@ on2:
 		if (mmask == netmask) {
 			m->rm_refs++;
 			tt->rn_mklist = m;
+			head->version++;
 			return tt;
 		}
 		if (rn_refines(netmask, mmask)
@@ -751,6 +755,7 @@ on2:
 			break;
 	}
 	*mp = rn_new_radix_mask(tt, *mp);
+	head->version++;
 	return tt;
 }
 
@@ -936,6 +941,7 @@ on1:
 out:
 	tt->rn_flags &= ~RNF_ACTIVE;
 	tt[1].rn_flags &= ~RNF_ACTIVE;
+	head->version++;
 	return (tt);
 }
 
Index: radix.h
===================================================================
RCS file: /home/ncvs/src/sys/net/radix.h,v
retrieving revision 1.25
diff -u -p -r1.25 radix.h
--- radix.h	18 Apr 2004 11:48:35 -0000	1.25
+++ radix.h	30 Nov 2004 11:45:10 -0000
@@ -132,6 +132,7 @@ struct radix_node_head {
 	struct	radix_node rnh_nodes[3];	/* empty tree for common case */
 #ifdef _KERNEL
 	struct	mtx rnh_mtx;			/* locks entire radix tree */
+	int	version;
 #endif
 };
 
Index: route.c
===================================================================
RCS file: /home/ncvs/src/sys/net/route.c,v
retrieving revision 1.107
diff -u -p -r1.107 route.c
--- route.c	21 Aug 2004 17:38:57 -0000	1.107
+++ route.c	30 Nov 2004 12:03:41 -0000
@@ -106,15 +106,18 @@ rtalloc(struct route *ro)
 void
 rtalloc_ign(struct route *ro, u_long ignore)
 {
+	struct radix_node_head *rnh = rt_tables[ro->ro_dst.sa_family];
 	struct rtentry *rt;
 
 	if ((rt = ro->ro_rt) != NULL) {
-		if (rt->rt_ifp != NULL && rt->rt_flags & RTF_UP)
+		if (rt->rt_ifp != NULL && rt->rt_flags & RTF_UP &&
+		    ro->version == rnh->version)
 			return;
 		RTFREE(rt);
 		ro->ro_rt = NULL;
 	}
 	ro->ro_rt = rtalloc1(&ro->ro_dst, 1, ignore);
+	ro->version = rnh->version;
 	if (ro->ro_rt)
 		RT_UNLOCK(ro->ro_rt);
 }
Index: route.h
===================================================================
RCS file: /home/ncvs/src/sys/net/route.h,v
retrieving revision 1.62
diff -u -p -r1.62 route.h
--- route.h	5 Oct 2004 19:48:33 -0000	1.62
+++ route.h	30 Nov 2004 12:05:12 -0000
@@ -47,6 +47,7 @@
  */
 struct route {
 	struct	rtentry *ro_rt;
+	int	version;
 	struct	sockaddr ro_dst;
 };
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/cvs-src/attachments/20041207/ddd26a7f/attachment.bin


More information about the cvs-src mailing list