All of lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: mohsin.bashr@gmail.com
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, shuah@kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 10/11] selftests: drv-net: tc_flower_police: Test policing with ntuple steering
Date: Sat, 05 Dec 2026 00:15:35 +0000	[thread overview]
Message-ID: <179642973590.3146.3354265315518170211@kernel.org> (raw)
In-Reply-To: <20261204000521.3396802-11-mohsin.bashr@gmail.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In police_with_ntuple
  (tools/testing/selftests/drivers/net/hw/tc_flower_police.py), the…
- [Low] police_with_ntuple handles a rejected second rule differently
  depending on install order.
- [Low] The commit author (From:) is Mohsin Bashir, but the first Signed-
  off-by is Jakub Kicinski's, followed by the author's, and there is no…
- [Low] selftests: premature defer() before channels_set() in
  police_with_ntuple()

--

selftests: drv-net: tc_flower_police: Test policing with ntuple steering

This commit adds a police_with_ntuple test to tc_flower_police.py. The
test installs an ntuple rule and a tc flower policer for the same flow, in
either order, then checks that the flow is rate limited and steered to the
ntuple queue. Devices that lack ntuple filters or reject the second rule
are skipped.

>     Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>     Signed-off-by: Mohsin Bashir <hmohsin@meta.com>

[Severity: Low]
This isn't a bug, but the trailer order looks inconsistent. The From:
author is Mohsin Bashir, but the first Signed-off-by is Jakub Kicinski's,
and there is no Co-developed-by tag.

Documentation/process/submitting-patches.rst says the first SoB entry
signals "primary authorship of a single author". It also says any
co-author needs a Co-developed-by: line immediately followed by their
Signed-off-by:.

If both of you developed this, should there be a "Co-developed-by: Jakub
Kicinski <kuba@kernel.org>" line right before his Signed-off-by? If Jakub
is the primary author, should From: name him instead? The other patches in
the series seem to use the same trailer pattern.

> diff --git a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py
> index 368882984411a..d0315e8bf2b2d 100755
> --- a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py
> +++ b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py

[ ... ]

> @@ -569,6 +569,120 @@ def police_ring_size(cfg):

[ ... ]

> +def police_with_ntuple(cfg, ntuple_first):
> +    """
> +    Check that an ntuple rule and a police rule for the same flow both take
> +    effect, whichever is installed first: the flow is policed and lands on
> +    the ntuple queue only.
> +    """

[ ... ]

> +    queue = cnt - 1
> +    _set_rss_indir(cfg, ehdr, [0])
> +
> +    _check_baseline_rate(cfg)
> +    flow = f"flow-type udp6 dst-ip {dst} action {queue}"
> +    if ntuple_first:
> +        _add_ntuple(cfg, flow)
> +        added, err = _try_filter(cfg, rule, _police(RATE_MBIT), pref=10)
> +        if not added:
> +            _skip_rejected(cfg, err, 10, "Policer next to the ntuple rule")

[Severity: Low]
Should this branch check that the ntuple rule still steers the flow before
it skips?

_skip_rejected() only checks that no tc filter is left at pref 10:

    def _skip_rejected(cfg, err, pref, what):
        if _filter_info(cfg, pref) is not None:
            raise KsftFailEx(f"Rejected {what} left behind")
        ksft_pr(err)
        raise KsftSkipEx(f"{what} not offloaded")

The police_first branch below does run traffic after the second rule is
rejected ("Rejecting the ntuple rule must not break the policer"). Nothing
similar happens here.

Suppose a driver merges both rules into one classifier entry. If it breaks
the existing ntuple steering while backing out a failed policer install,
wouldn't the ntuple_first variant report SKIP rather than FAIL?

Running iperf3 and checking that delta[queue] still carries the flow
before raising the skip would make the two install orders symmetric.

> +    else:
> +        _add_filter(cfg, rule, _police(RATE_MBIT), pref=10)
> +        try:
> +            _add_ntuple(cfg, flow)
> +        except KsftSkipEx:
> +            # Rejecting the ntuple rule must not break the policer
> +            got = _iperf3(cfg, dst, OFFERED_MBIT)
> +            if _check_rate(got, RATE_MBIT, "policer after ntuple rejection"):
> +                raise
> +            return
> +
> +    before = _rx_queue_pkts(cfg)
> +    got = _iperf3(cfg, dst, OFFERED_MBIT)
> +    after = _rx_queue_pkts(cfg)
> +    _check_rate(got, RATE_MBIT, "ntuple steered flow")
> +
> +    delta = {q: after[q] - before.get(q, 0) for q in after}
> +    ksft_ge(delta.get(queue, 0), _expected_pkts(got) * 0.9,
> +            f"Policed flow not on ntuple queue {queue}: {delta}")
> +    idle = sum(delta.values()) - delta.get(0, 0) - delta.get(queue, 0)
> +    ksft_eq(idle, 0, f"Traffic on queues other than 0 and {queue}: {delta}")

[Severity: Low]
Do these checks confirm that the flow lands "on the ntuple queue only", as
the docstring and commit message say?

_set_rss_indir(cfg, ehdr, [0]) makes queue 0 the fallback for anything the
ntuple rule misses. The idle sum leaves queue 0 out, and the only check on
the ntuple queue is the 90% lower bound.

The value of got is the rate the server measured over all received
packets, including any that went to queue 0. _expected_pkts() also leaves
out the policer burst from the unmeasured -O second. So a device that
sends roughly 10% of the policed flow to queue 0 would still pass both
checks.

Leaving queue 0 out makes sense, because the iperf3 TCP control connection
and ND traffic land there. The side effect is that leaked flow packets on
queue 0 can't be told apart from that traffic.

Could the docstring and commit message be reworded, for example "mostly on
the ntuple queue and on no other non-default queue"? Alternatively, could
the test require delta[0] to stay small compared with delta[queue]?

[ ... ]

> @@ -569,6 +569,120 @@ def police_ring_size(cfg):
>      _check_rate(got, RATE_MBIT, "after ring resize")
>  
>  
> +def _set_rss_indir(cfg, ehdr, indir):
> +    try:
> +        cfg.ethnl.rss_set(ehdr | {"indir": indir})
> +    except NlError as ex:
> +        raise KsftSkipEx("Cannot change the RSS indirection table") from ex
> +    defer(cfg.ethnl.rss_set, ehdr | {"indir": None})
> +
> +
> +def _require_ntuple(cfg):
> +    feat = ethtool(f"-k {cfg.ifname}", json=True)[0]["ntuple-filters"]
> +    if not feat["active"]:
> +        if feat["fixed"]:
> +            raise KsftSkipEx("Device does not support ntuple-filters")
> +        defer(ethtool, f"-K {cfg.ifname} ntuple-filters off")
> +        cmd(f"ethtool -K {cfg.ifname} ntuple-filters on", fail=False)
> +        feat = ethtool(f"-k {cfg.ifname}", json=True)[0]["ntuple-filters"]
> +        if not feat["active"]:
> +            raise KsftSkipEx("Cannot turn ntuple-filters on")
> +
> +
> +def _rx_queue_pkts(cfg):
> +    cfg.wait_hw_stats_settle()
> +    try:
> +        stats = cfg.netdevnl.qstats_get({"ifindex": cfg.ifindex,
> +                                         "scope": ["queue"]}, dump=True)
> +    except NlError as ex:
> +        raise KsftSkipEx("Device does not report queue stats") from ex
> +    pkts = {s["queue-id"]: s["rx-packets"] for s in stats
> +            if s["queue-type"] == "rx" and "rx-packets" in s}
> +    if not pkts:
> +        raise KsftSkipEx("Device does not report RX packets per queue")
> +    return pkts
> +
> +
> +def _expected_pkts(mbit):
> +    # The client sends for -t plus the -O second
> +    return mbit * 1e6 * (MEASURE_SEC + 1) / 8 / IP6_PKT_LEN
> +
> +
> +def _add_ntuple(cfg, flow):
> +    res = cmd(f"ethtool -N {cfg.ifname} {flow}", fail=False)
> +    if res.ret:
> +        ksft_pr(res.stderr.strip())
> +        raise KsftSkipEx("ntuple rule rejected")
> +    defer(ethtool, f"-N {cfg.ifname} delete {int(res.stdout.split()[-1])}")
> +
> +
> +@ksft_variants([
> +    KsftNamedVariant("ntuple_first", True),
> +    KsftNamedVariant("police_first", False),
> +])
> +def police_with_ntuple(cfg, ntuple_first):
> +    """
> +    Check that an ntuple rule and a police rule for the same flow both take
> +    effect, whichever is installed first: the flow is policed and lands on
> +    the ntuple queue only.
> +    """
> +    _setup_clsact(cfg)
> +    rule, dst = _dst_ip_rule(cfg)
> +    _require_ntuple(cfg)
> +    _rx_queue_pkts(cfg)
> +
> +    ehdr = {"header": {"dev-index": cfg.ifindex}}
> +    try:
> +        channels = cfg.ethnl.channels_get(ehdr)
> +    except NlError as ex:
> +        raise KsftSkipEx("channel-get not supported by device") from ex
> +    cnt = channels.get("combined-count", 0)
> +    if cnt < 2:
> +        if channels.get("combined-max", 0) < 2:
> +            raise KsftSkipEx("Need at least 2 combined channels")
> +        defer(wait_file, f"/sys/class/net/{cfg.ifname}/carrier",
> +              lambda x: x.strip() == "1", deadline=30)
> +        defer(cfg.ethnl.channels_set, ehdr | {"combined-count": cnt})
> +        try:
> +            cfg.ethnl.channels_set(ehdr | {"combined-count": 2})
> +        except NlError as ex:
> +            raise KsftSkipEx("Cannot set 2 combined channels") from ex
> +        wait_file(f"/sys/class/net/{cfg.ifname}/carrier",
> +                  lambda x: x.strip() == "1", deadline=30)
> +        cnt = 2
> +    queue = cnt - 1
> +    _set_rss_indir(cfg, ehdr, [0])
> +
> +    _check_baseline_rate(cfg)
> +    flow = f"flow-type udp6 dst-ip {dst} action {queue}"
> +    if ntuple_first:
> +        _add_ntuple(cfg, flow)
> +        added, err = _try_filter(cfg, rule, _police(RATE_MBIT), pref=10)
> +        if not added:
> +            _skip_rejected(cfg, err, 10, "Policer next to the ntuple rule")
> +    else:
> +        _add_filter(cfg, rule, _police(RATE_MBIT), pref=10)
> +        try:
> +            _add_ntuple(cfg, flow)
> +        except KsftSkipEx:
> +            # Rejecting the ntuple rule must not break the policer
> +            got = _iperf3(cfg, dst, OFFERED_MBIT)
> +            if _check_rate(got, RATE_MBIT, "policer after ntuple rejection"):
> +                raise
> +            return
> +
> +    before = _rx_queue_pkts(cfg)
> +    got = _iperf3(cfg, dst, OFFERED_MBIT)
> +    after = _rx_queue_pkts(cfg)
> +    _check_rate(got, RATE_MBIT, "ntuple steered flow")
> +
> +    delta = {q: after[q] - before.get(q, 0) for q in after}
> +    ksft_ge(delta.get(queue, 0), _expected_pkts(got) * 0.9,
> +            f"Policed flow not on ntuple queue {queue}: {delta}")
> +    idle = sum(delta.values()) - delta.get(0, 0) - delta.get(queue, 0)
> +    ksft_eq(idle, 0, f"Traffic on queues other than 0 and {queue}: {delta}")
> +
> +
>  def _link_down(cfg):
>      ctl_file_write("/proc/sys/net/ipv6/conf/all/keep_addr_on_down", 1)
>      ip(f"link set dev {cfg.ifname} down")

[Severity: Low]
Are these two defer() calls registered too early? They are queued
before cfg.ethnl.channels_set() to 2 has been attempted, so the skip
path right below still runs them during cleanup.

Take a device that reports a combined-count below 2 and a
combined-max of 2 or more, but where the set request fails. For
example, a driver might implement get_channels without set_channels.
In that case ethnl_set_channels_validate() returns -EOPNOTSUPP. The
test then raises KsftSkipEx("Cannot set 2 combined channels"), which
is what you want.

During teardown, ksft_flush_defer() runs the queued restore of
combined-count back to cnt. That request goes through
ethnl_default_set_doit() again and fails in set_validate() or in
ethnl_ops_begin(). Both run before ethnl_set_channels() could treat
the unchanged count as a no-op.

The NlError from the deferred callback sets KSFT_RESULT to False. The
case is then reported as "not ok ... # SKIP", and ksft_exit()
returns 1 for what should have been a clean skip.

Would it work to register both defer() callbacks only after
channels_set() to 2 succeeds? That is how _set_rss_indir() and
_add_ntuple() already handle it in this patch.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204000521.3396802-1-mohsin.bashr%40gmail.com

  reply	other threads:[~2026-12-05  0:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  0:05 [PATCH net-next 00/11] selftests: drv-net: Test tc-flower police offload Mohsin Bashir
2026-12-04  0:05 ` [PATCH net-next 01/11] selftests: drv-net: Iperf3Runner: Support UDP and server side results Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 02/11] selftests: drv-net: Add tc-flower police offload test Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 03/11] selftests: drv-net: tc_flower_police: Test that rules do not leak Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 04/11] selftests: drv-net: tc_flower_police: Test the policed rate and its scope Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 05/11] selftests: drv-net: tc_flower_police: Test destination prefix rules Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 06/11] selftests: drv-net: tc_flower_police: Test police parameters Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 07/11] selftests: drv-net: tc_flower_police: Test multiple policers Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 08/11] selftests: drv-net: tc_flower_police: Test rule removal Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 09/11] selftests: drv-net: tc_flower_police: Test policing across reconfiguration Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 10/11] selftests: drv-net: tc_flower_police: Test policing with ntuple steering Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko [this message]
2026-12-04  0:05 ` [PATCH net-next 11/11] selftests: drv-net: tc_flower_police: Test policing with RSS contexts Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko

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=179642973590.3146.3354265315518170211@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mohsin.bashr@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.