🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10008

Re: [PATCH net 1/6] seg6: fix skb checksum update helpers

#10008
From: Hangbin Liu
Date: Tue, 03 Nov 2026 01:25
59 lines
11214 bytes
On Sat, Oct 31, 2026 at 11:50:28PM +0100, Andrea Mayer wrote:
> With CHECKSUM_COMPLETE, ipv6_srh_rcv() updates skb->csum for the new
> Segments Left and destination address through seg6_update_csum().
> Replacing "from" with "to" in the packet must change skb->csum (C) to
> C - from + to, but update_csum_diff4() and update_csum_diff16() compute:
> 
>   ~csum_partial({ ~from, to }, ~C) = ~(~C + ~from + to) = C + from - to
> 
> This does not affect packets forwarded by ip6_forward(), which sets
> ip_summed to CHECKSUM_NONE. But when the packet is 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.
> 
> Fix update_csum_diff4() and update_csum_diff16() to compute C - from + to.
> 
> Found by manual code inspection, while checking that the skb->csum updates
> in the SRv6 receive path are consistent. A following commit adds a selftest
> that reproduces the problem with a tc ct action. The issue was confirmed in
> a VM without kernel changes or error injection: with the rest of this
> series and without this patch, that selftest fails, as UDP drops datagrams
> as checksum errors. Also tested against the srv6 selftests, and with a
> ConnectX-6 Lx NIC (mlx5) that provides CHECKSUM_COMPLETE.
> 
> Fixes: 1ababeba4a21 ("ipv6: implement dataplane support for rthdr type 4 (Segment Routing Header)")
> Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
> ---
>  include/net/seg6.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/net/seg6.h b/include/net/seg6.h
> index 82b3fbbcbb93..01d8034e48fc 100644
> --- a/include/net/seg6.h
> +++ b/include/net/seg6.h
> @@ -19,7 +19,7 @@ static inline void update_csum_diff4(struct sk_buff *skb, __be32 from,
>  {
>  	__be32 diff[] = { ~from, to };
>  
> -	skb->csum = ~csum_partial((char *)diff, sizeof(diff), ~skb->csum);
> +	skb->csum = csum_partial(diff, sizeof(diff), skb->csum);
>  }
>  
>  static inline void update_csum_diff16(struct sk_buff *skb, __be32 *from,
> @@ -30,7 +30,7 @@ static inline void update_csum_diff16(struct sk_buff *skb, __be32 *from,
>  		to[0], to[1], to[2], to[3],
>  	};
>  
> -	skb->csum = ~csum_partial((char *)diff, sizeof(diff), ~skb->csum);
> +	skb->csum = csum_partial(diff, sizeof(diff), skb->csum);
>  }
>  
>  struct seg6_pernet_data {
> -- 
> 2.43.0
> 

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID: <auk4COJzzhbGK-3g@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-355142-linux-kernel-netdev=dewy.ru
References: <20261031225033.64-1-andrea.mayer@uniroma2.it> <20261031225033.64-2-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-355142-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 1/6] seg6: fix skb checksum update helpers
Date: Tue, 3 Nov 2026 09:25:28 +0800
Organization: Usenet Network
Message-ID: <auk4COJzzhbGK-3g@fedora>
References: <20261031225033.64-1-andrea.mayer@uniroma2.it>
 <20261031225033.64-2-andrea.mayer@uniroma2.it>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="3072152"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:9J0BDMXePGw2zPfWdEjJS6D7D1o= sha256:ImJix8C6x8SaHK056aIKi8yE+TF8uBm8fq/adEh+ETo=
	sha1:lDyq05TZaUt/MENUxMuidX9kjxY= sha256:YE8p/NK67CDylmTNp4oRYAG/wSq3lSl+xbN24KitG70=
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 BFB2E1126EF; Tue,  3 Nov 2026 04:26:28 +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 xs5C997MgnBD;
	Tue,  3 Nov 2026 04:26:24 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-355142-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 401011123AC; Tue,  3 Nov 2026 04:26:16 +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 C023129CAF; Tue,  3 Nov 2026 01:25:53 +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=1793669153;
	b=E4EPYR2ogoTNC76k7aBqIuNHdB82Ep3Yk8ALWubUYe0sv2MHxap4rO4W3IAMa5IoEafm
	 JOsWl96hDVuFT9kzeX5JjWiVDTYZ/xCBId2eMJYuzWtrLVa8zKXiltQuXerXkSTIfzDIC
	 7LXzxfjWuAvKeivS2egzAClGcBG5QdnO8oc6n4GURuvTXFvARVA5EO+60CWQdLxnE2yyK
	 MAMq2z91o7xv7w/O4p3vXMlpSciuz9gqDWM3Mgq38o4glafHaM3OfEMNuut9EIWA1G2/H
	 V6XRTC/xccRfrDu9nKbJ/6dOUqBsDGBM8F0kWwdJwC9QPMuhVeGyA3CzEb5gctlUQJQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793669153;
	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=GQtsOse1qaHHpOot+MsPd8LDVEFm4Ow2k3IZR+G/F4o=;
	b=n30HtjewIVvVsiYaLyE+xcTCNnat4b0IFHDoLUQtklT22s38AqE37X9EsrOEFl+wPi2p
	 09zId7nTNZhLvTqD6ghviVkPnAfgk13/aQOrTjxgTa6wShHS1olyfx4n4cvXtKxPWyi/k
	 +acbISY8k6K28fPQHdHm5tCQXmDOkAbOovTYFGcrvR02fqxiy+uA3/pAQDVhy8YBVnKDx
	 mI7VCD5os78jtxxlQkF+pjpWp2rt7LcHCXC+/ZHwYzNEBA/+6F69y+LkwkCglzBG0iWOE
	 9yPbxO1esDkADt1ReWg05PYUxlmBGQw/Mgquhr4fncE01Z1fracwzXzwFi8TpTnB29w==
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=lgCB80zu;
	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 92A57606A337;
	Tue,  3 Nov 2026 01:25:53 +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=lgCB80zu
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.48
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793669152;
	b=sKR24t8EfhfPGHz64ICfu961CwrHon2Rg2MdDPqq6eNbBEnBXbvCDuo4/kligaSfCXLE
	 Yf/uwkK3OZPUrr4xTrkWYar/JIJjrmW0ub9xiPuNj1TM72kGAfJhljzNQ9w9f0vpZpqm7
	 QXXju+TSmmitnrZ2T4epTrUggxayo+1TmzH5xS1h9mkL96BmdknKDRPeZCtIbJhIme2oG
	 Odgi5PWNwC4ha7D7thyNNlfYjjzQ5ohtO+u90xjsEvFQTr4ZqyxYVNuljISExLOQcMUEG
	 VkbBjYWancdMy0jqKWi/fM0Fqsnc5+Y4sWhtMfG3+2Y5DlhwPCMYge/sKwNxB8GU1SQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793669152;
	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=GQtsOse1qaHHpOot+MsPd8LDVEFm4Ow2k3IZR+G/F4o=;
	b=fSqWqJe08JKngZV6ZtidtP2ziumI9Sn8cQhJPF0/DOzUozuRUkyBY7VgouNdPh10b8AS
	 d7v3xpLj+fV4JlqYZvXz9e6Hy/ayZx9PBByB/PbU5LlAhuhUAg4kP0C3+VaJIsyVwPfI0
	 DsY7H91tDUG9zTTTeL1tm8SHSxm87rrSKhOHKVuzxKEmiAFE/Tnvr5RezLfzV/wwAyaGg
	 uHZdAB2Bnu2T4rFugWsbG9aq8fH6xf/GEi/S/ZV819lDGg3mzkOBucDiq2LGofenrFXI6
	 gD89PUqEYi5RFCMnydt1PIEOxrP8emHrf2itoSZTotfOT+kNCgtqNUCEquB3krwpIYw==
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=lgCB80zu;
	arc=none smtp.remote-ip=95.215.58.48
X-Received: from mta1.migadu.com (out-48.mta1.migadu.com [95.215.58.48])
	(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 DCA5E606A327
	for <netdev@vger.kernel.org>; Tue,  3 Nov 2026 01:25:49 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DCA5E606A327
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=zAP4af6W/8M6VGTZwGRKoUek7DR1Y9SfEGiGrMO6wuQ=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1793669148; v=1; x=1794273948;
 b=lgCB80zuW4tSswDe6VDPJYBRdZHEMaJCq0U/2ybazv3A4PqyFLJTEySM8nnYfgeg2OmLVx+F
 NzXxNLlpUkfrhEOaUc9ou7XlQPSOGJrIxvD6pmIIbLdx1ians2B+KXR8xd8+x15kTlnlihsEi9Z
 N313ndmnalXWRiF+gLxw/nUA=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta11.migadu.com with ESMTPS id 86b764d73d51d8da;
	Tue, 03 Nov 2026 01:25:47 +0000
X-Mizu-Trace-ID: 86b764d73d51d8da
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-2-andrea.mayer@uniroma2.it>