From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C685B606A322 for ; Wed, 2 Dec 2026 21:06:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Xp+rCx5A; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.a=rsa-sha256 header.s=google09082023 header.b=JNhN8O2m DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=ikLkPWk4AlvfljuSS9vxcEF1Z+HmmjGjUj6VFHTbCw8=; b=Xp+rCx5AfLzTmVHeN5J91xViMa IpefT5MRN18K2dZcxOefJezPXq1S6+mQm7hbRXgIUmLE+rwnjDbKyCDHJ9qgHUW6pVun2tABNsX6J rj9wMWE/L8TVBgLG4A/923a/KKAxlnjtsmI5CXW/uOK1SLky6kXUC8oLu7/d4ZCjSCv2TL1PIFnIF tiG0Itn7Qu5Wqdr8jWghRIqVsit7PUT8UkllY2nxxpSnozm6LNlo1zPt+9gbbqVJGX0QhwOr1P0C1 ILd55JiszZEbZ3eNskemfDXxvDOdVj0hvwCwAavEElLsGTKEf8jLD8HNgddIuoJ45194eNXBLwS2T /yoUwkSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYrXL-0000000Cnom-3yNH; Wed, 02 Dec 2026 21:06:47 +0000 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYrXI-0000000Cnnr-3FOJ for linux-um@lists.infradead.org; Wed, 02 Dec 2026 21:06:47 +0000 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-845788309b4so6197276a34.1 for ; Wed, 02 Dec 2026 13:06:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1796245603; x=1796850403; darn=lists.infradead.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=ikLkPWk4AlvfljuSS9vxcEF1Z+HmmjGjUj6VFHTbCw8=; b=JNhN8O2mtV7I/UdVKDn1/BjIop3uN8Su4wjngp05sj3hdNMK52HfvzRerBcj1Fy4lH wwL/Bm3HaWFnKqqt35zhI4MctZEyh9BJiRatlOy0cGLZCuASZWmb+t3HYHuFDhZAQkiP pzZEZ3pWZgHH5Hx3HLdqjEgpBse97tcfDeHgmxQse0IrXQQgjeYZ1mU6fpFvPDuxjjpz SvxKufBsjBLTp1ybmVm1Y2EW3mG6oVcCq950Kjd1vrbtSK6+T0esfqQBEkj7uh9prigj dHIj83h3ADfCXII0z5ncTJzuEp58b1art/2Vk4e9S0DowlelvFJScZY071ODMNADYofg +p/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796245603; x=1796850403; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ikLkPWk4AlvfljuSS9vxcEF1Z+HmmjGjUj6VFHTbC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RIeHEbidLs+S+24lv8nnV8cnVJX6ZMYyfBeW3OdlyLrYs+WzIpZ/4+MKC7ka VUScN6gxDCyDSN1XnjMwissEMaMC9r45mVwvsNXMZ3qxkuLroAKvhaPGxZbAtOvkcCty6tYvJIC 57f2WSyD7g== X-Received: by 2002:a05:6830:b14:b0:81e:a323:f3bc with SMTP id 46e09a7af769-86315963eaemr45178877a34.13.1796245602581; Wed, 02 Dec 2026 13:06:42 -0800 (PST) Received: from 20HS2G4 ([2a09:bac6:bf21:1923::281:c]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863168dd6d8sm29336694a34.10.2026.12.02.13.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 13:06:41 -0800 (PST) Date: Wed, 2 Dec 2026 15:06:38 -0600 From: Chris Arges To: Showta Ishizaki Cc: "Michael S. Tsirkin" , Willem de Bruijn , Jason Wang , netdev@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Paolo Abeni , "David S. Miller" , Andrew Lunn , Simon Horman , Eugenio =?utf-8?B?UMOpcmV6?= , Xuan Zhuo , Richard Weinberger , Anton Ivanov , Johannes Berg , Jonathan Corbet , Shuah Khan , Randy Dunlap , Paulos Yibelo , =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= , virtualization@lists.linux.dev, linux-um@lists.infradead.org, linux-doc@vger.kernel.org Subject: Re: [PATCH RFC net v9 5/6] net: virtio: compute the outer checksum of non-GSO tunnel packets Message-ID: References: <20261202.rfcv9.41657.0.zakinko@snowrabbit.org> <20261202.rfcv9.41657.5.zakinko@snowrabbit.org> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202.rfcv9.41657.5.zakinko@snowrabbit.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261202_130644_837376_D1919FC6 X-CRM114-Status: GOOD ( 31.31 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On 2026-12-02 13:00:00, Showta Ishizaki wrote: > A packet may be tagged as UDP tunnel GSO and still be too small to > segment. Then nothing consumes the pseudo-header seed the sender left in > the outer UDP checksum. The GSO layer is not run, and transmit checksum > offload completes only the inner checksum, so the seed goes out as the > outer checksum. > > Zeroing it is not an option either: IPv6 receivers drop a zero UDP > checksum unless the tunnel opted in (RFC 6935, RFC 6936). > > Compute the outer checksum when VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM asks > for one: with local checksum offload while the inner checksum is still > partial, or by a full sum once the inner one was completed in software > because its metadata did not match the packet. Such packets no longer > need to be dropped. > > The addresses come from the outer header in the frame and the length > from the UDP header. udp_set_csum() is not used: it is built with > CONFIG_INET, which virtio_net does not depend on. > > Fixes: a2fb4bc4e2a6 ("net: implement virtio helpers to handle UDP GSO tunneling.") > Suggested-by: Willem de Bruijn > Signed-off-by: Showta Ishizaki > --- > include/linux/virtio_net.h | 105 ++++++++++++++++++++++++++++++++++--- > 1 file changed, 98 insertions(+), 7 deletions(-) > > diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h > index 714b20acd38f..9fb71a5ee991 100644 > --- a/include/linux/virtio_net.h > +++ b/include/linux/virtio_net.h > @@ -8,8 +8,10 @@ > #include > #include > #include > +#include > #include > #include > +#include > #include > #include > > @@ -553,6 +555,64 @@ virtio_net_tnl_offsets_ok(struct sk_buff *skb, bool has_eth, bool outer_isv6, > return ip_proto == IPPROTO_UDP && outer_th == thoff; > } > > +/* Fill in the outer UDP checksum of a tunnel packet that is not GSO. > + * While the inner checksum is still CHECKSUM_PARTIAL this is local > + * checksum offload, as udp_set_csum() does for udp_tunnel_xmit_skb(), > + * and needs the transport header at @outer_th. Once the inner > + * checksum has been completed the datagram is summed in full. > + * > + * The pseudo-header comes from the frame, not from the seed the sender > + * put in uh->check: the addresses of the outer IP header and the > + * length of the UDP header, which skb->len exceeds when the frame is > + * padded. > + * > + * udp_set_csum() itself is not used: it is built with CONFIG_INET, > + * which virtio_net does not depend on. > + */ > +static inline int > +virtio_net_tnl_set_outer_csum(struct sk_buff *skb, bool has_eth, > + bool outer_isv6, unsigned int outer_th) > +{ > + unsigned int thoff; > + struct udphdr *uh; > + int ip_proto, nhoff; > + __be16 proto; > + __wsum csum; > + int len, err; > + > + /* virtio_net_tnl_offsets_ok() has passed; this finds nhoff. */ > + if (!virtio_net_l3_start(skb, has_eth, &nhoff, &proto) || > + !virtio_net_l4_start(skb, nhoff, proto, &thoff, &ip_proto)) > + return -EINVAL; > + > + err = skb_ensure_writable(skb, outer_th + sizeof(*uh)); > + if (err) > + return err; > + > + uh = (struct udphdr *)(skb->data + outer_th); > + len = ntohs(uh->len); > + uh->check = 0; > + if (skb->ip_summed == CHECKSUM_PARTIAL) > + csum = lco_csum(skb); > + else > + csum = skb_checksum(skb, outer_th, skb->len - outer_th, 0); After doing some testing, I found that non-zero Ethernet padding causes full-checksum fallback to product incorrect outer UDP checksums. I was able to fix my tests with this change: ``` if (skb->ip_summed == CHECKSUM_PARTIAL) { csum = lco_csum(skb); } else { if (len < sizeof(*uh) || len > skb->len - outer_th) return -EINVAL; csum = skb_checksum(skb, outer_th, len, 0); } ```