Article View: linux.kernel.netdev
Article #10034Re: [PATCH net 4/6] seg6: discard CHECKSUM_COMPLETE after the End.BPF program
From: Hangbin Liu
Date: Tue, 03 Nov 2026 02:28
Date: Tue, 03 Nov 2026 02:28
57 lines
11055 bytes
11055 bytes
Hi Andrea,
On Sat, Oct 31, 2026 at 11:50:31PM +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 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 57a82477ce3f..3045a351f4e9 100644
> --- a/net/ipv6/seg6_local.c
> +++ b/net/ipv6/seg6_local.c
> @@ -1582,6 +1582,12 @@ static int input_action_end_bpf(struct sk_buff *skb,
> goto drop;
> }
>
> + /* The program may have changed the packet and seg6_bpf_has_valid_srh()
> + * may rewrite the SRH Hdr Ext Len below.
> + * skb->csum may then no longer be the checksum of the full packet.
> + */
> + skb_checksum_complete_unset(skb);
> +
Should we move this a bit later?
> if (srh_state->srh && !seg6_bpf_has_valid_srh(skb))
> goto drop;
> local_unlock_nested_bh(&seg6_bpf_srh_states.bh_lock);
> --
e.g. after this. As there is not need to do the setting if the skb is dropped.
Thanks
Hangbin
Technical Details
Message-ID:
<aulG5DJroKs6BuzS@fedora>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355181-linux-kernel-netdev=dewy.ruReferences:
<20261031225033.64-1-andrea.mayer@uniroma2.it> <20261031225033.64-5-andrea.mayer@uniroma2.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355181-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 4/6] seg6: discard CHECKSUM_COMPLETE after the End.BPF program Date: Tue, 3 Nov 2026 10:28:52 +0800 Organization: Usenet Network Message-ID: <aulG5DJroKs6BuzS@fedora> References: <20261031225033.64-1-andrea.mayer@uniroma2.it> <20261031225033.64-5-andrea.mayer@uniroma2.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="3080753"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:H34QDkVUy/BsUnO5H3+B2cuC0d4= sha256:xky3QCCvTdWkOZRaOQpq8PQIQblXXd6h3l/AiKca6lY= sha1:f/86a0EcH1QVpTTS3cyEyleQq2A= sha256:hl7N1VDi9u0EXOE5momdnvVkyfXS/p4y2tA9zjH/Dfo= 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 2E2B4112713; Tue, 3 Nov 2026 05:30:44 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 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] 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 AJxdfKupX96V; Tue, 3 Nov 2026 05:30:40 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-355181-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id B85B11126FF; Tue, 3 Nov 2026 05:30:31 +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 50FB229BB3; Tue, 3 Nov 2026 02:29:25 +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=1793672958; b=0QUBakxGNoGmRATPugk1nvn0HQDlWr5yMkCgyvA0YQByGl5vbs+jvwpxfBcWj6m6fbsp 1n61IQEf9aJ1FUzopl9AxBEdOjVrOSb+TrJ6Q/QI1ZJLt5L1UmjacPiiJsoDFAuzxNpO6 ySlX3aAaoAj8WQ5DW4orhdm/U18Dc40lZqcYI8l4IHPmWjk8nMbd6PwGTJwpbvB1+r8Z8 FqQNoy2zFpHqfqPHJrAm/diAg+/z8wPSHZDqXcC457WdVOlh1TiaehX9Rvt6KJZcm79iW y0daGEuqjN5L8OAJzYtPe2hPsOQ1zQ6k3hfoTIDVTc0xE8KFc2FwcMnL0EbfidiFp2g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793672958; 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=+Odq/nWUXS9jHPYJFLtSPbg5YmanbMJct1bOQuLz9a0=; b=uY2AvE1U9syshf4pPnIVl7z+zmTgveiGjew0gC1fZgBgC+E4bGnSWe0fdUHGdxDTIZax ZPatMBwDUF6eEc9aF1g/YgDiMZjmDYnSl1/A6vdVBIN/fVlWT19fAZDH2BEWToYSaTVdP QoGokgF/vMbxCks8peY8QL8Ge9SyiI6Wy3U7RYlsHbM/9+TWBH49b7u4vd2OSgZz8bDa0 xHZVfc519ZrDTQ1amGCoqA1ZaR34xHBClYoR4K178xhFShheds+2y6IAE0x+vEqmPIxc+ wjdVj4gFBbf/8m95zSzQD36lcch0rQRvdwwEvpRZgHFYX8WhJj5spUfToBiy3cS4bIA== 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=gbaU8Ezm; 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 6EABB606D81A; Tue, 3 Nov 2026 02:29:18 +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=gbaU8Ezm X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.177 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793672957; b=qQtGv5hYNEdmrWhz8TRA3fImpgkdVaMi7+cs33Wnr4dSMTy5ypYAtNRRhKA9FeLzoN5L k500Q8BWyzjI86b63KovcuiW8dJj0MOQGK+NngqEmBfKUCsKzD+L88gXL7SGeZO9CMA38 +wNkZxgQFk699AdUE1whwwMX4gYwTxMngevI8QY8PIbAjP3lmNYMVp5L1DNZXtM4WLRgK x+SQv+H3P5fQ0fSHI914eOfc6COhMFf98jEODikdtVRBvsXkAP3xyFXbuB6LABPeGS90F nckMgOmXuYEKpMSdJbc5zpAI69A2bKoLn+T/RX3bKI/99um46cTHhrGNVM934u9umFg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793672957; 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=+Odq/nWUXS9jHPYJFLtSPbg5YmanbMJct1bOQuLz9a0=; b=Eu4quB3gK1ATNSuEF1v3XIyfseM1j0Nz5kbO8GLCRcApKcjC953TF6XAq+UOCu55pB4o AwxNRPLIeB8sej9OUzDTBUpyVLLUSgtkPPpVaMU2Kb/pUo2t9uDPoIXjgfhscijJUb9UR Au/o6AgruEqxvDx6Hctcz2JkPom4Wfm5LQZi2VZYqkpVoGYPTtgM3lGvEXdXTpmT4eteW hKazL2HLIZYCmP0RoLrW6aQQHPK4L2ALPJqVTozbvvMZMeLg9KzYdGYipMwJkhDhDJYa0 EfQPxvxyAp6N8HUCuIP19BGg+p2CCouBVGfZRR3xiBq/7aTVf+C39vD7xQeRBxfbSbg== 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=gbaU8Ezm; arc=none smtp.remote-ip=91.218.175.177 X-Received: from mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 CE4B8606D803 for <netdev@vger.kernel.org>; Tue, 3 Nov 2026 02:29:16 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CE4B8606D803 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=K7tUnBieg+x8yoMHcEYMmFpmpR2noKDKE9apnAPDyxQ=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793672954; v=1; x=1794277754; b=gbaU8EzmhpM70F02M6NZuxqiGA/M3RfyTnyhoPLdG9UkR7FnGJTkry7QY/EqGuMe7bIAgj1Z KCXu0+nAecYzRtMRB5LzLh/9OyK5zrcgRCYGFGb5nxq673/stw5ehoyCU3iWPtaG6vGDaJ2iay3 5+GI147Y7BVdk4EZ7unaIvlo= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta11.migadu.com with ESMTPS id 406c5c1624b3d690; Tue, 03 Nov 2026 02:29:14 +0000 X-Mizu-Trace-ID: 406c5c1624b3d690 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>, 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: <20261031225033.64-5-andrea.mayer@uniroma2.it>