@@ -41,7 +41,8 @@ int inet_recv_error(struct sock *sk, struct msghdr *msg, int len,
static inline void inet_ctl_sock_destroy(struct sock *sk)
{
- sk_release_kernel(sk);
+ get_net(sock_net(sk));
+ sock_release(sk->sk_socket);
}
#endif
@@ -1430,7 +1430,7 @@ int inet_ctl_sock_create(struct sock **sk, unsigned short family,
struct net *net)
{
struct socket *sock;
- int rc = sock_create_kern(family, type, protocol, &sock);
+ int rc = __sock_create(net, family, type, protocol, &sock, 1);
if (rc == 0) {
*sk = sock->sk;
@@ -1441,7 +1441,7 @@ int inet_ctl_sock_create(struct sock **sk, unsigned short family,
*/
(*sk)->sk_prot->unhash(*sk);
- sk_change_net(*sk, net);
+ put_net(sock_net(*sk));
}
return rc;
}
As the race between put_net() and kernel socket's creation is gone, it's unnecessary to switch namespace for a kernel socket from init_net to its desirable one. But as the kernel socket is part of a namespace, we should not hold a reference counter to the namespace, otherwise, probably modules relying on it cannot be stopped. Signed-off-by: Ying Xue <ying.xue@windriver.com> --- include/net/inet_common.h | 3 ++- net/ipv4/af_inet.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)