diff options
author | Denis V. Lunev <den@openvz.org> | 2008-02-29 14:19:22 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-02-29 14:19:22 -0500 |
commit | 5c8cafd65e1448b1d55cad3fb1e42ad42607e5be (patch) | |
tree | 42b7de16c3724a4f9e6d401313ef2c60da05aa71 | |
parent | edf0208702007ec1f6a36756fdd005f771a4cf17 (diff) |
[NETNS]: icmp(v6)_sk should not pin a namespace.
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>
-rw-r--r-- | net/ipv4/icmp.c | 12 | ||||
-rw-r--r-- | net/ipv6/icmp.c | 11 |
2 files changed, 9 insertions, 14 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 7c62a0da5264..97d97ada4ce6 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -1146,14 +1146,8 @@ static void __exit icmp_exit(void) | |||
1146 | { | 1146 | { |
1147 | int i; | 1147 | int i; |
1148 | 1148 | ||
1149 | for_each_possible_cpu(i) { | 1149 | for_each_possible_cpu(i) |
1150 | struct sock *sk; | 1150 | sk_release_kernel(__icmp_sk[i]); |
1151 | |||
1152 | sk = __icmp_sk[i]; | ||
1153 | if (sk == NULL) | ||
1154 | continue; | ||
1155 | sock_release(sk->sk_socket); | ||
1156 | } | ||
1157 | kfree(__icmp_sk); | 1151 | kfree(__icmp_sk); |
1158 | __icmp_sk = NULL; | 1152 | __icmp_sk = NULL; |
1159 | } | 1153 | } |
@@ -1176,6 +1170,8 @@ int __init icmp_init(void) | |||
1176 | goto fail; | 1170 | goto fail; |
1177 | 1171 | ||
1178 | __icmp_sk[i] = sk = sock->sk; | 1172 | __icmp_sk[i] = sk = sock->sk; |
1173 | sk_change_net(sk, &init_net); | ||
1174 | |||
1179 | sk->sk_allocation = GFP_ATOMIC; | 1175 | sk->sk_allocation = GFP_ATOMIC; |
1180 | 1176 | ||
1181 | /* Enough space for 2 64K ICMP packets, including | 1177 | /* Enough space for 2 64K ICMP packets, including |
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 3368f32fe226..3eb594d54172 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
@@ -802,6 +802,8 @@ int __init icmpv6_init(void) | |||
802 | } | 802 | } |
803 | 803 | ||
804 | __icmpv6_sk[i] = sk = sock->sk; | 804 | __icmpv6_sk[i] = sk = sock->sk; |
805 | sk_change_net(sk, &init_net); | ||
806 | |||
805 | sk->sk_allocation = GFP_ATOMIC; | 807 | sk->sk_allocation = GFP_ATOMIC; |
806 | /* | 808 | /* |
807 | * Split off their lock-class, because sk->sk_dst_lock | 809 | * Split off their lock-class, because sk->sk_dst_lock |
@@ -831,11 +833,8 @@ int __init icmpv6_init(void) | |||
831 | return 0; | 833 | return 0; |
832 | 834 | ||
833 | fail: | 835 | fail: |
834 | for (j = 0; j < i; j++) { | 836 | for (j = 0; j < i; j++) |
835 | if (!cpu_possible(j)) | 837 | sk_release_kernel(__icmpv6_sk[j]); |
836 | continue; | ||
837 | sock_release(__icmpv6_sk[j]->sk_socket); | ||
838 | } | ||
839 | 838 | ||
840 | return err; | 839 | return err; |
841 | } | 840 | } |
@@ -845,7 +844,7 @@ void icmpv6_cleanup(void) | |||
845 | int i; | 844 | int i; |
846 | 845 | ||
847 | for_each_possible_cpu(i) { | 846 | for_each_possible_cpu(i) { |
848 | sock_release(__icmpv6_sk[i]->sk_socket); | 847 | sk_release_kernel(__icmpv6_sk[i]); |
849 | } | 848 | } |
850 | inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6); | 849 | inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6); |
851 | } | 850 | } |