All of lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Harald Welte <laforge@gnumonks.org>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>
Subject: Re: loosing netdevices with namespaces and unshare?
Date: Sat, 03 Jun 2017 05:53:48 -0500	[thread overview]
Message-ID: <8760gd735v.fsf@xmission.com> (raw)
In-Reply-To: <CAM_iQpWaJ7WKOEQe=00AX35x_gCKHoHikVTGH6UQTPw+3oD_pw@mail.gmail.com> (Cong Wang's message of "Fri, 2 Jun 2017 16:25:44 -0700")

Cong Wang <xiyou.wangcong@gmail.com> writes:

> On Wed, May 31, 2017 at 11:32 PM, Eric W. Biederman
> <ebiederm@xmission.com> wrote:
>> Cong Wang <xiyou.wangcong@gmail.com> writes:
>>> Network namespace does not special-case the physical devices,
>>> it treats them all equally as abstract net devices.
>>
>> Absolutely not true.
>>
>> The relevant code is in net/core/dev.c:default_device_exit
>>
>> If a network device does not implement rntl_link_ops it is returned to
>> the initial network namespace.   Anything else will loose physical
>> devices.
>
> Hmm, I never noticed that if check...
>
>>
>> Only for pure software based devices do we delete them.  Perhaps your
>> sub interface implements rtnl_link_ops?  Either that or something is
>> still holding a reference to your network namespace, which would prevent
>> the network device from being returned.
>>
>
> But this simply sucks:
>
>                 snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
>                 err = dev_change_net_namespace(dev, &init_net, fb_name);
>                 if (err) {
>                         pr_emerg("%s: failed to move %s to init_net: %d\n",
>                                  __func__, dev->name, err);
>                         BUG();
>                 }
>
> It is essentially hard to handle the error here, but it is quite easy to
> trigger such BUG() by naming other device devX, it is no better
> than just losing it.

The rename only happens if there is a conflicting device name.

Beyond that there is the entire hotplug functionality so it should be
possible to automatically detect a new device in your network namespace
and do something with it.

Eric

  reply	other threads:[~2017-06-03 11:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-30 22:07 loosing netdevices with namespaces and unshare? Harald Welte
2017-05-30 23:18 ` Cong Wang
2017-05-31 12:27   ` Harald Welte
2017-05-31 17:44     ` Cong Wang
2017-05-31 18:11       ` Harald Welte
2017-05-31 22:40         ` Cong Wang
2017-05-31 23:13           ` Harald Welte
2017-06-01  6:32       ` Eric W. Biederman
2017-06-01  7:00         ` Harald Welte
2017-06-01  7:48           ` Eric W. Biederman
2017-06-02 23:25         ` Cong Wang
2017-06-03 10:53           ` Eric W. Biederman [this message]
2017-05-30 23:41 ` David Ahern

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=8760gd735v.fsf@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=laforge@gnumonks.org \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    /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.