[PATCH] IPv6: Default Route Support on Router

STALE8723d

8 messages, 4 authors, 2002-09-30 · open the first message on its own page

[PATCH] IPv6: Default Route Support on Router

From: YOSHIFUJI Hideaki / 吉藤英明 <hidden>
Date: 2002-09-28 06:14:41

Hello.

When a Linux box is configured as a router (forwarding=1), 
it does not recognize default routes. 

We can't understand why Linux forbid to hold IPv6 default route
other than RA. We think IPv6 routers which use as edge router, not
backbone core router should accept IPv6 default route as default.
Because an edge router which doesn't speak BGP4+ may not have IPv6
full routes.

This patch changes the behavior and respects IPv6 default routes.

Following patch is against linux-2.4.19.

Thank you in advance.

-------------------------------------------------------------------
Patch-Name: Default Route Support on Router
Patch-Id: FIX_2_4_19_RTR_DEFROUTE-20020912
Patch-Author: YOSHIFUJI Hideaki / USAGI Project [off-list ref]
Credit: Yuji SEKIYA / USAGI Project [off-list ref]
-------------------------------------------------------------------
Index: net/ipv6/ip6_fib.c
===================================================================
RCS file: /cvsroot/usagi/usagi-backport/linux24/net/ipv6/ip6_fib.c,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.10.1
diff -u -r1.1.1.1 -r1.1.1.1.10.1
--- net/ipv6/ip6_fib.c	2002/08/20 09:47:02	1.1.1.1
+++ net/ipv6/ip6_fib.c	2002/09/12 01:49:00	1.1.1.1.10.1
@@ -13,6 +13,12 @@
  *      2 of the License, or (at your option) any later version.
  */
 
+/*
+ * 	Changes:
+ * 	Yuji SEKIYA @USAGI:	Support default route on router node;
+ * 				remove ip6_null_entry from the top of
+ * 				routing table.
+ */
 #include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/types.h>
@@ -248,9 +254,6 @@
 
 	fn = root;
 
-	if (plen == 0)
-		return fn;
-
 	do {
 		key = (struct rt6key *)((u8 *)fn->leaf + offset);
 
@@ -427,6 +430,17 @@
 
 	ins = &fn->leaf;
 
+	if (fn->fn_flags&RTN_TL_ROOT &&
+	    fn->leaf == &ip6_null_entry &&
+	    !(rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF | RTF_ALLONLINK)) ){
+		/*
+		 * The top fib of ip6 routing table includes ip6_null_entry.
+		 */
+		fn->leaf = rt;
+		rt->u.next = NULL;
+		goto out;
+	}
+
 	for (iter = fn->leaf; iter; iter=iter->u.next) {
 		/*
 		 *	Search for duplicates
@@ -462,6 +476,7 @@
 	 *	insert node
 	 */
 
+out:
 	rt->u.next = iter;
 	*ins = rt;
 	rt->rt6i_node = fn;
@@ -675,7 +690,7 @@
 
 	fn = fib6_lookup_1(root, args);
 
-	if (fn == NULL)
+	if (fn == NULL || fn->fn_flags & RTN_TL_ROOT)
 		fn = root;
 
 	return fn;
@@ -896,6 +911,9 @@
 	read_unlock(&fib6_walker_lock);
 
 	rt->u.next = NULL;
+
+	if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT)
+		fn->leaf = &ip6_null_entry;
 
 	/* If it was last route, expunge its radix tree node */
 	if (fn->leaf == NULL) {

Re: [PATCH] IPv6: Default Route Support on Router

From: <hidden>
Date: 2002-09-28 20:47:05

Hello!
Following patch is against linux-2.4.19.
OK!


One question, what is this chunk for?
quoted hunk
@@ -675,7 +690,7 @@
 
 	fn = fib6_lookup_1(root, args);
 
-	if (fn == NULL)
+	if (fn == NULL || fn->fn_flags & RTN_TL_ROOT)
 		fn = root;
 
 	return fn;
Alexey

Re: [PATCH] IPv6: Default Route Support on Router

From: David S. Miller <hidden>
Date: 2002-09-29 00:23:06

   From: kuznet@ms2.inr.ac.ru
   Date: Sun, 29 Sep 2002 00:47:05 +0400 (MSD)

   One question, what is this chunk for?

This reminds me, nothing is aparently going to make use
of net/ipv6/ip6_fw.c, it sits unused and untouched for
years, can we just detroy it? :-)

Re: [PATCH] IPv6: Default Route Support on Router

From: Andi Kleen <hidden>
Date: 2002-09-29 02:08:22

On Sat, Sep 28, 2002 at 05:23:06PM -0700, David S. Miller wrote:
   From: kuznet@ms2.inr.ac.ru
   Date: Sun, 29 Sep 2002 00:47:05 +0400 (MSD)

   One question, what is this chunk for?

This reminds me, nothing is aparently going to make use
of net/ipv6/ip6_fw.c, it sits unused and untouched for
years, can we just detroy it? :-)
It never worked correctly and was unfinished. I would destroy it.

-Andi

Re: [PATCH] IPv6: Default Route Support on Router

From: <hidden>
Date: 2002-09-29 02:09:52

Hello!
This reminds me, nothing is aparently going to make use
of net/ipv6/ip6_fw.c, it sits unused and untouched for
years, 
... and unwritten. :-)
can we just detroy it? :-)
Must, I think.

Though with your current mood about per-flow cache the file
could deserve... mmm... post-mortem examination. :-)

Alexey

Re: [PATCH] IPv6: Default Route Support on Router

From: David S. Miller <hidden>
Date: 2002-09-29 06:19:15

   From: kuznet@ms2.inr.ac.ru
   Date: Sun, 29 Sep 2002 06:09:52 +0400 (MSD)

   > can we just detroy it? :-)
   
   Must, I think.
   
   Though with your current mood about per-flow cache the file
   could deserve... mmm... post-mortem examination. :-)

Oh I see... perhaps you imply I should destroy CONFIG_RT6_POLICY
remnants as well? :-)

I think we should, the less clutter when hacking these things
the better.

Re: [PATCH] IPv6: Default Route Support on Router

From: David S. Miller <hidden>
Date: 2002-09-29 06:22:10

   From: kuznet@ms2.inr.ac.ru
   Date: Sun, 29 Sep 2002 00:47:05 +0400 (MSD)

   > Following patch is against linux-2.4.19.
   
   OK!
   
Patch is applied to both 2.4.x and 2.5.x
   
   One question, what is this chunk for?
   
Once this is resolved, please send a patch if necessary.

Re: [PATCH] IPv6: Default Route Support on Router

From: <hidden>
Date: 2002-09-30 14:56:36

Hello!
Oh I see... perhaps you imply I should destroy CONFIG_RT6_POLICY
remnants as well? :-)
Yes, the bits in route.c must be killed.

But I would prefer to preserve subtrees support in ip6_fib.c.
It is... well, it really constrains hacking, but in a useful manner,
not allowing to forget that a radix node may open second level lookup.

Alexey
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help