]> Pileus Git - ~andy/linux/blobdiff - drivers/net/xen-netback/netback.c
xen-netback: switch to use skb_partial_csum_set()
[~andy/linux] / drivers / net / xen-netback / netback.c
index cd49ba9496361cccfceeaa4dbf8251cf3657e763..9f71844042634e06af148b872e6a343c54a789f1 100644 (file)
@@ -942,7 +942,6 @@ static int netbk_count_requests(struct xenvif *vif,
 }
 
 static struct page *xen_netbk_alloc_page(struct xen_netbk *netbk,
-                                        struct sk_buff *skb,
                                         u16 pending_idx)
 {
        struct page *page;
@@ -976,7 +975,7 @@ static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk,
 
                index = pending_index(netbk->pending_cons++);
                pending_idx = netbk->pending_ring[index];
-               page = xen_netbk_alloc_page(netbk, skb, pending_idx);
+               page = xen_netbk_alloc_page(netbk, pending_idx);
                if (!page)
                        goto err;
 
@@ -1157,7 +1156,6 @@ static int netbk_set_skb_gso(struct xenvif *vif,
 static int checksum_setup(struct xenvif *vif, struct sk_buff *skb)
 {
        struct iphdr *iph;
-       unsigned char *th;
        int err = -EPROTO;
        int recalculate_partial_csum = 0;
 
@@ -1181,27 +1179,26 @@ static int checksum_setup(struct xenvif *vif, struct sk_buff *skb)
                goto out;
 
        iph = (void *)skb->data;
-       th = skb->data + 4 * iph->ihl;
-       if (th >= skb_tail_pointer(skb))
-               goto out;
-
-       skb->csum_start = th - skb->head;
        switch (iph->protocol) {
        case IPPROTO_TCP:
-               skb->csum_offset = offsetof(struct tcphdr, check);
+               if (!skb_partial_csum_set(skb, 4 * iph->ihl,
+                                         offsetof(struct tcphdr, check)))
+                       goto out;
 
                if (recalculate_partial_csum) {
-                       struct tcphdr *tcph = (struct tcphdr *)th;
+                       struct tcphdr *tcph = tcp_hdr(skb);
                        tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
                                                         skb->len - iph->ihl*4,
                                                         IPPROTO_TCP, 0);
                }
                break;
        case IPPROTO_UDP:
-               skb->csum_offset = offsetof(struct udphdr, check);
+               if (!skb_partial_csum_set(skb, 4 * iph->ihl,
+                                         offsetof(struct udphdr, check)))
+                       goto out;
 
                if (recalculate_partial_csum) {
-                       struct udphdr *udph = (struct udphdr *)th;
+                       struct udphdr *udph = udp_hdr(skb);
                        udph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
                                                         skb->len - iph->ihl*4,
                                                         IPPROTO_UDP, 0);
@@ -1215,9 +1212,6 @@ static int checksum_setup(struct xenvif *vif, struct sk_buff *skb)
                goto out;
        }
 
-       if ((th + skb->csum_offset + 2) > skb_tail_pointer(skb))
-               goto out;
-
        err = 0;
 
 out:
@@ -1381,7 +1375,7 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
                }
 
                /* XXX could copy straight to head */
-               page = xen_netbk_alloc_page(netbk, skb, pending_idx);
+               page = xen_netbk_alloc_page(netbk, pending_idx);
                if (!page) {
                        kfree_skb(skb);
                        netbk_tx_err(vif, &txreq, idx);
@@ -1496,6 +1490,7 @@ static void xen_netbk_tx_submit(struct xen_netbk *netbk)
 
                skb->dev      = vif->dev;
                skb->protocol = eth_type_trans(skb, skb->dev);
+               skb_reset_network_header(skb);
 
                if (checksum_setup(vif, skb)) {
                        netdev_dbg(vif->dev,
@@ -1504,6 +1499,8 @@ static void xen_netbk_tx_submit(struct xen_netbk *netbk)
                        continue;
                }
 
+               skb_probe_transport_header(skb, 0);
+
                vif->dev->stats.rx_bytes += skb->len;
                vif->dev->stats.rx_packets++;
 
@@ -1548,7 +1545,7 @@ static void xen_netbk_idx_release(struct xen_netbk *netbk, u16 pending_idx,
 
        xenvif_put(vif);
 
-       netbk->mmap_pages[pending_idx]->mapping = 0;
+       netbk->mmap_pages[pending_idx]->mapping = NULL;
        put_page(netbk->mmap_pages[pending_idx]);
        netbk->mmap_pages[pending_idx] = NULL;
 }