🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #1611

Re: [PATCH net v2] calipso: keep BIG TCP payload_len in calipso_skbuff_setattr()

#1611
From: Wang Zhan
Date: Sat, 10 Oct 2026 09:05
62 lines
11290 bytes
On Fri, 09 Oct 2026 12:59:19 -0300 Joas Antonio dos Santos wrote:
> calipso_skbuff_setattr() adjusts payload_len by the length of the
> option it inserts or resizes:
>
> 	payload = ntohs(ip6_hdr->payload_len);
> 	ip6_hdr->payload_len = htons(payload + len_delta);
>
> GRO can build BIG TCP packets larger than IPV6_MAXPLEN, and stores
> payload_len == 0 for them; ipv6_payload_len() then falls back to
> skb->len.  For such a packet forwarded to a destination mapped to
> CALIPSO, the code above writes len_delta (or 65536 + len_delta when
> shrinking) into payload_len, and ipv6_payload_len() no longer falls
> back to skb->len.  nf_tables, conntrack and sch_cake rely on it.
>
> The same arithmetic also wraps when a packet grows past IPV6_MAXPLEN,
> and a BIG TCP packet that shrinks below IPV6_MAXPLEN should get its
> real length back.
>
> Set payload_len from the skb length with ipv6_set_payload_len(), which
> stores 0 above IPV6_MAXPLEN and the real length otherwise, as
> ipv6_gro_complete() does.  The network header was just reset to
> skb->data, so skb->len - sizeof(*ip6_hdr) is the payload length.
>
> Tested on one kernel (arm64, QEMU) with SELinux permissive, a minimal
> mdp-generated policy (network_peer_controls=1), "netlabelctl calipso
> add pass doi:16" and a NetLabel mapping of fd00:2::/64 to CALIPSO
> DOI 16.  calipso_skbuff_setattr() was called through
> netlbl_skbuff_setattr() from a test-only debugfs hook (not part of
> this patch) adding a level-only label; payload_len after the call:
>
>   case                         before fix   after fix   real length
>   1000, unlabeled                    1016        1016          1016
>   70000 GSO, payload_len 0             16           0         70016
>   65530 GSO, grows past MAXPLEN        10           0         65546
>   65540 GSO with a 24 byte hop
>   header, shrinks below MAXPLEN     65528       65532         65532
>   1000 with a 24 byte hop header      992         992           992
>
> (0 means ipv6_payload_len() returns the real length.)  On the forward
> path, with a client injecting unlabeled UDP through a router to a
> server, the router adds the CALIPSO option and the server delivers all
> datagrams (Udp6InDatagrams 5, Ip6InTruncatedPkts 0) with this patch.
>
> Fixes: 81fbc812132c ("ipv6/gro: insert temporary HBH/jumbo header")
> Suggested-by: Eric Dumazet <edumazet@kernel.org>
> Suggested-by: Wang Zhan <wang.zhan@smartx.com>
> Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
> Assisted-by: Claude:claude-opus-5-5

Reviewed-by: Wang Zhan <wang.zhan@smartx.com>

> @@ -1357,8 +1357,8 @@ static int calipso_skbuff_setattr(struct sk_buff *skb,
>  			sizeof(*ip6_hdr) + start);
>  		skb_reset_network_header(skb);
>  		ip6_hdr = ipv6_hdr(skb);
> -		payload = ntohs(ip6_hdr->payload_len);
> -		ip6_hdr->payload_len = htons(payload + len_delta);
> +		/* 0 above IPV6_MAXPLEN (BIG TCP), the real length otherwise */

nit: consider dropping the comment, it just repeats what
ipv6_set_payload_len() does.
Technical Details
Message-ID: <20261010090534.317149-1-wang.zhan@smartx.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-344113-linux-kernel-netdev=dewy.ru
References: <179156155963.36253.400481753322266658@gmail.com>

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-344113-linux-kernel-netdev=dewy.ru
From: wang.zhan@smartx.com (Wang Zhan)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] calipso: keep BIG TCP payload_len in calipso_skbuff_setattr()
Date: Sat, 10 Oct 2026 17:05:34 +0800
Organization: Usenet Network
Message-ID: <20261010090534.317149-1-wang.zhan@smartx.com>
References: <179156155963.36253.400481753322266658@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1293447"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:x6pg2MLMaAKie/MagctfdnmW3zQ= sha256:T/wvy4FfI3BksksFcd4fsenobF9GQN+EMtVHkslby84=
	sha1:LSZEPlJePvcdyXd+HCmDkBXfVds= sha256:8jJJ27Lmz07e0VaYDDOwR6tLhGhLwgCE69NvMBMojdw=
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 B699A10F886; Sat, 10 Oct 2026 12:06:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.951
X-Spam-Status: No, score=-2.951 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-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 (2048-bit key)
	header.d=smartx-com.20251104.gappssmtp.com
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 M0WIvSMA7avB;
	Sat, 10 Oct 2026 12:06:27 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-344113-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=smartx.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 9DF9610F887; Sat, 10 Oct 2026 12:06:21 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id C830E3CECE; Sat, 10 Oct 2026 09:06:10 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D3EB3E0750;
	Sat, 10 Oct 2026 09:06:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=smartx-com.20251104.gappssmtp.com header.i=@smartx-com.20251104.gappssmtp.com header.b="gk+CwX+L"
X-Received: from mail-dy1-f177.google.com (mail-dy1-f177.google.com [74.125.82.177])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2706F36F909
	for <netdev@vger.kernel.org>; Sat, 10 Oct 2026 09:06:06 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.177
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791623170; cv=none; b=gmEKyr38461HXRXIuvO1w5xQ9JY9R5DFKNJYp8k3wfSmgQ03+i03x+3p/EyJR5G9jneuoREWsSDUwdug2W5kP76rtxW4y9KRnsMHXz6ko5B8Jl/0WrmDoTQ1L5A149F61seLyvdUF7wqY65uH8ITYtOjGkLogbaSFsdZtjNaQ7A=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791623170; c=relaxed/simple;
	bh=cKRxNm86gzxnVgmkPil6uvSeyJZxMrBzx9O2/9KRxls=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version; b=o0mmm3XXtN83AYGLR7Blqk0vhIt/W/G6bggnctzAWiUlHP34st1c34US0lgVRp5l7wA8nNASygwT9gfi3O7MxDtuvrcm3QfiD8oJLZE9Jn5wYMfljI+wKaP0GDe4H4GLV17yj5yc5ux3GuMf7KL++6Q39vRBk8bsQV4E5TrulBc=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=smartx.com; spf=pass smtp.mailfrom=smartx.com; dkim=pass (2048-bit key) header.d=smartx-com.20251104.gappssmtp.com header.i=@smartx-com.20251104.gappssmtp.com header.b=gk+CwX+L; arc=none smtp.client-ip=74.125.82.177
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=smartx.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=smartx.com
X-Received: by mail-dy1-f177.google.com with SMTP id 5a478bee46e88-354ba08cfd1so834221eec.1
        for <netdev@vger.kernel.org>; Sat, 10 Oct 2026 02:06:06 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=smartx-com.20251104.gappssmtp.com; s=20251104; t=1791623166; x=1792227966; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=aZs8U0ZjQ35oS4ozK838xXyPfIOXVraWP2I51EAkJ5w=;
        b=gk+CwX+LRz8ORl6Q0IvKrzDJV+ECVTG7KteaoM7bYAlJHNcSqlRndQPqp+2EsBuYeN
         DWvdQWpevv/vg6KyLfayqYfyHSA87Ty7IaDX/M5wwSUN/qmRiPCeoNkPq8I/IfUD6hHW
         PUgygYE49ss2bZFLxJE06/GYaGtotmcEbGA6CoRINpqY0V/NLICnJYbJDicgTVLfEPkw
         A1M4OL4hG3iJHvozEhyKtCqqBIEXvTp4uJa7uab2bqrFWC9JvqsrARLxZ0gt6hFYBxME
         btA5fdpIC0cmzz4GkT7SeJeXAG7iKFi+NHH6xpEpby0Gbw0AOEx8rcE+ST1WsIuvfRkf
         JJsA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1791623166; x=1792227966;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=aZs8U0ZjQ35oS4ozK838xXyPfIOXVraWP2I51EAkJ5w=;
        b=2lz8n+PsCwcQ6x8D88kxVq+CE9C1y4qBAYygFnNtxzgFLZKtVW7yqqknvS38TV11Vh
         IaUY3pxaBX8LGvXQn1Qw69IgV6NlPhWjOtoKnUekiEBrxsRis8gR9M/Fp5zYMEfAZwWz
         jAPj7rSJv8l/KAOHQGKbJBLoZdc7a00dXrn6CQCX3AHRwBXRr2+5PZwIWDALfV+lG5vt
         iTqLDyL6UW1WI77+olJojEAtC9jJnAN6VeZRO91nd5AO1vYaF/HWhPCG61RevpT8s+Fl
         K8FBjID+Ej44gWF3/dbpm1fjU8GTsxKsiZ01IYS3Qq9DEbvLeCz5vd3jUmahpt1BHirS
         lBjg==
X-Gm-Message-State: AFq9FYIOsoKPP5wXpYiZh9v+zY3tpQx63khWa8x0xyiIZjZN8LLAYbxQ
	DPvHM2FMkU1y14EYwTBB5xtl8Gbhu4olJuVFEQjFAdWP9SMZ7po7Q6RoOTvvtvpl9+SqIqtYLWl
	PjvqiJuVS8f8U9ClBEHU57paqg1glYeGPKBXfGjEqMXaJc38/fjURYw1qcMguN/7zwuwODgzw
X-Gm-Gg: AYBFou2DfGvCedVxUMMuk4BYXrs3xlUZm+q7I+IvC66G5bD3VeKveGyS+BFtO8sVF2o
	GIYT3hqAU7niyvJgt42uLAH3WhFBZPaabW1GojlCgaNmhmfS++BCTYksZhjXLTX26VaBwoqeYvR
	jMVQmT6HtQEX2Sn1p5uGtciz+SeKTK/vCWfgA468p+ZkBz0N4m3IUO18Mj2l89Ym0WUYwGhHBHO
	hGneuU2jxDY3zlUG2XJjizvOYr4TXLBhV92mUPIyEnt7jBntxaFpG6oJfJuISi0wHMdsmzIGlPn
	HDC0YT/rGMxRdHjn4F5BmYH5b487mRnEhjVokBuKk5kHpNtH88PdXkID61I2QR4dVCpFeswmfVG
	Tj01+uzd1FLngUaVxfZAYz18QUNEFD351s+apn47cM28LzxWXPF1ofQWknmIOEgDvaPF6aEK2Qp
	0J1AY5IXk27v0uNgDSsnUfSvx7u+EgYdGJrniLAg1ZvpKNjpxQ5T7TKU5w3tD1M8foKYWyiBrIg
	GzHsei68Ro=
X-Received: by 2002:a05:7022:ea48:10b0:166:5552:780a with SMTP id a92af1059eb24-16a5afe59d1mr5532791c88.8.1791623165597;
        Sat, 10 Oct 2026 02:06:05 -0700 (PDT)
X-Received: from localhost.localdomain ([23.148.204.241])
        by smtp.gmail.com with ESMTPSA id a92af1059eb24-1699718c547sm12212587c88.3.2026.10.10.02.06.02
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sat, 10 Oct 2026 02:06:05 -0700 (PDT)
X-Cc: Wang Zhan <wang.zhan@smartx.com>,
	Paul Moore <paul@paul-moore.com>,
	Eric Dumazet <edumazet@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	linux-security-module@vger.kernel.org,
	Alice Mikityanska <alice.kernel@fastmail.im>
X-Mailer: git-send-email 2.47.3
X-In-Reply-To: <179156155963.36253.400481753322266658@gmail.com>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>