From: Denis V. Lunev Date: Wed, 16 Apr 2008 09:02:18 +0000 (-0700) Subject: [NETNS]: Add netns refcnt debug for network devices. X-Git-Tag: v2.6.26-rc1~1138^2~15 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=f3005d7f4abe03ad41af33b1548602cd086d86a2;p=linux-2.6-omap-h63xx.git [NETNS]: Add netns refcnt debug for network devices. dev_set_net is called for - just allocated devices - devices moving from one namespace to another release_net has proper check inside to distinguish these cases. Signed-off-by: Denis V. Lunev Signed-off-by: David S. Miller --- diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 8b17ed40dea..7c1d4466583 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -758,7 +758,8 @@ static inline void dev_net_set(struct net_device *dev, struct net *net) { #ifdef CONFIG_NET_NS - dev->nd_net = net; + release_net(dev->nd_net); + dev->nd_net = hold_net(net); #endif } diff --git a/net/core/dev.c b/net/core/dev.c index 7aa01125287..77530e9a34f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4042,6 +4042,8 @@ EXPORT_SYMBOL(alloc_netdev_mq); */ void free_netdev(struct net_device *dev) { + release_net(dev_net(dev)); + /* Compatibility with error handling in drivers */ if (dev->reg_state == NETREG_UNINITIALIZED) { kfree((char *)dev - dev->padded);