diff options
author | Denis V. Lunev <den@openvz.org> | 2008-02-29 14:16:46 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-02-29 14:16:46 -0500 |
commit | 405666db84b984b68fc75794069f424c02e5796c (patch) | |
tree | d764573e97686f02c2a47fc7da96aefe97cbc458 /net/ipv4/icmp.c | |
parent | b7e729c4b4778aac4dbbec9dc070acde93071f4d (diff) |
[ICMP]: Pass proper ICMP socket into icmp(v6)_xmit_(un)lock.
We have to get socket lock inside icmp(v6)_xmit_lock/unlock. The socket
is get from global variable now. When this code became namespaces, one
should pass a namespace and get socket from it.
Though, above is useless. Socket is available in the caller, just pass
it inside. This saves a bit of code now and saves more later.
add/remove: 0/0 grow/shrink: 1/3 up/down: 1/-169 (-168)
function old new delta
icmp_rcv 718 719 +1
icmpv6_rcv 2343 2303 -40
icmp_send 1566 1518 -48
icmp_reply 549 468 -81
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>
Diffstat (limited to 'net/ipv4/icmp.c')
-rw-r--r-- | net/ipv4/icmp.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 3a4da43d8309..9bcf263f06ca 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -232,11 +232,11 @@ static const struct icmp_control icmp_pointers[NR_ICMP_TYPES+1]; | |||
232 | static DEFINE_PER_CPU(struct sock *, __icmp_sk) = NULL; | 232 | static DEFINE_PER_CPU(struct sock *, __icmp_sk) = NULL; |
233 | #define icmp_sk __get_cpu_var(__icmp_sk) | 233 | #define icmp_sk __get_cpu_var(__icmp_sk) |
234 | 234 | ||
235 | static inline int icmp_xmit_lock(void) | 235 | static inline int icmp_xmit_lock(struct sock *sk) |
236 | { | 236 | { |
237 | local_bh_disable(); | 237 | local_bh_disable(); |
238 | 238 | ||
239 | if (unlikely(!spin_trylock(&icmp_sk->sk_lock.slock))) { | 239 | if (unlikely(!spin_trylock(&sk->sk_lock.slock))) { |
240 | /* This can happen if the output path signals a | 240 | /* This can happen if the output path signals a |
241 | * dst_link_failure() for an outgoing ICMP packet. | 241 | * dst_link_failure() for an outgoing ICMP packet. |
242 | */ | 242 | */ |
@@ -246,9 +246,9 @@ static inline int icmp_xmit_lock(void) | |||
246 | return 0; | 246 | return 0; |
247 | } | 247 | } |
248 | 248 | ||
249 | static inline void icmp_xmit_unlock(void) | 249 | static inline void icmp_xmit_unlock(struct sock *sk) |
250 | { | 250 | { |
251 | spin_unlock_bh(&icmp_sk->sk_lock.slock); | 251 | spin_unlock_bh(&sk->sk_lock.slock); |
252 | } | 252 | } |
253 | 253 | ||
254 | /* | 254 | /* |
@@ -387,7 +387,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) | |||
387 | if (ip_options_echo(&icmp_param->replyopts, skb)) | 387 | if (ip_options_echo(&icmp_param->replyopts, skb)) |
388 | return; | 388 | return; |
389 | 389 | ||
390 | if (icmp_xmit_lock()) | 390 | if (icmp_xmit_lock(sk)) |
391 | return; | 391 | return; |
392 | 392 | ||
393 | icmp_param->data.icmph.checksum = 0; | 393 | icmp_param->data.icmph.checksum = 0; |
@@ -415,7 +415,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) | |||
415 | icmp_push_reply(icmp_param, &ipc, rt); | 415 | icmp_push_reply(icmp_param, &ipc, rt); |
416 | ip_rt_put(rt); | 416 | ip_rt_put(rt); |
417 | out_unlock: | 417 | out_unlock: |
418 | icmp_xmit_unlock(); | 418 | icmp_xmit_unlock(sk); |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
@@ -440,6 +440,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
440 | __be32 saddr; | 440 | __be32 saddr; |
441 | u8 tos; | 441 | u8 tos; |
442 | struct net *net; | 442 | struct net *net; |
443 | struct sock *sk = icmp_sk; | ||
443 | 444 | ||
444 | if (!rt) | 445 | if (!rt) |
445 | goto out; | 446 | goto out; |
@@ -507,7 +508,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
507 | } | 508 | } |
508 | } | 509 | } |
509 | 510 | ||
510 | if (icmp_xmit_lock()) | 511 | if (icmp_xmit_lock(sk)) |
511 | return; | 512 | return; |
512 | 513 | ||
513 | /* | 514 | /* |
@@ -546,7 +547,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
546 | icmp_param.data.icmph.checksum = 0; | 547 | icmp_param.data.icmph.checksum = 0; |
547 | icmp_param.skb = skb_in; | 548 | icmp_param.skb = skb_in; |
548 | icmp_param.offset = skb_network_offset(skb_in); | 549 | icmp_param.offset = skb_network_offset(skb_in); |
549 | inet_sk(icmp_sk)->tos = tos; | 550 | inet_sk(sk)->tos = tos; |
550 | ipc.addr = iph->saddr; | 551 | ipc.addr = iph->saddr; |
551 | ipc.opt = &icmp_param.replyopts; | 552 | ipc.opt = &icmp_param.replyopts; |
552 | 553 | ||
@@ -654,7 +655,7 @@ route_done: | |||
654 | ende: | 655 | ende: |
655 | ip_rt_put(rt); | 656 | ip_rt_put(rt); |
656 | out_unlock: | 657 | out_unlock: |
657 | icmp_xmit_unlock(); | 658 | icmp_xmit_unlock(sk); |
658 | out:; | 659 | out:; |
659 | } | 660 | } |
660 | 661 | ||