Skip to content

Commit

Permalink
[NETNS]: icmp(v6)_sk should not pin a namespace.
Browse files Browse the repository at this point in the history
So, change icmp(v6)_sk creation/disposal to the scheme used in the
netlink for rtnl, i.e. create a socket in the context of the init_net
and assign the namespace without getting a referrence later.

Also use sk_release_kernel instead of sock_release to properly destroy
such sockets.

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>
  • Loading branch information
Denis V. Lunev authored and David S. Miller committed Feb 29, 2008
1 parent edf0208 commit 5c8cafd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
12 changes: 4 additions & 8 deletions net/ipv4/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,14 +1146,8 @@ static void __exit icmp_exit(void)
{
int i;

for_each_possible_cpu(i) {
struct sock *sk;

sk = __icmp_sk[i];
if (sk == NULL)
continue;
sock_release(sk->sk_socket);
}
for_each_possible_cpu(i)
sk_release_kernel(__icmp_sk[i]);
kfree(__icmp_sk);
__icmp_sk = NULL;
}
Expand All @@ -1176,6 +1170,8 @@ int __init icmp_init(void)
goto fail;

__icmp_sk[i] = sk = sock->sk;
sk_change_net(sk, &init_net);

sk->sk_allocation = GFP_ATOMIC;

/* Enough space for 2 64K ICMP packets, including
Expand Down
11 changes: 5 additions & 6 deletions net/ipv6/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,8 @@ int __init icmpv6_init(void)
}

__icmpv6_sk[i] = sk = sock->sk;
sk_change_net(sk, &init_net);

sk->sk_allocation = GFP_ATOMIC;
/*
* Split off their lock-class, because sk->sk_dst_lock
Expand Down Expand Up @@ -831,11 +833,8 @@ int __init icmpv6_init(void)
return 0;

fail:
for (j = 0; j < i; j++) {
if (!cpu_possible(j))
continue;
sock_release(__icmpv6_sk[j]->sk_socket);
}
for (j = 0; j < i; j++)
sk_release_kernel(__icmpv6_sk[j]);

return err;
}
Expand All @@ -845,7 +844,7 @@ void icmpv6_cleanup(void)
int i;

for_each_possible_cpu(i) {
sock_release(__icmpv6_sk[i]->sk_socket);
sk_release_kernel(__icmpv6_sk[i]);
}
inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6);
}
Expand Down

0 comments on commit 5c8cafd

Please sign in to comment.