🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24573

Re: [PATCH net v3 2/2] xsk: fill in header offsets for TX checksum offload

#24573
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 11:12
167 lines
13711 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] xsk_skb_csum() (net/xdp/xsk.c:1071-1076) assumes that the
  user-supplied csum_start is the L4 header right after the outermost L3…
- [Low] The commit message of "xsk: fill in header offsets for TX
  checksum offload" relies on its companion commit "net: reset the mac…

--

xsk: fill in header offsets for TX checksum offload

This commit changes xsk_skb_sw_csum() into xsk_skb_csum(). For
CHECKSUM_PARTIAL skbs built from AF_XDP TX metadata, the new function
parses the Ethernet header and any VLAN tags. It then sets skb->protocol,
the network header and the transport header, so that the checksum
request can be offloaded to hardware.

> skb->protocol is set to the outer ethertype, as the rest of the stack does
> for in-band VLAN tags, so skb_vlan_tagged() and vlan_features_check()
> keep seeing the tags. can_checksum_protocol() and the drivers get the L3
> type through vlan_get_protocol(). The mac header is anchored by
> __dev_direct_xmit() in the previous patch.

[Severity: Low]
This has no runtime effect in this tree, but could the dependency be
named explicitly? "the previous patch" seems to mean "net: reset the mac
header in __dev_direct_xmit()". That commit has a different Fixes tag
(35fcde7f8deb) and is also Cc stable.

Before this patch, skb->protocol stayed 0 for xsk skbs, so
skb_vlan_tagged_multi() returned early:

include/linux/if_vlan.h:skb_vlan_tagged_multi() {
    ...
		if (likely(!eth_type_vlan(protocol)))
			return false;
		...
		veh = skb_vlan_eth_hdr(skb);
    ...
}

skb->protocol is now set to ETH_P_8021Q/ETH_P_8021AD for in-band VLAN
frames, so this dereferences skb_mac_header(). That is only valid
because the companion patch calls skb_reset_mac_header() in
__dev_direct_xmit() before validate_xmit_skb_list().

Suppose this patch is backported to stable without the companion. Would
a VLAN-tagged copy-mode frame that requests XDP_TXMD_FLAGS_CHECKSUM then
read through an unset mac header?

Could the companion commit be referenced by subject, or could a stable
dependency annotation be added?

> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 18cbd50047d80..ea94ba07db813 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c

[ ... ]

> @@ -1026,12 +1030,51 @@ static int xsk_skb_metadata(struct sk_buff *skb, void *buffer,

[ ... ]

> +	switch (proto) {
> +	case htons(ETH_P_IP):
> +		l3_min = sizeof(struct iphdr);
> +		break;
> +	case htons(ETH_P_IPV6):
> +		l3_min = sizeof(struct ipv6hdr);
> +		break;
> +	default:
> +		return 0;
> +	}
> +
> +	if (unlikely(skb_checksum_start_offset(skb) < nhoff + l3_min))
> +		return 0;
> +
> +	skb->protocol = eth->h_proto;
> +	skb_set_network_header(skb, nhoff);
> +	skb_set_transport_header(skb, skb_checksum_start_offset(skb));

[Severity: Medium]
Is a lower bound on csum_start enough here? The commit message says
"request.csum_start is already the offset of the L4 header from the
start of the frame, so the transport header is known exactly". However,
nothing ties csum_start to the real L3 header length or to the L4
protocol in the IP header.

Before this patch skb->protocol was 0. On IP_CSUM/IPV6_CSUM-only devices
the sequence was:

  can_checksum_protocol() fails
  harmonize_features() strips the checksum features
  skb_checksum_help() writes the checksum at csum_start + csum_offset

Now an IPv4 frame keeps NETIF_F_IP_CSUM. In this case
skb_csum_hwoffload_help() only looks at csum_offset:

net/core/dev.c:skb_csum_hwoffload_help() {
    ...
	if (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) {
		if (skb_has_ipv6_extension_hdr(skb))
			goto sw_checksum;

		switch (skb->csum_offset) {
		case offsetof(struct tcphdr, check):
		case offsetof(struct udphdr, check):
			return 0;
    ...
}

The catch for tunnels without skb->encapsulation only exists for IPv6.

Drivers whose checksum engines pick the L4 type from the IP header then
ignore csum_offset. For example, ice_tx_csum() on E810 (no ICE_F_GCS)
and i40e_tx_enable_csum() both do:

	l4_proto = ip.v4->protocol;

and ice programs IPLEN as (l3_len / 4).

Take Eth/IPv4(proto=UDP)/UDP/IPv4/TCP, where user space asks for the
inner TCP checksum with csum_start=62 and csum_offset=16. The check
above passes (62 >= 14 + 20), and ice programs L4T=UDP with IPLEN=48/4.

The NIC would then write a UDP checksum at 62 + 6 = 68, which is inside
the inner TCP sequence number. The real checksum field at 78 keeps the
pseudo-header seed.

There is a separate case. ice_features_check() only rejects odd network
header lengths:

	len = skb_network_header_len(skb);
	if (len > ICE_TXD_IPLEN_MAX || len & 0x1)
		goto out_rm_features;

A length like 70 (VXLAN inner TCP, 84 - 14) is truncated to 68 in the
dword-granular IPLEN field. The hardware L4 start then no longer matches
csum_start.

Could UDP-encapsulated IPv4 frames that used to get a correct software
checksum now leave the NIC with a corrupted checksum?

Would it be safer to leave the skb untouched unless both of these hold?

  csum_start - nhoff equals the real L3 header length (IHL * 4 for IPv4,
  40 for IPv6)
  the L3 next protocol (TCP/UDP) matches csum_offset

Another option might be to set up the headers only for devices with
NETIF_F_HW_CSUM.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129111056.11124-1-kerneljasonxing%40gmail.com
Technical Details
Message-ID: <179603715316.3146.17515519924922655886@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374125-linux-kernel-netdev=dewy.ru
References: <20261129111056.11124-3-kerneljasonxing@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374125-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3 2/2] xsk: fill in header offsets for TX checksum offload
Date: Mon, 30 Nov 2026 11:12:33 +0000
Organization: Usenet Network
Message-ID: <179603715316.3146.17515519924922655886@kernel.org>
References: <20261129111056.11124-3-kerneljasonxing@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1410284"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:EyhkVBtaSg/MV8bkcFX9Ke95ay4= sha256:l6y0vY34a1eudFT3/2x4BChM8pSOdV0qdeIY9NHqN2g=
	sha1:827lGx1FBoBPwhCgUnZWRQUMtgo= sha256:+XEmSXrSm6jooBN1m4O8y40gi8a1uuP3hvGNg9jmdFU=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id B47C4125FDC; Mon, 30 Nov 2026 14:12:51 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id N6nM9jKW3Lcm;
	Mon, 30 Nov 2026 14:12:47 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374125-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 51C81125D23; Mon, 30 Nov 2026 14:12:38 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 8BDA22B00C; Mon, 30 Nov 2026 11:12:36 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796037156;
	b=FSYhhVSHSNHXEBOsLdPtm6RCXUwE7sFOuCSmlXyMS0iePeU++kcBqLi7mIZv38ag3Eqe
	 GfM5UplB3iKASt4NNx32jHRDKXVFzBnfwFyLdV8kNPMi/juoOLzB4htR5Ly4WegA0Ee+Z
	 rONfp2Yt8mB8qhJux/41QiTa33bmrrP0EDb/qSrUi/rE+6N5VM3dr4j7jKBrAGMFyIWym
	 XvqQp7njQq95fCse9I13eLLKNb0Zqy+sj0U5Hz0LieljhvtCqS5xumaZD9NHSzysm0JCe
	 vYctFzq/hF6qn3zsZ0V+xbMT1dFCMSxqdHBoaCkTqdKg+YAoFsct8zGynC1s1D3VcEA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796037156;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=VCm3s459m6x3Dl6cfPl5XFF9gdWcW3YA7u2ii5nU7eo=;
	b=dn+4G6Cbx2/m/T9XY6WXbh+katk0FCxUBr6FysyPjbPakbEDMnTD9bj1TCGDyk0bG03i
	 rkDyYkmIgHwn5JxV2c8IvMpRL0bGaKCPt/c4wm9v83rK3r7NB2wiBaVD7Ppr80FHvO1nw
	 vzvCxsei+NPnA4DiDMo8tRwvezGw/1xmVC4z2HN4UtMSmzBdw6RiVoDF7W6sdmN4MNr6R
	 IDma0KuYRIaP6kSAt8ixFWUaqqwA3BXiV/fPPnr04cM/Jqinfu0mdeNi54fjExip6hR5L
	 VT86ir6IUTislWSnT1C05QRo7nIqs+3g92gZSJDv5Fdx1EsfIfJJHcdvQ8LqvBK0wEg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EpH+Lfwc;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BA26606A31C;
	Mon, 30 Nov 2026 11:12:36 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EpH+Lfwc
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796037155;
	b=p2QvXw/e2dEj+bfcB2vQ70hWwiqyYuvGI1G0Ro518BEH+/NJKxrXUNQhwVs1DlBflSI2
	 f5IsQHVr6BHRD2Ke1X9/0cIpUN+0ZOZ53T2nflKJg4Nqu3ADkMbssbZOAiL0ieCSfMVZF
	 58tM/0+v/vMWXLCKmbEv3MZOxY7tzAtx1/vdilYyG3GilM+hKQQ42HaWKKOH6YLun10J7
	 Xs/TqlIn6TzAK+Gca6hzT9sJqSgVgb2keIMx/7GyIoON5MrNZ/2KSX3i6S4QzqOX36+1s
	 NVdbvlrOdM3UCoo+fseA9/0PbJfmp/gdorw91aAb1b+Mq/3f/C9Ur1JpHnmZ0YWOYaw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796037155;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=VCm3s459m6x3Dl6cfPl5XFF9gdWcW3YA7u2ii5nU7eo=;
	b=pepOsq4McZErU70eOADBOYL0UI3qjG/KpceTI3bt8mS12crRx/CZ87fDgVVCKTVSCXqF
	 hQnqGQWjFs/dtQDFQNPvOrxHbP9ugmNhDmn3RP4nYhdXjFrnpxHuW1vD9J3fE1fnsUk7g
	 Jb4yzOW5DlwtGTqrT9TKdbS09U8YaN+BncQHjVeIGxek0oY1uKutqTCVGhGj1ykFyL5/s
	 b5f9X/C06tnqmyEzAr9Ci6Ba3bedTJlYMbJRR2Pg+N5wEy9TpB+r6u45LHAH20+cVz7MO
	 GFWRU1p8GKeUYdV15PTSDXfWY+qLzPAQ5ZJ2tXZrXErbk75DY2Mg9XkXXV9joaBfK0A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EpH+Lfwc;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BAF2606A320;
	Mon, 30 Nov 2026 11:12:34 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B14631F00898;
	Mon, 30 Nov 2026 11:12:33 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796037154;
	bh=VCm3s459m6x3Dl6cfPl5XFF9gdWcW3YA7u2ii5nU7eo=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=EpH+LfwcOKBMy2jMmV3wa04UVudq69/GNNJRHUzb0JYhQCUBeEQ6rXDG52rnpPIvM
	 0dPWULXmG/GIgpd/WkwDMCQrlQILgeR0GxYeRfywKi3fM7hvZF6WG7qZLLuL5MDhTZ
	 R+VlPPYccTjYDVPMTpv7NxeKV7giFUcUux+5ws1WtP/KW2yb9lqHqy2HtK6GKZ/3D5
	 t3TzG5qjOXjr7NtenO89PrxpeC982G1+BTNt1pE6WWF7Fq4KRmyB98cv2WByP9sZ2B
	 7H/ePwtovtDIBpU9RaS5/0CXfS7Z1Pc+dRuYgGD2iMuW0ZM/jNHHcTzlDwLsdK1QmJ
	 xp1+KyF6gEKtw==
X-Cc: willemb@google.com, magnus.karlsson@intel.com,
 maciej.fijalkowski@intel.com, sdf@fomichev.me, bjorn@kernel.org,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 horms@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org,
 stable@vger.kernel.org
X-In-Reply-To: <20261129111056.11124-3-kerneljasonxing@gmail.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list