diff options
Diffstat (limited to 'net/ipv4/icmp.c')
-rw-r--r-- | net/ipv4/icmp.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index b345b3d9bcaa..831b6adbe4e0 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -346,19 +346,21 @@ static int icmp_glue_bits(void *from, char *to, int offset, int len, int odd, | |||
346 | static void icmp_push_reply(struct icmp_bxm *icmp_param, | 346 | static void icmp_push_reply(struct icmp_bxm *icmp_param, |
347 | struct ipcm_cookie *ipc, struct rtable *rt) | 347 | struct ipcm_cookie *ipc, struct rtable *rt) |
348 | { | 348 | { |
349 | struct sock *sk; | ||
349 | struct sk_buff *skb; | 350 | struct sk_buff *skb; |
350 | 351 | ||
351 | if (ip_append_data(icmp_socket->sk, icmp_glue_bits, icmp_param, | 352 | sk = icmp_socket->sk; |
353 | if (ip_append_data(sk, icmp_glue_bits, icmp_param, | ||
352 | icmp_param->data_len+icmp_param->head_len, | 354 | icmp_param->data_len+icmp_param->head_len, |
353 | icmp_param->head_len, | 355 | icmp_param->head_len, |
354 | ipc, rt, MSG_DONTWAIT) < 0) | 356 | ipc, rt, MSG_DONTWAIT) < 0) |
355 | ip_flush_pending_frames(icmp_socket->sk); | 357 | ip_flush_pending_frames(sk); |
356 | else if ((skb = skb_peek(&icmp_socket->sk->sk_write_queue)) != NULL) { | 358 | else if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) { |
357 | struct icmphdr *icmph = icmp_hdr(skb); | 359 | struct icmphdr *icmph = icmp_hdr(skb); |
358 | __wsum csum = 0; | 360 | __wsum csum = 0; |
359 | struct sk_buff *skb1; | 361 | struct sk_buff *skb1; |
360 | 362 | ||
361 | skb_queue_walk(&icmp_socket->sk->sk_write_queue, skb1) { | 363 | skb_queue_walk(&sk->sk_write_queue, skb1) { |
362 | csum = csum_add(csum, skb1->csum); | 364 | csum = csum_add(csum, skb1->csum); |
363 | } | 365 | } |
364 | csum = csum_partial_copy_nocheck((void *)&icmp_param->data, | 366 | csum = csum_partial_copy_nocheck((void *)&icmp_param->data, |
@@ -366,7 +368,7 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param, | |||
366 | icmp_param->head_len, csum); | 368 | icmp_param->head_len, csum); |
367 | icmph->checksum = csum_fold(csum); | 369 | icmph->checksum = csum_fold(csum); |
368 | skb->ip_summed = CHECKSUM_NONE; | 370 | skb->ip_summed = CHECKSUM_NONE; |
369 | ip_push_pending_frames(icmp_socket->sk); | 371 | ip_push_pending_frames(sk); |
370 | } | 372 | } |
371 | } | 373 | } |
372 | 374 | ||
@@ -1156,25 +1158,28 @@ static void __exit icmp_exit(void) | |||
1156 | 1158 | ||
1157 | int __init icmp_init(void) | 1159 | int __init icmp_init(void) |
1158 | { | 1160 | { |
1159 | struct inet_sock *inet; | ||
1160 | int i, err; | 1161 | int i, err; |
1161 | 1162 | ||
1162 | for_each_possible_cpu(i) { | 1163 | for_each_possible_cpu(i) { |
1163 | err = sock_create_kern(PF_INET, SOCK_RAW, IPPROTO_ICMP, | 1164 | struct sock *sk; |
1164 | &per_cpu(__icmp_socket, i)); | 1165 | struct socket *sock; |
1166 | struct inet_sock *inet; | ||
1165 | 1167 | ||
1168 | err = sock_create_kern(PF_INET, SOCK_RAW, IPPROTO_ICMP, &sock); | ||
1166 | if (err < 0) | 1169 | if (err < 0) |
1167 | goto fail; | 1170 | goto fail; |
1168 | 1171 | ||
1169 | per_cpu(__icmp_socket, i)->sk->sk_allocation = GFP_ATOMIC; | 1172 | per_cpu(__icmp_socket, i) = sock; |
1173 | sk = sock->sk; | ||
1174 | sk->sk_allocation = GFP_ATOMIC; | ||
1170 | 1175 | ||
1171 | /* Enough space for 2 64K ICMP packets, including | 1176 | /* Enough space for 2 64K ICMP packets, including |
1172 | * sk_buff struct overhead. | 1177 | * sk_buff struct overhead. |
1173 | */ | 1178 | */ |
1174 | per_cpu(__icmp_socket, i)->sk->sk_sndbuf = | 1179 | sk->sk_sndbuf = |
1175 | (2 * ((64 * 1024) + sizeof(struct sk_buff))); | 1180 | (2 * ((64 * 1024) + sizeof(struct sk_buff))); |
1176 | 1181 | ||
1177 | inet = inet_sk(per_cpu(__icmp_socket, i)->sk); | 1182 | inet = inet_sk(sk); |
1178 | inet->uc_ttl = -1; | 1183 | inet->uc_ttl = -1; |
1179 | inet->pmtudisc = IP_PMTUDISC_DONT; | 1184 | inet->pmtudisc = IP_PMTUDISC_DONT; |
1180 | 1185 | ||
@@ -1182,7 +1187,7 @@ int __init icmp_init(void) | |||
1182 | * see it, we do not wish this socket to see incoming | 1187 | * see it, we do not wish this socket to see incoming |
1183 | * packets. | 1188 | * packets. |
1184 | */ | 1189 | */ |
1185 | per_cpu(__icmp_socket, i)->sk->sk_prot->unhash(per_cpu(__icmp_socket, i)->sk); | 1190 | sk->sk_prot->unhash(sk); |
1186 | } | 1191 | } |
1187 | return 0; | 1192 | return 0; |
1188 | 1193 | ||