]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ibmveth: fix bad UDP checksums
authorSantiago Leon <santil@us.ibm.com>
Wed, 20 Aug 2008 19:09:19 +0000 (13:09 -0600)
committerJeff Garzik <jgarzik@redhat.com>
Wed, 27 Aug 2008 09:36:57 +0000 (05:36 -0400)
This patch fixes a ibmveth bug where bad UDP checksums are being transmitted
when checksum offloading is enabled.
The hypervisor does checksum offloading only on TCP packets, so ibmveth calls
skb_checksum_help() for any other protocol.  The bug happens because
the packet is being modified after the DMA map, so we would need a memory
barrier before making the hypervisor call.  Reordering the code so that the
DMA map happens after skb_checksum_help() has the additional advantage of
fixing a DMA map leak if skb_checksum_help() where to fail.

Signed-off-by: Santiago Leon <santil@us.ibm.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/net/ibmveth.c

index a03fe1fb61ca4caf7b6f1faca1ee9da359c25ca6..c2d57f836088c4ba38955de02a5ecd9408f478f8 100644 (file)
@@ -904,8 +904,6 @@ static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev)
        unsigned long data_dma_addr;
 
        desc.fields.flags_len = IBMVETH_BUF_VALID | skb->len;
-       data_dma_addr = dma_map_single(&adapter->vdev->dev, skb->data,
-                                      skb->len, DMA_TO_DEVICE);
 
        if (skb->ip_summed == CHECKSUM_PARTIAL &&
            ip_hdr(skb)->protocol != IPPROTO_TCP && skb_checksum_help(skb)) {
@@ -924,6 +922,8 @@ static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev)
                buf[1] = 0;
        }
 
+       data_dma_addr = dma_map_single(&adapter->vdev->dev, skb->data,
+                                      skb->len, DMA_TO_DEVICE);
        if (dma_mapping_error(&adapter->vdev->dev, data_dma_addr)) {
                if (!firmware_has_feature(FW_FEATURE_CMO))
                        ibmveth_error_printk("tx: unable to map xmit buffer\n");
@@ -932,6 +932,7 @@ static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev)
                desc.fields.address = adapter->bounce_buffer_dma;
                tx_map_failed++;
                used_bounce = 1;
+               wmb();
        } else
                desc.fields.address = data_dma_addr;