public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Jan Hinnerk Stosch <janhinnerk.stosch@gmail.com>,
	David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Mihai Maruseac <mihai.maruseac@gmail.com>
Subject: [PATCH] ipv6: addrconf: fix /proc/net/if_inet6
Date: Tue, 16 Oct 2012 19:37:27 +0200	[thread overview]
Message-ID: <1350409047.3954.1295.camel@edumazet-glaptop> (raw)
In-Reply-To: <1350406522.3954.1242.camel@edumazet-glaptop>

From: Eric Dumazet <edumazet@google.com>

Commit 1d5783030a1 (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: Jan Hinnerk Stosch <janhinnerk.stosch@gmail.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Mihai Maruseac <mihai.maruseac@gmail.com>
---
Please Jan test following fix, thanks !

 net/ipv6/addrconf.c |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index d7c56f8..0424e4e 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3064,14 +3064,15 @@ static struct inet6_ifaddr *if6_get_first(struct seq_file *seq, loff_t pos)
 		struct hlist_node *n;
 		hlist_for_each_entry_rcu_bh(ifa, n, &inet6_addr_lst[state->bucket],
 					 addr_lst) {
+			if (!net_eq(dev_net(ifa->idev->dev), net))
+				continue;
 			/* sync with offset */
 			if (p < state->offset) {
 				p++;
 				continue;
 			}
 			state->offset++;
-			if (net_eq(dev_net(ifa->idev->dev), net))
-				return ifa;
+			return ifa;
 		}
 
 		/* prepare for next bucket */
@@ -3089,18 +3090,20 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq,
 	struct hlist_node *n = &ifa->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++;
-		if (net_eq(dev_net(ifa->idev->dev), net))
-			return ifa;
+		return ifa;
 	}
 
 	while (++state->bucket < IN6_ADDR_HSIZE) {
 		state->offset = 0;
 		hlist_for_each_entry_rcu_bh(ifa, n,
 				     &inet6_addr_lst[state->bucket], addr_lst) {
+			if (!net_eq(dev_net(ifa->idev->dev), net))
+				continue;
 			state->offset++;
-			if (net_eq(dev_net(ifa->idev->dev), net))
-				return ifa;
+			return ifa;
 		}
 	}
 

  reply	other threads:[~2012-10-16 17:37 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-14 15:38 regression when connecting to ipv6 localhost Jan Hinnerk Stosch
2012-10-14 19:29 ` Eric Dumazet
2012-10-14 19:48   ` Jan Hinnerk Stosch
2012-10-14 19:54     ` Eric Dumazet
2012-10-14 19:57       ` Jan Hinnerk Stosch
2012-10-14 20:25         ` Eric Dumazet
2012-10-14 20:26           ` Eric Dumazet
2012-10-14 20:28             ` Eric Dumazet
2012-10-14 20:39               ` Jan Hinnerk Stosch
2012-10-14 20:45                 ` Eric Dumazet
2012-10-14 20:47                   ` Eric Dumazet
2012-10-14 20:56                     ` Jan Hinnerk Stosch
2012-10-14 21:02                       ` Eric Dumazet
2012-10-14 21:07                 ` Eric Dumazet
2012-10-14 21:21                   ` Jan Hinnerk Stosch
2012-10-14 21:35                     ` Eric Dumazet
2012-10-14 21:54                       ` Jan Hinnerk Stosch
2012-10-14 22:01                         ` Eric Dumazet
2012-10-14 22:11                           ` Jan Hinnerk Stosch
2012-10-15  5:42                             ` Eric Dumazet
2012-10-15  7:03                               ` Jan Hinnerk Stosch
2012-10-15  7:14                               ` Joe Perches
2012-10-15  7:39                                 ` Eric Dumazet
2012-10-15  7:43                                   ` Eric Dumazet
2012-10-15 11:25                                   ` Joe Perches
2012-10-15 12:31                                     ` Eric Dumazet
2012-10-15 13:10                                       ` Jan Hinnerk Stosch
2012-10-15 13:21                                         ` Eric Dumazet
2012-10-15 13:28                                           ` Jan Hinnerk Stosch
2012-10-16 16:07                                             ` Jan Hinnerk Stosch
2012-10-16 16:43                                               ` Eric Dumazet
2012-10-16 16:55                                                 ` Eric Dumazet
2012-10-16 17:37                                                   ` Eric Dumazet [this message]
2012-10-16 18:30                                                     ` [PATCH] ipv6: addrconf: fix /proc/net/if_inet6 Jan Hinnerk Stosch
2012-10-16 18:39                                                       ` David Miller
2012-10-16 22:01                                                       ` Joe Perches
2012-10-16 18:55                                                     ` David Miller
2012-10-15  9:25                               ` regression when connecting to ipv6 localhost Eric Dumazet
2012-10-15 10:32                                 ` Jan Hinnerk Stosch
2012-10-15  9:07                         ` Jan Ceuleers

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=1350409047.3954.1295.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=janhinnerk.stosch@gmail.com \
    --cc=mihai.maruseac@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox