From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796245604; b=CbF+BhcsHXiiyAqZigdbrqIA+V2EmPhA6ZoOV+7jCESmltaeO9WAv7BJ5T5lTcjnRJbE JboAwsj5nDneeXM4PqvxwNRoauz27INzzBp9BBc3ODk5kKvO0Itv+fKpg7p5RQeJl4WPV Xm3s/Lhv7fDraQNtXSRtGEVEVTVCcV487Ur+yp89VvprWDHbor1cVbn1OSalE37qs4ZxC PNZZ/nxDMErIqPFDiWqeobRnP2Ox1CSrrTOdS5CfWT7GE0yG2slHu+wMfYwaG8wRGn9vh BEoZNL4bQXD+McfIfxaVoczHmH91b12bZGUsv2ErJcZ2LWegZo1O46Z6ZigVAAgtCFQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796245604; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=ikLkPWk4AlvfljuSS9vxcEF1Z+HmmjGjUj6VFHTbCw8=; b=fkJtva7P0A2qjvSv6M6Itqb42C0alvh/zbWw8emOdRy3Z8J8yjIzq+u9eKWtBpbyfHb7 WkWfld1cGIN3lvR6A5EONxNZyhu4XKo3CAOK3gMLEO1PkJ62dQimVh3GfVw/u/cLBIH08 +Nb1AGI3wIUuYZpvDJk6bbxQnDUts6iVwA4uHbI/9bcKN+El5wl6g961+0Z2AXh5MlFKE aqXiTUV+r97K8gA9EAgpJXkL6d4aFY198sPaAVVEPzYr4j86TOZ5W94UT7UtNymmmBiEE ZNc4z1pg3CEXM2JJ4TtJCgo6bE94JB5jym23D8XBpyd0b1lBy32nXJdmxbX/8c6mESg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cloudflare.com; spf=pass smtp.mailfrom=cloudflare.com; dkim=pass header.d=cloudflare.com header.i=@cloudflare.com header.a=rsa-sha256 header.s=google09082023 header.b=epOXTQRj; arc=none smtp.remote-ip=209.85.210.46 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5B98606A322 for ; Wed, 2 Dec 2026 21:06:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B5B98606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=cloudflare.com header.i=@cloudflare.com header.a=rsa-sha256 header.s=google09082023 header.b=epOXTQRj Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-862b090e41eso6904132a34.0 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.linux.dev; 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=epOXTQRjyRXGHnzs1pwpuINQiaTq9uMCZojTvhiq3H1bRZFy2StR7ktKkY+5jP4XTG kDQAxI2CeJPi/H4ZWWlpXU6O/F+dO+ZO/MMXpDLbRmctA7053biTfJ5dVVMDnJ/fHV5U FXqGgRygJFaigAhNYWG7o3cSUa3cEHMy0uD5U/zpOAES8CZHatfVIcHnoAufPY7YN0B0 r7EIXyCHrrOJRsPrpoAQmlZk3wCLqMggmlEXlYErgPhfk1wZE+l3qw6xpcs+jW6rF3v0 YQpU0tQZm6xq8DfNGW156TKTQgR30LtOLk59K1IwqSTtGtfhbA9S9AmxoJqxrZ7oX3Xc eLuA== 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+HmmjGjUj6VFHTbCw8=; b=WlzN2MJE+HpWypMyg29RBM18T+iaTStZ5kPoU/dyU/1kIL4OYpQVXvJeJefJa+Fdxg M960owpt0YjKOWE2Q+p2KjCXDdwt+WFeuLsweXWeZkwcBSw7RD4GYSB9MSoX8RnXYbB4 TeV5HgfjyhQpdsOUJlvd+6z9WD3R5M99UoAGonrCwMssMGLSSNxT4L2dsFhSht3LXLtV kc4d6Wyt+/8+tR32vz9IW5V5YN9nN+LT/Kk3oFflY/vZU+yJWE4ZSOquCZRSbUOtkw5r sZDKrjqROl00DE4H+C4WyvMMXdf+RTD5ZLRhN9+5HlXUfyChsw1wr8EGVbR6h7tCKuBW GwIg== X-Forwarded-Encrypted: i=1; AL+hErFsYXDl6oHJG8mhxMNixB23RYZRtQRHgSpmxJJM0Ar+WYgV8dQDrnjwVirj3QjgLUWGdp4wLG/MKwJM+qHz7A==@lists.linux.dev X-Gm-Message-State: APuU4Z+cG4Ml3+x6iTzrej1r2IOH+h7L+EQWsPmTyvLYto7/g0rUkIde XHW3Tu67ONX6FqvmRIgjv8cg1kETCBQDCyNhD5QPm5gRsu9BVBWRRBgAkVEcd6N+0ls= X-Gm-Gg: AZFdTZfmPD5It7KgNJHnsf9pQoOKvCupCZ6+9NKJsRaivbL0Q7Rif7WsI1Gqndg0cyJ Vr5EmEz7T78kDORq425YzKd+fWa4jR1Bv342uwO2NeI80ME0EL2PW6Qgqv5yB/Msgfpd0m5CqqG q3/JWv78OC3P+7u5zZRouUoGMIxOL9kpUYzG0Ckl1mBnqrU067XAQzsbUW+KObxaQwMb8QkoxzG Av8EKOPseseF45lVRnj0tW/Alq+8qrC9ZJunzI86De7N6/z367BgWXMNvK6RNEcT9AdX5wcZqzJ oVmmlY8bDClkFJTwa8PhLP49KANECevi+/+UUqQ383a0JALzNDNB1Cqc2F3wKCedCXUKGCY83Kz Te49PxpvJnwFLuPjtS1LpVEocbuFg8Pm+l/0U9VdloxpfN4oaMdaK+NCrGK9OXYFx1xBqBqoaGl gGWQsHEKI/5TdqbSmtVh4slk/P3oNgDb1K1euOGRTipaUFvirqiNfGLiECI0t8dmdMaxLtmAZ+v 0ZZi8X56tphWidAJUY1Svrfnw70D2UepSanMqKxGTvwfYdQUs1AVk6hDx0W1lvLS4iBirTkz02X 4gR5Yjuy+Q== 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-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202.rfcv9.41657.5.zakinko@snowrabbit.org> 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); } ```