Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: jhs@mojatatu.com
Cc: netdev@vger.kernel.org, jiri@resnulli.us, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	willemb@google.com, horms@kernel.org,
	alexei.starovoitov@gmail.com, victor@mojatatu.com,
	Po.Liu@nxp.com, stable@vger.kernel.org,
	syzbot+0054fed3dc9085390f51@syzkaller.appspotmail.com,
	shawnq1@163.com
Subject: Re: [PATCH net v4 3/3] selftests: tc-testing: act_gate: cover the new cycle time and interval limits
Date: Wed, 25 Nov 2026 14:15:14 +0000	[thread overview]
Message-ID: <179561611414.3135.147725315288144189@kernel.org> (raw)
In-Reply-To: <ACT-WEXM.v4.r0.20261124074514-3@mojatatu.com>

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.

> 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
> @@ -347,5 +347,194 @@

[ ... ]

> +    {
> +        "id": "2c35",
> +        "name": "Reject gate action with a schedule entry below the minimum interval",

[ ... ]

> +        "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?

[ ... ]

> +    {
> +        "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?

[ ... ]

> +    {
> +        "id": "7d1f",
> +        "name": "Add gate action with the maximum base time",

[ ... ]

> +        "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

      reply	other threads:[~2026-11-25 14:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 14:12 [PATCH net v4 0/3] net/sched: act_gate: bound the cycle time and refuse schedule entries shorter than 10 us Jamal Hadi Salim
2026-11-24 14:12 ` [PATCH net v4 1/3] net/sched: act_gate: bound the cycle time and start time arithmetic Jamal Hadi Salim
2026-11-24 19:56   ` Alexei Starovoitov
2026-11-24 23:31     ` Jamal Hadi Salim
2026-11-24 23:38       ` Alexei Starovoitov
2026-11-25 14:15   ` netdev-bot+sashiko
2026-11-24 14:12 ` [PATCH net v4 2/3] net/sched: act_gate: refuse schedule entries shorter than 10 us Jamal Hadi Salim
2026-11-24 16:12   ` Sebastian Andrzej Siewior
2026-11-24 16:58     ` Jamal Hadi Salim
2026-11-24 17:11       ` Jamal Hadi Salim
2026-11-25 14:15   ` netdev-bot+sashiko
2026-11-24 14:12 ` [PATCH net v4 3/3] selftests: tc-testing: act_gate: cover the new cycle time and interval limits Jamal Hadi Salim
2026-11-25 14:15   ` netdev-bot+sashiko [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=179561611414.3135.147725315288144189@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Po.Liu@nxp.com \
    --cc=alexei.starovoitov@gmail.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=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shawnq1@163.com \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+0054fed3dc9085390f51@syzkaller.appspotmail.com \
    --cc=victor@mojatatu.com \
    --cc=willemb@google.com \
    /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