Re: loosing netdevices with namespaces and unshare?
From: Cong Wang <hidden>
Date: 2017-05-31 22:40:59
On Wed, May 31, 2017 at 11:11 AM, Harald Welte [off-list ref] wrote:
I mean, what is the *use case* for loosing any refrence to a physical network device and unregistering it from the stack? Is there any API by which a new netdevice structure can be instantiated on the actual hardware? Registering the netdev is what the driver does during discovering the system hardware. If there's a method to "automagically" loose devices, at the very least I wold expect some reasonable method to resurrect them. Unloading the kernel module and reloading it is for sure not elegant, particularly not if you have multiple Ethernet devices/ports sharing the same driver. One could e.g. also think of something like a special namespace that collects all the "orphan" netdevices. Something analogous to the old Unix tradition of "pid 1" collecting all the orphan tasks whose parents died. Transferring them into that "netdev orphanage" could automatically set the link down so that no accidential routing/forwarding of traffic between the devices is possible.
Understand. But you have other choices than using the physical interface directly in non-root ns, for example, creating a virtual pair and connect it with the physical one with a bridge. There are various ways to achieve this.