aboutsummaryrefslogtreecommitdiff
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 9bcf263f06c..7c62a0da526 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];
*
* On SMP we have one ICMP socket per-cpu.
*/
-static DEFINE_PER_CPU(struct sock *, __icmp_sk) = NULL;
-#define icmp_sk __get_cpu_var(__icmp_sk)
+static struct sock **__icmp_sk = NULL;
+#define icmp_sk (__icmp_sk[smp_processor_id()])
static inline int icmp_xmit_lock(struct sock *sk)
{
@@ -1149,18 +1149,23 @@ static void __exit icmp_exit(void)
for_each_possible_cpu(i) {
struct sock *sk;
- sk = per_cpu(__icmp_sk, i);
+ sk = __icmp_sk[i];
if (sk == NULL)
continue;
- per_cpu(__icmp_sk, i) = NULL;
sock_release(sk->sk_socket);
}
+ kfree(__icmp_sk);
+ __icmp_sk = NULL;
}
int __init icmp_init(void)
{
int i, err;
+ __icmp_sk = kzalloc(nr_cpu_ids * sizeof(struct sock *), GFP_KERNEL);
+ if (__icmp_sk == NULL)
+ return -ENOMEM;
+
for_each_possible_cpu(i) {
struct sock *sk;
struct socket *sock;
@@ -1170,7 +1175,7 @@ int __init icmp_init(void)
if (err < 0)
goto fail;
- per_cpu(__icmp_sk, i) = sk = sock->sk;
+ __icmp_sk[i] = sk = sock->sk;
sk->sk_allocation = GFP_ATOMIC;
/* Enough space for 2 64K ICMP packets, including