]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
netvsc: fix incorrect receive checksum offloading
authorStephen Hemminger <sthemmin@microsoft.com>
Mon, 24 Oct 2016 04:32:47 +0000 (21:32 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 12 Oct 2017 14:28:20 +0000 (15:28 +0100)
commit e52fed7177f74382f742c27de2cc5314790aebb6 upstream.

The Hyper-V netvsc driver was looking at the incorrect status bits
in the checksum info. It was setting the receive checksum unnecessary
flag based on the IP header checksum being correct. The checksum
flag is skb is about TCP and UDP checksum status. Because of this
bug, any packet received with bad TCP checksum would be passed
up the stack and to the application causing data corruption.
The problem is reproducible via netcat and netem.

This had a side effect of not doing receive checksum offload
on IPv6. The driver was also also always doing checksum offload
independent of the checksum setting done via ethtool.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/hyperv/netvsc_drv.c

index ab68d940a2c71be5f9cbd5088ab928bd8c4403e0..ff0e464441d0106f156509a3ac6b2b1d1722a300 100644 (file)
@@ -643,15 +643,18 @@ int netvsc_recv_callback(struct hv_device *device_obj,
                packet->total_data_buflen);
 
        skb->protocol = eth_type_trans(skb, net);
-       if (csum_info) {
-               /* We only look at the IP checksum here.
-                * Should we be dropping the packet if checksum
-                * failed? How do we deal with other checksums - TCP/UDP?
-                */
-               if (csum_info->receive.ip_checksum_succeeded)
+
+       /* skb is already created with CHECKSUM_NONE */
+       skb_checksum_none_assert(skb);
+
+       /*
+        * In Linux, the IP checksum is always checked.
+        * Do L4 checksum offload if enabled and present.
+        */
+       if (csum_info && (net->features & NETIF_F_RXCSUM)) {
+               if (csum_info->receive.tcp_checksum_succeeded ||
+                   csum_info->receive.udp_checksum_succeeded)
                        skb->ip_summed = CHECKSUM_UNNECESSARY;
-               else
-                       skb->ip_summed = CHECKSUM_NONE;
        }
 
        if (packet->vlan_tci & VLAN_TAG_PRESENT)