Skip to contentSkip to conversation

selftest: add tests for packet per second

PATCH Applied Simon Horman 4 participants 6 messages Mar 26, 2021 – Mar 29, 2021

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover selftest: add tests for packet per second

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/[email protected]/

[2] [PATCH iproute2-next] police: add support for packet-per-second rate limiting

    https://lore.kernel.org/netdev/[email protected]/

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(+)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 selftests: tc-testing: add action police selftest for packets per second

From: Baowen Zheng <[email protected]>

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

---
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(+)
tools/testing/selftests/tc-testing/tc-tests/actions/police.json +48 -0
index b8268da5adaa..8e45792703ed 100644
@@ -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"
+        ]
     }
 ]
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH net-next 1/2] selftests: tc-testing: add action police selftest for packets per second

Quoted 7 lines · Simon Horman

From: Baowen Zheng <[email protected]>

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

Gracias.

cheers,
jamal

#3 lore raw

PATCH 2/2 selftests: forwarding: Add tc-police tests for packets per second

In reply to Simon Horman

From: Baowen Zheng <[email protected]>

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.

---
 tools/testing/selftests/net/forwarding/lib.sh |  9 +++
 .../selftests/net/forwarding/tc_police.sh     | 56 +++++++++++++++++++
 2 files changed, 65 insertions(+)
tools/testing/selftests/net/forwarding/lib.sh +9 -0
index 05c05e02bade..42e28c983d41 100644
@@ -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
tools/testing/selftests/net/forwarding/tc_police.sh +56 -0

68 lines not on this page · raw message

Signature · 1 line
2.20.1
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH net-next 2/2] selftests: forwarding: Add tc-police tests for packets per second

Quoted 8 lines · Simon Horman

From: Baowen Zheng <[email protected]>

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.

FWIW (I see it was already merged):

Thanks!

#5 lore raw
In reply to Simon Horman
This series was applied to netdev/net-next.git (refs/heads/master):

Hello:

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

Quoted 10 lines · 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/[email protected]/

[...]

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