From: Daniel Lezcano <daniel.lezcano-GANU6spQydw@public.gmane.org>
To: nicolas.dichtel-rosZqcz4S8v2eFz/2MeuCQ@public.gmane.org
Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
"Eric W. Biederman"
<ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>,
David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Subject: Re: [PATCH] netns: remove useless synchronize_net()
Date: Sun, 15 Feb 2009 17:13:01 +0100 [thread overview]
Message-ID: <49983F0D.2090905@free.fr> (raw)
In-Reply-To: <49943C17.5080509-GANU6spQydw@public.gmane.org>
Daniel Lezcano wrote:
> Eric W. Biederman wrote:
>
>> Daniel Lezcano <daniel.lezcano-GANU6spQydw@public.gmane.org> writes:
>>
>>
>>
>>> Eric W. Biederman wrote:
>>>
>>>
>>>> Daniel Lezcano <daniel.lezcano-GANU6spQydw@public.gmane.org> writes:
>>>>
>>>>
>>>>
>>>>> Hmm, at the first glance I would say it is useless but perhaps there is a
>>>>>
>>>>>
>>> trick
>>>
>>>
>>>>> here I do not understand.
>>>>> Eric, is there any particular reason to call synchronize_net before exiting
>>>>>
>>>>>
>>> the
>>>
>>>
>>>>> dev_change_net_namespace function ?
>>>>>
>>>>>
>>>>>
>>>> I haven't thought about that part of the code path in detail in a long
>>>> time. dev_change_net_namespace() is a condensed version of
>>>> register_netdevice() unregister_netdevice(). With the calls down into
>>>> the driver removed.
>>>>
>>>> On a side note. It looks like we now cope with:
>>>> call_netdevice_notifiers(NETDEV_REGISTER, dev); failing in
>>>> register_netdev, but no one updated dev_change_net_namespace to handle
>>>> the change, looks like a real pain to cope with.
>>>>
>>>> As for the synchronize_net, and in response to the original
>>>> comment as best as I can tell we do have things being being
>>>> deleted that are at least candidates for synchronize_net.
>>>>
>>>> dev_addr_discard(dev);
>>>> dev_net_set(dev, net);
>>>> netdev_unregister_kobject(dev);
>>>>
>>>> We very much do access dev->net with only rcu protection.
>>>>
>>>> Hmm.
>>>>
>>>> It looks like I originally took the second synchronize_net from what
>>>> became rollback_registered, which happens just before we start freeing
>>>> the netdevice.
>>>>
>>>> The nastiest case that I can envision is if we happen to receive a
>>>> packet (on another cpu) for the network device that we are moving,
>>>> just after it has registered in the new network namespace. If we read
>>>> the old network namespace and forward it up the network stack in that
>>>> context I can imagine it being a recipe for all kinds of strange
>>>> non-deterministic behavior.
>>>>
>>>>
>>>>
>>> The code does:
>>>
>>> dev_close
>>> dev_deactive
>>> synchronize_rcu
>>> synchronize_net
>>> ...
>>> dev_shutdown
>>> ...
>>> synchronize_net
>>>
>>> The network device can no longer receive packets after dev_deactive, no ?
>>> The first synchronize_net will wait for the outstanding packets to be delivered
>>> to the upper layer and we change the nd_net field after.
>>> Your scenario makes sense for the first synchronize_net but I am not sure that
>>> can happen if we remove the second synchronize_net.
>>>
>>>
>> Good point. Visibility is key. What can find us after we
>> call list_netdevice() ? Aren't there some pieces of code that
>> do for_each_netdevice under the rcu lock?
>>
>>
> AFAIR, no. for_each_netdev is protected by rtnl_lock.
>
Nicolas,
At the first glance it looks like the removing of the second
synchronize_net is fine, but before posting the patch do you mind to
wait a little ?
I would like to do some tests with your patch to check if we don't
missed something.
Thanks
-- Daniel
next prev parent reply other threads:[~2009-02-15 16:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-05 10:21 [PATCH] netns: remove useless synchronize_net() Nicolas Dichtel
2009-02-06 7:45 ` David Miller
2009-02-06 13:50 ` Nicolas Dichtel
2009-02-06 22:10 ` David Miller
2009-02-10 15:40 ` Nicolas Dichtel
2009-02-10 16:40 ` Daniel Lezcano
2009-02-10 16:48 ` Nicolas Dichtel
2009-02-10 17:13 ` Daniel Lezcano
2009-02-11 7:51 ` Eric W. Biederman
2009-02-11 15:49 ` Daniel Lezcano
2009-02-11 23:03 ` Eric W. Biederman
2009-02-12 15:11 ` Daniel Lezcano
[not found] ` <49943C17.5080509-GANU6spQydw@public.gmane.org>
2009-02-15 16:13 ` Daniel Lezcano [this message]
[not found] ` <49983F0D.2090905-GANU6spQydw@public.gmane.org>
2009-02-16 13:46 ` Nicolas Dichtel
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=49983F0D.2090905@free.fr \
--to=daniel.lezcano-ganu6spqydw@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nicolas.dichtel-rosZqcz4S8v2eFz/2MeuCQ@public.gmane.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;
as well as URLs for NNTP newsgroup(s).