Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp2689134imc; Sat, 23 Feb 2019 08:51:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IYyncu5UspCdwughkh3eLf0P2AgPNbNQoAl7zAqjoU7MHK32xNE65Pypv3s+FkheMrNw7XF X-Received: by 2002:a63:374e:: with SMTP id g14mr9696087pgn.59.1550940685211; Sat, 23 Feb 2019 08:51:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550940685; cv=none; d=google.com; s=arc-20160816; b=k0hZAVxnDuqRcliq3izK2Btq1eK05r4+rIsh1BhKkky0GYzF1DioDfdYnpcHTXM+a1 vO3X9EhSnB9kc4WDt+8rfYUwvQPJNTMDjoQWMG34v5OQL9rsiQw+VXU65aeztJ28AFCy QOCqMzVFvFVu5uL2D9qf+Fh1fKYMEPb/C1Bd5yPEVqulSXUS6mrcAPkzobo14u8kQBef 9qyFEhHtedUD1D+Nud3DIPcJDmDPWdZmErMhebQCNVWWitYr/2jILJ9r5xF5GMQE7Fpw QnCqBMB/TxyVUV+ayC+R9fbuC9e4+qA8W7HVkQFj14VS6XwqnddSL14K8lmHU+33/VyR jm5A== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=2tqvMGNGecekmRBMhWxcCbgkjDH0E0cWlXiOAYIkicQ=; b=dvHgYrEdmi3rOaYW2qmlzgNW9a7jgw4MxI2EkbzuQTDbRpYzIGscQWZbKTEiR4aoI+ uqRwTnD2cHc/d7dkaxNI30FgWZsDTyyWhWQ42J/S6Oz8CwSA7mSplo1RaG4I80Tv4nSf 1E92ngu9JEux7E3TDIIvGz4x2rXYJ3Asga8+KTOrsox+MdJH0COKtAHgBtJIccGw/7k3 1f5/jSpqWWpKm+e3B4N2J+CKn9njvREWPxYm3bHlQZoeFwwJ+HhsO1aGvDdUXlZQGJu3 +KUQ2sCTWfqdDkkxClaB2792m9LJFwKrXT1Zp6+aKjt5kzamKSdOUCt2GIBf04zGbwHh idvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=AncxuAb6; 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 d19si3898556pgv.522.2019.02.23.08.51.09; Sat, 23 Feb 2019 08:51:25 -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; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=AncxuAb6; 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 S1727749AbfBWQq3 (ORCPT + 99 others); Sat, 23 Feb 2019 11:46:29 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38108 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726370AbfBWQq2 (ORCPT ); Sat, 23 Feb 2019 11:46:28 -0500 Received: by mail-pf1-f196.google.com with SMTP id n125so2518144pfn.5 for ; Sat, 23 Feb 2019 08:46:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2tqvMGNGecekmRBMhWxcCbgkjDH0E0cWlXiOAYIkicQ=; b=AncxuAb6VmxEHCMCfnlHnFv7ycW0twGHcjGW5aayXJk7VX1A081i2rx+NbzVer9wye 9+iHAdSkp3a0bs6KR9qEMEU9v5XmOVYpdIRqfhyRtvtP57RAlbG8jyU1Cs+uxczrdcxt LCgv3QYLuk6XI+xgM9ann/5ClFZKSAxW8ziUgoTKzb52ogjF7g3k3Dm4HlS0t0bRgrOu 8sra4eEW6nc4mAsHm+EjiSmF/ziienzj8jJ0J2E6UoUsLl3a3G7EvvnNzJuylfsI/yo6 /malusikt+BA+DCMPMM2CUorsEXKtGYcnfDDfP7kB+g56c+ZSc96YPKsh0psoZhCfPxf YKNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2tqvMGNGecekmRBMhWxcCbgkjDH0E0cWlXiOAYIkicQ=; b=bnQf/PcXFcAv8uZMlvrbkLe9vwDtooF1hevnEdh7HHt9bhZZvzKz1R/a7zHBo+mBvZ lsw60KFjgV0uWvKn5OfRQroGJhwftrfFLnOiKqZq5d4jkZc/X/uznWLzVUcJ0hqVn8A3 U7z3ObnJbGmPwr7Wn8w7JiCyW60hdDibuY+XRTpl3vBmSiKwr7fFby9PJajEp9JD1EkJ fbYmrOaZV80CayBvJy+yHPpjO5AQey6T4OAAdFd/9QSCvJ8voViT0XgV2X/ETTqZ18Hg 2bUqRIikom3tV68Fk6Np8zSihc6ZkZCY1wW9524nKFYuPOdWqJ9iW0f8mJhMbgOKhuMZ D6NA== X-Gm-Message-State: AHQUAubN1Y57/xrQo9XxdGJGCDbl4/AoDsvTPWYbsXQ6332VfMs8Hw0i id6NJhZ+bSAUMnO+HstyxFg0ow== X-Received: by 2002:a63:7f46:: with SMTP id p6mr9565771pgn.54.1550940388010; Sat, 23 Feb 2019 08:46:28 -0800 (PST) Received: from shemminger-XPS-13-9360 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 33sm14689464pgs.81.2019.02.23.08.46.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 23 Feb 2019 08:46:27 -0800 (PST) Date: Sat, 23 Feb 2019 08:46:24 -0800 From: Stephen Hemminger To: Haiyang Zhang Cc: haiyangz@microsoft.com, sashal@kernel.org, linux-hyperv@vger.kernel.org, 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: Re: [PATCH hyperv-fixes] hv_netvsc: Fix IP header checksum for coalesced packets Message-ID: <20190223084624.0d0c60a0@shemminger-XPS-13-9360> In-Reply-To: <20190222182503.12160-1-haiyangz@linuxonhyperv.com> References: <20190222182503.12160-1-haiyangz@linuxonhyperv.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 22 Feb 2019 18:25:03 +0000 Haiyang Zhang wrote: > 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; Can you use iphdr(skb) here? > + > + 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); Does this still handle for coalesced and non-coalesced packets which are received with bad IP checksum? My concern is that you are potentially correcting the checksum for a packet whose received checksum was bad. > + /* Do L4 checksum offload if enabled and present. > */ > if (csum_info && (net->features & NETIF_F_RXCSUM)) { > if (csum_info->receive.tcp_checksum_succeeded ||