From: ebiederm@xmission.com (Eric W. Biederman)
To: Daniel Lezcano <dlezcano@fr.ibm.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, den@sw.ru,
xemul@openvz.org, containers@lists.osdl.org,
yoshfuji@linux-ipv6.org, Benjamin Thery <benjamin.thery@bull.net>
Subject: Re: [patch 1/1][NETNS][IPV6] protect addrconf from loopback registration
Date: Mon, 12 Nov 2007 09:40:32 -0700 [thread overview]
Message-ID: <m1lk934dtr.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20071112152403.273795630@mai.toulouse-stg.fr.ibm.com> (Daniel Lezcano's message of "Mon, 12 Nov 2007 16:19:54 +0100")
Daniel Lezcano <dlezcano@fr.ibm.com> writes:
> The loopback is now dynamically allocated. The ipv6 code was written
> considering the loopback is allocated before the ipv6 protocol
> initialization. This is still the case when we don't use multiple
> network namespaces.
You do know that register_netdevice_notifier delivers events
REGISTER and UP events for devices that are already up?
Thinking about it I wonder if unregister_netdevice_notifier should
actually deliver UNREGISTER events. It wouldn't change the ipv6
case as I don't believe you can unregister ipv6.
> In the case of the network namespaces, ipv6 notification handler is
> already setup and active (done by the initial network namespace),
> so when a network namespace is created, a new instance of the
> loopback device, via dynamic allocation, will trigger a REGISTER event
> to addrconf_notify and this one will try to setup the network device
> while the ipv6 protocol is not yet initialized for the network namespace.
Ok. This sounds like a race in ipv6 that should get fixed.
I know last time my patchset covered ipv6 I did send patches for several
reference counting problems. I'm surprised something bad still exists.
Anyway let's not patch around this and fix whatever the real problem.
> Because the ipv6 is relying on the fact that the loopback device will
> not trigger REGISTER/UNREGISTER events, I just protect the addrconf_notify
> function when the loopback register event is triggered.
This can't be the case REGISTER events happen.
> In the case of multiple network namespaces, the usual ipv6 protocol
> initialization will be done after the loopback initialization with
> the subsystem registration mechanism.
>
> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
> Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
> ---
> net/ipv6/addrconf.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> Index: linux-2.6-netns/net/ipv6/addrconf.c
> ===================================================================
> --- linux-2.6-netns.orig/net/ipv6/addrconf.c
> +++ linux-2.6-netns/net/ipv6/addrconf.c
> @@ -2272,7 +2272,8 @@ static int addrconf_notify(struct notifi
>
> switch(event) {
> case NETDEV_REGISTER:
> - if (!idev && dev->mtu >= IPV6_MIN_MTU) {
> + if (!(dev->flags & IFF_LOOPBACK) &&
> + !idev && dev->mtu >= IPV6_MIN_MTU) {
> idev = ipv6_add_dev(dev);
> if (!idev)
> return notifier_from_errno(-ENOMEM);
This hunk is clearly bogus.
> @@ -2366,11 +2367,15 @@ static int addrconf_notify(struct notifi
> /* MTU falled under IPV6_MIN_MTU. Stop IPv6 on this
> interface. */
>
> case NETDEV_DOWN:
> + addrconf_ifdown(dev, 0);
> + break;
> +
> case NETDEV_UNREGISTER:
> /*
> * Remove all addresses from this interface.
> */
> - addrconf_ifdown(dev, event != NETDEV_DOWN);
> + if (!(dev->flags & IFF_LOOPBACK))
> + addrconf_ifdown(dev, 1);
I can see how this could be a problem.
> break;
>
> case NETDEV_CHANGENAME:
>
> --
prev parent reply other threads:[~2007-11-12 16:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20071112151953.052335971@mai.toulouse-stg.fr.ibm.com>
2007-11-12 15:19 ` [patch 1/1][NETNS][IPV6] protect addrconf from loopback registration Daniel Lezcano
2007-11-12 16:05 ` Denis V. Lunev
2007-11-12 16:11 ` Daniel Lezcano
2007-11-12 16:49 ` Denis V. Lunev
2007-11-12 16:59 ` Eric W. Biederman
2007-11-12 22:24 ` David Miller
2007-11-13 12:59 ` Eric W. Biederman
[not found] ` <473879C3.5020301-3ImXcnM4P+0@public.gmane.org>
2007-11-12 16:51 ` Eric W. Biederman
2007-11-12 17:01 ` Daniel Lezcano
2007-11-12 19:50 ` Eric W. Biederman
2007-11-13 1:52 ` YOSHIFUJI Hideaki / 吉藤英明
2007-11-13 13:11 ` Eric W. Biederman
2007-11-13 10:55 ` Daniel Lezcano
2007-11-12 21:00 ` Denis V. Lunev
2007-11-12 16:40 ` Eric W. Biederman [this message]
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=m1lk934dtr.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=benjamin.thery@bull.net \
--cc=containers@lists.osdl.org \
--cc=davem@davemloft.net \
--cc=den@sw.ru \
--cc=dlezcano@fr.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=xemul@openvz.org \
--cc=yoshfuji@linux-ipv6.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