mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linkui Xiao <xiaolinkui@126.com>
To: jhs@mojatatu.com, jiri@resnulli.us, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Linkui Xiao <xiaolinkui@kylinos.cn>
Subject: [PATCH net-next 3/3] selftests: tc-testing: add gact probability dump tests
Date: Fri,  6 Nov 2026 14:41:14 +0800	[thread overview]
Message-ID: <20261106064114.3592670-4-xiaolinkui@126.com> (raw)
In-Reply-To: <20261106064114.3592670-1-xiaolinkui@126.com>

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


      parent reply	other threads:[~2026-11-06  6:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06  6:41 [PATCH net-next 0/3] net/sched: get_fill_size() budget fixes for act_gact and act_vlan Linkui Xiao
2026-11-06  6:41 ` [PATCH net-next 1/3] net/sched: act_gact: size TCA_GACT_PROB unconditionally Linkui Xiao
2026-11-06  6:41 ` [PATCH net-next 2/3] net/sched: act_vlan: size push_eth in get_fill_size Linkui Xiao
2026-11-06  6:41 ` Linkui Xiao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261106064114.3592670-4-xiaolinkui@126.com \
    --to=xiaolinkui@126.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=xiaolinkui@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®