]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/core/netpoll.c
[SK_BUFF]: Introduce skb_reset_network_header(skb)
[net-next-2.6.git] / net / core / netpoll.c
index da1019451ccbe68185af1db8b7db3bb30a305c8f..b4d1cdd58f11542d189a2d64a8554767d7dddba2 100644 (file)
@@ -324,7 +324,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
        iph->check    = ip_fast_csum((unsigned char *)iph, iph->ihl);
 
        eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
-       skb->mac.raw = skb->data;
+       skb_reset_mac_header(skb);
        skb->protocol = eth->h_proto = htons(ETH_P_IP);
        memcpy(eth->h_source, np->local_mac, 6);
        memcpy(eth->h_dest, np->remote_mac, 6);
@@ -359,7 +359,8 @@ static void arp_reply(struct sk_buff *skb)
                                 (2 * sizeof(u32)))))
                return;
 
-       skb->h.raw = skb->nh.raw = skb->data;
+       skb_reset_network_header(skb);
+       skb->h.raw = skb->data;
        arp = skb->nh.arph;
 
        if ((arp->ar_hrd != htons(ARPHRD_ETHER) &&
@@ -389,7 +390,7 @@ static void arp_reply(struct sk_buff *skb)
        if (!send_skb)
                return;
 
-       send_skb->nh.raw = send_skb->data;
+       skb_reset_network_header(send_skb);
        arp = (struct arphdr *) skb_put(send_skb, size);
        send_skb->dev = skb->dev;
        send_skb->protocol = htons(ETH_P_ARP);
@@ -443,7 +444,7 @@ int __netpoll_rx(struct sk_buff *skb)
                goto out;
 
        /* check if netpoll clients need ARP */
-       if (skb->protocol == __constant_htons(ETH_P_ARP) &&
+       if (skb->protocol == htons(ETH_P_ARP) &&
            atomic_read(&trapped)) {
                skb_queue_tail(&npi->arp_tx, skb);
                return 1;
@@ -471,6 +472,13 @@ int __netpoll_rx(struct sk_buff *skb)
        if (skb->len < len || len < iph->ihl*4)
                goto out;
 
+       /*
+        * Our transport medium may have padded the buffer out.
+        * Now We trim to the true length of the frame.
+        */
+       if (pskb_trim_rcsum(skb, len))
+               goto out;
+
        if (iph->protocol != IPPROTO_UDP)
                goto out;