提交 9f0d3c27 编写于 作者: E Eric Dumazet 提交者: David S. Miller

ipv6: addrconf: fix /proc/net/if_inet6

Commit 1d578303 (ipv6/addrconf: speedup /proc/net/if_inet6 filling)
added bugs hiding some devices from if_inet6 and breaking applications.

"ip -6 addr" could still display all IPv6 addresses, while "ifconfig -a"
couldnt.

One way to reproduce the bug is by starting in a shell :

unshare -n /bin/bash
ifconfig lo up

And in original net namespace, lo device disappeared from if_inet6
Reported-by: NJan Hinnerk Stosch <janhinnerk.stosch@gmail.com>
Tested-by: NJan Hinnerk Stosch <janhinnerk.stosch@gmail.com>
Signed-off-by: NEric Dumazet <edumazet@google.com>
Cc: Mihai Maruseac <mihai.maruseac@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 2384d6aa
...@@ -3064,13 +3064,14 @@ static struct inet6_ifaddr *if6_get_first(struct seq_file *seq, loff_t pos) ...@@ -3064,13 +3064,14 @@ static struct inet6_ifaddr *if6_get_first(struct seq_file *seq, loff_t pos)
struct hlist_node *n; struct hlist_node *n;
hlist_for_each_entry_rcu_bh(ifa, n, &inet6_addr_lst[state->bucket], hlist_for_each_entry_rcu_bh(ifa, n, &inet6_addr_lst[state->bucket],
addr_lst) { addr_lst) {
if (!net_eq(dev_net(ifa->idev->dev), net))
continue;
/* sync with offset */ /* sync with offset */
if (p < state->offset) { if (p < state->offset) {
p++; p++;
continue; continue;
} }
state->offset++; state->offset++;
if (net_eq(dev_net(ifa->idev->dev), net))
return ifa; return ifa;
} }
...@@ -3089,8 +3090,9 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq, ...@@ -3089,8 +3090,9 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq,
struct hlist_node *n = &ifa->addr_lst; struct hlist_node *n = &ifa->addr_lst;
hlist_for_each_entry_continue_rcu_bh(ifa, n, addr_lst) { hlist_for_each_entry_continue_rcu_bh(ifa, n, addr_lst) {
if (!net_eq(dev_net(ifa->idev->dev), net))
continue;
state->offset++; state->offset++;
if (net_eq(dev_net(ifa->idev->dev), net))
return ifa; return ifa;
} }
...@@ -3098,8 +3100,9 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq, ...@@ -3098,8 +3100,9 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq,
state->offset = 0; state->offset = 0;
hlist_for_each_entry_rcu_bh(ifa, n, hlist_for_each_entry_rcu_bh(ifa, n,
&inet6_addr_lst[state->bucket], addr_lst) { &inet6_addr_lst[state->bucket], addr_lst) {
if (!net_eq(dev_net(ifa->idev->dev), net))
continue;
state->offset++; state->offset++;
if (net_eq(dev_net(ifa->idev->dev), net))
return ifa; return ifa;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册