Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 89815
b: refs/heads/master
c: 79c9115
h: refs/heads/master
i:
  89813: 3b83215
  89811: b5eb89d
  89807: cddf18b
v: v3
  • Loading branch information
Denis V. Lunev authored and David S. Miller committed Feb 29, 2008
1 parent 2906804 commit 5c1bc0c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 405666db84b984b68fc75794069f424c02e5796c
refs/heads/master: 79c911595390c8fdc8d8a487ac1951d854b1cd09
15 changes: 10 additions & 5 deletions trunk/net/ipv4/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down
14 changes: 9 additions & 5 deletions trunk/net/ipv6/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ EXPORT_SYMBOL(icmpv6msg_statistics);
*
* On SMP we have one ICMP socket per-cpu.
*/
static DEFINE_PER_CPU(struct sock *, __icmpv6_sk) = NULL;
#define icmpv6_sk __get_cpu_var(__icmpv6_sk)
static struct sock **__icmpv6_sk = NULL;
#define icmpv6_sk (__icmpv6_sk[smp_processor_id()])

static int icmpv6_rcv(struct sk_buff *skb);

Expand Down Expand Up @@ -785,6 +785,10 @@ int __init icmpv6_init(void)
struct sock *sk;
int err, i, j;

__icmpv6_sk = kzalloc(nr_cpu_ids * sizeof(struct sock *), GFP_KERNEL);
if (__icmpv6_sk == NULL)
return -ENOMEM;

for_each_possible_cpu(i) {
struct socket *sock;
err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6,
Expand All @@ -797,7 +801,7 @@ int __init icmpv6_init(void)
goto fail;
}

per_cpu(__icmpv6_sk, i) = sk = sock->sk;
__icmpv6_sk[i] = sk = sock->sk;
sk->sk_allocation = GFP_ATOMIC;
/*
* Split off their lock-class, because sk->sk_dst_lock
Expand Down Expand Up @@ -830,7 +834,7 @@ int __init icmpv6_init(void)
for (j = 0; j < i; j++) {
if (!cpu_possible(j))
continue;
sock_release(per_cpu(__icmpv6_sk, j)->sk_socket);
sock_release(__icmpv6_sk[j]->sk_socket);
}

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

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

0 comments on commit 5c1bc0c

Please sign in to comment.