Commit 03bcefc4 authored by Hideaki Yoshifuji's avatar Hideaki Yoshifuji Committed by David S. Miller

net/ipv6/ip6_fib.c: Default route support on router.

parent 457a6c8c
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
* 2 of the License, or (at your option) any later version. * 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/config.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -248,9 +254,6 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr, ...@@ -248,9 +254,6 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr,
fn = root; fn = root;
if (plen == 0)
return fn;
do { do {
key = (struct rt6key *)((u8 *)fn->leaf + offset); key = (struct rt6key *)((u8 *)fn->leaf + offset);
...@@ -427,6 +430,17 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt) ...@@ -427,6 +430,17 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt)
ins = &fn->leaf; 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) { for (iter = fn->leaf; iter; iter=iter->u.next) {
/* /*
* Search for duplicates * Search for duplicates
...@@ -462,6 +476,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt) ...@@ -462,6 +476,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt)
* insert node * insert node
*/ */
out:
rt->u.next = iter; rt->u.next = iter;
*ins = rt; *ins = rt;
rt->rt6i_node = fn; rt->rt6i_node = fn;
...@@ -675,7 +690,7 @@ struct fib6_node * fib6_lookup(struct fib6_node *root, struct in6_addr *daddr, ...@@ -675,7 +690,7 @@ struct fib6_node * fib6_lookup(struct fib6_node *root, struct in6_addr *daddr,
fn = fib6_lookup_1(root, args); fn = fib6_lookup_1(root, args);
if (fn == NULL) if (fn == NULL || fn->fn_flags & RTN_TL_ROOT)
fn = root; fn = root;
return fn; return fn;
...@@ -897,6 +912,9 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp) ...@@ -897,6 +912,9 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp)
rt->u.next = NULL; 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 it was last route, expunge its radix tree node */
if (fn->leaf == NULL) { if (fn->leaf == NULL) {
fn->fn_flags &= ~RTN_RTINFO; fn->fn_flags &= ~RTN_RTINFO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment