Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The four new negative tests in tools/testing/selftests/tc-
testing/tc-tests/actions/gate.json (2c35, 92b8, 8265 and 5c47) re-run…
- [Medium] Tests 92b8 and 8265 in gate.json pass the decimal string
9223372036854775808 (2^63) as base-time and cycle-time, and expect the…
- [Low] The boundary tests 7d1f and 9f10 in gate.json add a gate action
with base-time and cycle-time 9223372036854775807 (KTIME_MAX).
--
selftests: tc-testing: act_gate: cover the new cycle time and interval limits
This adds seven tdc test cases for the gate action. They cover the new
KTIME_MAX bound on base-time and cycle-time and the 10 us minimum schedule
entry interval. The negative cases re-run the failing command and match the
error text that tc prints.
quoted hunk ↗ jump to hunk
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/gate.json b/tools/testing/selftests/tc-testing/tc-tests/actions/gate.json
index db645c22ad7be..1c910e07c41c9 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/actions/gate.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/actions/gate.json
[ ... ]
quoted hunk ↗ jump to hunk
+ {
+ "id": "2c35",
+ "name": "Reject gate action with a schedule entry below the minimum interval",
[ ... ]
quoted hunk ↗ jump to hunk
+ "cmdUnderTest": "$TC action add action gate sched-entry close 9999ns index 100",
+ "expExitCode": "255",
+ "verifyCmd": "$TC action add action gate sched-entry close 9999ns index 100 2>&1",
+ "matchPattern": "RTNETLINK answers: Invalid argument",
[Severity: Medium]
Will this pattern match when tc is built with libmnl?
On this path, fill_gate_entry() in net/sched/act_gate.c sets an extack
message before it fails:
NL_SET_ERR_MSG_FMT(extack, "Entry interval must be at least %u ns",
GATE_MIN_INTERVAL_NSEC);
return -EINVAL;
The extack pointer is passed down unchanged:
tc_ctl_action()->tcf_action_add()->tcf_action_init()->
tcf_action_init_1()->tcf_gate_init()
A tc linked against libmnl prints "Error: Entry interval must be at least
10000 ns." and does not print the "RTNETLINK answers: ..." line. The
matchPattern would then find zero matches, but matchCount requires one.
The same applies to 92b8, 8265 and 5c47. Those values fail the
NLA_POLICY_FULL_RANGE(NLA_U64, &gate_time_range) check in gate_policy
during nla_parse_nested() in tcf_gate_init(). That check sets the "integer
out of range" extack, so tc prints "Error: integer out of range."
instead.
tools/testing/selftests/net/bpf_offload.py already expects tc to print the
"Error: ..." form, and warns "libmnl missing?" when it is absent.
With a tc built without libmnl the patterns do match. But the strerror text
matches any -EINVAL or -ERANGE, so it can't show that the 10 us floor or
the KTIME_MAX bound caused the refusal.
The commit message says:
tc does not pass the action path's extended acknowledgment back to the
caller, so the negative cases re-run the failing command and match the
kernel's own error text instead of relying on the exit code alone.
Is this accurate? The text matched here is iproute2's strerror output, and
the kernel does deliver the extack on this path.
Would it work better to match the kernel strings ("Entry interval must be
at least 10000 ns", "integer out of range"), or to use a regex that accepts
both output forms?
[ ... ]
quoted hunk ↗ jump to hunk
+ {
+ "id": "92b8",
+ "name": "Reject gate action with a base time above S64_MAX",
[ ... ]
+ "cmdUnderTest": "$TC action add action gate base-time 9223372036854775808 sched-entry close 10000ns index 200",
[Severity: Medium]
Does 2^63 reach the kernel as 0x8000000000000000 on every architecture?
In iproute2, get_s64() fails with ERANGE for this string, so tc falls back
to get_time64(). That function parses the string with strtod() and assigns
the double to an __s64. Converting 2^63 to int64 is undefined in C.
On x86-64, cvttsd2si gives 0x8000000000000000, which is above KTIME_MAX,
so the kernel refuses it.
On arm64 (FCVTZS), and likewise on riscv, powerpc and s390, the conversion
saturates to 0x7fffffffffffffff, which is exactly KTIME_MAX.
The bound in gate_time_range in net/sched/act_gate.c is inclusive:
static const struct netlink_range_validation gate_time_range = {
.min = 0,
.max = KTIME_MAX,
};
Tests 7d1f and 9f10 rely on KTIME_MAX being accepted. On those
architectures, cmdUnderTest would exit 0 instead of 255. verifyCmd would
then fail with EEXIST, not with the out of range error.
The cycle-time value in 8265 has the same problem. 5c47 covers the
base-time bound deterministically with -1. 8265 is the only refusal test
for the cycle-time upper bound, so on non-x86 hosts that bound would go
untested.
The preceding commit, "net/sched: act_gate: bound the cycle time and start
time arithmetic", already notes that iproute2 rewrites out of range values
through strtod().
Could 92b8 and 8265 fail on a correct kernel on arm64?
[ ... ]
quoted hunk ↗ jump to hunk
+ {
+ "id": "7d1f",
+ "name": "Add gate action with the maximum base time",
[ ... ]
quoted hunk ↗ jump to hunk
+ "cmdUnderTest": "$TC action add action gate base-time 9223372036854775807 sched-entry close 10000ns index 201",
+ "expExitCode": "0",
+ "verifyCmd": "$TC action get action gate index 201",
+ "matchPattern": "index 201",
[Severity: Low]
This isn't a bug, but should this check the stored base-time rather than
only the index? The same question applies to "index 301" in 9f10.
Other tests in this file check the read-back value, for example "base-time
200s" in 7189, "cycle-time 200s" in a721 and "base-time 400s" in 3719.
As written, 7d1f and 9f10 would still pass if the kernel clamped, zeroed or
replaced the value. For example, tcf_gate_init() replaces a cycle-time of
0 with the cycle derived from the entries.
The commit message says:
An entry interval of exactly 10000 ns installs and reads back with the
interval it was given, and so do a base time and a cycle time of exactly
KTIME_MAX.
It also claims coverage of "both ends of the cycle time range". Only the
upper bound is tested. An explicit cycle-time 0, which the preceding commit
keeps valid as "derive from entries", is not covered.
Similarly, c873 matches "interval 10us". tc prints intervals with %.3g
scaling, so any stored interval from 10000 to about 10049 ns gives the
same text. The test can't confirm that exactly 10000 ns was stored.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/ACT-WEXM.v4.r0.20261124074514%40mojatatu.com