aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/icmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/icmp.c')
-rw-r--r--net/ipv4/icmp.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 9bcf263f06ca..7c62a0da5264 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -229,8 +229,8 @@ static const struct icmp_control icmp_pointers[NR_ICMP_TYPES+1];
229 * 229 *
230 * On SMP we have one ICMP socket per-cpu. 230 * On SMP we have one ICMP socket per-cpu.
231 */ 231 */
232static DEFINE_PER_CPU(struct sock *, __icmp_sk) = NULL; 232static struct sock **__icmp_sk = NULL;
233#define icmp_sk __get_cpu_var(__icmp_sk) 233#define icmp_sk (__icmp_sk[smp_processor_id()])
234 234
235static inline int icmp_xmit_lock(struct sock *sk) 235static inline int icmp_xmit_lock(struct sock *sk)
236{ 236{
@@ -1149,18 +1149,23 @@ static void __exit icmp_exit(void)
1149 for_each_possible_cpu(i) { 1149 for_each_possible_cpu(i) {
1150 struct sock *sk; 1150 struct sock *sk;
1151 1151
1152 sk = per_cpu(__icmp_sk, i); 1152 sk = __icmp_sk[i];
1153 if (sk == NULL) 1153 if (sk == NULL)
1154 continue; 1154 continue;
1155 per_cpu(__icmp_sk, i) = NULL;
1156 sock_release(sk->sk_socket); 1155 sock_release(sk->sk_socket);
1157 } 1156 }
1157 kfree(__icmp_sk);
1158 __icmp_sk = NULL;
1158} 1159}
1159 1160
1160int __init icmp_init(void) 1161int __init icmp_init(void)
1161{ 1162{
1162 int i, err; 1163 int i, err;
1163 1164
1165 __icmp_sk = kzalloc(nr_cpu_ids * sizeof(struct sock *), GFP_KERNEL);
1166 if (__icmp_sk == NULL)
1167 return -ENOMEM;
1168
1164 for_each_possible_cpu(i) { 1169 for_each_possible_cpu(i) {
1165 struct sock *sk; 1170 struct sock *sk;
1166 struct socket *sock; 1171 struct socket *sock;
@@ -1170,7 +1175,7 @@ int __init icmp_init(void)
1170 if (err < 0) 1175 if (err < 0)
1171 goto fail; 1176 goto fail;
1172 1177
1173 per_cpu(__icmp_sk, i) = sk = sock->sk; 1178 __icmp_sk[i] = sk = sock->sk;
1174 sk->sk_allocation = GFP_ATOMIC; 1179 sk->sk_allocation = GFP_ATOMIC;
1175 1180
1176 /* Enough space for 2 64K ICMP packets, including 1181 /* Enough space for 2 64K ICMP packets, including