Skip to contentSkip to conversation

hyperv: Properly handle checksum offload

PATCH Superseded K. Y. Srinivasan 2 participants 3 messages Apr 26, 2014 – Apr 28, 2014

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hyperv: Properly handle checksum offload

Do checksum offload only if the client of the driver wants checksum to be offloaded.

In this version of the patch, I have addressed comments from Stephen Hemminger <[email protected]> and Eric Dumazet <[email protected]>.

This patch fixes a bug that is exposed in gateway scenarios.

---
 drivers/net/hyperv/netvsc_drv.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/net/hyperv/netvsc_drv.c +3 -0
index 939e3af..7ca9daa 100644
@@ -467,6 +467,9 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 	if (skb_is_gso(skb))
 		goto do_lso;
 
+	if (skb->ip_summed != CHECKSUM_PARTIAL)
+		goto do_send;
+
 	rndis_msg_size += NDIS_CSUM_PPI_SIZE;
 	ppi = init_ppi_data(rndis_msg, NDIS_CSUM_PPI_SIZE,
 			    TCPIP_CHKSUM_PKTINFO);
Signature · 1 line
1.7.4.1
maintainer
#1 lore raw

From: "K. Y. Srinivasan" <[email protected]>
Date: Fri, 25 Apr 2014 20:55:23 -0700

drivers/net/hyperv/netvsc_drv.c static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) · line 472

Quoted 7 lines
drivers/net/hyperv/netvsc_drv.c +3 -0
@@ -467,6 +467,9 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 	if (skb_is_gso(skb))
 		goto do_lso;
 
+	if (skb->ip_summed != CHECKSUM_PARTIAL)
+		goto do_send;
+

There are many possible values of ip_summed, why would you go to do_send if for example it was set to CHECKSUM_COMPLETE?

I think you are just rushing this change, take your time and implement the fix properly.

For example, if you only expect two possible values here (CHECKSUM_PARTIAL and something else), design your test so that it only allows those two values and therefore you'll be documenting this invariant.

#2 lore raw
Quoted 27 lines

-----Original Message-----
From: David Miller [mailto:[email protected]]
Sent: Monday, April 28, 2014 10:24 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V1 net-next 1/1] hyperv: Properly handle checksum offload

From: "K. Y. Srinivasan" <[email protected]>
Date: Fri, 25 Apr 2014 20:55:23 -0700

Review static int netvsc_start_xmit(struct sk_buff *skb,

Quoted 1 line
(quoted diff) +0 -0
@@ -467,6 +467,9 @@ static int netvsc_start_xmit(struct sk_buff *skb,

struct net_device *net)

drivers/net/hyperv/netvsc_drv.c static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) · line 472

Quoted 6 lines
drivers/net/hyperv/netvsc_drv.c +3 -0
 	if (skb_is_gso(skb))
 		goto do_lso;
 
+	if (skb->ip_summed != CHECKSUM_PARTIAL)
+		goto do_send;
+

There are many possible values of ip_summed, why would you go to do_send if for example it was set to CHECKSUM_COMPLETE?

Quoted 6 lines

I think you are just rushing this change, take your time and implement the fix properly.

For example, if you only expect two possible values here (CHECKSUM_PARTIAL and something else), design your test so that it only allows those two values and therefore you'll be documenting this invariant.

David,

I based this check on the check I see in tcp_v4_send_check() (and tcp_v6_send_check). Looking at the code some more, it looks like if ip_summed is set to CHECKSUM_NONE, the software has computed the checksum and we can bypass the code for offloading the checksum.

Regards,

K. Y