🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19046

Re: [PATCH net v2 4/6] seg6: discard CHECKSUM_COMPLETE after the End.BPF program

#19046
From: Hangbin Liu
Date: Thu, 19 Nov 2026 08:42
53 lines
11074 bytes
On Wed, Nov 18, 2026 at 04:02:49PM +0100, Andrea Mayer wrote:
> The End.BPF program can change the packet through the seg6 BPF helpers,
> for instance the SRH Tag with bpf_lwt_seg6_store_bytes(). After the
> program, seg6_bpf_has_valid_srh() can also rewrite the SRH Hdr Ext Len.
> 
> With CHECKSUM_COMPLETE, the program does not always update skb->csum for
> the bytes it writes, and seg6_bpf_has_valid_srh() does not either. If the
> packet is then delivered on the same node and skb->csum was computed in
> software, for instance by conntrack, UDP can drop the packet as a checksum
> error. With skb->csum computed by the device, TCP can instead log a
> "hw csum failure", as if the device had computed a wrong skb->csum.
> 
> Discard CHECKSUM_COMPLETE with skb_checksum_complete_unset() after the
> program, since input_action_end_bpf() does not know which bytes the program
> changed. The checksum is then verified in software.
> 
> Found by manual code inspection and reproduced in a VM without kernel
> changes or error injection: with skb->csum computed by a tc ct action, an
> End.BPF program that writes the SRH Tag, followed by End.B6.Encaps and a
> local End.DT6 SID, makes UDP drop the packet. With this patch, the packet
> is delivered. Also tested against the srv6 selftests, the lwt_seg6local
> BPF selftest, and with a ConnectX-6 Lx NIC (mlx5) that provides
> CHECKSUM_COMPLETE.
> 
> Fixes: 004d4b274e2a ("ipv6: sr: Add seg6local action End.BPF")
> Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
> ---
>  net/ipv6/seg6_local.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
> index 56c6be841e53..f7e1bbc6e9f9 100644
> --- a/net/ipv6/seg6_local.c
> +++ b/net/ipv6/seg6_local.c
> @@ -1661,6 +1661,12 @@ static int input_action_end_bpf(struct sk_buff *skb,
>  		goto drop;
>  	local_unlock_nested_bh(&seg6_bpf_srh_states.bh_lock);
>  
> +	/* The program may have changed the packet and seg6_bpf_has_valid_srh()
> +	 * may have rewritten the SRH Hdr Ext Len.
> +	 * skb->csum may then no longer be the checksum of the full packet.
> +	 */
> +	skb_checksum_complete_unset(skb);
> +
>  	if (ret != BPF_REDIRECT)
>  		seg6_lookup_nexthop(skb, NULL, 0);
>  
> -- 
> 2.43.0
> 

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID: <av62bJ3xNkvqD-gD@fedora>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366858-linux-kernel-netdev=dewy.ru
References: <20261118150251.65-1-andrea.mayer@uniroma2.it> <20261118150251.65-5-andrea.mayer@uniroma2.it>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366858-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 4/6] seg6: discard CHECKSUM_COMPLETE after the
 End.BPF program
Date: Thu, 19 Nov 2026 16:42:20 +0800
Organization: Usenet Network
Message-ID: <av62bJ3xNkvqD-gD@fedora>
References: <20261118150251.65-1-andrea.mayer@uniroma2.it>
 <20261118150251.65-5-andrea.mayer@uniroma2.it>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2830956"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:xVJhaFiTlLDJ82V+gpWWONphZgo= sha256:pZCONgVdDy8gp/fQNV0C0hH84qLO9oaxyl5oOVfkTec=
	sha1:0rR+3D7Q+OqoBxNi32aYShBXirg= sha256:LmS/yAIcAJukhb27AycGB3rPpH5Rgt6KU3ER/OJMgzM=
Content-Disposition: inline
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 DE9C311556A; Thu, 19 Nov 2026 11:43:50 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
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 nZuLTNp37doo;
	Thu, 19 Nov 2026 11:43: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-366858-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id ED169115568; Thu, 19 Nov 2026 11:43: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 9BB2C3285A7; Thu, 19 Nov 2026 08:42:52 +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=1795077760;
	b=XFlSkj0aici827aHzTohaulRR+JoEj7DiI8eqAoSiRnWaio7YsgKzAy5No5rC0UkParI
	 vey0Om2mShDaER9ixpc5vLdrspnqzWQmcj4BvEqG3Mt9Ibaiw1pDIIrB4eIRW/l19MABA
	 tXSW9zGVhX4n7FZO1lLGf/2lP/lVA6dNAK5emMJc0gwJrsZzXQDGd8xZFMtNvYOp3dMOm
	 gGo3HrPdHsXhdR4pZzrgMMyRC7bOX7sJTisp9h/UtREoNncfWjzEBr2pwMvah0aZfyg9X
	 hFyMpowrTLJdeParwqTJ5F6FbC3tkAVJb+DdvQh1/05oH/DTbX+c/KpgUtj2V0WNPhw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795077760;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=iWiJbFtVqVddp2vrnL7/ZGl130GuxHSvBxEu5wOIpWo=;
	b=pjZz6eIeS058ddXx+tW7zuBGbu0VyRkENzmid+ABSXJlL3B6Ec/RwGsvfekCFkiI+Ir8
	 JRVt8FxeFT9jqQgeSS5rcOStGYWB4vyjfGeMbquYA8lzZD+OcMuNUwPVi0MmzAqnKpHu3
	 sGMiAhLIY0BiPdLLy8B3lkS9HI0cbhb+Siww+VjBy1MfbGJGtna6K7omcS8EqzZtc/5fi
	 u2821e5/xbdAYGrjhMPUgUTu81pQ2IxdTuJuuhB5CDFY2wx4DvBg+ukwG5+mz9NMwM/a0
	 j4bm71UQLMfxGBd6kPaDbjW894DXpqXJDaqRUGazNylDhpsAZci6WZWklACbFSAWA1A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=q8pJCaj3;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	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 83191606A324;
	Thu, 19 Nov 2026 08:42:40 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=q8pJCaj3
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.75
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795077759;
	b=BZZv4ZvgeUi/ZcptuY6v3LswthxAlq/wnq818YVDIvW188amIJaGkNnjYn34EwcNVsZk
	 lgcicLfaflvjJ9p0/O5wU2buAg9Z+1Xf5iJ2AMikQVgXIdIZqfSodscNemMrYUZXFdsDf
	 m1GsVl9wnDf+ZQiN/JYX6R86m2VTerhbQ6tNgd3uurwO30sKNml39QDo9FPVZ7ithOGVP
	 wdGYtr6L8InzAc3Duh6pJ56TqMu5dbVpV7GUzDKbgjD2xBm69nY1pLd8XQXQdFOvsY2fB
	 rOLJ9FU/UiQn9gAQv6kPYXmkS/7Gcg6Pmy6lc2BwDLj37qz2vCvDQdxPg8JHq44jMiw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795077759;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=iWiJbFtVqVddp2vrnL7/ZGl130GuxHSvBxEu5wOIpWo=;
	b=kbH5XXNwTIAjAuMy1H96PYOu+9ENkrAjVkKDBNps5K6zWct1B3s5Xnjdh3apOcEHBzuw
	 JDHzAJYqu8nUj8gn/rTuPuTpaogRj1nHjTYO/yJpYtxn8R/VLPjfJ0U7J8POgkvfRaFGm
	 Bqex1OrRjY8H8ELlMr19v1LRqIfoFFIGuz7NYQwkwoWDWiiRc0XL8JJsSTI8+yFLEWy8f
	 xsFYLst1tlCcQjK3HTkxc/ZpPu+32mZRAzTTf9YnwGwjiPzKVi69rECpZRaXKC0+Kf3rF
	 zcDgv2qCoo9cNrMI/z5CxKNyLGbx+4zQStKIzvFz2OcwR92TmP9oj15o4ckfbWb0J/g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=q8pJCaj3;
	arc=none smtp.remote-ip=95.215.58.75
X-Received: from mta1.migadu.com (out-75.mta1.migadu.com [95.215.58.75])
	(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 2C001606A320
	for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 08:42:37 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2C001606A320
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=vL/J4zG6bd1pCk4S7uhM04WqGErVOFa1v5NdfiiZhWs=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1795077756; v=1; x=1795682556;
 b=q8pJCaj3gX6e+McaWww+F+gOZ7PqhkSpMuCMBqUbaupfpH6mxRZl69UsuvBvL4zwofdGOrSs
 Jvi4C12rOZ7EEWtUlmgSlR7LZt2qIQRl2RCQ34rqnibEtfTixwbrPmHOtwTfIw/O8Y8HfcDYFCU
 1tN7udbbGN9yIKHWl1y1wRTo=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta11.migadu.com with ESMTPS id 42f76bb1e926322b;
	Thu, 19 Nov 2026 08:42:35 +0000
X-Mizu-Trace-ID: 42f76bb1e926322b
X-Migadu-Flow: FLOW_OUT
X-Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>,
	Ido Schimmel <idosch@nvidia.com>, Shuah Khan <shuah@kernel.org>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-kselftest@vger.kernel.org, bpf@vger.kernel.org,
	David Lebrun <david.lebrun@uclouvain.be>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Mathieu Xhonneux <m.xhonneux@gmail.com>,
	David Lebrun <dlebrun@google.com>,
	Justin Iurman <justin.iurman@gmail.com>,
	Stefano Salsano <stefano.salsano@uniroma2.it>,
	Andrea Mayer <andrea@common-net.org>
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
X-In-Reply-To: <20261118150251.65-5-andrea.mayer@uniroma2.it>