]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/core/netpoll.c
[SK_BUFF]: Remove skb_add_mtu() leftovers
[linux-2.6-omap-h63xx.git] / net / core / netpoll.c
index b3c559b9ac35cb9495edb39e4e77c8fedd5f26cf..57a82445c4654cbb6557acbef54af9f7232dc033 100644 (file)
@@ -55,6 +55,7 @@ static void queue_process(struct work_struct *work)
        struct netpoll_info *npinfo =
                container_of(work, struct netpoll_info, tx_work.work);
        struct sk_buff *skb;
+       unsigned long flags;
 
        while ((skb = skb_dequeue(&npinfo->txq))) {
                struct net_device *dev = skb->dev;
@@ -64,15 +65,19 @@ static void queue_process(struct work_struct *work)
                        continue;
                }
 
-               netif_tx_lock_bh(dev);
+               local_irq_save(flags);
+               netif_tx_lock(dev);
                if (netif_queue_stopped(dev) ||
                    dev->hard_start_xmit(skb, dev) != NETDEV_TX_OK) {
                        skb_queue_head(&npinfo->txq, skb);
-                       netif_tx_unlock_bh(dev);
+                       netif_tx_unlock(dev);
+                       local_irq_restore(flags);
 
                        schedule_delayed_work(&npinfo->tx_work, HZ/10);
                        return;
                }
+               netif_tx_unlock(dev);
+               local_irq_restore(flags);
        }
 }
 
@@ -232,32 +237,38 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
 {
        int status = NETDEV_TX_BUSY;
        unsigned long tries;
-       struct net_device *dev = np->dev;
-       struct netpoll_info *npinfo = np->dev->npinfo;
+       struct net_device *dev = np->dev;
+       struct netpoll_info *npinfo = np->dev->npinfo;
 
-       if (!npinfo || !netif_running(dev) || !netif_device_present(dev)) {
-               __kfree_skb(skb);
-               return;
-       }
+       if (!npinfo || !netif_running(dev) || !netif_device_present(dev)) {
+               __kfree_skb(skb);
+               return;
+       }
 
        /* don't get messages out of order, and no recursion */
        if (skb_queue_len(&npinfo->txq) == 0 &&
-           npinfo->poll_owner != smp_processor_id() &&
-           netif_tx_trylock(dev)) {
-               /* try until next clock tick */
-               for (tries = jiffies_to_usecs(1)/USEC_PER_POLL; tries > 0; --tries) {
-                       if (!netif_queue_stopped(dev))
-                               status = dev->hard_start_xmit(skb, dev);
+                   npinfo->poll_owner != smp_processor_id()) {
+               unsigned long flags;
 
-                       if (status == NETDEV_TX_OK)
-                               break;
+               local_irq_save(flags);
+               if (netif_tx_trylock(dev)) {
+                       /* try until next clock tick */
+                       for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
+                                       tries > 0; --tries) {
+                               if (!netif_queue_stopped(dev))
+                                       status = dev->hard_start_xmit(skb, dev);
 
-                       /* tickle device maybe there is some cleanup */
-                       netpoll_poll(np);
+                               if (status == NETDEV_TX_OK)
+                                       break;
+
+                               /* tickle device maybe there is some cleanup */
+                               netpoll_poll(np);
 
-                       udelay(USEC_PER_POLL);
+                               udelay(USEC_PER_POLL);
+                       }
+                       netif_tx_unlock(dev);
                }
-               netif_tx_unlock(dev);
+               local_irq_restore(flags);
        }
 
        if (status != NETDEV_TX_OK) {
@@ -285,7 +296,9 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
        memcpy(skb->data, msg, len);
        skb->len += len;
 
-       skb->h.uh = udph = (struct udphdr *) skb_push(skb, sizeof(*udph));
+       skb_push(skb, sizeof(*udph));
+       skb_reset_transport_header(skb);
+       udph = udp_hdr(skb);
        udph->source = htons(np->local_port);
        udph->dest = htons(np->remote_port);
        udph->len = htons(udp_len);
@@ -297,7 +310,9 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
        if (udph->check == 0)
                udph->check = CSUM_MANGLED_0;
 
-       skb->nh.iph = iph = (struct iphdr *)skb_push(skb, sizeof(*iph));
+       skb_push(skb, sizeof(*iph));
+       skb_reset_network_header(skb);
+       iph = ip_hdr(skb);
 
        /* iph->version = 4; iph->ihl = 5; */
        put_unaligned(0x45, (unsigned char *)iph);
@@ -313,7 +328,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);
@@ -330,6 +345,7 @@ static void arp_reply(struct sk_buff *skb)
        unsigned char *arp_ptr;
        int size, type = ARPOP_REPLY, ptype = ETH_P_ARP;
        __be32 sip, tip;
+       unsigned char *sha;
        struct sk_buff *send_skb;
        struct netpoll *np = NULL;
 
@@ -347,8 +363,9 @@ static void arp_reply(struct sk_buff *skb)
                                 (2 * sizeof(u32)))))
                return;
 
-       skb->h.raw = skb->nh.raw = skb->data;
-       arp = skb->nh.arph;
+       skb_reset_network_header(skb);
+       skb_reset_transport_header(skb);
+       arp = arp_hdr(skb);
 
        if ((arp->ar_hrd != htons(ARPHRD_ETHER) &&
             arp->ar_hrd != htons(ARPHRD_IEEE802)) ||
@@ -356,9 +373,14 @@ static void arp_reply(struct sk_buff *skb)
            arp->ar_op != htons(ARPOP_REQUEST))
                return;
 
-       arp_ptr = (unsigned char *)(arp+1) + skb->dev->addr_len;
+       arp_ptr = (unsigned char *)(arp+1);
+       /* save the location of the src hw addr */
+       sha = arp_ptr;
+       arp_ptr += skb->dev->addr_len;
        memcpy(&sip, arp_ptr, 4);
-       arp_ptr += 4 + skb->dev->addr_len;
+       arp_ptr += 4;
+       /* if we actually cared about dst hw addr, it would get copied here */
+       arp_ptr += skb->dev->addr_len;
        memcpy(&tip, arp_ptr, 4);
 
        /* Should we ignore arp? */
@@ -372,7 +394,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);
@@ -381,7 +403,7 @@ static void arp_reply(struct sk_buff *skb)
 
        if (np->dev->hard_header &&
            np->dev->hard_header(send_skb, skb->dev, ptype,
-                                np->remote_mac, np->local_mac,
+                                sha, np->local_mac,
                                 send_skb->len) < 0) {
                kfree_skb(send_skb);
                return;
@@ -405,7 +427,7 @@ static void arp_reply(struct sk_buff *skb)
        arp_ptr += np->dev->addr_len;
        memcpy(arp_ptr, &tip, 4);
        arp_ptr += 4;
-       memcpy(arp_ptr, np->remote_mac, np->dev->addr_len);
+       memcpy(arp_ptr, sha, np->dev->addr_len);
        arp_ptr += np->dev->addr_len;
        memcpy(arp_ptr, &sip, 4);
 
@@ -426,7 +448,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;
@@ -454,6 +476,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;
 
@@ -659,7 +688,7 @@ int netpoll_setup(struct netpoll *np)
                }
 
                atleast = jiffies + HZ/10;
-               atmost = jiffies + 4*HZ;
+               atmost = jiffies + 4*HZ;
                while (!netif_carrier_ok(ndev)) {
                        if (time_after(jiffies, atmost)) {
                                printk(KERN_NOTICE
@@ -755,9 +784,9 @@ void netpoll_cleanup(struct netpoll *np)
                        np->dev->npinfo = NULL;
                        if (atomic_dec_and_test(&npinfo->refcnt)) {
                                skb_queue_purge(&npinfo->arp_tx);
-                               skb_queue_purge(&npinfo->txq);
+                               skb_queue_purge(&npinfo->txq);
                                cancel_rearming_delayed_work(&npinfo->tx_work);
-                               flush_scheduled_work();
+                               flush_scheduled_work();
 
                                kfree(npinfo);
                        }