]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[NETNS]: Add netns refcnt debug for network devices.
authorDenis V. Lunev <den@openvz.org>
Wed, 16 Apr 2008 09:02:18 +0000 (02:02 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Apr 2008 09:02:18 +0000 (02:02 -0700)
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 <den@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h
net/core/dev.c

index 8b17ed40dea2446ff4b5c47a7d4d4fa67e0c9324..7c1d4466583b74e05ea09a16f86ea96a98651e8f 100644 (file)
@@ -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
 }
 
index 7aa01125287e5878446a512d2babde3e3d8e6fb1..77530e9a34fc83fea16010e292ad002ea8a36d5a 100644 (file)
@@ -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);