aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/sock.c
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-02-29 14:18:32 -0500
committerDavid S. Miller <davem@davemloft.net>2008-02-29 14:18:32 -0500
commitedf0208702007ec1f6a36756fdd005f771a4cf17 (patch)
treef323141ddde44db532d984ea7bf769a05220aa0c /net/core/sock.c
parent9dfbec1fb2bedff6b118504055cd9f0485edba45 (diff)
[NET]: Make netlink_kernel_release publically available as sk_release_kernel.
This staff will be needed for non-netlink kernel sockets, which should also not pin a namespace like tcp_socket and icmp_socket. Signed-off-by: Denis V. Lunev <den@openvz.org> Acked-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/sock.c')
-rw-r--r--net/core/sock.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index 09cb3a74de7f..c71b645a78f0 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -987,6 +987,24 @@ void sk_free(struct sock *sk)
987 sk_prot_free(sk->sk_prot_creator, sk); 987 sk_prot_free(sk->sk_prot_creator, sk);
988} 988}
989 989
990/*
991 * Last sock_put should drop referrence to sk->sk_net. It has already
992 * been dropped in sk_change_net. Taking referrence to stopping namespace
993 * is not an option.
994 * Take referrence to a socket to remove it from hash _alive_ and after that
995 * destroy it in the context of init_net.
996 */
997void sk_release_kernel(struct sock *sk)
998{
999 if (sk == NULL || sk->sk_socket == NULL)
1000 return;
1001
1002 sock_hold(sk);
1003 sock_release(sk->sk_socket);
1004 sk->sk_net = get_net(&init_net);
1005 sock_put(sk);
1006}
1007
990struct sock *sk_clone(const struct sock *sk, const gfp_t priority) 1008struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
991{ 1009{
992 struct sock *newsk; 1010 struct sock *newsk;