From: Sabrina Dubroca <sd@queasysnail.net>
To: Alexander Duyck <alexander.h.duyck@redhat.com>
Cc: netdev@vger.kernel.org
Subject: ipv4 route dump broken with multiple subnets
Date: Tue, 10 Mar 2015 18:07:46 +0100 [thread overview]
Message-ID: <20150310170746.GA1743@kria> (raw)
With this setup (no other address assigned):
ip link add type dummy
ip link set dummy0 up
ip a a 10.0.0.1/24 dev dummy0
route dump works:
# ip r
10.0.0.0/24 dev dummy0 proto kernel scope link src 10.0.0.1
If I add another address:
ip a a 10.0.1.1/24 dev dummy0
or a route:
ip r a 10.0.1.0/24 via 10.0.0.2
# ip r
<empty>
It's the same with /proc/net/route instead of ip route.
But with a default route the table appears again.
This patch seems to fix the problem, but I'm not sure it is correct.
---
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 90955455884e..418043dc3a12 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1767,6 +1767,11 @@ int fib_table_dump(struct fib_table *tb, struct sk_buff *skb,
*/
int count = cb->args[2];
t_key key = cb->args[3];
+ if (!key) {
+ struct key_vector *n = get_child_rcu(tp, 0);
+ if (n)
+ key = n->key;
+ }
while ((l = leaf_walk_rcu(&tp, key)) != NULL) {
if (fn_trie_dump_leaf(l, tb, skb, cb) < 0) {
@@ -2276,10 +2281,12 @@ static struct key_vector *fib_route_get_idx(struct fib_route_iter *iter,
pos -= iter->pos;
key = iter->key;
} else {
+ struct key_vector *n;
t = (struct trie *)tb->tb_data;
iter->tnode = t->kv;
iter->pos = 0;
- key = 0;
+ n = rcu_dereference(t->kv->tnode[0]);
+ key = n ? n->key : 0;
}
while ((l = leaf_walk_rcu(tp, key)) != NULL) {
@@ -2308,6 +2315,7 @@ static void *fib_route_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(RCU)
{
struct fib_route_iter *iter = seq->private;
+ struct key_vector *n;
struct fib_table *tb;
struct trie *t;
@@ -2323,9 +2331,15 @@ static void *fib_route_seq_start(struct seq_file *seq, loff_t *pos)
return fib_route_get_idx(iter, *pos);
t = (struct trie *)tb->tb_data;
- iter->tnode = t->kv;
+ n = rcu_dereference(t->kv->tnode[0]);
+ if (IS_TNODE(n)) {
+ iter->tnode = n;
+ iter->key = n->key;
+ } else {
+ iter->tnode = t->kv;
+ iter->key = 0;
+ }
iter->pos = 0;
- iter->key = 0;
return SEQ_START_TOKEN;
}
next reply other threads:[~2015-03-10 17:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-10 17:07 Sabrina Dubroca [this message]
2015-03-10 17:37 ` ipv4 route dump broken with multiple subnets Alexander Duyck
2015-03-10 18:25 ` [net-next PATCH] fib_trie: Correctly handle case of key == 0 in leaf_walk_rcu Alexander Duyck
2015-03-10 18:48 ` Sabrina Dubroca
2015-03-10 20:14 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150310170746.GA1743@kria \
--to=sd@queasysnail.net \
--cc=alexander.h.duyck@redhat.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.