🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26618

[PATCH net-next 06/11] selftests: drv-net: tc_flower_police: Test police parameters

#26618
From: Mohsin Bashir
Date: Fri, 04 Dec 2026 00:05
117 lines
14980 bytes
From: Mohsin Bashir <hmohsin@meta.com>

act_police supports more than a rate and a burst, and drivers usually
offload only a subset of it. Add police_params to cover the pipe exceed
action, peak rate, overhead and packet rate, and verify that traffic
shows the effect of each option the device accepts. If the device
rejects an option, the test checks that a plain police rule still works
and skips. A rejected rule must not be left behind.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Mohsin Bashir <hmohsin@meta.com>
---
 .../drivers/net/hw/tc_flower_police.py        | 56 +++++++++++++++++--
 1 file changed, 52 insertions(+), 4 deletions(-)

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 cdff5cb6b6a3..66d32f6e13f7 100755
--- a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py
+++ b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py
@@ -9,6 +9,7 @@ import tempfile
 import time
 from lib.py import ksft_run, ksft_exit, ksft_pr
 from lib.py import ksft_eq, ksft_ge
+from lib.py import ksft_variants, KsftNamedVariant
 from lib.py import CmdExitFailure, KsftSkipEx, KsftXfailEx, KsftFailEx
 from lib.py import Iperf3Runner, NetDrvEpEnv
 from lib.py import set_ethtool_feat
@@ -68,9 +69,9 @@ def _add_secondary_addr(cfg, want=None):
     return addr
 
 
-def _police(rate_mbit):
+def _police(rate_mbit, extra="", exceed="drop"):
     return (f"action police rate {rate_mbit}mbit burst 1m "
-            "conform-exceed drop/ok")
+            f"conform-exceed {exceed}/ok {extra}")
 
 
 def _try_filter(cfg, rule, action, pref):
@@ -82,10 +83,16 @@ def _try_filter(cfg, rule, action, pref):
     return res.ret == 0, res.stderr.strip()
 
 
-def _add_filter(cfg, rule, action, pref):
+def _add_filter(cfg, rule, action, pref, dst=None):
     added, err = _try_filter(cfg, rule, action, pref)
     if not added:
         raise KsftSkipEx(f"Rule not offloaded: {err}")
+    if dst is None:
+        return
+    got = _iperf3(cfg, dst, OFFERED_MBIT)
+    if not _check_rate(got, RATE_MBIT, f"rule at pref {pref}"):
+        raise KsftFailEx(f"Police rule at pref {pref} not at the "
+                         "expected rate")
 
 
 def _filter_info(cfg, pref):
@@ -330,6 +337,46 @@ def police_dst_prefix(cfg):
         ksft_pr("LOCAL_PREFIX_V6 is a /120, shorter masks not checked")
 
 
+@ksft_variants([
+    KsftNamedVariant("exceed_pipe",
+                     f"{_police(RATE_MBIT, exceed='pipe')} "
+                     f"{_police(RATE_MBIT // 2)}",
+                     RATE_MBIT + RATE_MBIT // 2),
+    KsftNamedVariant("peakrate",
+                     _police(OFFERED_MBIT * 2,
+                             extra=f"peakrate {RATE_MBIT}mbit mtu 65535"),
+                     RATE_MBIT),
+    KsftNamedVariant("overhead",
+                     _police(RATE_MBIT, extra=f"overhead {UDP_PAYLOAD}"),
+                     RATE_MBIT * IP6_PKT_LEN / (IP6_PKT_LEN + UDP_PAYLOAD)),
+    KsftNamedVariant("pkts_rate",
+                     "action police pkts_rate 1000 pkts_burst 100 "
+                     "conform-exceed drop/ok", 1000 * IP6_PKT_LEN * 8 / 1e6),
+])
+def police_params(cfg, action, expect):
+    """
+    Check police parameters beyond the rate and burst. A device that
+    offloads the rule must limit the traffic as configured. A device may
+    reject it, and a plain police rule must then still limit the traffic,
+    after which the case is skipped.
+    """
+    _setup_clsact(cfg)
+    rule, dst = _dst_ip_rule(cfg)
+
+    _check_baseline_rate(cfg)
+    added, err = _try_filter(cfg, rule, action, pref=10)
+    if added:
+        got = _iperf3(cfg, dst, OFFERED_MBIT)
+        _check_rate(got, expect, "policed flow")
+        return
+
+    if _filter_info(cfg, 10) is not None:
+        raise KsftFailEx(f"Rejected filter left behind: {err}")
+    _add_filter(cfg, rule, _police(RATE_MBIT), pref=10, dst=dst)
+    reason = err.partition("\n")[0]
+    raise KsftSkipEx(f"Not offloaded: {reason}")
+
+
 def main() -> None:
     """Ksft boilerplate main."""
     with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
@@ -339,7 +386,8 @@ def main() -> None:
                   link_baseline,
                   police_rate,
                   police_isolation,
-                  police_dst_prefix],
+                  police_dst_prefix,
+                  police_params],
                  args=(cfg,))
     ksft_exit()
 
-- 
2.53.1-Meta
Technical Details
Message-ID: <20261204000521.3396802-7-mohsin.bashr@gmail.com>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer05.iad!feed-me.highwinds-media.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376923-linux-kernel-netdev=dewy.ru
References: <20261204000521.3396802-1-mohsin.bashr@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer05.iad!feed-me.highwinds-media.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376923-linux-kernel-netdev=dewy.ru
From: mohsin.bashr@gmail.com (Mohsin Bashir)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next 06/11] selftests: drv-net: tc_flower_police: Test police parameters
Date: Thu,  3 Dec 2026 16:05:16 -0800
Organization: Usenet Network
Message-ID: <20261204000521.3396802-7-mohsin.bashr@gmail.com>
References: <20261204000521.3396802-1-mohsin.bashr@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="2635249"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:8k9DU+BP3+nUH3CiZOkPfb6Hv1I= sha256:38fM0kSPcrS8ed3TW2/whMrpLOUXlEYxtWWoYjfpxvU= sha1:jz2wGxHuHKj1PEqzDb94jlytLG8= sha256:VNpAvRCNfhNT/g7up9MUrJAu+MCtiBm3r9jFsPPCWXc=
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 E4EB6117A7A; Fri,  4 Dec 2026 03:05:56 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.396
X-Spam-Status: No, score=-3.396 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
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 2Fxr0UEkgcLl; Fri,  4 Dec 2026 03:05:54 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376923-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 4CD31117A78; Fri,  4 Dec 2026 03:05:46 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 0389625B1A; Fri,  4 Dec 2026 00:05:44 +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=1796342743; b=jK+w2PRY34p1MmtxIA13Cq0PqSxgpaGtEpoD422GSWWUp+kuXtrQZO8jUofE7mq+ZLKk C1bIWmPeQ8Ao/xS/VO9dY1WKp/ZT/1NCzBmfi/gk63hvaXdZQwdpSYORnefAsstc2VEiB y7Vj65p6nvrBMA1dwywJyBGjvGBoyQOwEmMLsbxDtEWRTIarllEwTElQtU7WH/75rGShg ptPGbgNp8kUnRLwEIFflxJCQjPfYZaNqZSwDI4tpucZxaHxgQCm7DWEbwdTc8yp1Io6jp X5+O85rJLZiFYl2f5SyauDa1FaoL0T5XhgN+8NQIg3AbS2w4gxLILtWs/mCOMNSXHiQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796342743; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received: Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=gsXoP6kjKXvWEElwaLibgpYc6AVIlhcjNUDWlFMTr/Q=; b=hsADB2R8i6QQoxu02AaMWblI/V87oG0KMoMAAZsUXWq3JIbJOSLvscenO8G2Guas5/jr w/lxuQpsiK9afGa9BWoSPEfUqh5A/z39oRwQFSLIgDq1VubTX6aPla8RM4IewFA8Sjnua K/evFU5tJTc4GOvVyIeWalK2YangptItyZbH7QGUEqQRlz7Hdwe8LRc83gcQyr5gwaB8j SuxnDjSddk24EhtwNrILCd9dDmSEeiBwWgCW0QXr+51MTTu2xImrsuTz1O9f3wHn4kgew X4k2T1eo6MRDH2ReiGQaoAlj//MQT3IDL44A0KtID+k+PPMJ1mJFcozafzN19DsFKKg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oYcKcbZK; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; 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 E4C7E606A691; Fri,  4 Dec 2026 00:05:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oYcKcbZK
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.50
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796342742; b=bGxd3M5bUGnWmtipfVNGZGM2WObdFPqdzhSOlasuQq2prqnXLkWEu1eYPq944eWerMbW 6h0vljG0ohgW7b/AkcyspgvThdS3QASu2SzaZFlFd1lYOqiNlgx+90CjIsdZWa22po7sx 5cwtBtnpmrQaWN/qZSlOCCMewZqLD+Wei+fvMCfBcrC17VP6LHMyGK2QYe3kvQlukDjAF PykNTFpHXOCtgRdSNpNNyr5ve2i/z6u5mqJ2q6CTUDREhYM6jqEhDDdmPr9Oq0wyQsuCV BBQJtHtkpxXdCc0amJOF4npuD5U9H0OTOc91VfzvUhf/PbIfOY1Zf3o0fQSitzc98mg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796342742; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=gsXoP6kjKXvWEElwaLibgpYc6AVIlhcjNUDWlFMTr/Q=; b=XjbLbDgEDluFacIRnUD6e03HwjkBU/TOtYdKJQJkrMg8pmTdfSWRZuwCV0pCVdnRoER9 7zw96SIY8oakvBCfCM4pgYtWAcL1t2vX1YyXKK8bE1yGyu1nxYLIymfhTFUrvR7hnynfj M6KXFTs8LeWCDHJL8RSdkwtbUlcRPHNQkxaVTgtGqMgZNQbdkKaL5hDQQxtEteqmS1VGU ElpftJiUn38VW/VcmUtBUEWHMxPyo6GUoNw4skNwZsHF14ltxW4VaRsR8AuL2qTiBf6yt 9MigtvNhBJAwtQ+des7HavsZv0APex5MmALytXK2oMI7jm2onNVtwNrNCxUGEpQZ1Ww==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oYcKcbZK; arc=none smtp.remote-ip=209.85.128.50
X-Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53CEF606A686 for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 00:05:41 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 53CEF606A686
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4bb85e07aadso3651075e9.1 for <netdev@vger.kernel.org>; Thu, 03 Dec 2026 16:05:41 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796342740; x=1796947540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=gsXoP6kjKXvWEElwaLibgpYc6AVIlhcjNUDWlFMTr/Q=; b=oYcKcbZKeM/LOM4EsJc6UL//egH6AdxXkpcqMf7haZGnQEUi1ecRX2PdsXux6e1e4Q lbRrA01wDQHgdYDeNaupXJH/bdpkHnqBtiXHn5idjRfVpkmxCNdipPF7Ehh4RZ1Rrol5 zulo3SwJ4U1/fITLjwaqivyI8CmGHFatHUmCYog+Hk0KjBsnGvgkFkttutZ0lob8oBbS o95Jd9xZuywatmvB77jXCNn9cF0ljjtFBatz5jJjDwF54YdWk05MUuWep3/KOtm/KcQ1 KRWZt29irMbZw7QjnfOVOyTGcMo8WVx8/FLD79vJyokmIY24+XirhLMbjZ3iDOjv/OSp INpw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796342740; x=1796947540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=gsXoP6kjKXvWEElwaLibgpYc6AVIlhcjNUDWlFMTr/Q=; b=x6I7kRKUeKN7rudsPKAUKCFSUNfl5r3VK2vTX/S6oG6coR648wSd5fGqKh3zkCNZrS J8KoPKdbWa/nJv0fIqkHeXie5sKTfxR2aIpXW5qOdm/bKAuAKPSIviSmAoUZo7cgKu11 dPKWMmoZU7LbPFSi2YhzcO4bq4xY3a8KHKlaAVV9g+/mfuwjggCDAYYxR+HjZiEEY/8d JYaJtFafqjkYeb4FTqAapeLdmTrLJwDfJAGQ+tygzGRlanhZ479KMTkl45RBXgNNOIa3 Hxl6BLO6h4oDOBtb/dVqLRZHbYSMDB2ASaemQFVZ6JlI8NAFSUiTcZPuDv53aO4muath IOOg==
X-Gm-Message-State: APuU4Z+m1dqekkebu+PZM0xv15Z97GZ3tsBB3IULkQkXb+vxUuuH6LJx x+BtoNwTIamLpk/2yGlsH5pnD/Yy3gHCIkeYBbJ1meJQmBaV8xDVt0YmpEnlBbu2
X-Gm-Gg: AZFdTZe3PCkaenfnIjzeJ7daKs8wOWGSplzhIHx9uQSLqyq+7QMFT3sx0scRcTFUQe4 l6iia05JAuBhY8HFVw7Xn20lEJmJxtbCptADoU4FPTlUb2aiGGo3xTbe+KCCEEnXo1nghnJBKGT BykTxYD7EWoPdl/bw7d+npHd0jVpEJXLZrDpHrhKB2Eo1xHAFCZ+zR07M8edDlY2Es+u4rXtE1D lchAGX7uK9G1rxsgbLzFvOdMtZQCm8jCDKTTY72dKghQMCK5K/UVciuzkC3EBCUdCm0PczMkfu8 0kcUFr8CXPS1wUyyvBWt0fr4AhRAoxWy3buD7cyd/kqhOTlzo8bsKaTmj9NpT/XUuXPoMk4Bpqn D4NxSM53QqGFTDiW88WDb2JgJMPPnQSG2AzIr3B0RlcVkKfcSYbFZMgT68C8mZGVEs84V5S/NB9 Xi7w7HLT6jQOVRFvUkvMy9DNEDC5EQjkg78p99uiT21O33TSKjUYrWXWJvrKrvx+O4t72wkje59 Dj0SdJ63uLRKg3+gZxlHojobW/Q8Xkp7vQnQehvTIdVaCj3cRG/WOk2SF809kraryHRI1m3Pnyt 6RwcBbRqNlB3pwdO7g/008txUpk=
X-Received: by 2002:a05:600c:4504:b0:4bb:60bd:53b2 with SMTP id 5b1f17b1804b1-4bbeb84cce6mr4560785e9.6.1796342739555; Thu, 03 Dec 2026 16:05:39 -0800 (PST)
X-Received: from localhost ([2a03:2880:31ff:59::]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbea285a26sm11955695e9.7.2026.12.03.16.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 16:05:39 -0800 (PST)
X-Cc: 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-Mailer: git-send-email 2.53.1
X-In-Reply-To: <20261204000521.3396802-1-mohsin.bashr@gmail.com>
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
X-Received-Bytes: 14783