From: Eric W. Biederman Date: Wed, 12 Sep 2007 10:57:33 +0000 (+0200) Subject: [NET]: Initialize the network namespace of network devices. X-Git-Tag: v2.6.24-rc1~1454^2~698 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d34b1c27a72d5d1c73c567b2f6b1fde316e0eae;p=linux-2.6 [NET]: Initialize the network namespace of network devices. 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 Signed-off-by: David S. Miller --- diff --git a/net/core/dev.c b/net/core/dev.c index 618fb1c1dd..40fd66fbe4 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3725,6 +3725,7 @@ struct net_device *alloc_netdev_mq(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 = ((char *)dev +