Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp1752412imc; Fri, 22 Feb 2019 10:29:16 -0800 (PST) X-Google-Smtp-Source: AHgI3IbE7AWscHRslUHpVHDYUkOlgX7E4OW4SQIqbYapyfCyQ0bE9py6Dy3LOycj0GrWcyvQVjL6 X-Received: by 2002:a62:55c4:: with SMTP id j187mr5479663pfb.129.1550860156851; Fri, 22 Feb 2019 10:29:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550860156; cv=none; d=google.com; s=arc-20160816; b=tqn/AZ1BRzg7CW3Wb+B2sNurS/dES7WX7YgZzdmauCxHsBOSiM8491MG6QyR9AbM5q oRf3qBNYgN7whQxPVGKXYH4RZwZneOzREsh3A8WEU3NIS/eXfADqXTZHfLPhh44hhSxH QykKKy+liDn3UOspZXKYd2PSmzVjC05woqGare5qn6ytRRusbAOuXq6j2Z01nqIyz0la YBs0ZAk8CtHd5p8+2t9KYBRDsF9M0PFTJnUG9OCGnwbGeye4mpuAlqfOAFR75QFo23dA uGARYDXQ57C+GdJ2FwqJVliZpgBusQxeKNlZgvxKmYBxFLKE6Twxta8bI0UXoNxECftK SDgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:reply-to :mime-version:message-id:date:subject:cc:to:from; bh=nmtSNtbxj5tYWIO3d4Gh3aD++KW4IIJbF76vuil+ipI=; b=zRUITNFk63MQiXBW3StwsfSYr+on77JzQobbTqxIwX6gpoqVas2EXHl7Ul0drHVEdX 8QOt5DtiRpXjL57NOkAjVzyujZDDad3P4JDO2eg13vDWNqu+p77NLX8E84i+f8nwBiO+ cLsl4ycVZTpj/FJ3+uQaiMl960S2LX2yx5xFGtFYeVKF4DUaNZ54a49aOBTfjYiEDF0+ HD7XfV68CacIT3mjGvtSJK4qP/hZtyo7cof2vKXQG//0gttd6u9UFaa1b+uLrIhaECJy Nx2bY4K7hbViEiFRZZpmAQ0H0V6iqw2rWaz0JHt845Mw6/EK5WqtPXcLj4aSOMeS17Lh RvZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97si1914416plm.3.2019.02.22.10.29.01; Fri, 22 Feb 2019 10:29:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727605AbfBVS0p (ORCPT + 99 others); Fri, 22 Feb 2019 13:26:45 -0500 Received: from a2nlsmtp01-02.prod.iad2.secureserver.net ([198.71.225.36]:37252 "EHLO a2nlsmtp01-02.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbfBVS0o (ORCPT ); Fri, 22 Feb 2019 13:26:44 -0500 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with ESMTP id xFW3ghWxKhEQ7xFW3gUlkm; Fri, 22 Feb 2019 11:25:43 -0700 x-originating-ip: 107.180.71.197 Received: from haiyangz by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.91) (envelope-from ) id 1gxFW3-0003Aq-Bn; Fri, 22 Feb 2019 11:25:43 -0700 From: Haiyang Zhang To: sashal@kernel.org, linux-hyperv@vger.kernel.org Cc: haiyangz@microsoft.com, kys@microsoft.com, sthemmin@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH hyperv-fixes] hv_netvsc: Fix IP header checksum for coalesced packets Date: Fri, 22 Feb 2019 18:25:03 +0000 Message-Id: <20190222182503.12160-1-haiyangz@linuxonhyperv.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Reply-To: haiyangz@microsoft.com Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfAdO3BIupsRjgTvMK/y1eJzwxhgPoRgQSW3yr1z8H7YHKhKrdWAPhRkKvYWaGAVBdvEBALHtb3A/P9vUadekn00sIF7lncMMrl/H/aQiNYyrPGyBFZ8N pIbUq91qbfVHE9AU4LTx1bJL3AmAkCfVUjeoZsYJfzeO/2Lyv6C6rSdNm23rqYWfUs/XWJknfmQbqLvPj0d1O9bdURQdmSUe7FZPKb1ERXbVsuBVRDb+KJ0m oh1VqXfDQ/qMSbXyy/iYNKY+N8UOY7kTqXifzVpI7Fph+QRbscjdVjg7vVwMck/HpUzW7gGa45opl/i3N/vM1dYiY+VIKUnDurIuWdAKlICNoIcHJYXhTrkF RNofzeSdRsDJM72g+F9fKSCVvpRmI32sx5tRZUY5Ql3dh48M6mtXP2U1OaFEnkgmY4B+GsuutzoD5R5AgPpiiOo/13uBoc49pwQIxwZsvCkmwRMv6OUsBYyE XVDyEqmCw8D0hirlSNPTbirRuf3rBV8RWbWCGGMWcePTX6jCam8Mic7tvqg= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haiyang Zhang Incoming packets may have IP header checksum verified by the host. They may not have IP header checksum computed after coalescing. This patch re-compute the checksum when necessary, otherwise the packets may be dropped, because Linux network stack always checks it. Signed-off-by: Haiyang Zhang --- drivers/net/hyperv/netvsc_drv.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 256adbd044f5..cf4897043e83 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -744,6 +744,14 @@ void netvsc_linkstatus_callback(struct net_device *net, schedule_delayed_work(&ndev_ctx->dwork, 0); } +static void netvsc_comp_ipcsum(struct sk_buff *skb) +{ + struct iphdr *iph = (struct iphdr *)skb->data; + + iph->check = 0; + iph->check = ip_fast_csum(iph, iph->ihl); +} + static struct sk_buff *netvsc_alloc_recv_skb(struct net_device *net, struct netvsc_channel *nvchan) { @@ -770,9 +778,17 @@ static struct sk_buff *netvsc_alloc_recv_skb(struct net_device *net, /* 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. + /* Incoming packets may have IP header checksum verified by the host. + * They may not have IP header checksum computed after coalescing. + * We compute it here if the flags are set, because on Linux, the IP + * checksum is always checked. + */ + if (csum_info && csum_info->receive.ip_checksum_value_invalid && + csum_info->receive.ip_checksum_succeeded && + skb->protocol == htons(ETH_P_IP)) + netvsc_comp_ipcsum(skb); + + /* Do L4 checksum offload if enabled and present. */ if (csum_info && (net->features & NETIF_F_RXCSUM)) { if (csum_info->receive.tcp_checksum_succeeded || -- 2.19.1