🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27180

Re: [PATCH net-next 04/11] selftests: drv-net: tc_flower_police: Test the policed rate and its scope

#27180
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 00:15
238 lines
16816 bytes
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] The commit author (From:) is Mohsin Bashir, but the trailers are
  'Signed-off-by: Jakub Kicinski' followed by 'Signed-off-by: Mohsin…
- [Low] In this patch, _add_secondary_addr() gains a `want` filter
  callback that no caller uses (_dst_ip_rule() calls it with no…
- [Low] selftests: drv-net: _iperf3() leaks iperf3 server on
  TimeoutExpired

--

selftests: drv-net: tc_flower_police: Test the policed rate and its scope

This commit adds three tests to tc_flower_police.py: link_baseline,
police_rate and police_isolation. police_rate checks that UDP sent at twice
the police rate to a rule's destination address arrives at the police rate,
within 10%. police_isolation checks that traffic to another address of the
device is not limited, and link_baseline measures the unpoliced rate so the
policing tests can skip on slow links.

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

[Severity: Low]
This isn't a bug, but should there be a Co-developed-by: tag for Jakub
here?

The patch author is Mohsin Bashir, but the first Signed-off-by: is
Jakub's. Documentation/process/submitting-patches.rst describes the SoB
chain "with the first SoB entry signalling primary authorship of a single
author". It also says co-authors should be credited with Co-developed-by:,
followed immediately by their Signed-off-by:.

As written, the trailers suggest Jakub is the primary author, and that
doesn't match the From: line. The other patches in this series have the
same trailers, from "selftests: drv-net: Iperf3Runner: Support UDP and
server side results" through "selftests: drv-net: tc_flower_police: Test
policing with RSS contexts".

Could "Co-developed-by: Jakub Kicinski <kuba@kernel.org>" be added right
before his Signed-off-by:? If Jakub wrote the patch, the From: author
could be changed to him instead.

> 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 b03a00ad0c0ba..b42ed22419ad1 100755
> --- a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py
> +++ b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py

[ ... ]

> @@ -36,6 +47,27 @@ def _local_prefix(cfg):
>      return net
>  
>  
> +def _dev_addrs(cfg):
> +    addrs = ip(f"-6 addr show dev {cfg.ifname}", json=True)[0]
> +    return {a["local"] for a in addrs.get("addr_info", [])}
> +
> +
> +def _add_secondary_addr(cfg, want=None):
> +    net = _local_prefix(cfg)
> +
> +    taken = _dev_addrs(cfg)
> +    hosts = range(1, min(net.num_addresses, 1 << 16))
> +    for i in random.sample(hosts, len(hosts)):
> +        addr = str(net[i])
> +        if addr not in taken and (want is None or want(addr)):
> +            break

[ ... ]

> @@ -79,6 +111,81 @@ def _ctrl_rule(cfg, i=0):

[ ... ]

> +def _check_rate(got, expect, what):
> +    low, high = expect * (1 - TOLERANCE), expect * (1 + TOLERANCE)
> +    ksft_ge(high, got, f"{what} above the expected {expect:.0f} Mbit/s")
> +    ksft_ge(got, low, f"{what} below the expected {expect:.0f} Mbit/s")
> +    return low <= got <= high

[ ... ]

> +def _dst_ip_rule(cfg):
> +    dst = _add_secondary_addr(cfg)
> +    return f"protocol ipv6 flower dst_ip {dst}", dst

[ ... ]

> @@ -152,11 +259,54 @@ def police_no_leak(cfg):

[ ... ]

> +def police_rate(cfg):
> +    """
> +    Check that UDP sent at twice the police rate to the destination IP of
> +    a rule is limited to that rate.
> +    """
> +    _setup_clsact(cfg)
> +    rule, dst = _dst_ip_rule(cfg)
> +
> +    _check_baseline_rate(cfg)
> +    _add_filter(cfg, rule, _police(RATE_MBIT), pref=10)
> +    _check_in_hw(cfg, 10)
> +
> +    got = _iperf3(cfg, dst, OFFERED_MBIT)
> +    _check_rate(got, RATE_MBIT, "matching flow")

[Severity: Low]
This isn't a bug, but in this patch nothing uses the want argument of
_add_secondary_addr(). Its only caller, _dst_ip_rule(), calls
_add_secondary_addr(cfg) without one. Similarly, police_rate() is the only
caller of _check_rate() and ignores the boolean it returns.

Both get users later in the series. In "selftests: drv-net:
tc_flower_police: Test destination prefix rules", police_dst_prefix()
passes a want lambda. In "selftests: drv-net: tc_flower_police: Test
police parameters", _add_filter(..., dst=...) raises KsftFailEx based on
the return value of _check_rate().

Would it be cleaner to add the want argument and the return value in the
patches that use them?

[ ... ]

> @@ -79,6 +111,81 @@ def _ctrl_rule(cfg, i=0):
>      return f"protocol ipv6 flower dst_ip {net[i + 1]}"
>  
>  
> +def _payload_mbit(mbit):
> +    # iperf3 rates only count the UDP payload
> +    return round(mbit * UDP_PAYLOAD / IP6_PKT_LEN, 3)
> +
> +
> +def _iperf3(cfg, dst_addr, bw_mbit):
> +    runner = Iperf3Runner(cfg, port=rand_port(), server_ip=dst_addr)
> +    server = runner.start_server(json=True)
> +    done = False
> +    try:
> +        runner.start_client(duration=MEASURE_SEC, omit=1,
> +                            udp_mbit=_payload_mbit(bw_mbit),
> +                            length=UDP_PAYLOAD)
> +        done = True
> +    except CmdExitFailure as ex:
> +        out = f"{ex.cmd.stderr} {ex.cmd.stdout}"
> +        raise KsftFailEx(f"iperf3 failed: {out}") from ex
> +    finally:
> +        server.process(terminate=not done, fail=False, timeout=5)
> +    return _rx_mbit(server.stdout)
> +
> +
> +def _rx_ivals(out):
> +    try:
> +        res = json.loads(out)
> +        if "error" in res:
> +            raise KsftFailEx(f"iperf3 server: {res['error']}")
> +        return [(i["sum"]["seconds"],
> +                 i["sum"]["bytes"] * IP6_PKT_LEN / UDP_PAYLOAD)
> +                for i in res["intervals"]
> +                if not i["sum"].get("omitted")]
> +    except (ValueError, KeyError) as ex:
> +        raise KsftFailEx(f"iperf3 server output: {out}") from ex
> +
> +
> +def _rx_mbit(out):
> +    ivals = _rx_ivals(out)
> +    secs = sum(secs for secs, _ in ivals)
> +    rx_bytes = sum(rx_bytes for _, rx_bytes in ivals)
> +    return rx_bytes * 8 / secs / 1e6 if secs else 0
> +
> +
> +def _check_rate(got, expect, what):
> +    low, high = expect * (1 - TOLERANCE), expect * (1 + TOLERANCE)
> +    ksft_ge(high, got, f"{what} above the expected {expect:.0f} Mbit/s")
> +    ksft_ge(got, low, f"{what} below the expected {expect:.0f} Mbit/s")
> +    return low <= got <= high
> +
> +
> +def _check_unpoliced(got, rate_mbit, what):
> +    ksft_ge(got, rate_mbit * (1 + TOLERANCE), f"{what} looks policed")
> +
> +
> +def _get_baseline(cfg):
> +    if cfg.baseline is None:
> +        cfg.require_ipver("6")
> +        cfg.require_cmd("iperf3", local=True, remote=True)
> +        cfg.baseline = _iperf3(cfg, cfg.addr_v["6"], OFFERED_MBIT)
> +        ksft_pr(f"Unpoliced UDP rate {cfg.baseline:.0f} Mbit/s")
> +    return cfg.baseline
> +
> +
> +def _check_baseline_rate(cfg):
> +    want = OFFERED_MBIT * (1 - TOLERANCE)
> +    baseline = _get_baseline(cfg)
> +    if baseline < want:
> +        raise KsftSkipEx(f"Baseline rate {baseline:.0f} Mbit/s too low, "
> +                         f"need {want:.0f} Mbit/s")
> +
> +
> +def _dst_ip_rule(cfg):
> +    dst = _add_secondary_addr(cfg)
> +    return f"protocol ipv6 flower dst_ip {dst}", dst
> +
> +
>  def offload_flags(cfg):
>      """
>      Check that a skip_sw police rule is offloaded and reported in_hw, and

[Severity: Low]
What cleans up the local iperf3 server if it doesn't exit within
5 seconds here?

When the client succeeds, done is True, so server.process() is called
with terminate=False and no signal is sent to the server. If
communicate(timeout=5) in cmd._process_terminate() then expires,
subprocess.TimeoutExpired propagates out of _iperf3(). The server is
not terminated, killed or reaped, and its stdout and stderr pipes are
not closed. The terminate=True path has the same problem if iperf3 is
slow to act on SIGTERM.

ksft_run() catches the exception, runs the deferred cleanups and moves
on to the next test case. The orphaned iperf3 server can then keep
running through police_isolation and the tests added later in the
series, and possibly after the script exits.

The _iperf3_flows() helper added in "selftests: drv-net:
tc_flower_police: Test multiple policers" already handles this. On
TimeoutExpired it retries with terminate=True and then calls kill().
Could _iperf3() use the same fallback, or could the two helpers share
that logic?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204000521.3396802-1-mohsin.bashr%40gmail.com
Technical Details
Message-ID: <179642972895.3146.2755836031252797072@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377759-linux-kernel-netdev=dewy.ru
References: <20261204000521.3396802-5-mohsin.bashr@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377759-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 04/11] selftests: drv-net: tc_flower_police: Test
 the policed rate and its scope
Date: Sat, 05 Dec 2026 00:15:28 +0000
Organization: Usenet Network
Message-ID: <179642972895.3146.2755836031252797072@kernel.org>
References: <20261204000521.3396802-5-mohsin.bashr@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2913469"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:iHOMlgfJgmgpld3qEhVSsYNzefk= sha256:bgCTrsHgO10i3RSkiOrMAg1sHjYD5mh20+kmQmgI/VY=
	sha1:s+yBg+OAZpgOoe7yXY6jis+sANE= sha256:HmuyRCnTOgjyVVoFUL6KRbZ9+foPPRrLHGYqq6gKlKE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 6E50E117D2B; Sat,  5 Dec 2026 03:15:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.642
X-Spam-Status: No, score=-3.642 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id NL16FVByp5fe;
	Sat,  5 Dec 2026 03:15:44 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-377759-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id ED105117D15; Sat,  5 Dec 2026 03:15:35 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 46119606B7E; Sat,  5 Dec 2026 00:15:34 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796429731;
	b=lBmdFdCW/I6N8Nk4DcqSldY3eJbtXXckQ9CCmxtt1sHMTY13Fr+s1VWJ5eyh+Rk5nNiR
	 E+E9NKDQ0x2XdMdX/lJ0NR/OmJ8ubHQvD7zFw0vbyveC2aue2PYhtrV7cK0juIK8n/cJe
	 ycanjkaczkZmD5gbTGwf+HkjjDNyBBKS2xbZdyCbMkkUbpHRFzbT1YOQJz3V9N7scRaSb
	 1WwqwKaf2rX5lsmkdVBHwSfSv1uITxSOSabjVMrJP0QZpugj4VS19fO3CV0V5p2y/5a+T
	 a3h7lSB0iGTOroopZjq7IWBMeStodI3ZI0t65bkY5awvATAuQrFFg7f8bw5j1qz2Fsw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796429731;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=58kGy+aOmpg0qvU0u5tICrP0CcX8FnYQbxji9ExnV3w=;
	b=IuAZL/jG5hz/l83SgGj+18lwohx+PtvLqCjVwBbEuDvIFQ8Fg7o5tiT3JY4D7CBA/6uq
	 986lcilpDaiZXBeqCQzf9iZz+L3hvFmjQrGFRPHyRkQfRhuj+l6+C2/5QMmBuCIE4+/KY
	 kIYnmt7qZWA6I+04ureWJsCBlUkBa/S6CLm0rRpYqQkst4sGS772B0Ou94ntmIpAebzKg
	 qI5hOSQ/QimyhRwQLgAQbVVGsiIqeCIGDH/0j6gflX4tku7JHTyyKr0otygL1Ds6Hhz/6
	 6rlAVRtvzjzbZ1qMW8fdr1ESBMoPKdPnqKGLe+NC9u/8Q4RoKB7kMLitl0LggccycJQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PCUQtYKZ;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EF03606A6A0;
	Sat,  5 Dec 2026 00:15:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PCUQtYKZ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796429730;
	b=ZyDiiAc0b+ujoQmja75ZvDkKCy7sWmBV2THOlGRolVF+2PqcG8WyqdQNz3SaZTRqzeH1
	 FwZ0IRn+2LzHF7Qgb+bZSPTpJxw3Vy6LSQmgHJD/bZQJvCV2mdPXwX2nDaAHyb0SY4mse
	 GbMyhapjZxHb7HQ0y71kwu4+nlajFSZOrmUQ+mk4fpB8Ay8Sl824u/3I3/KEcW6XreY+h
	 V2oMa34riRSHeuLbdditBlfkOtPE0MMnU44cHOq1kJrTZmAfVFQ84nFjTz9c6OwoZk0iE
	 gHn46SvDt7HTyh7D5O4uPAEi7kDVavhjgxoopkStURsZUW6yT5mxhvV7l1r0W2KTtrw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796429730;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=58kGy+aOmpg0qvU0u5tICrP0CcX8FnYQbxji9ExnV3w=;
	b=0rATW3lxhBprhY3ClcftoJjJm43slR0zI6ASjRCztgsN+TRYJ0c9CG0h6qAwPpzpOtEr
	 crSKV1mYg/pSSp0bKiPRq7gmzJ4e5T/97kvnwleUk749wjZk2GS91KJC5XSTcheimPypH
	 kjxYde1+FDNfDzzbKXD7UZ3T4XCfdSGs4Mu4humKikmyA9PFW9MEtJzc2ftFcpY4rCTEn
	 p9jHkU/fcm8pI/g542Ybun0+QApecXC3twxdtbUkh+BX9a7v7GtcZUDdLQiWJygndeRBW
	 dfAQen3mSXJ4aAR+Ho2DOP6bRbv1kBBWG5nlu2rhcqUaLZeB7GPzJ2S2tiQn1c7jY4Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PCUQtYKZ;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 504C8606A68A;
	Sat,  5 Dec 2026 00:15:30 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6511F1F00A1A;
	Sat,  5 Dec 2026 00:15:29 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796429730;
	bh=58kGy+aOmpg0qvU0u5tICrP0CcX8FnYQbxji9ExnV3w=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=PCUQtYKZTx2ZTl4WSAVYmmCGDyJe7jYIxiFhGyUOsu2mc2Hfm8DSyIPETwhrUwPaj
	 TWZictupxh6JL8BZMezs/VKUXqOzljPGsnngZ7f5UrKmIjt/HruRio2rw1+lLPpNGc
	 o3VBURmKN7KDW36IYDW1zkE/rgoP/fxzRiCOjsTscK0xyjSDuqakaESq0wERiJJIry
	 PsiJcJ8kDrh4MLSc+MlWRxeH68Qn3u9GiLWvrz1XKT2b93lCZnbbtKU1SnUHtAUmxx
	 7kW8Cf0dNa8uhUxxGVEZVdNxML946TNHAWHbpEFnbpsCPc3JUoK4Wqc/RwoglSqdcl
	 jC4tkf0Beyrjg==
X-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
X-In-Reply-To: <20261204000521.3396802-5-mohsin.bashr@gmail.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list