aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/netpoll.c
diff options
context:
space:
mode:
authorAmerigo Wang <amwang@redhat.com>2013-06-03 12:31:36 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-04 20:37:04 -0400
commit00f97da17a0c8d656d0c9a60b1d7f38735f69817 (patch)
tree472a9a30b7367331d97ac9c7bead437d5f4227b2 /net/core/netpoll.c
parent525cebedb32a87fa48584bc44e14170beb2c10d1 (diff)
netpoll: fix position of network header
Similar to the problem in pktgen, netpoll uses skb_tail_offset() too, as the code is copied from pktgen. Also use return values of skb_put() directly, this will simiplify the code. Reported-by: Thomas Graf <tgraf@suug.ch> Cc: Thomas Graf <tgraf@suug.ch> Cc: Daniel Borkmann <dborkmann@redhat.com> Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Cong Wang <amwang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/netpoll.c')
-rw-r--r--net/core/netpoll.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 688517c7ff17..03c8ec3edc72 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -676,8 +676,6 @@ static void netpoll_neigh_reply(struct sk_buff *skb, struct netpoll_info *npinfo
676 676
677 spin_lock_irqsave(&npinfo->rx_lock, flags); 677 spin_lock_irqsave(&npinfo->rx_lock, flags);
678 list_for_each_entry_safe(np, tmp, &npinfo->rx_np, rx) { 678 list_for_each_entry_safe(np, tmp, &npinfo->rx_np, rx) {
679 unsigned long tail_offset;
680
681 if (!ipv6_addr_equal(daddr, &np->local_ip.in6)) 679 if (!ipv6_addr_equal(daddr, &np->local_ip.in6))
682 continue; 680 continue;
683 681
@@ -691,30 +689,20 @@ static void netpoll_neigh_reply(struct sk_buff *skb, struct netpoll_info *npinfo
691 send_skb->dev = skb->dev; 689 send_skb->dev = skb->dev;
692 690
693 skb_reset_network_header(send_skb); 691 skb_reset_network_header(send_skb);
694 skb_put(send_skb, sizeof(struct ipv6hdr)); 692 hdr = (struct ipv6hdr *) skb_put(send_skb, sizeof(struct ipv6hdr));
695 hdr = ipv6_hdr(send_skb);
696
697 *(__be32*)hdr = htonl(0x60000000); 693 *(__be32*)hdr = htonl(0x60000000);
698
699 hdr->payload_len = htons(size); 694 hdr->payload_len = htons(size);
700 hdr->nexthdr = IPPROTO_ICMPV6; 695 hdr->nexthdr = IPPROTO_ICMPV6;
701 hdr->hop_limit = 255; 696 hdr->hop_limit = 255;
702 hdr->saddr = *saddr; 697 hdr->saddr = *saddr;
703 hdr->daddr = *daddr; 698 hdr->daddr = *daddr;
704 699
705 tail_offset = skb_tail_offset(skb); 700 icmp6h = (struct icmp6hdr *) skb_put(send_skb, sizeof(struct icmp6hdr));
706 if (tail_offset > 0xffff) {
707 kfree_skb(send_skb);
708 continue;
709 }
710 skb_set_network_header(send_skb, tail_offset);
711 skb_put(send_skb, size);
712
713 icmp6h = (struct icmp6hdr *)skb_transport_header(skb);
714 icmp6h->icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT; 701 icmp6h->icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT;
715 icmp6h->icmp6_router = 0; 702 icmp6h->icmp6_router = 0;
716 icmp6h->icmp6_solicited = 1; 703 icmp6h->icmp6_solicited = 1;
717 target = (struct in6_addr *)(skb_transport_header(send_skb) + sizeof(struct icmp6hdr)); 704
705 target = (struct in6_addr *) skb_put(send_skb, sizeof(struct in6_addr));
718 *target = msg->target; 706 *target = msg->target;
719 icmp6h->icmp6_cksum = csum_ipv6_magic(saddr, daddr, size, 707 icmp6h->icmp6_cksum = csum_ipv6_magic(saddr, daddr, size,
720 IPPROTO_ICMPV6, 708 IPPROTO_ICMPV6,