Commit 13d3078e authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

netlink: Create kernel netlink sockets in the proper network namespace

Utilize the new functionality of sk_alloc so that nothing needs to be
done to suprress the reference counting on kernel sockets.
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 26abe143
...@@ -2516,16 +2516,11 @@ __netlink_kernel_create(struct net *net, int unit, struct module *module, ...@@ -2516,16 +2516,11 @@ __netlink_kernel_create(struct net *net, int unit, struct module *module,
if (sock_create_lite(PF_NETLINK, SOCK_DGRAM, unit, &sock)) if (sock_create_lite(PF_NETLINK, SOCK_DGRAM, unit, &sock))
return NULL; return NULL;
/*
* We have to just have a reference on the net from sk, but don't if (__netlink_create(net, sock, cb_mutex, unit, 1) < 0)
* get_net it. Besides, we cannot get and then put the net here.
* So we create one inside init_net and the move it to net.
*/
if (__netlink_create(&init_net, sock, cb_mutex, unit, 0) < 0)
goto out_sock_release_nosk; goto out_sock_release_nosk;
sk = sock->sk; sk = sock->sk;
sk_change_net(sk, net);
if (!cfg || cfg->groups < 32) if (!cfg || cfg->groups < 32)
groups = 32; groups = 32;
...@@ -2581,7 +2576,10 @@ EXPORT_SYMBOL(__netlink_kernel_create); ...@@ -2581,7 +2576,10 @@ EXPORT_SYMBOL(__netlink_kernel_create);
void void
netlink_kernel_release(struct sock *sk) netlink_kernel_release(struct sock *sk)
{ {
sk_release_kernel(sk); if (sk == NULL || sk->sk_socket == NULL)
return;
sock_release(sk->sk_socket);
} }
EXPORT_SYMBOL(netlink_kernel_release); EXPORT_SYMBOL(netlink_kernel_release);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment