From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796245604; b=paHJw0NBCNjsSDw+JsvFwXE2i6SbIyxvenP2hPP+fCFnmG6TVt90efgh6+Rmqdc2ca5Q QO7ifRqVUmDRP4G7WR7ROhLLQW5GUpeQDcBrfMm+fAKNZQp/lCBQsbw9zeOt1iOQBxYWy kRfiZ5lCVXg7xTPPnZTvhBaAKNPtRGfstXOVKjlHLewWilqi3WEEtgKZ36n8oaCG4c+S0 NTlii0AM9B9n2u9Sfxve5ILMSQzpz/8BP9Sp5FLqDChS7SkaPfla9u5It/7JjOYkYrwNS EGKrPhaBnHk8P7TEuRa3m2T4rk9RKykb8Ghx15JFDAsVAeeMQDDITfKgxYmIpV7rLlA== 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=dmTnvTq9XY1337YUfM1zBgNq1S7BJJ7EHhpYK7I9wCC0Iwl0J9uk1yXXN7ugwlBduojd /Oh+Dh+QGCTJMPE9lEZuO9Yv+cP+5o8mAESAO8YkvVAvEJr6HHtuiPpRxBwZL6/PbgOEO gqZYNxUAPoafYP3bCFQ9L+Fi4k2PVuXy+24Gll2CMcYY8gdzlJFlaNn9ZK7bbUHINXo1X Y4y8tKA0HEYw4PyIa3y1JTJG/swW3fOQESA4rW5v6NAogSfpBesXwfGjhvYW/nhFUn7TN ufq72A3+P0TAO8uarM3SAw0R1t/Kbv52XBvb6jGDI2QPPtv5WrA1bD0uvTebaw2hnCQ== 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="CiaL+W/F"; arc=none smtp.remote-ip=209.85.210.47 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 BC291606A32D for ; Wed, 2 Dec 2026 21:06:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BC291606A32D 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) header.d=cloudflare.com header.i=@cloudflare.com header.a=rsa-sha256 header.s=google09082023 header.b=CiaL+W/F Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-862b090e41eso6904133a34.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=vger.kernel.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=CiaL+W/FJsDigJgsTENd2wucBk8Mr0cml8dBtfZCbPuHYOWLHYIMmDiS9DoNzJ1uS2 tBQWw8OOSzS5PrCtFRXArO0rq5u/Ke8iaYmXALzPtOd+XfheYoU4CFEirnLWKLvS6PAF mxp9rDr9kCZKnFMNZnWeRBZ/haT34S4ARJnBjPznyaiCQKqN4j/X64hxkVG6aw+Tnxgd peKUdUdV7mxGmXtJbgu04FJtfNBW3/OHxeRxq0Bx8KTDTXyCnimOgnowLjm9XgCTXjqL Yc8oRPhh75IwqiGXoBVOgRLJbYw9wFbCPB1Gc/GLaunOzKf6/sc+ZK04mMyM74G6UupB fSbQ== 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=LPXFQoj5AQhqp/Xiau+CacVRN6dL3ZGtsrMrLayDkuHMiJGthu50PlaBuq7BqgMPqB 4X5kWFjdvZFa73Wc22oOX04na4r6usGiEFpim1OlXIrIN6UZ7yS6dKLWzgcflomEIZOQ q896cAwPHF9aDkJKM9gzCaYV6xG1AN1+pTVBcfHuP22nvE2I1tdvdSgOGSmmqQSyoeDJ 1hvKzcfgVES+OwQIPxjaR07kSP+uTjROVF0xOm8uRjMLsGz38UJAQ/rkExEC8PlSDomH EpAKXyVwnTw9XwrPbT/4HZpXPR6LNI1+R7i2SNN2o7PtzixDyhWksw3O9m5IT5zan4p4 1Vmw== X-Forwarded-Encrypted: i=1; AL+hErHnvwT+EF22jfx/BLkSKpdPJ4H+Pap/rbxQrCD96DEsvj2K5iw/YHZQmUHhfGFSdpNfKP6ra84aMI0=@vger.kernel.org X-Gm-Message-State: APuU4Z91Exzry90FFlgtHOQzqhRgWa1wOiBNgy5WYFZZQY/SxHWt5FKj 7gZqLplVwGM9uK3JZEqgjicd0b435rTr8fyab8M3x//QBLZif1nw5Ch2gt1FckO9ifs= X-Gm-Gg: AZFdTZetgTRi3RfUOdv586GLKW2p5TlIHQDZq5rYLdox/xuUSyzyzq9/EEyvE9vlM+j t587Oa1ZouBeco9SjxivTyWfSBg+VqjrBrs0rMl/+sbJyOTJJ59gLmZa6ypzsSZ4JdWX+bjHoYr qzbXUKeMKDgU2YOC4X/QC1xAtH+6SZi7qvQtkJSo002yM8yVPQVop1o4muhOJmr88GCzfT67kEg yU1GAsC8g1tx4Of4+Ga5f3amrN4xh6ENHAz1W9h4DhJhIZf2RYylvV4W/80kVfKqBAEBL1VRuiq 5gwl8bD9LYUy6tnTd7ABL6tAobvparpESMLSmlQeM80VuJqs0OQq5TTJFHiHxgvyDIUOpRWgMCX 0gbmNnMXocHnulzZhwEi0hd3/fkBLuiBJR5Es5XVc5gJsCxteXBDV0f3PT5lFp9FAmtVKcwteCl PE3zkRmy72eVxur3IoU+O4XaSKSDU3PtUIwuTBf6/SxZ21NCdgrJLnb80i7Qp7G2O3lCuNRfgfI MQP2g1zO32pwSJQNqrPWQUYHPnbtAhDBAxC29CknDUkIqhFzNwWOfpE+cFHVP7kyOEYYYPzFY+y /y49iTKmnw== 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: linux-doc@vger.kernel.org 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); } ```