[PATCH net-next 3/3] selftests: tc-testing: add gact probability dump tests
From: Linkui Xiao
Date: Fri Nov 06 2026 - 01:42:34 EST
From: Linkui Xiao <xiaolinkui@xxxxxxxxxx>
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@xxxxxxxxxx>
---
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