[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>
This commit is contained in:
parent
a21b069626
commit
6640e69731
|
@ -1989,6 +1989,10 @@ static struct node *fib_trie_get_next(struct fib_trie_iter *iter)
|
||||||
unsigned cindex = iter->index;
|
unsigned cindex = iter->index;
|
||||||
struct tnode *p;
|
struct tnode *p;
|
||||||
|
|
||||||
|
/* A single entry routing table */
|
||||||
|
if (!tn)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
pr_debug("get_next iter={node=%p index=%d depth=%d}\n",
|
pr_debug("get_next iter={node=%p index=%d depth=%d}\n",
|
||||||
iter->tnode, iter->index, iter->depth);
|
iter->tnode, iter->index, iter->depth);
|
||||||
rescan:
|
rescan:
|
||||||
|
@ -2037,11 +2041,18 @@ static struct node *fib_trie_get_first(struct fib_trie_iter *iter,
|
||||||
if(!iter)
|
if(!iter)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (n && IS_TNODE(n)) {
|
if (n) {
|
||||||
iter->tnode = (struct tnode *) n;
|
if (IS_TNODE(n)) {
|
||||||
iter->trie = t;
|
iter->tnode = (struct tnode *) n;
|
||||||
iter->index = 0;
|
iter->trie = t;
|
||||||
iter->depth = 1;
|
iter->index = 0;
|
||||||
|
iter->depth = 1;
|
||||||
|
} else {
|
||||||
|
iter->tnode = NULL;
|
||||||
|
iter->trie = t;
|
||||||
|
iter->index = 0;
|
||||||
|
iter->depth = 0;
|
||||||
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue