aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_trie.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-01-24 17:42:04 -0500
committerDavid S. Miller <davem@davemloft.net>2007-01-24 17:42:04 -0500
commit6640e69731b42fd5e3d2b26201c8b34fc897a0ee (patch)
tree903302427bccceaea7bfd3b90b4d0a05c7f5638b /net/ipv4/fib_trie.c
parenta21b0696261c2865d329afa4156ce15fcdf5e772 (diff)
[IPV4]: Fix the fib trie iterator to work with a single entry routing tables
In a kernel with trie routing enabled I had a simple routing setup with only a single route to the outside world and no default route. "ip route table list main" showed my the route just fine but /proc/net/route was an empty file. What was going on? Thinking it was a bug in something I did and I looked deeper. Eventually I setup a second route and everything looked correct, huh? Finally I realized that the it was just the iterator pair in fib_trie_get_first, fib_trie_get_next just could not handle a routing table with a single entry. So to save myself and others further confusion, here is a simple fix for the fib proc iterator so it works even when there is only a single route in a routing table. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Robert Olsson <robert.olsson@its.uu.se> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/fib_trie.c')
-rw-r--r--net/ipv4/fib_trie.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index cfb249cc0a58..13307c04d5a1 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1989,6 +1989,10 @@ static struct node *fib_trie_get_next(struct fib_trie_iter *iter)
1989 unsigned cindex = iter->index; 1989 unsigned cindex = iter->index;
1990 struct tnode *p; 1990 struct tnode *p;
1991 1991
1992 /* A single entry routing table */
1993 if (!tn)
1994 return NULL;
1995
1992 pr_debug("get_next iter={node=%p index=%d depth=%d}\n", 1996 pr_debug("get_next iter={node=%p index=%d depth=%d}\n",
1993 iter->tnode, iter->index, iter->depth); 1997 iter->tnode, iter->index, iter->depth);
1994rescan: 1998rescan:
@@ -2037,11 +2041,18 @@ static struct node *fib_trie_get_first(struct fib_trie_iter *iter,
2037 if(!iter) 2041 if(!iter)
2038 return NULL; 2042 return NULL;
2039 2043
2040 if (n && IS_TNODE(n)) { 2044 if (n) {
2041 iter->tnode = (struct tnode *) n; 2045 if (IS_TNODE(n)) {
2042 iter->trie = t; 2046 iter->tnode = (struct tnode *) n;
2043 iter->index = 0; 2047 iter->trie = t;
2044 iter->depth = 1; 2048 iter->index = 0;
2049 iter->depth = 1;
2050 } else {
2051 iter->tnode = NULL;
2052 iter->trie = t;
2053 iter->index = 0;
2054 iter->depth = 0;
2055 }
2045 return n; 2056 return n;
2046 } 2057 }
2047 return NULL; 2058 return NULL;