Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 3 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] selftests/drv-net: police_shared_action() allows a dropping rule to pass - [Low] The authorship tags contradict the From: line. - [Low] selftests/drv-net: police_shared_action() index exceeds HW policer table size - [Low] selftests/drv-net: _iperf3_flows() does not reap child or close pipes on kill -- selftests: drv-net: tc_flower_police: Test multiple policers This commit adds three tests to tc_flower_police.py: police_independent, police_shared_action and police_priority. Together they check that a device keeps separate policers apart, shares a police action across rules when asked to, and applies overlapping rules in priority order. Both flows run at the same time through a new _iperf3_flows() helper.
> Signed-off-by: Jakub Kicinski <ku…@kernel.org> > Signed-off-by: Mohsin Bashir <hmoh…@meta.com>
[Severity: Low] This isn't a bug, but do these trailers match the From: line? The 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. It also says that when a patch has more than one author, each co-author needs a Co-developed-by tag immediately followed by their Signed-off-by. If Jakub co-developed the patch, should the block look like this? Co-developed-by: Jakub Kicinski <ku…@kernel.org> Signed-off-by: Jakub Kicinski <ku…@kernel.org> Signed-off-by: Mohsin Bashir <hmoh…@meta.com> If Jakub is the sole author, should the From: line carry his name instead? Every patch in the series has the same trailer, from "selftests: drv-net: Iperf3Runner: Support UDP and server side results" through "selftests: drv-net: tc_flower_police: Test policing with RSS contexts", so the same change would apply to all of them. [ ... ]
> diff --git a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py > --- a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py > +++ b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py > @@ -377,6 +378,108 @@ def police_params(cfg, action, expect): > raise KsftSkipEx(f"Not offloaded: {reason}") > > > +def _iperf3_flows(cfg, dsts, bw_mbit): > + runners = [Iperf3Runner(cfg, port=port, server_ip=dst) > + for dst, port in zip(dsts, rand_ports(len(dsts)))] > + servers, clients = [], [] > + try: > + for runner in runners: > + servers.append(runner.start_server(json=True)) > + for runner in runners: > + clients.append(runner.start_client(background=True, > + duration=MEASURE_SEC, omit=1, > + udp_mbit=_payload_mbit(bw_mbit), > + length=UDP_PAYLOAD)) > + for proc in clients: > + proc.process(terminate=False, timeout=MEASURE_SEC + 15) > + for proc in servers: > + proc.process(terminate=False, fail=False, timeout=5) > + except CmdExitFailure as ex: > + out = f"{ex.cmd.stderr} {ex.cmd.stdout}" > + raise KsftFailEx(f"iperf3 failed: {out}") from ex > + finally: > + for proc in clients + servers: > + if proc.ret is None: > + try: > + proc.process(terminate=True, fail=False, timeout=5) > + except subprocess.TimeoutExpired: > + proc.proc.kill() > + return [_rx_mbit(server.stdout) for server in servers] > + > + > +def police_independent(cfg): > + """ > + Check that two rules with their own police actions each enforce their > + own rate. > + """ > + _setup_clsact(cfg) > + rule1, dst1 = _dst_ip_rule(cfg) > + rule2, dst2 = _dst_ip_rule(cfg) > + > + _check_baseline_rate(cfg) > + _add_filter(cfg, rule1, _police(RATE_MBIT // 4), pref=10) > + _add_filter(cfg, rule2, _police(RATE_MBIT // 2), pref=11) > + > + got1, got2 = _iperf3_flows(cfg, [dst1, dst2], OFFERED_MBIT // 2) > + _check_rate(got1, RATE_MBIT // 4, "first filter") > + _check_rate(got2, RATE_MBIT // 2, "second filter") > + > + > +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") > + > + > +def police_shared_action(cfg): > + """ > + Check that two rules sharing a police action index are limited together > + to a single rate. > + """ > + _setup_clsact(cfg) > + rule1, dst1 = _dst_ip_rule(cfg) > + rule2, dst2 = _dst_ip_rule(cfg) > + while True: > + index = random.randint(1000, 60000)
[Severity: Low] Does this leave the killed process behind? proc.process(terminate=True, ...) ends up in cmd._process_terminate(). That function calls self.proc.communicate(timeout=timeout) before it closes self.proc.stdout and self.proc.stderr and sets self.ret. When communicate() raises subprocess.TimeoutExpired, none of that happens. proc.proc.kill() then only sends SIGKILL. Nothing waits for the child afterwards. It stays a zombie, and its pipes stay open until the objects are garbage collected. The deferred teardown of the test addresses and the clsact qdisc can then race with the dying iperf3 process. Later test cases in the same run also keep the leaked descriptors. Would it be better to follow the kill with proc.proc.wait(), or with another proc.process(terminate=False, fail=False) call? The kperf helpers in drivers/net/lib/py already handle their kill path that way. [Severity: Low] Will this index work on devices that map the police action index straight onto a hardware policer slot? The kernel hands act->tcfa_index to drivers as flow_action_entry.hw_index, and some in-tree drivers use it directly. ocelot_flower_parse_action() computes pol_ix from a->hw_index plus vcap_pol.base, and returns -EINVAL once that reaches vcap_pol.max, which is 191 on VSC7514. enetc_psfp_parse_clsflower() uses entryp->hw_index as the flow meter index. random.randint(1000, 60000) never picks anything below 1000. On such hardware the first _add_filter() in police_shared_action() would be rejected, and the test would bail out before the shared rule is even tried. That can happen even if the device supports shared policers just fine. Could the first rule be installed without an explicit index, and the index the kernel assigned be read back for the second rule? For example, _filter_info() on pref 10 could provide it, if it exposes the action index. Or would probing for a free index starting from a low value be simpler?
> + if cmd(f"tc actions get action police index {index}", > + fail=False).ret: > + break > + > + _check_baseline_rate(cfg) > + _add_filter(cfg, rule1, _police(RATE_MBIT, extra=f"index {index}"), > + pref=10) > + added, err = _try_filter(cfg, rule2, f"action police index {index}", > + pref=11) > + if not added: > + _skip_rejected(cfg, err, 11, "Shared police action") > + > + total = sum(_iperf3_flows(cfg, [dst1, dst2], OFFERED_MBIT // 2)) > + _check_rate(total, RATE_MBIT, "aggregate of shared action") > + > + > …@ksft_variants([ > + KsftNamedVariant("slow_first", 10, 20, RATE_MBIT // 2), > + KsftNamedVariant("fast_first", 20, 10, RATE_MBIT), > +]) > +def police_priority(cfg, slow_pref, fast_pref, expect): > + """ > + Check that of two rules with the same match, the one with the lower > + priority value decides, whichever of them is installed first. > + """ > + _setup_clsact(cfg) > + rule, dst = _dst_ip_rule(cfg) > + _check_baseline_rate(cfg) > + > + _add_filter(cfg, rule, _police(RATE_MBIT // 2), pref=slow_pref) > + added, err = _try_filter(cfg, rule, _police(RATE_MBIT), pref=fast_pref) > + if not added: > + _skip_rejected(cfg, err, fast_pref, "Second rule with the same match") > + > + got = _iperf3(cfg, dst, OFFERED_MBIT) > + _check_rate(got, expect, "rule with the lower pref") > + > + > def main() -> None: > """Ksft boilerplate main.""" > with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
[Severity: Medium] Can this check pass when one of the two rules is not forwarding anything? _iperf3_flows() is called with OFFERED_MBIT // 2, so each flow offers 100 Mbit/s. That is already the full RATE_MBIT of the shared policer. Only the sum of the two measured rates is compared against RATE_MBIT. Suppose the device mis-programs the second rule, the one created with "action police index N", and drops all of its traffic. The first flow alone then delivers about 100 Mbit/s, and _check_rate() is satisfied. The same holds the other way round. That looks like exactly the kind of breakage a shared-action test should catch. Would it make sense to also check that each value returned by _iperf3_flows() carries a meaningful share of the rate? Alternatively, each flow could offer less than RATE_MBIT * (1 - TOLERANCE). The policer is still oversubscribed in aggregate, but a single flow can no longer reach the limit on its own.
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40gmail.com