Re: [PATCH net-next 09/11] selftests: drv-net: tc_flower_police: Test policing across reconfiguration

From: netdev-bot+sashiko

Date: Fri Dec 04 2026 - 19:16:35 EST


Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 3 · 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] police_channels() and police_ring_size() in
tools/testing/selftests/drivers/net/hw/tc_flower_police.py lack…
- [Medium] police_ring_size() requests new = cur*2 (or cur//2 if doubling
would exceed rx-max).
- [Medium] selftests: drv-net: premature defer() in
police_channels()/police_ring_size()
- [Low] The attribution tags conflict with the author field.

--

selftests: drv-net: tc_flower_police: Test policing across reconfiguration

This adds tests to tc_flower_police.py that check a flower police rule
keeps limiting traffic across a channel count change, an RX ring size
change and a link flap. It also checks that a rule added while the link
is down takes effect once the link comes back up.

> Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
> Signed-off-by: Mohsin Bashir <hmohsin@xxxxxxxx>

[Severity: Low]
Is a Co-developed-by: Jakub Kicinski tag missing here? The Author line
says Mohsin Bashir, but the first Signed-off-by is Jakub's.

Documentation/process/submitting-patches.rst says the first SoB entry
signals primary authorship. It also says co-authors get a
Co-developed-by: tag immediately followed by their Signed-off-by.

As written, the trailers make Jakub look like the primary author, but the
From: line names someone else. The other tc_flower_police commits in the
series use the same 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 73162c31bd59a..368882984411a 100755
> --- a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py
> +++ b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py

[ ... ]

> @@ -495,9 +495,139 @@ def police_delete(cfg):
> _check_unpoliced(got, RATE_MBIT, "after delete")
>
>
> +def police_channels(cfg):
> + """
> + Check that a police rule keeps working after the channel count changes.
> + """

[ ... ]

> + 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": new})
> + except NlError as ex:
> + raise KsftSkipEx(f"Cannot change the channel count to {new}: "
> + f"{ex}") from ex
> + wait_file(f"/sys/class/net/{cfg.ifname}/carrier",
> + lambda x: x.strip() == "1", deadline=30)

[Severity: Medium]
Is the restore deferred too early here? The carrier wait and the
channels_set() restore are both queued before channels_set(new) has
succeeded.

Take a driver that implements get_channels but not set_channels. The
channels_get() above succeeds. The set then fails with -EOPNOTSUPP
from ethnl_set_channels_validate(), and the except branch raises
KsftSkipEx.

When ksft_run() handles the skip, it flushes the defer queue. The
restore to the unchanged cnt also goes through
ethnl_default_set_doit(). There, set_validate() runs before
ethnl_set_channels() can notice that nothing changed, so the restore
fails with -EOPNOTSUPP again.

ksft_flush_defer() catches that NlError, prints a Defer Exception
traceback and sets KSFT_RESULT = False. The case is reported as a
skip, but the whole run exits non-zero.

police_ring_size() has the same problem with rings_set() and
ethnl_set_rings_validate() when set_ringparam is missing.

This is reachable on real hardware. enetc, am65-cpsw and ef100 all
offload flower police and have the get callback without the matching
set one. On those devices, what the commit message describes as a
clean skip turns into a failed run.

Would it work to register both defer() calls only after the
try/except block, once the new value has actually been applied?

[Severity: Medium]
Should police_channels() and police_ring_size() be marked
@ksft_disruptive?

After channels_set() or rings_set(), both tests wait up to 30 seconds for
carrier to come back. They wait again in the deferred restore, so they
expect the link to drop.

tools/testing/selftests/drivers/net/README.rst says:

All tests which may disconnect NETIF
must be annotated with @ksft_disruptive.

This patch does mark police_link_flap() and police_add_while_down(). With
DISRUPTIVE=False, these two tests still run. They can drop carrier on the
interface used to reach the remote, for up to 30 seconds per step.

If the NIC does not come back, wouldn't both the remote session and the
deferred restore be lost?

> + ksft_eq(cfg.ethnl.channels_get(ehdr)["combined-count"], new,
> + "Combined channel count")
> + got = _iperf3(cfg, dst, OFFERED_MBIT)
> + _check_rate(got, RATE_MBIT, "after channel change")
> +
> +
> +def police_ring_size(cfg):
> + """
> + Check that a police rule keeps working after the RX ring size changes.
> + """

[ ... ]

> + cur = rings["rx"]
> + new = cur * 2 if cur * 2 <= rings["rx-max"] else cur // 2
> + if not new:
> + raise KsftSkipEx("Cannot change the RX ring size")

[ ... ]

> + wait_file(f"/sys/class/net/{cfg.ifname}/carrier",
> + lambda x: x.strip() == "1", deadline=30)
> + ksft_eq(cfg.ethnl.rings_get(ehdr)["rx"], new, "RX ring size")

[Severity: Medium]
Can this exact comparison fail on drivers that round the requested ring
size instead of rejecting it?

octeontx2 offloads flower police (FLOW_ACTION_POLICE in otx2_tc.c), and
otx2_set_ringparam() only allows 16*4^n sizes:

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c:otx2_set_ringparam() {
...
rx_count = Q_COUNT(Q_SIZE(rx_count, 3));
...
}

Take a 256 entry ring. Doubling it requests 512, the driver rounds that
up to 1024, and rings_get() reports 1024. ksft_eq() then fails even
though the resize and the policing both worked.

ice_set_ringparam() also rounds silently:

new_rx_cnt = ALIGN(ring->rx_pending, ICE_REQ_DESC_MULTIPLE);

An E810 ring at its 8160 maximum would request 4080 and read back 4096.
ice does not offload police today, so this case is not reachable yet.

Would it be enough to check that the reported size differs from cur, or
to use the value read back for the later checks?

> + got = _iperf3(cfg, dst, OFFERED_MBIT)
> + _check_rate(got, RATE_MBIT, "after ring resize")

[ ... ]

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