From: Denis V. Lunev Date: Wed, 16 Apr 2008 08:59:46 +0000 (-0700) Subject: [NETNS]: Add netns refcnt debug for kernel sockets. X-Git-Tag: v2.6.26-rc1~1138^2~21 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=65a18ec58e5e6186103f62f720acea94dfb26f4e;p=linux-2.6-omap-h63xx.git [NETNS]: Add netns refcnt debug for kernel sockets. Protocol control sockets and netlink kernel sockets should not prevent the namespace stop request. They are initialized and disposed in a special way by sk_change_net/sk_release_kernel. Signed-off-by: Denis V. Lunev Signed-off-by: David S. Miller --- diff --git a/include/net/sock.h b/include/net/sock.h index 09255eae93e..dc42b44c2aa 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1314,7 +1314,7 @@ void sock_net_set(struct sock *sk, struct net *net) static inline void sk_change_net(struct sock *sk, struct net *net) { put_net(sock_net(sk)); - sock_net_set(sk, net); + sock_net_set(sk, hold_net(net)); } extern void sock_enable_timestamp(struct sock *sk); diff --git a/net/core/sock.c b/net/core/sock.c index c0ecbdcf75d..54c836a2216 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1001,6 +1001,7 @@ void sk_release_kernel(struct sock *sk) sock_hold(sk); sock_release(sk->sk_socket); + release_net(sock_net(sk)); sock_net_set(sk, get_net(&init_net)); sock_put(sk); }