From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796342742; b=D0fpDH9DYIyT9ayzgQsSNAJQm8w9F9HaQ9EWwwy9reC9B/ZQUG22dnzBOc/yyXOZKN6y jJKLqUTz6w8Q30K5JGbPfO6B6L5JBx2uPDEqGCFJYgzy/tPMZuzbWPLomm+//sXwjAoK8 xvJ/IG9xIgP8C2ortdQcvN2ZW9T2icEVAmFYb2zrQVaKWrRjUDszx8OjTvYN4XNZTMP07 ne1iQlrdzLPd1CFSsqMCPysO9QdZPp0aZ3KoEXM+cRxUthe2Aa92S4azz/JdeS5ObjNzu sJg97uqcyEmuxu9IerK16nf0dD7jf5g0H7J1kIzUzdkDqhts3iWCHms7Rsmok0Ho2HQ== 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-Forwarded-Encrypted: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=Axf2TRUvj3CFmsrhAmU3UX/yJFxtOXXQHYT+I5xSmeZHQCW/V8Yp9ess4nrjvGT7J5A+ jtRrZsouS/Mlrw9YclPwz5B30NARTqVLr9ALl7JwjSwgRMWIpQDuk1R+UtXUGMhVn9Sxz 8s8X093aW1twMD3rcXbW7SpOpGSan9cDzRKSk8vDQfi4bzmli9AhlTDUJwhdVbeSe/OIC q4oBLEefBZ32Ldn/5UN5R3i72rL1vrnC4cLJAzDft5jldsiwFVbuDoc/cBXnt28ESkiBO EpYNv5Lzz9BmouMdRFA0v0THQiP3o2Zm1ATVwBBxSivP7CCB12JBu08BKhAF6MmmYuA== 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 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 53CAC606A335 for ; Fri, 4 Dec 2026 00:05:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 53CAC606A335 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4a2d6d01ecbso1825885e9.0 for ; Thu, 03 Dec 2026 16:05:41 -0800 (PST) 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=Mg8dGf0xKzu99bOYdP95YOoCEllhZvSCMF4XemguV9yTIVdxw2C6bc6uLDu/SCW0ya NZY5Lyzj6UT/RzE1mE+v4HiP1PhUKr9LWeu7vr35zrY4T3ghYGpVhKhXGsdHVCXtWQRF AFVRqepfLspfpwOCA9D5QwHClfFvCtUszmIVo1jMSfKfDcsEZ7EhSD6al/mfbnvR27fe YKf322z3Z02AmKgsMh9M73IGiXgZ9dMWL0iIZxHlSfESMXoaH4idAaNSigNJFyJAxHPS YkI08uxkFJQ14HkUb85WUv8DVWZOQttnOdUsVq5ySTbNKlbhQhSfUNKybKD5IqWhuBAq nr7A== X-Forwarded-Encrypted: i=1; AL+hErFq5blVZXtX3R2iNlJurMf3SVjcjOuN3pDcATVeBW/qSiBbSDjzjbd70g88ObS4HNBygLQgOy3rgrbP7c9CLXs=@vger.kernel.org X-Gm-Message-State: APuU4Z+EQhsNaOGiXIhlPNIt+nN4pMEGCpFIcD09WnJKceqyhDJcE3l4 VO3lEdTePxoHVVM9QEnqrCvEbZ9Gp2Pw6o3iobOIR4i1kjbPRm1s8Sm+ X-Gm-Gg: AZFdTZc8d2YRxTzB+B/ekUCAfyVga6RSlc1/8HD3LgINbzv690h+Vw9ypFxN1UkQtEm uYlYFfdrrjdQO1u/MC3202zqec7Xi/H7NPT5EzdWA++1Iy3yI4v4Yn18QhknDwPOPu0R0vz7DoJ V5vNZh3WP2WOaKY07QuSn7UmQgq3kvPwZheB4Rt6+E7NSQwoLy82BB9vSMQQ+Wv8ZVdhk/h2GdB tobkp7fWZuOf5HJ+N8pA/V58+GCA3U8+scS+38V6gDrLfj+oKJCbbl+b7CvrTFwzLbE2SpbSmHh QHNDycqFsc8c9XqRl7H9COv7tCfsIU1woRoi/UIQab148qfMGZz2pKzo2AQWYM9SKxaF2mIeVOn PX4x99XIjGTlXaLMUnktPvA/d5MhFyPIYPPgY6toKVr5ROSO9QPmCX0CqhfKP9mfmB9uJTY/7HZ 610+2Y6ypHpqyC024rkSOXFeC9DHMZQTtSBbebfWByfc239DrNlu0jfxVyHxIYoVqjKk2r1+RXg qQtIDi67hMVdXu+mHrUg+qIOt8Ji40kxvUkcCt35CaQMea4GykpKIATpCREdN1PhbFUXlDjBjvC ZQSxZyve4FUDI3DRO79ahBN+ahs= 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) 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) From: Mohsin Bashir To: netdev@vger.kernel.org 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 Subject: [PATCH net-next 06/11] selftests: drv-net: tc_flower_police: Test police parameters Date: Thu, 3 Dec 2026 16:05:16 -0800 Message-ID: <20261204000521.3396802-7-mohsin.bashr@gmail.com> X-Mailer: git-send-email 2.53.1 In-Reply-To: <20261204000521.3396802-1-mohsin.bashr@gmail.com> References: <20261204000521.3396802-1-mohsin.bashr@gmail.com> X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Mohsin Bashir 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 Signed-off-by: Mohsin Bashir --- .../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