🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12029

[PATCH net-next 3/3] selftests: tc-testing: add gact probability dump tests

#12029
From: Linkui Xiao
Date: Fri, 06 Nov 2026 06:41
130 lines
13100 bytes
From: Linkui Xiao <xiaolinkui@kylinos.cn>

gact probability attributes are emitted by tcf_gact_dump() only when
tcfg_ptype is set, and budgeted for by tcf_gact_get_fill_size().  The
only gact cases that look at a probability today are 8e47 and ca89, and
both check it through `tc actions list`, which is served by the netlink
dump machinery and never consumes the get_fill_size() budget.  The one
case that uses `tc actions get`, 525f, runs against an action with no
probability, so the RTM_GETACTION reply path -- tcf_get_notify(), which
does size its skb from get_fill_size() -- is never exercised with a
probability, and the netrand random type is not exercised anywhere.

Add three cases: adding an action with a netrand probability and getting
it back; replacing a probability-less action with a deterministic one
and getting it back, covering the tcfg_ptype 0 -> non-zero transition
that the unconditional TCA_GACT_PROB budget in patch 1 has to cover; and
getting a probability-less action, whose dump must report no probability.

These are coverage for the dump and sizing paths that nothing tested
before, not reproducers: RTM_NEWACTION, RTM_DELACTION and RTM_GETACTION
all take
rtnl, so sizing and dumping always run in the same critical section
and a replace cannot interleave between them from userspace.  They pass
both before and after patches 1 and 2.

Verified by running the tdc gact suite (38 cases, including these
three) against a kernel with CONFIG_GACT_PROB=y and this series
applied; all passed.

Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
---
 tools/testing/selftests/tc-testing/tc-tests/actions/gact.json | 83 +++++++++++
 1 file changed, 83 insertions(+)

diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json b/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json
index 0fcd52742939..94f032aeab68 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json
@@ -761,5 +761,88 @@
                 1
             ]
         ]
+    },
+    {
+        "id": "b4f8",
+        "name": "Add gact action with random netrand and get it",
+        "category": [
+            "actions",
+            "gact"
+        ],
+        "plugins": {
+           "requires": "nsPlugin"
+        },
+        "setup": [
+            [
+                "$TC actions flush action gact",
+                0,
+                1,
+                255
+            ]
+        ],
+        "cmdUnderTest": "$TC actions add action pass random netrand drop 20 index 91",
+        "expExitCode": "0",
+        "verifyCmd": "$TC actions get action gact index 91",
+        "matchPattern": "action order [0-9]*: gact action pass.*random type netrand drop val 20.*index 91 ref",
+        "matchCount": "1",
+        "teardown": [
+            "$TC actions flush action gact"
+        ]
+    },
+    {
+        "id": "e3d7",
+        "name": "Replace gact action without probability with random determ and get it",
+        "category": [
+            "actions",
+            "gact"
+        ],
+        "plugins": {
+           "requires": "nsPlugin"
+        },
+        "setup": [
+            [
+                "$TC actions flush action gact",
+                0,
+                1,
+                255
+            ],
+            "$TC actions add action pass index 92"
+        ],
+        "cmdUnderTest": "$TC actions replace action pass random determ drop 5 index 92",
+        "expExitCode": "0",
+        "verifyCmd": "$TC actions get action gact index 92",
+        "matchPattern": "action order [0-9]*: gact action pass.*random type determ drop val 5.*index 92 ref",
+        "matchCount": "1",
+        "teardown": [
+            "$TC actions flush action gact"
+        ]
+    },
+    {
+        "id": "c2a9",
+        "name": "Get gact action without probability",
+        "category": [
+            "actions",
+            "gact"
+        ],
+        "plugins": {
+           "requires": "nsPlugin"
+        },
+        "setup": [
+            [
+                "$TC actions flush action gact",
+                0,
+                1,
+                255
+            ],
+            "$TC actions add action pass index 93"
+        ],
+        "cmdUnderTest": "$TC actions get action gact index 93",
+        "expExitCode": "0",
+        "verifyCmd": "$TC actions get action gact index 93",
+        "matchPattern": "action order [0-9]*: gact action pass.*random type none.*index 93 ref",
+        "matchCount": "1",
+        "teardown": [
+            "$TC actions flush action gact"
+        ]
     }
 ]
-- 
2.25.1
Technical Details
Message-ID: <20261106064114.3592670-4-xiaolinkui@126.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-357788-linux-kernel-netdev=dewy.ru
References: <20261106064114.3592670-1-xiaolinkui@126.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-357788-linux-kernel-netdev=dewy.ru
From: xiaolinkui@126.com (Linkui Xiao)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next 3/3] selftests: tc-testing: add gact probability dump tests
Date: Fri,  6 Nov 2026 14:41:14 +0800
Organization: Usenet Network
Message-ID: <20261106064114.3592670-4-xiaolinkui@126.com>
References: <20261106064114.3592670-1-xiaolinkui@126.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3812397"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:8Qo1PgPzKh8+YeQqMD2+CGM1Uu4= sha256:3cvJT+SEJ2LWJ+aF/ccR5GSrk/e6auHf1m3asLoOFHk=
	sha1:O6/bxwuHIckWfteuH0COSLbzmow= sha256:0PGZe8Gwf4OhkaCS2QXUxdoNnKtGT6efSUh34ZeqBWY=
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 DEA72113182; Fri,  6 Nov 2026 09:45:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 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, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, 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, UNPARSEABLE_RELAY=0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=126.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 vrDDm-_cj5SF;
	Fri,  6 Nov 2026 09:45:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-357788-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=126.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 9834A11309C; Fri,  6 Nov 2026 09:45:42 +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 85319309CF; Fri,  6 Nov 2026 06:42:17 +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=1793947337;
	b=XZ40S/CKpcIJKkTQgZoNuCIAMLjFBdEzhcQMK56rzXd/+4LOgoBWkbeQEZfbi4sYze06
	 UziDWvJM5hOPY44ssTHrBjFaAa6n62ZqOOODQx2ffEyvL9CkSvrnLeFsg4h4rGed1UlL9
	 uiNT6wdjs9yMPRgrgzY7cHOVzcEVqJkgRdVcFsEqn1PaDpOQQAT+zsDkLziEr/cQceIWV
	 LXUAuafJYfxmc/rBDygK5yRJEwU38LXWA9t0yi5HNe7qMs2AwhM5+Q74kfpIvXz7cNkkv
	 aSRApHMH20Y5NOQjMadNCzLQrZArrh8q15Zgi0Mz2iaMTpFXUbmjhgk1jUlmDXp2SJA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793947337;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received: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-CM-TRANSID:X-Coremail-Antispam:
	 X-CM-SenderInfo;
	bh=0bUMKH9d0uJfnXeq5eKB6jEiDxTQUE7bE1foO+3EmWM=;
	b=Mo3Z82G4MDdG6/rz1sAmZMui6ZKeH3iUJxgDjZYw8dGCrOIEM/H0GIh8ylNJ1f9hJ7fT
	 rAno6dUZbUm7ZsaGamRlKhOquaSr0qiKd2h7/iV5cOFKAMwDUMrSyQDq6i1HPav9AXers
	 jOXUfsaAHVN7TQkHUZxNJUNShQnbr1fdyie+RBIxQmPkj+GPbxsGWz1vzCGVGHczdoEUV
	 4LNszK7R0jGjeBVIWytf6785JO0S8jtNhBN5nMrAStW8uRedsvAQGBZMvg1U2hr05f0As
	 tMY2wy0jcl6HofQLl1l/y7lXrGe+pR6Nxs1Iz6/csKgQcSWf1K1yaqCy1KhR2NZ497w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=mghFzSbn;
	dmarc=pass header.from=126.com;
	spf=pass smtp.mailfrom=126.com;
	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 5CA3A606A330;
	Fri,  6 Nov 2026 06:42:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=mghFzSbn
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.8
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793947331;
	b=wnG/s6Ch1ch98rOvCjbzy6seDZAWOCKyPeIxPi0HheKUNbD04hiyo7BPPRsKDHCslLQ5
	 jiaAAeZr7OHBb1EXfb3+hRfJbgXmVqpcz0g8KEq28pmS4SLs0QV9WPL6zaBfySNf+/O31
	 bvqjwvqNuGzOrcN6OV1nIsYJUA09+uPbuDPiJLO9an5j33BbwRaGaMV3ICrGcC0hiC96e
	 NBoChhCuv0zT57dript9e8Aubu0KyFN6ZlRv6k70d8nCG5UXSVV8SZw5oZueZvjhzwzJ9
	 ykGEdJQeJCwGtt7A49WPotwXtqOLS3bmYmST2fJQpubyxS+xyh6qI5R89fUUqP1Sikg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793947331;
	h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date:
	 Message-Id:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam:
	 X-CM-SenderInfo;
	bh=0bUMKH9d0uJfnXeq5eKB6jEiDxTQUE7bE1foO+3EmWM=;
	b=QEPGovWYBvkra2wDsviS59jSBMkcTeQ22KAYIBtuy1CWWBHpWvBYqFHiGpoDrYQ7iEhW
	 0q63WmdSkuCfKmCbYC6Oaus2HOTB77FwZZUtTFw8jr27Y5HeWJIBlBls0IJh2eRrrIite
	 qmIyD0JrVTBIZTb53tTB/2Ym9p1gn1ifDP62ge1JqGYE7IdkCRNM8bCukz6vE4OZKnhjz
	 iQ7tsU3rM6aieTIXxgfFSl/Xb5HrYvQfmWGuoUNrWEggOhbsLjHZN9BFHPYGA9wxLfyQh
	 PTcLwbiRLWyZwu1lwPDUYKbUC5mihkQWl7yToY9PigOnAbHjTYycefmYLALWNSJKY4Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=126.com;
	spf=pass smtp.mailfrom=126.com;
	dkim=pass header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=mghFzSbn;
	arc=none smtp.remote-ip=117.135.210.8
X-Received: from m16.mail.126.com (m16.mail.126.com [117.135.210.8])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F1A0606A33B;
	Fri,  6 Nov 2026 06:42:08 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9F1A0606A33B
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com;
	s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=0b
	UMKH9d0uJfnXeq5eKB6jEiDxTQUE7bE1foO+3EmWM=; b=mghFzSbnoNlsdG8RNe
	XIydCP3Dx2KP8tXBKzzyI43XCX0+mRWfJgP9IlErvNRb+NU6UaNNrtu6s6UGphFr
	82AFzZL608UdUDxueycuFFgsvnWgbJ4tUOq5xxwufCKtozdpnoN2G7nKIvOCzdHZ
	LStG2AuN6umz4scWX2lyT9X1c=
X-Received: from localhost.localdomain (unknown [])
	by gzga-smtp-mtada-g0-4 (Coremail) with SMTP id _____wDnR+uMdu1qZ7kzCw--.3170S5;
	Fri, 06 Nov 2026 14:41:23 +0800 (CST)
X-Cc: netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Linkui Xiao <xiaolinkui@kylinos.cn>
X-Mailer: git-send-email 2.25.1
X-In-Reply-To: <20261106064114.3592670-1-xiaolinkui@126.com>
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-CM-TRANSID: _____wDnR+uMdu1qZ7kzCw--.3170S5
X-Coremail-Antispam: 1Uf129KBjvJXoWxGr4ruF1Dury3tF1xAryfXrb_yoWrXF4rpr
	ySyF1Yyrn8tr97Aw1UurWrXF4a93WkCw4UJry5JrW7u3WUKa4ktFZ7tF4Iva4jyrZYvw43
	ZFn093Z7ZrZrA3JanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2
	9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UQa9fUUUUU=
X-CM-SenderInfo: p0ld0z5lqn3xa6rslhhfrp/xtbBqRPXrmrtdpN4mgAA3D