From: Eric W. Biederman <[EMAIL PROTECTED]> - unquoted Except for carefully selected pseudo devices all network interfaces should start out in the initial network namespace. Ultimately it will be register_netdev that examines what dev->nd_net is set to and places a device in a network namespace.
This patch modifies alloc_netdev to initialize the network namespace a device is in with the initial network namespace. This gets it right for the vast majority of devices so their drivers need not be modified and for those few pseudo devices that need something different they can change this parameter before calling register_netdevice. The network namespace parameter on a network device is not reference counted as the devices are inside of a network namespace and cannot remain in that namespace past the lifetime of the network namespace. Signed-off-by: Eric W. Biederman <[EMAIL PROTECTED]> --- drivers/net/loopback.c | 1 + net/core/dev.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 2b739fd..22b672d 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -231,6 +231,7 @@ struct net_device loopback_dev = { /* Setup and register the loopback device. */ static int __init loopback_init(void) { + loopback_dev.nd_net = init_net(); return register_netdev(&loopback_dev); }; diff --git a/net/core/dev.c b/net/core/dev.c index 90e4c0e..a3ee150 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3192,6 +3192,7 @@ struct net_device *alloc_netdev(int sizeof_priv, const char *name, dev = (struct net_device *) (((long)p + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST); dev->padded = (char *)dev - (char *)p; + dev->nd_net = init_net(); if (sizeof_priv) dev->priv = netdev_priv(dev); -- 1.4.4.1.g278f - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html