Article View: linux.kernel.netdev
Article #18592[PATCH net v2 1/6] seg6: fix skb checksum update helpers
From: Andrea Mayer
Date: Wed, 18 Nov 2026 15:02
Date: Wed, 18 Nov 2026 15:02
56 lines
12276 bytes
12276 bytes
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)")
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
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
Technical Details
Message-ID:
<20261118150251.65-2-andrea.mayer@uniroma2.it>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366230-linux-kernel-netdev=dewy.ruReferences:
<20261118150251.65-1-andrea.mayer@uniroma2.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366230-linux-kernel-netdev=dewy.ru
From: andrea.mayer@uniroma2.it (Andrea Mayer)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2 1/6] seg6: fix skb checksum update helpers
Date: Wed, 18 Nov 2026 16:02:46 +0100
Organization: Usenet Network
Message-ID: <20261118150251.65-2-andrea.mayer@uniroma2.it>
References: <20261118150251.65-1-andrea.mayer@uniroma2.it>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2625330"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:w+7bja5/jyAdjkDrHo+XkEqqoy8= sha256:dqnIf+cb9liVsiJoPoIFFs9fXVwtCkNpiwo/RBWLhpg=
sha1:07JdwbFhsokb5SSv9pAQcekZK/s= sha256:vMwCmVghx7C3ytp/cfJkfvwO+cWyxRnromAzyX9dCxE=
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 4D2B21152F6; Wed, 18 Nov 2026 18:09:33 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.151
X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31
tests=[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=neutral
reason="invalid (unsupported algorithm ed25519-sha256)"
header.d=uniroma2.it header.b=T7ufADa2; dkim=pass (2048-bit key)
header.d=uniroma2.it header.b=WQrK2KaO
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 8smFEhKtzRZJ;
Wed, 18 Nov 2026 18:09:30 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-366230-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=uniroma2.it
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id 6FB3B1152ED; Wed, 18 Nov 2026 18:09:10 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sto.lore.kernel.org (Postfix) with ESMTP id 9DEAD6160B3; Wed, 18 Nov 2026 15:09:02 +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=1795014518;
b=HEnXfNjaYYpFt+kbfakpxR1RLQ7l/cIprJRM8Ilue8hBcGa8BdVgxFCNtH+SLLOp19fc
4YNv6mSPPBXOdjfGrwaEMBBesw1BJKggyuHRuzLiGpdg8ZOdidiNYxaBbflK/knVK+Bww
Kg1+w9oTgel60tnejPnxLNL9v2RjUCQuAK6TMI1WesybM6jqkXeFcm6yDTRzNVaj2fwj5
DkUEqxkqpm6364qROHWRZuGvV+nObvp2sHXOjlEPUYX4WyzKQWQf/efu+GylqtH/sPpJ8
JuvdkEiXaEMwuaWC3Y70iMuoWf/XidJokmVcg/Yj9aUYl6aSw0FLAi/0LnMn28bsOVA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795014518;
h=X-Original-To:Received:DMARC-Filter:Received:Received:DKIM-Signature:
DKIM-Signature:From:To:Cc:Subject:Date:Message-Id:X-Mailer:
In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding:X-Virus-Scanned:X-Virus-Status;
bh=m1ZNuz2XvgTICjD4dKx1tmn+c6cIPSi7406A8Wc/VPk=;
b=MHkx5xerHK8lgGRTey8m1aZ0t5dP57vCGtdYrdGikn8dnurZE11UNaLgBftnbD2aMz6a
UYv+WpXrNnE1Vrr/LkubJtETjOUuZJ0IDhPM6igm+k2/ugmoFHliEo91Ly0ij3Lfi5ZNb
883GysopNvO9+jzfD8F09xeuf2aJcuzsAhyO7yagJthLCJx/DUbLIw/QlVIuTHD77J0p9
G7FvtCvk0D/sQrXusDCyJ4wo7DU7sjp8n7Yefa3kTp7ZfHv5HQub87Ks0qbFB4en/INJ1
kDFMaevkA6FsOs8YIR01BzdGcM00iqxBlNi15JjedQrnqldqySqgv/AXa6XbS50+ilQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=ed25519-sha256 header.s=ed201904 header.b=T7ufADa2;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=rsa-sha256 header.s=rsa201904 header.b=WQrK2KaO;
dmarc=pass header.from=uniroma2.it;
spf=pass smtp.mailfrom=uniroma2.it;
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 5864460A2610;
Wed, 18 Nov 2026 15:08:38 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=ed25519-sha256 header.s=ed201904 header.b=T7ufADa2;
dkim=pass (2048-bit key) header.d=uniroma2.it header.i=@uniroma2.it header.a=rsa-sha256 header.s=rsa201904 header.b=WQrK2KaO
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=160.80.4.37
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795014512;
b=MHlByVcVvKCLYOnUFbunEJSJRhfrKtNm2ul5OdE2+D/bCa5eIKg0c/teGNYW4X3bmGdL
vpMp2Yzu/QT0k2lTr0H7M4L6xUd+aumA50Is7hOnxZiaFhN8RNz2+o4dId/2fZPcSP73G
pe5BFiSBNTmCUOqGoxPU0UCp72PPZc1dTKVLFy9EwE7Y29xrbfaybEXCJPi2WsyzKxmfe
4IHISjuYHjXl7nIQhGCwOuFQiR+SV7NF34C4fS68ZjiRzDU/gLN1R7DKDX/wbsD3y3MJP
oDQZnMVF7yjFI56qygxp6g8L5wiZEUi7wUsz7rUi+ocVc2x6jEy6ps3JqGaHTdzKUiA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795014512;
h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature:From:To:
Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:
MIME-Version:Content-Transfer-Encoding:X-Virus-Scanned:
X-Virus-Status;
bh=m1ZNuz2XvgTICjD4dKx1tmn+c6cIPSi7406A8Wc/VPk=;
b=MBr8Jzf3yh70fKGvIDMObvVTesxYXmXH/R4WU17dXYesru7eufigvwGSh4WznvXKkxKe
3JgJ7tK8tG+WrwSMu9LDSSucsYnIhAJ52KWhvqCTlBYWljdB+eZxU/wEdxvSlm1qaUfZ7
55e7o1CCvIOzmMjzjarehDKcfRszrp8DsTo6Ko1Yu24B67wX26hSLyJXvtJ3XP0EDWzoB
yOhatGeIyPLZDPKtOfxiZgiKIr+CtoVEM0KwmIc+ebwZYRNdaC8OvVk5S6mf/rFWkqdgj
mq1ZmgQL1McQEzyyr5Xj98T8/bplEc0kfGWu/vgfoSxHUFJwxHkb+u1Q3m8MAVz0AkA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=uniroma2.it;
spf=pass smtp.mailfrom=uniroma2.it;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=ed25519-sha256 header.s=ed201904 header.b=T7ufADa2;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=rsa-sha256 header.s=rsa201904 header.b=WQrK2KaO;
arc=none smtp.remote-ip=160.80.4.37
X-Received: from smtp.uniroma2.it (smtp-2015.uniroma2.it [160.80.4.37])
by smtp.subspace.kernel.org (Postfix) with ESMTP id C448860A2604;
Wed, 18 Nov 2026 15:08:31 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C448860A2604
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniroma2.it
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniroma2.it
X-Received: from smtpauth-2019-1.uniroma2.it (smtpauth-2019-1.uniroma2.it [160.80.5.46])
by smtp-2015.uniroma2.it (8.14.4/8.14.4/Debian-8) with ESMTP id 6AIF7XIO012188;
Wed, 18 Nov 2026 16:07:38 +0100
X-Received: from localhost.localdomain (unknown [160.80.105.87])
by smtpauth-2019-1.uniroma2.it (Postfix) with ESMTPSA id 3CC7C122948;
Wed, 18 Nov 2026 16:07:30 +0100 (CET)
X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=uniroma2.it;
s=ed201904; t=1795014450; h=from:from:sender:reply-to:subject:subject:date:date:
message-id:message-id:to:to:cc:cc:mime-version:mime-version:
content-type:content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references;
bh=m1ZNuz2XvgTICjD4dKx1tmn+c6cIPSi7406A8Wc/VPk=;
b=T7ufADa2hAC2G+d2pzvy15dKm1AFCZ2tQd1O6/kOGH5N6sfqcOmb4ZVqD1Q1gp8X8ke4AH
wWnvvvH8p7R6p+DQ==
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniroma2.it; s=rsa201904;
t=1795014450; h=from:from:sender:reply-to:subject:subject:date:date:
message-id:message-id:to:to:cc:cc:mime-version:mime-version:
content-type:content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references;
bh=m1ZNuz2XvgTICjD4dKx1tmn+c6cIPSi7406A8Wc/VPk=;
b=WQrK2KaOz/FAeQtDI2fCLwg08GSed24M4jMjys5Vr+kZ4r0HroePi4AgoYtYGOHGXPWTjT
Q8tKPiE3nnng9I3ggXrj2zPIDDPI4Zmn+r3C1PhcsU1HzsrDueiSPyWAOc4PeNAREqJsMK
vkIUmIKgusnbgp6Un6LYoGt94dwTd7vZef6Wmp8QuoSHASmg9bpMJiRlJKlTyij+EutHOs
w/20YtIBifYkJoLMAtf6MmzTMXzo+qKg9oj1wYUh9l/i0sWJab79jbGDoBZ8nXXR4NNlxs
4Rzn88ujfDE96wyxVM+jxpv/So5jR+SbFi3AKlSVYj+TmQ+aB3Eh8fC3qyJvSQ==
X-Cc: 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>, Hangbin Liu <hangbin.liu@linux.dev>,
Justin Iurman <justin.iurman@gmail.com>,
Stefano Salsano <stefano.salsano@uniroma2.it>,
Andrea Mayer <andrea@common-net.org>,
Andrea Mayer <andrea.mayer@uniroma2.it>,
Hangbin Liu <liuhangbin@kylinos.cn>
X-Mailer: git-send-email 2.39.5
X-In-Reply-To: <20261118150251.65-1-andrea.mayer@uniroma2.it>
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-Virus-Scanned: clamav-milter 0.100.0 at smtp-2015
X-Virus-Status: Clean