All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Harald Welte <laforge@gnumonks.org>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>
Subject: Re: loosing netdevices with namespaces and unshare?
Date: Tue, 30 May 2017 16:18:17 -0700	[thread overview]
Message-ID: <CAM_iQpW2ARBTmGK8JhVXSFCaB1F-WPDKeDZwEbxMLf_Xi7aXQw@mail.gmail.com> (raw)
In-Reply-To: <20170530220741.ldmhwj3bsvdoaofc@nataraja>

On Tue, May 30, 2017 at 3:07 PM, Harald Welte <laforge@gnumonks.org> wrote:
> But, to the contrary, this doesn't happen.  The unshare-created netns is
> gone, but the netdevice did not get moved back to the root namespace
> either.  The only hack to get back to the "eth0" device is to unload the
> driver and re-load it.


Net namespace simply unregisters all netdevices inside when it is
gone, no matter where they are from. I am pretty sure you can move it
back to root-ns if you want, it is a little tricky because you have to give
the root-ns a name first.


>
> I can reproduce the above without starting any other process inside that
> namespace.  I have verified that there are no /proc/*/ns/net symlinks
> left pointing to the ID of that namespace.  What am I missing here?  Is
> this the intended behavior?

Yes it is.

>
> Of course I know I could simply do something like "ip link set eth0
> netns 1" from within the namespace before leaving.  But what if the
> process is not bash and the process exits abnormally?   I'd consider
> that explicit reassignment more like a hack than a proper solution...

It doesn't make sense to move it back to where it is from, for example,
what if you move a veth0 from netns1 to netns2 and netns1 is gone
before netns2?

Regards.

  reply	other threads:[~2017-05-30 23:18 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 [this message]
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
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=CAM_iQpW2ARBTmGK8JhVXSFCaB1F-WPDKeDZwEbxMLf_Xi7aXQw@mail.gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=laforge@gnumonks.org \
    --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 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.