All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] selftest: add tests for packet per second
@ 2021-03-26 13:09 Simon Horman
  2021-03-26 13:09 ` [PATCH net-next 1/2] selftests: tc-testing: add action police selftest for packets " Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Simon Horman @ 2021-03-26 13:09 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, netdev, oss-drivers,
	Ido Schimmel, Baowen Zheng, Simon Horman

Add self tests for the recently added packet per second rate limiting
feature of the TC policer action[1].

The forwarding selftest (patch 2/2) depends on iproute2 support
for packet per second rate limiting, which has been posted separately[2]

[1] [PATCH v3 net-next 0/3] net/sched: act_police: add support for packet-per-second policing
    https://lore.kernel.org/netdev/20210312140831.23346-1-simon.horman@netronome.com/

[2] [PATCH iproute2-next] police: add support for packet-per-second rate limiting
    https://lore.kernel.org/netdev/20210326125018.32091-1-simon.horman@netronome.com/

Baowen Zheng (2):
  selftests: tc-testing: add action police selftest for packets per
    second
  selftests: forwarding: Add tc-police tests for packets per second

 tools/testing/selftests/net/forwarding/lib.sh |  9 +++
 .../selftests/net/forwarding/tc_police.sh     | 56 +++++++++++++++++++
 .../tc-testing/tc-tests/actions/police.json   | 48 ++++++++++++++++
 3 files changed, 113 insertions(+)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/2] selftests: tc-testing: add action police selftest for packets per second
  2021-03-26 13:09 [PATCH net-next 0/2] selftest: add tests for packet per second Simon Horman
@ 2021-03-26 13:09 ` Simon Horman
  2021-03-28  0:55   ` Jamal Hadi Salim
  2021-03-26 13:09 ` [PATCH net-next 2/2] selftests: forwarding: Add tc-police tests " Simon Horman
  2021-03-29  0:50 ` [PATCH net-next 0/2] selftest: add tests for packet " patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Simon Horman @ 2021-03-26 13:09 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, netdev, oss-drivers,
	Ido Schimmel, Baowen Zheng, Simon Horman

From: Baowen Zheng <baowen.zheng@corigine.com>

Add selftest cases in action police for packets per second.
These tests depend on corresponding iproute2 command support.

Signed-off-by: Baowen Zheng <baowen.zheng@corigine.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
It is also planned, as a follow-up, to provide packet per second rate
limiting tests in tools/testing/selftests/net/forwarding/tc_police.sh
---
 .../tc-testing/tc-tests/actions/police.json   | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/police.json b/tools/testing/selftests/tc-testing/tc-tests/actions/police.json
index b8268da5adaa..8e45792703ed 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/actions/police.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/actions/police.json
@@ -764,5 +764,53 @@
         "teardown": [
             "$TC actions flush action police"
         ]
+    },
+    {
+        "id": "cdd7",
+        "name": "Add valid police action with packets per second rate limit",
+        "category": [
+            "actions",
+            "police"
+        ],
+        "setup": [
+            [
+                "$TC actions flush action police",
+                0,
+                1,
+                255
+            ]
+        ],
+        "cmdUnderTest": "$TC actions add action police pkts_rate 1000 pkts_burst 200 index 1",
+        "expExitCode": "0",
+        "verifyCmd": "$TC actions ls action police",
+        "matchPattern": "action order [0-9]*:  police 0x1 rate 0bit burst 0b mtu 4096Mb pkts_rate 1000 pkts_burst 200",
+        "matchCount": "1",
+        "teardown": [
+            "$TC actions flush action police"
+        ]
+    },
+    {
+        "id": "f5bc",
+        "name": "Add invalid police action with both bps and pps",
+        "category": [
+            "actions",
+            "police"
+        ],
+        "setup": [
+            [
+                "$TC actions flush action police",
+                0,
+                1,
+                255
+            ]
+        ],
+        "cmdUnderTest": "$TC actions add action police rate 1kbit burst 10k pkts_rate 1000 pkts_burst 200 index 1",
+        "expExitCode": "255",
+        "verifyCmd": "$TC actions ls action police",
+        "matchPattern": "action order [0-9]*:  police 0x1 ",
+        "matchCount": "0",
+        "teardown": [
+            "$TC actions flush action police"
+        ]
     }
 ]
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/2] selftests: forwarding: Add tc-police tests for packets per second
  2021-03-26 13:09 [PATCH net-next 0/2] selftest: add tests for packet per second Simon Horman
  2021-03-26 13:09 ` [PATCH net-next 1/2] selftests: tc-testing: add action police selftest for packets " Simon Horman
@ 2021-03-26 13:09 ` Simon Horman
  2021-03-29  7:16   ` Ido Schimmel
  2021-03-29  0:50 ` [PATCH net-next 0/2] selftest: add tests for packet " patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Simon Horman @ 2021-03-26 13:09 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, netdev, oss-drivers,
	Ido Schimmel, Baowen Zheng, Simon Horman

From: Baowen Zheng <baowen.zheng@corigine.com>

Test tc-police action for packets per second.
The test is mainly in scenarios Rx policing and Tx policing.
The test passes with veth pairs ports.

Signed-off-by: Baowen Zheng <baowen.zheng@corigine.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 tools/testing/selftests/net/forwarding/lib.sh |  9 +++
 .../selftests/net/forwarding/tc_police.sh     | 56 +++++++++++++++++++
 2 files changed, 65 insertions(+)

diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 05c05e02bade..42e28c983d41 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -772,6 +772,15 @@ rate()
 	echo $((8 * (t1 - t0) / interval))
 }
 
+packets_rate()
+{
+	local t0=$1; shift
+	local t1=$1; shift
+	local interval=$1; shift
+
+	echo $(((t1 - t0) / interval))
+}
+
 mac_get()
 {
 	local if_name=$1
diff --git a/tools/testing/selftests/net/forwarding/tc_police.sh b/tools/testing/selftests/net/forwarding/tc_police.sh
index 160f9cccdfb7..4f9f17cb45d6 100755
--- a/tools/testing/selftests/net/forwarding/tc_police.sh
+++ b/tools/testing/selftests/net/forwarding/tc_police.sh
@@ -35,6 +35,8 @@ ALL_TESTS="
 	police_shared_test
 	police_rx_mirror_test
 	police_tx_mirror_test
+	police_pps_rx_test
+	police_pps_tx_test
 "
 NUM_NETIFS=6
 source tc_common.sh
@@ -290,6 +292,60 @@ police_tx_mirror_test()
 	police_mirror_common_test $rp2 egress "police tx and mirror"
 }
 
+police_pps_common_test()
+{
+	local test_name=$1; shift
+
+	RET=0
+
+	# Rule to measure bandwidth on ingress of $h2
+	tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
+		dst_ip 198.51.100.1 ip_proto udp dst_port 54321 \
+		action drop
+
+	mausezahn $h1 -a own -b $(mac_get $rp1) -A 192.0.2.1 -B 198.51.100.1 \
+		-t udp sp=12345,dp=54321 -p 1000 -c 0 -q &
+
+	local t0=$(tc_rule_stats_get $h2 1 ingress .packets)
+	sleep 10
+	local t1=$(tc_rule_stats_get $h2 1 ingress .packets)
+
+	local er=$((2000))
+	local nr=$(packets_rate $t0 $t1 10)
+	local nr_pct=$((100 * (nr - er) / er))
+	((-10 <= nr_pct && nr_pct <= 10))
+	check_err $? "Expected rate $(humanize $er), got $(humanize $nr), which is $nr_pct% off. Required accuracy is +-10%."
+
+	log_test "$test_name"
+
+	{ kill %% && wait %%; } 2>/dev/null
+	tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
+}
+
+police_pps_rx_test()
+{
+	# Rule to police traffic destined to $h2 on ingress of $rp1
+	tc filter add dev $rp1 ingress protocol ip pref 1 handle 101 flower \
+		dst_ip 198.51.100.1 ip_proto udp dst_port 54321 \
+		action police pkts_rate 2000 pkts_burst 400 conform-exceed drop/ok
+
+	police_pps_common_test "police pps on rx"
+
+	tc filter del dev $rp1 ingress protocol ip pref 1 handle 101 flower
+}
+
+police_pps_tx_test()
+{
+	# Rule to police traffic destined to $h2 on egress of $rp2
+	tc filter add dev $rp2 egress protocol ip pref 1 handle 101 flower \
+		dst_ip 198.51.100.1 ip_proto udp dst_port 54321 \
+		action police pkts_rate 2000 pkts_burst 400 conform-exceed drop/ok
+
+	police_pps_common_test "police pps on tx"
+
+	tc filter del dev $rp2 egress protocol ip pref 1 handle 101 flower
+}
+
 setup_prepare()
 {
 	h1=${NETIFS[p1]}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 1/2] selftests: tc-testing: add action police selftest for packets per second
  2021-03-26 13:09 ` [PATCH net-next 1/2] selftests: tc-testing: add action police selftest for packets " Simon Horman
@ 2021-03-28  0:55   ` Jamal Hadi Salim
  0 siblings, 0 replies; 6+ messages in thread
From: Jamal Hadi Salim @ 2021-03-28  0:55 UTC (permalink / raw)
  To: Simon Horman, David Miller, Jakub Kicinski
  Cc: Cong Wang, Jiri Pirko, netdev, oss-drivers, Ido Schimmel, Baowen Zheng

On 2021-03-26 9:09 a.m., Simon Horman wrote:
> From: Baowen Zheng <baowen.zheng@corigine.com>
> 
> Add selftest cases in action police for packets per second.
> These tests depend on corresponding iproute2 command support.
> 
> Signed-off-by: Baowen Zheng <baowen.zheng@corigine.com>
> Signed-off-by: Simon Horman <simon.horman@netronome.com>

Gracias.

Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>

cheers,
jamal


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/2] selftest: add tests for packet per second
  2021-03-26 13:09 [PATCH net-next 0/2] selftest: add tests for packet per second Simon Horman
  2021-03-26 13:09 ` [PATCH net-next 1/2] selftests: tc-testing: add action police selftest for packets " Simon Horman
  2021-03-26 13:09 ` [PATCH net-next 2/2] selftests: forwarding: Add tc-police tests " Simon Horman
@ 2021-03-29  0:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-29  0:50 UTC (permalink / raw)
  To: Simon Horman
  Cc: davem, kuba, jhs, xiyou.wangcong, jiri, netdev, oss-drivers,
	idosch, baowen.zheng

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Fri, 26 Mar 2021 14:09:36 +0100 you wrote:
> Add self tests for the recently added packet per second rate limiting
> feature of the TC policer action[1].
> 
> The forwarding selftest (patch 2/2) depends on iproute2 support
> for packet per second rate limiting, which has been posted separately[2]
> 
> [1] [PATCH v3 net-next 0/3] net/sched: act_police: add support for packet-per-second policing
>     https://lore.kernel.org/netdev/20210312140831.23346-1-simon.horman@netronome.com/
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] selftests: tc-testing: add action police selftest for packets per second
    https://git.kernel.org/netdev/net-next/c/c127ffa23e41
  - [net-next,2/2] selftests: forwarding: Add tc-police tests for packets per second
    https://git.kernel.org/netdev/net-next/c/53b61f29367d

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 2/2] selftests: forwarding: Add tc-police tests for packets per second
  2021-03-26 13:09 ` [PATCH net-next 2/2] selftests: forwarding: Add tc-police tests " Simon Horman
@ 2021-03-29  7:16   ` Ido Schimmel
  0 siblings, 0 replies; 6+ messages in thread
From: Ido Schimmel @ 2021-03-29  7:16 UTC (permalink / raw)
  To: Simon Horman
  Cc: David Miller, Jakub Kicinski, Jamal Hadi Salim, Cong Wang,
	Jiri Pirko, netdev, oss-drivers, Baowen Zheng

On Fri, Mar 26, 2021 at 02:09:38PM +0100, Simon Horman wrote:
> From: Baowen Zheng <baowen.zheng@corigine.com>
> 
> Test tc-police action for packets per second.
> The test is mainly in scenarios Rx policing and Tx policing.
> The test passes with veth pairs ports.
> 
> Signed-off-by: Baowen Zheng <baowen.zheng@corigine.com>
> Signed-off-by: Simon Horman <simon.horman@netronome.com>

FWIW (I see it was already merged):

Reviewed-by: Ido Schimmel <idosch@nvidia.com>

Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-29  7:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26 13:09 [PATCH net-next 0/2] selftest: add tests for packet per second Simon Horman
2021-03-26 13:09 ` [PATCH net-next 1/2] selftests: tc-testing: add action police selftest for packets " Simon Horman
2021-03-28  0:55   ` Jamal Hadi Salim
2021-03-26 13:09 ` [PATCH net-next 2/2] selftests: forwarding: Add tc-police tests " Simon Horman
2021-03-29  7:16   ` Ido Schimmel
2021-03-29  0:50 ` [PATCH net-next 0/2] selftest: add tests for packet " patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.