[SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph
[pandora-kernel.git] / drivers / net / loopback.c
index 93fbea1..20b5cb1 100644 (file)
@@ -75,8 +75,9 @@ static DEFINE_PER_CPU(struct pcpu_lstats, pcpu_lstats);
 #ifdef LOOPBACK_TSO
 static void emulate_large_send_offload(struct sk_buff *skb)
 {
-       struct iphdr *iph = skb->nh.iph;
-       struct tcphdr *th = (struct tcphdr*)(skb->nh.raw + (iph->ihl * 4));
+       struct iphdr *iph = ip_hdr(skb);
+       struct tcphdr *th = (struct tcphdr *)(skb_network_header(skb) +
+                                             (iph->ihl * 4));
        unsigned int doffset = (iph->ihl + th->doff) * 4;
        unsigned int mtu = skb_shinfo(skb)->gso_size + doffset;
        unsigned int offset = 0;
@@ -90,10 +91,10 @@ static void emulate_large_send_offload(struct sk_buff *skb)
                if (!nskb)
                        break;
                skb_reserve(nskb, 32);
-               nskb->mac.raw = nskb->data - 14;
-               nskb->nh.raw = nskb->data;
-               iph = nskb->nh.iph;
-               memcpy(nskb->data, skb->nh.raw, doffset);
+               skb_set_mac_header(nskb, -ETH_HLEN);
+               skb_reset_network_header(nskb);
+               iph = ip_hdr(nskb);
+               memcpy(nskb->data, skb_network_header(skb), doffset);
                if (skb_copy_bits(skb,
                                  doffset + offset,
                                  nskb->data + doffset,
@@ -108,7 +109,7 @@ static void emulate_large_send_offload(struct sk_buff *skb)
                memcpy(nskb->cb, skb->cb, sizeof(skb->cb));
                nskb->pkt_type = skb->pkt_type;
 
-               th = (struct tcphdr*)(nskb->nh.raw + iph->ihl*4);
+               th = (struct tcphdr *)(skb_network_header(nskb) + iph->ihl * 4);
                iph->tot_len = htons(frag_size + doffset);
                iph->id = htons(id);
                iph->check = 0;
@@ -137,7 +138,6 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
        skb_orphan(skb);
 
        skb->protocol = eth_type_trans(skb,dev);
-       skb->dev = dev;
 #ifndef LOOPBACK_MUST_CHECKSUM
        skb->ip_summed = CHECKSUM_UNNECESSARY;
 #endif
@@ -145,7 +145,7 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
 #ifdef LOOPBACK_TSO
        if (skb_is_gso(skb)) {
                BUG_ON(skb->protocol != htons(ETH_P_IP));
-               BUG_ON(skb->nh.iph->protocol != IPPROTO_TCP);
+               BUG_ON(ip_hdr(skb)->protocol != IPPROTO_TCP);
 
                emulate_large_send_offload(skb);
                return 0;
@@ -153,14 +153,14 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
 #endif
        dev->last_rx = jiffies;
 
-       lb_stats = &per_cpu(pcpu_lstats, get_cpu());
+       /* it's OK to use __get_cpu_var() because BHs are off */
+       lb_stats = &__get_cpu_var(pcpu_lstats);
        lb_stats->bytes += skb->len;
        lb_stats->packets++;
-       put_cpu();
 
        netif_rx(skb);
 
-       return(0);
+       return 0;
 }
 
 static struct net_device_stats loopback_stats;
@@ -229,9 +229,11 @@ struct net_device loopback_dev = {
 };
 
 /* Setup and register the loopback device. */
-int __init loopback_init(void)
+static int __init loopback_init(void)
 {
        return register_netdev(&loopback_dev);
 };
 
+module_init(loopback_init);
+
 EXPORT_SYMBOL(loopback_dev);