diff options
author | Denis V. Lunev <den@openvz.org> | 2008-04-16 04:58:04 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-16 04:58:04 -0400 |
commit | 5d1e4468a7705db7c1415a65fd16f07113afc1b2 (patch) | |
tree | 41d34aa3f0e3b8cc0453973d8ce9e03303264080 /net/core | |
parent | 554eb27782d4bb79e0a286a08ecafb81f758058c (diff) |
[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.c | 4 |
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) | |||
35 | struct net_generic *ng; | 35 | struct net_generic *ng; |
36 | 36 | ||
37 | atomic_set(&net->count, 1); | 37 | atomic_set(&net->count, 1); |
38 | #ifdef NETNS_REFCNT_DEBUG | ||
38 | atomic_set(&net->use_count, 0); | 39 | atomic_set(&net->use_count, 0); |
40 | #endif | ||
39 | 41 | ||
40 | error = -ENOMEM; | 42 | error = -ENOMEM; |
41 | ng = kzalloc(sizeof(struct net_generic) + | 43 | ng = kzalloc(sizeof(struct net_generic) + |
@@ -86,11 +88,13 @@ static void net_free(struct net *net) | |||
86 | if (!net) | 88 | if (!net) |
87 | return; | 89 | return; |
88 | 90 | ||
91 | #ifdef NETNS_REFCNT_DEBUG | ||
89 | if (unlikely(atomic_read(&net->use_count) != 0)) { | 92 | if (unlikely(atomic_read(&net->use_count) != 0)) { |
90 | printk(KERN_EMERG "network namespace not free! Usage: %d\n", | 93 | printk(KERN_EMERG "network namespace not free! Usage: %d\n", |
91 | atomic_read(&net->use_count)); | 94 | atomic_read(&net->use_count)); |
92 | return; | 95 | return; |
93 | } | 96 | } |
97 | #endif | ||
94 | 98 | ||
95 | kmem_cache_free(net_cachep, net); | 99 | kmem_cache_free(net_cachep, net); |
96 | } | 100 | } |