From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.177 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== 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== 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 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 ; Tue, 3 Nov 2026 02:29:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CE4B8606D803 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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-Envelope-To: netdev@vger.kernel.org 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 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 Date: Tue, 3 Nov 2026 10:28:52 +0800 From: Hangbin Liu To: Andrea Mayer Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , David Ahern , Ido Schimmel , Shuah Khan , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, David Lebrun , Daniel Borkmann , Mathieu Xhonneux , David Lebrun , Stefano Salsano , Andrea Mayer Subject: Re: [PATCH net 4/6] seg6: discard CHECKSUM_COMPLETE after the End.BPF program Message-ID: References: <20261031225033.64-1-andrea.mayer@uniroma2.it> <20261031225033.64-5-andrea.mayer@uniroma2.it> X-Mailing-List: netdev@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: <20261031225033.64-5-andrea.mayer@uniroma2.it> 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 > --- > 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