🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26344

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

#26344
From: Björn Töpel
Date: Thu, 03 Dec 2026 12:05
51 lines
10100 bytes
Jason Xing <kerneljasonxing@gmail.com> writes:

> An XDP_TXMD_FLAGS_CHECKSUM request is turned into an skb carrying
> CHECKSUM_PARTIAL by xsk_skb_metadata() where csum_start/csum_offset/
> ip_summed are set.
>
> However skb->protocol stays 0, the offload never actually reaches
> the hardware and checksum ends up being computed in software:
> 1. harmonize_features() strips the checksum features on devices.
> 2. ice_features_check() rejects the frame on NETIF_F_HW_CSUM capable ice.
>
> The frame layout comes from user space, and request.csum_start is
> already the offset of the L4 header from the start of the frame. It is
> checked against the L3 header length found in the frame, and the L4
> protocol has to be TCP or UDP with a matching csum_offset, so the
> transport header is known exactly.
>
> Only the L2 length has to be found, by parsing the Ethernet header and,
> when present, the VLAN tag stack. skb_header_pointer() is used for that,
> so it works for frames whose data is not in the linear part of the skb.
>
> 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 the
> previous commit ("net: reset the mac header in __dev_direct_xmit()").
>
> A frame whose L2 header cannot be parsed, whose L3 type is not IPv4 or
> IPv6, whose csum_start does not match the L3 header length, or whose L4
> protocol and csum_offset disagree is left untouched, so
> validate_xmit_skb() keeps deciding between hardware offload and software
> checksum as before.
>
> The patch is based on Maciej suggestion: 1) do not rely on mac header that
> probe in AF_PACKET uses, 2) use skb_header_pointer and walk vlan tags to
> inspect the accurate location of each field that existing drivers
> possibly use.
>
> [1]: https://lore.kernel.org/all/arKm5gCaERk6MaGA@boxer/
>
> Fixes: 48eb03dd2630 ("xsk: Add TX timestamp and TX checksum offload support")
> Cc: stable@vger.kernel.org # depends on "net: reset the mac header in __dev_direct_xmit()"
> Suggested-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Signed-off-by: Jason Xing <kerneljasonxing@gmail.com>

Thanks, Jason! The skb path is... tricky. :-)

Reviewed-by: Björn Töpel <bjorn@kernel.org>
Technical Details
Message-ID: <871p7y36y6.fsf@all.your.base.are.belong.to.us>
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376567-linux-kernel-netdev=dewy.ru
References: <20261201075731.36746-1-kerneljasonxing@gmail.com> <20261201075731.36746-3-kerneljasonxing@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376567-linux-kernel-netdev=dewy.ru
From: bjorn@kernel.org (Björn Töpel)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v4 2/2] xsk: fill in header offsets for TX checksum
 offload
Date: Thu, 03 Dec 2026 13:05:37 +0100
Organization: Usenet Network
Message-ID: <871p7y36y6.fsf@all.your.base.are.belong.to.us>
References: <20261201075731.36746-1-kerneljasonxing@gmail.com>
 <20261201075731.36746-3-kerneljasonxing@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="2482553"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ds/qIbNPaQKwgkYC/OM+0ftxmWA= sha256:GqxgC7FeQVMkF0YdmzVMwACCTyNQkpckOu0lMptmBKg=
	sha1:OW5sVkPaeFAqKl4lSTsHHexXt0M= sha256:mzs6FAYGTGr0AJoXjqPGovujf9oBXqHSrYM41gFYQRI=
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 D78C61178DD; Thu,  3 Dec 2026 15:10:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.74
X-Spam-Status: No, score=-3.74 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.24, 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 MUWeSD1uBwyj;
	Thu,  3 Dec 2026 15:10:41 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376567-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 1C341117917; Thu,  3 Dec 2026 15:10:33 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 8AB052B382; Thu,  3 Dec 2026 12:10:23 +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=1796299547;
	b=J/JIaBCzrfVR+rlOhPL/Kyi9arWEuJQ14qJ65X0Ibq2RQ+3DoNTkOcZIu0lRrzRsz/pO
	 SPHI+HrH1EtSR7LVmsbMv6y+McK0CYYjcqvQSBaw/LgDIor4p+0Hzfcnikq6PFmI5Bdld
	 vZ0UXSHDfPytxuG44H7w+AWGrD1R/BZ453mSAAdiFOyXE6o1Iixz8+ic1Qs8PwJTEIYOh
	 /686jNpDN6UQvZ+0IuUZBTZbwNTHEi7kb2a97Lw4jJA1+TePr7xNQno3lpRuEcWIu/21s
	 yWTZBnNrnsYxo+9a0zmY4DaB53LQIDhMEhzaVvUZTvLFEPBYcg3dqqEQKg7efFUuLPQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796299547;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 In-Reply-To:References:Date:Message-ID:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding;
	bh=QR4nnYMYWj31wBSB34r4nob6vDGvg78oP9qiy6EULDY=;
	b=fQx0U7JhePVPKqMJ1G41xd+YOCA3+nOY5oWRd+j1UctaQbpUU2R0NmkAyFJ80Rg3BtHh
	 ROwGXHl8HaM3WcYVrT8w4WTSKPOcaRnON5sgaHCZl7Q3Yce1uvfkr77ecMkHM+aiEfQxs
	 prDkuB0CjMIgx+EhDzsVFM8viEfpaV7rrypJF20b2ENSTuD/bHbq9YVWSXfawsqCTNFWb
	 asWx4p1FHzf1v9GmHTP0BMRhiem+AbzaYokLa8kqAB7z8WaKfzDtjj+nLmcdqVRVmwZE9
	 XxOI2khmC0NuDxT7nRVdAu59EfbjvmROn9zAU4zZxswST16gClzprSgGnHR5sg1kXNw==
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=J+gtGVym;
	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 370C3606CE18;
	Thu,  3 Dec 2026 12:05:47 +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=J+gtGVym
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=1796299541;
	b=Ayng64rpKnYRSiyN7qkkfQ+cKwQ9MWN6iXfDjPLHxDusyXrKbSWigxQ4X4oFjVfw3gMF
	 zfCBd4/KUuXiJ15z5CYL4bdwUPcnfxVfOMmsoh5WcRyOZiBqPXDAzwnaWVuP3ghc5fJJg
	 jizuY2ow+sNxI539CT8Ake4BG3sHdvZ7pTm5RQ0wGmJc7p0eNX7oSK1EdoXpaMAOOBdrn
	 df63m6Tq5s/t/ItUCx9zZVvN4ixz0sfbEuv8BrkIkj+HLwepvOI5Il3AFzkPLQjOfoi/X
	 sZCV6zWgKMu837J1A0NJAMf5kTd4f041dSl1NKV2o15SeCg3J+Tf/3LCs3dqmaFBX1g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796299541;
	h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References:
	 Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding;
	bh=QR4nnYMYWj31wBSB34r4nob6vDGvg78oP9qiy6EULDY=;
	b=tJoeTsQQwOudukZ30P1yWqi4fjxmTzeTcD9ZAQWmY7HqxH5HL4dsjlDwfCSjAxsR+Y7C
	 HPXBLIEgXMA1QOPO/0zvMmY02NK861i5CDbUAdey9o1VQG6vT+8o4I0JXmkJdILVBQCgP
	 IPkZcI7MhzK/iy5QLoSv1dg5l7VFXzcjirbO22EXp8U+nJde98Tq24ee4Sr3OdX9ajLzl
	 4WDF3honBk3XH4QVvy0SyD3ZeEj45wM9at4gyvB/kEFOH5/b+vtHDGJ2DP6tfVxHZY3jB
	 MD9s8WRDt1a/mmXazd1qMFl+/wUJf3kiJEig/WVDMTIDrzOMn4PAz8pibatiqEyCAzg==
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=J+gtGVym;
	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 550716079CF5;
	Thu,  3 Dec 2026 12:05:41 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB3B81F00923;
	Thu,  3 Dec 2026 12:05:40 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796299541;
	bh=QR4nnYMYWj31wBSB34r4nob6vDGvg78oP9qiy6EULDY=;
	h=From:To:Cc:Subject:In-Reply-To:References:Date;
	b=J+gtGVymVWMCckQUSQvaM6xveyRemeJDvCWrWL041wbP7PgTashKFWCTIrLV7SWRh
	 JZKgGd/8o2tZvEsD/Qhb1yKySO2v0H0fniTY2vN9n97zHBPVwvoGKyO/vbBmma+Z4z
	 GRhWRJpKJyt+sPB9t1FcxJ9jINQErRMUnbpyNnuu6ohnirMWTWcFf/+tKflar51wWr
	 K0Opl+oltjqqujRCKPFctw30xn78Hg9zelZTdKmImdFHAqCPDFT6q2AccGLkksFiGT
	 7QqYcno+91Ikkt1CDNCz+Oo7St7HbdYB97olBlN7qNIRh3DVXAv63epiIjOtg+AlfL
	 Dtz5LTo9LIeqQ==
X-Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Jason Xing
 <kerneljasonxing@gmail.com>, stable@vger.kernel.org
X-In-Reply-To: <20261201075731.36746-3-kerneljasonxing@gmail.com>
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