aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/icmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/icmp.c')
-rw-r--r--net/ipv4/icmp.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 4b7a0d946a0d..d38cbba92a4d 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -355,7 +355,7 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param,
355 ipc, rt, MSG_DONTWAIT) < 0) 355 ipc, rt, MSG_DONTWAIT) < 0)
356 ip_flush_pending_frames(icmp_socket->sk); 356 ip_flush_pending_frames(icmp_socket->sk);
357 else if ((skb = skb_peek(&icmp_socket->sk->sk_write_queue)) != NULL) { 357 else if ((skb = skb_peek(&icmp_socket->sk->sk_write_queue)) != NULL) {
358 struct icmphdr *icmph = skb->h.icmph; 358 struct icmphdr *icmph = icmp_hdr(skb);
359 __wsum csum = 0; 359 __wsum csum = 0;
360 struct sk_buff *skb1; 360 struct sk_buff *skb1;
361 361
@@ -392,7 +392,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
392 icmp_param->data.icmph.checksum = 0; 392 icmp_param->data.icmph.checksum = 0;
393 icmp_out_count(icmp_param->data.icmph.type); 393 icmp_out_count(icmp_param->data.icmph.type);
394 394
395 inet->tos = skb->nh.iph->tos; 395 inet->tos = ip_hdr(skb)->tos;
396 daddr = ipc.addr = rt->rt_src; 396 daddr = ipc.addr = rt->rt_src;
397 ipc.opt = NULL; 397 ipc.opt = NULL;
398 if (icmp_param->replyopts.optlen) { 398 if (icmp_param->replyopts.optlen) {
@@ -404,7 +404,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
404 struct flowi fl = { .nl_u = { .ip4_u = 404 struct flowi fl = { .nl_u = { .ip4_u =
405 { .daddr = daddr, 405 { .daddr = daddr,
406 .saddr = rt->rt_spec_dst, 406 .saddr = rt->rt_spec_dst,
407 .tos = RT_TOS(skb->nh.iph->tos) } }, 407 .tos = RT_TOS(ip_hdr(skb)->tos) } },
408 .proto = IPPROTO_ICMP }; 408 .proto = IPPROTO_ICMP };
409 security_skb_classify_flow(skb, &fl); 409 security_skb_classify_flow(skb, &fl);
410 if (ip_route_output_key(&rt, &fl)) 410 if (ip_route_output_key(&rt, &fl))
@@ -448,9 +448,10 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
448 * Check this, icmp_send is called from the most obscure devices 448 * Check this, icmp_send is called from the most obscure devices
449 * sometimes. 449 * sometimes.
450 */ 450 */
451 iph = skb_in->nh.iph; 451 iph = ip_hdr(skb_in);
452 452
453 if ((u8 *)iph < skb_in->head || (u8 *)(iph + 1) > skb_in->tail) 453 if ((u8 *)iph < skb_in->head ||
454 (skb_in->network_header + sizeof(*iph)) > skb_in->tail)
454 goto out; 455 goto out;
455 456
456 /* 457 /*
@@ -484,7 +485,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
484 u8 _inner_type, *itp; 485 u8 _inner_type, *itp;
485 486
486 itp = skb_header_pointer(skb_in, 487 itp = skb_header_pointer(skb_in,
487 skb_in->nh.raw + 488 skb_network_header(skb_in) +
488 (iph->ihl << 2) + 489 (iph->ihl << 2) +
489 offsetof(struct icmphdr, 490 offsetof(struct icmphdr,
490 type) - 491 type) -
@@ -536,7 +537,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
536 icmp_param.data.icmph.un.gateway = info; 537 icmp_param.data.icmph.un.gateway = info;
537 icmp_param.data.icmph.checksum = 0; 538 icmp_param.data.icmph.checksum = 0;
538 icmp_param.skb = skb_in; 539 icmp_param.skb = skb_in;
539 icmp_param.offset = skb_in->nh.raw - skb_in->data; 540 icmp_param.offset = skb_network_offset(skb_in);
540 icmp_out_count(icmp_param.data.icmph.type); 541 icmp_out_count(icmp_param.data.icmph.type);
541 inet_sk(icmp_socket->sk)->tos = tos; 542 inet_sk(icmp_socket->sk)->tos = tos;
542 ipc.addr = iph->saddr; 543 ipc.addr = iph->saddr;
@@ -613,7 +614,7 @@ static void icmp_unreach(struct sk_buff *skb)
613 if (!pskb_may_pull(skb, sizeof(struct iphdr))) 614 if (!pskb_may_pull(skb, sizeof(struct iphdr)))
614 goto out_err; 615 goto out_err;
615 616
616 icmph = skb->h.icmph; 617 icmph = icmp_hdr(skb);
617 iph = (struct iphdr *)skb->data; 618 iph = (struct iphdr *)skb->data;
618 619
619 if (iph->ihl < 5) /* Mangled header, drop. */ 620 if (iph->ihl < 5) /* Mangled header, drop. */
@@ -676,7 +677,7 @@ static void icmp_unreach(struct sk_buff *skb)
676 printk(KERN_WARNING "%u.%u.%u.%u sent an invalid ICMP " 677 printk(KERN_WARNING "%u.%u.%u.%u sent an invalid ICMP "
677 "type %u, code %u " 678 "type %u, code %u "
678 "error to a broadcast: %u.%u.%u.%u on %s\n", 679 "error to a broadcast: %u.%u.%u.%u on %s\n",
679 NIPQUAD(skb->nh.iph->saddr), 680 NIPQUAD(ip_hdr(skb)->saddr),
680 icmph->type, icmph->code, 681 icmph->type, icmph->code,
681 NIPQUAD(iph->daddr), 682 NIPQUAD(iph->daddr),
682 skb->dev->name); 683 skb->dev->name);
@@ -743,7 +744,7 @@ static void icmp_redirect(struct sk_buff *skb)
743 744
744 iph = (struct iphdr *)skb->data; 745 iph = (struct iphdr *)skb->data;
745 746
746 switch (skb->h.icmph->code & 7) { 747 switch (icmp_hdr(skb)->code & 7) {
747 case ICMP_REDIR_NET: 748 case ICMP_REDIR_NET:
748 case ICMP_REDIR_NETTOS: 749 case ICMP_REDIR_NETTOS:
749 /* 750 /*
@@ -751,8 +752,8 @@ static void icmp_redirect(struct sk_buff *skb)
751 */ 752 */
752 case ICMP_REDIR_HOST: 753 case ICMP_REDIR_HOST:
753 case ICMP_REDIR_HOSTTOS: 754 case ICMP_REDIR_HOSTTOS:
754 ip_rt_redirect(skb->nh.iph->saddr, iph->daddr, 755 ip_rt_redirect(ip_hdr(skb)->saddr, iph->daddr,
755 skb->h.icmph->un.gateway, 756 icmp_hdr(skb)->un.gateway,
756 iph->saddr, skb->dev); 757 iph->saddr, skb->dev);
757 break; 758 break;
758 } 759 }
@@ -780,7 +781,7 @@ static void icmp_echo(struct sk_buff *skb)
780 if (!sysctl_icmp_echo_ignore_all) { 781 if (!sysctl_icmp_echo_ignore_all) {
781 struct icmp_bxm icmp_param; 782 struct icmp_bxm icmp_param;
782 783
783 icmp_param.data.icmph = *skb->h.icmph; 784 icmp_param.data.icmph = *icmp_hdr(skb);
784 icmp_param.data.icmph.type = ICMP_ECHOREPLY; 785 icmp_param.data.icmph.type = ICMP_ECHOREPLY;
785 icmp_param.skb = skb; 786 icmp_param.skb = skb;
786 icmp_param.offset = 0; 787 icmp_param.offset = 0;
@@ -816,7 +817,7 @@ static void icmp_timestamp(struct sk_buff *skb)
816 icmp_param.data.times[2] = icmp_param.data.times[1]; 817 icmp_param.data.times[2] = icmp_param.data.times[1];
817 if (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4)) 818 if (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4))
818 BUG(); 819 BUG();
819 icmp_param.data.icmph = *skb->h.icmph; 820 icmp_param.data.icmph = *icmp_hdr(skb);
820 icmp_param.data.icmph.type = ICMP_TIMESTAMPREPLY; 821 icmp_param.data.icmph.type = ICMP_TIMESTAMPREPLY;
821 icmp_param.data.icmph.code = 0; 822 icmp_param.data.icmph.code = 0;
822 icmp_param.skb = skb; 823 icmp_param.skb = skb;
@@ -943,7 +944,7 @@ int icmp_rcv(struct sk_buff *skb)
943 if (!pskb_pull(skb, sizeof(struct icmphdr))) 944 if (!pskb_pull(skb, sizeof(struct icmphdr)))
944 goto error; 945 goto error;
945 946
946 icmph = skb->h.icmph; 947 icmph = icmp_hdr(skb);
947 948
948 /* 949 /*
949 * 18 is the highest 'known' ICMP type. Anything else is a mystery 950 * 18 is the highest 'known' ICMP type. Anything else is a mystery