summaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-04-16 10:58:04 +0200
committerDavid S. Miller <davem@davemloft.net>2008-04-16 10:58:04 +0200
commit5d1e4468a7705db7c1415a65fd16f07113afc1b2 (patch)
tree41d34aa3f0e3b8cc0453973d8ce9e03303264080 /net/core
parent[IP6TUNNEL]: Allow to create IP6 tunnels in net namespaces. (diff)
downloadlinux-5d1e4468a7705db7c1415a65fd16f07113afc1b2.tar.xz
linux-5d1e4468a7705db7c1415a65fd16f07113afc1b2.zip
[NETNS]: Make netns refconting debug like a socket one.
Make release_net/hold_net noop for performance-hungry people. This is a debug staff and should be used in the debug mode only. Add check for net != NULL in hold/release calls. This will be required later on. [ Added minor simplifications suggested by Brian Haley. -DaveM ] Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/net_namespace.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 763674e1e593..72b4c184dd84 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -35,7 +35,9 @@ static __net_init int setup_net(struct net *net)
struct net_generic *ng;
atomic_set(&net->count, 1);
+#ifdef NETNS_REFCNT_DEBUG
atomic_set(&net->use_count, 0);
+#endif
error = -ENOMEM;
ng = kzalloc(sizeof(struct net_generic) +
@@ -86,11 +88,13 @@ static void net_free(struct net *net)
if (!net)
return;
+#ifdef NETNS_REFCNT_DEBUG
if (unlikely(atomic_read(&net->use_count) != 0)) {
printk(KERN_EMERG "network namespace not free! Usage: %d\n",
atomic_read(&net->use_count));
return;
}
+#endif
kmem_cache_free(net_cachep, net);
}