netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ibmveth: fix bad UDP checksums
@ 2008-08-20 19:09 Santiago Leon
  2008-08-21 19:41 ` Brian King
  2008-08-27  9:37 ` Jeff Garzik
  0 siblings, 2 replies; 3+ messages in thread
From: Santiago Leon @ 2008-08-20 19:09 UTC (permalink / raw)
  To: jeff; +Cc: Santiago Leon, netdev

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.

Please consider applying.

Signed-off-by: Santiago Leon <santil@us.ibm.com>
---

 ibmveth.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/drivers/net/ibmveth.c	2008-08-19 07:31:29.000000000 -0400
+++ b/drivers/net/ibmveth.c	2008-08-19 07:46:24.000000000 -0400
@@ -904,8 +904,6 @@ static int ibmveth_start_xmit(struct sk_
 	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_
 		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_
 		desc.fields.address = adapter->bounce_buffer_dma;
 		tx_map_failed++;
 		used_bounce = 1;
+		wmb();
 	} else
 		desc.fields.address = data_dma_addr;
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ibmveth: fix bad UDP checksums
  2008-08-20 19:09 [PATCH] ibmveth: fix bad UDP checksums Santiago Leon
@ 2008-08-21 19:41 ` Brian King
  2008-08-27  9:37 ` Jeff Garzik
  1 sibling, 0 replies; 3+ messages in thread
From: Brian King @ 2008-08-21 19:41 UTC (permalink / raw)
  To: Santiago Leon; +Cc: jeff, netdev

Acked by: Brian King <brking@linux.vnet.ibm.com>

Santiago Leon wrote:
> 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.
> 
> Please consider applying.
> 
> Signed-off-by: Santiago Leon <santil@us.ibm.com>
> ---
> 
>  ibmveth.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> --- a/drivers/net/ibmveth.c	2008-08-19 07:31:29.000000000 -0400
> +++ b/drivers/net/ibmveth.c	2008-08-19 07:46:24.000000000 -0400
> @@ -904,8 +904,6 @@ static int ibmveth_start_xmit(struct sk_
>  	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_
>  		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_
>  		desc.fields.address = adapter->bounce_buffer_dma;
>  		tx_map_failed++;
>  		used_bounce = 1;
> +		wmb();
>  	} else
>  		desc.fields.address = data_dma_addr;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Brian King
Linux on Power Virtualization
IBM Linux Technology Center



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ibmveth: fix bad UDP checksums
  2008-08-20 19:09 [PATCH] ibmveth: fix bad UDP checksums Santiago Leon
  2008-08-21 19:41 ` Brian King
@ 2008-08-27  9:37 ` Jeff Garzik
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Garzik @ 2008-08-27  9:37 UTC (permalink / raw)
  To: Santiago Leon; +Cc: netdev

Santiago Leon wrote:
> 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.
> 
> Please consider applying.
> 
> Signed-off-by: Santiago Leon <santil@us.ibm.com>
> ---
> 
>  ibmveth.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

applied



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-08-27  9:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-20 19:09 [PATCH] ibmveth: fix bad UDP checksums Santiago Leon
2008-08-21 19:41 ` Brian King
2008-08-27  9:37 ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).