aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/icmp.c
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-02-29 14:16:08 -0500
committerDavid S. Miller <davem@davemloft.net>2008-02-29 14:16:08 -0500
commitb7e729c4b4778aac4dbbec9dc070acde93071f4d (patch)
tree31c84099f0821e0929407ba2a2e704fd933e1ec1 /net/ipv4/icmp.c
parent1e3cf6834e7db1eac94314338c9e30c2103ac409 (diff)
[ICMP]: Store sock rather than socket for ICMP flow control.
Basically, there is no difference, what to store: socket or sock. Though, sock looks better as there will be 1 less dereferrence on the fast path. 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.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 831b6adbe4e0..3a4da43d8309 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -229,14 +229,14 @@ 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 socket *, __icmp_socket) = NULL; 232static DEFINE_PER_CPU(struct sock *, __icmp_sk) = NULL;
233#define icmp_socket __get_cpu_var(__icmp_socket) 233#define icmp_sk __get_cpu_var(__icmp_sk)
234 234
235static inline int icmp_xmit_lock(void) 235static inline int icmp_xmit_lock(void)
236{ 236{
237 local_bh_disable(); 237 local_bh_disable();
238 238
239 if (unlikely(!spin_trylock(&icmp_socket->sk->sk_lock.slock))) { 239 if (unlikely(!spin_trylock(&icmp_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 */
@@ -248,7 +248,7 @@ static inline int icmp_xmit_lock(void)
248 248
249static inline void icmp_xmit_unlock(void) 249static inline void icmp_xmit_unlock(void)
250{ 250{
251 spin_unlock_bh(&icmp_socket->sk->sk_lock.slock); 251 spin_unlock_bh(&icmp_sk->sk_lock.slock);
252} 252}
253 253
254/* 254/*
@@ -349,7 +349,7 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param,
349 struct sock *sk; 349 struct sock *sk;
350 struct sk_buff *skb; 350 struct sk_buff *skb;
351 351
352 sk = icmp_socket->sk; 352 sk = icmp_sk;
353 if (ip_append_data(sk, icmp_glue_bits, icmp_param, 353 if (ip_append_data(sk, icmp_glue_bits, icmp_param,
354 icmp_param->data_len+icmp_param->head_len, 354 icmp_param->data_len+icmp_param->head_len,
355 icmp_param->head_len, 355 icmp_param->head_len,
@@ -378,7 +378,7 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param,
378 378
379static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) 379static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
380{ 380{
381 struct sock *sk = icmp_socket->sk; 381 struct sock *sk = icmp_sk;
382 struct inet_sock *inet = inet_sk(sk); 382 struct inet_sock *inet = inet_sk(sk);
383 struct ipcm_cookie ipc; 383 struct ipcm_cookie ipc;
384 struct rtable *rt = (struct rtable *)skb->dst; 384 struct rtable *rt = (struct rtable *)skb->dst;
@@ -546,7 +546,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
546 icmp_param.data.icmph.checksum = 0; 546 icmp_param.data.icmph.checksum = 0;
547 icmp_param.skb = skb_in; 547 icmp_param.skb = skb_in;
548 icmp_param.offset = skb_network_offset(skb_in); 548 icmp_param.offset = skb_network_offset(skb_in);
549 inet_sk(icmp_socket->sk)->tos = tos; 549 inet_sk(icmp_sk)->tos = tos;
550 ipc.addr = iph->saddr; 550 ipc.addr = iph->saddr;
551 ipc.opt = &icmp_param.replyopts; 551 ipc.opt = &icmp_param.replyopts;
552 552
@@ -1146,13 +1146,13 @@ static void __exit icmp_exit(void)
1146 int i; 1146 int i;
1147 1147
1148 for_each_possible_cpu(i) { 1148 for_each_possible_cpu(i) {
1149 struct socket *sock; 1149 struct sock *sk;
1150 1150
1151 sock = per_cpu(__icmp_socket, i); 1151 sk = per_cpu(__icmp_sk, i);
1152 if (sock == NULL) 1152 if (sk == NULL)
1153 continue; 1153 continue;
1154 per_cpu(__icmp_socket, i) = NULL; 1154 per_cpu(__icmp_sk, i) = NULL;
1155 sock_release(sock); 1155 sock_release(sk->sk_socket);
1156 } 1156 }
1157} 1157}
1158 1158
@@ -1169,8 +1169,7 @@ int __init icmp_init(void)
1169 if (err < 0) 1169 if (err < 0)
1170 goto fail; 1170 goto fail;
1171 1171
1172 per_cpu(__icmp_socket, i) = sock; 1172 per_cpu(__icmp_sk, i) = sk = sock->sk;
1173 sk = sock->sk;
1174 sk->sk_allocation = GFP_ATOMIC; 1173 sk->sk_allocation = GFP_ATOMIC;
1175 1174
1176 /* Enough space for 2 64K ICMP packets, including 1175 /* Enough space for 2 64K ICMP packets, including