diff mbox series

[ovs-dev,v3,2/2] add test cases for ingress_policing_kpkts parameters

Message ID 20210609095209.6205-3-simon.horman@netronome.com
State New
Headers show
Series add port-based ingress policing based packet-per-second rate-limiting | expand

Commit Message

Simon Horman June 9, 2021, 9:52 a.m. UTC
From: Tianyu Yuan <tianyu.yuan@corigine.com>

Exercise OVS setting of ingress_policing_kpkts parameters using ovs-vsctl
and verify that the correct values are stored on OVSDB.

Verify the ingress_policing parameters with tc command. Also check offload
and non-offload in tc software datapath based on tc filter type (matchall
and basic).  Skip test of pps if OVS or kernel does not support pps rate
limit.

Example invocation:
make check TESTSUITEFLAGS='-k ingress_policing_kpkts'
make check-offloads TESTSUITEFLAGS='-k ingress_policing_kpkts'

Signed-off-by: Tianyu Yuan <tianyu.yuan@corigine.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 tests/atlocal.in                 | 17 +++++++++--
 tests/ovs-vsctl.at               | 23 +++++++++++++++
 tests/system-offloads-traffic.at | 50 ++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+), 3 deletions(-)

Comments

0-day Robot June 9, 2021, 8:14 p.m. UTC | #1
Bleep bloop.  Greetings Simon Horman, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: Simon Horman <simon.horman@netronome.com>
Lines checked: 152, Warnings: 1, Errors: 0


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
diff mbox series

Patch

diff --git a/tests/atlocal.in b/tests/atlocal.in
index e1b75f5a3..a0ad239ec 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -159,9 +159,6 @@  find_command()
 # Set HAVE_NC
 find_command nc
 
-# Set HAVE_TC
-find_command tc
-
 # Determine correct netcat option to quit on stdin EOF
 if nc --version 2>&1 | grep -q nmap.org; then
     # Nmap netcat
@@ -171,6 +168,20 @@  else
     NC_EOF_OPT="-q 1 -w 5"
 fi
 
+# Set HAVE_TC
+find_command tc
+
+# When HAVE_TC=yes, check if the current tc supports adding pps filter
+SUPPORT_TC_INGRESS_PPS="no"
+if test $HAVE_TC="yes"; then
+    ip link add veth0 type veth peer name veth1
+    tc qdisc add dev veth0 handle ffff: ingress
+    if tc filter add dev veth0 parent ffff: u32 match u32 0 0 police pkts_rate 100 pkts_burst 10; then
+        SUPPORT_TC_INGRESS_PPS="yes"
+    fi
+    ip link del veth0
+fi
+
 # Set HAVE_TCPDUMP
 find_command tcpdump
 
diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at
index dccb11741..d6cd2c084 100644
--- a/tests/ovs-vsctl.at
+++ b/tests/ovs-vsctl.at
@@ -1687,3 +1687,26 @@  ingress_policing_rate: 100
 ])
 OVS_VSCTL_CLEANUP
 AT_CLEANUP
+
+dnl ----------------------------------------------------------------------
+AT_BANNER([set ingress policing(kpkts) test])
+
+AT_SETUP([set ingress_policing_kpkts_rate and ingress_policing_kpkts_burst])
+AT_KEYWORDS([ingress_policing_kpkts])
+OVS_VSCTL_SETUP
+AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
+   [add-br a],
+   [add-port a a1],
+   [set interface a1 ingress_policing_kpkts_rate=100],
+   [set interface a1 ingress_policing_kpkts_burst=10],
+   [--columns=ingress_policing_kpkts_burst,ingress_policing_kpkts_rate list interface a1])],
+   [0],
+   [
+
+
+
+ingress_policing_kpkts_burst: 10
+ingress_policing_kpkts_rate: 100
+])
+OVS_VSCTL_CLEANUP
+AT_CLEANUP
diff --git a/tests/system-offloads-traffic.at b/tests/system-offloads-traffic.at
index c8e4c68fa..be63057bb 100644
--- a/tests/system-offloads-traffic.at
+++ b/tests/system-offloads-traffic.at
@@ -120,3 +120,53 @@  matchall
 ])
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
+
+AT_SETUP([offloads - set ingress_policing_kpkts_rate and ingress_policing_kpkts_burst - offloads disabled])
+AT_KEYWORDS([ingress_policing_kpkts])
+AT_SKIP_IF([test $SUPPORT_TC_INGRESS_PPS = "no"])
+OVS_TRAFFIC_VSWITCHD_START()
+AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:hw-offload=false])
+AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"])
+ADD_NAMESPACES(at_ns0)
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+AT_CHECK([ovs-vsctl set interface ovs-p0 ingress_policing_kpkts_rate=100])
+AT_CHECK([ovs-vsctl set interface ovs-p0 ingress_policing_kpkts_burst=10])
+AT_CHECK([ovs-vsctl --columns=other_config list open], [0], [dnl
+other_config        : {hw-offload="false"}
+])
+AT_CHECK([tc -o -s -d filter show dev ovs-p0 ingress |
+  sed -n 's/.*\(pkts_rate [[0-9]]*[[a-zA-Z]]* pkts_burst [[0-9]]*[[a-zA-Z]]*\).*/\1/; T; p; q'],
+  [0],[dnl
+pkts_rate 100000 pkts_burst 10240
+])
+AT_CHECK([tc -s -d filter show dev ovs-p0 ingress |
+  sed -n 's/.*\(basic\).*/\1/; T; p; q'], [0], [dnl
+basic
+])
+OVS_TRAFFIC_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([offloads - set ingress_policing_kpkts_rate and ingress_policing_kpkts_burst - offloads enabled])
+AT_KEYWORDS([ingress_policing_kpkts])
+AT_SKIP_IF([test $SUPPORT_TC_INGRESS_PPS = "no"])
+OVS_TRAFFIC_VSWITCHD_START()
+AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:hw-offload=true])
+AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"])
+ADD_NAMESPACES(at_ns0)
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+AT_CHECK([ovs-vsctl set interface ovs-p0 ingress_policing_kpkts_rate=100])
+AT_CHECK([ovs-vsctl set interface ovs-p0 ingress_policing_kpkts_burst=10])
+AT_CHECK([ovs-vsctl --columns=other_config list open], [0], [dnl
+other_config        : {hw-offload="true"}
+])
+AT_CHECK([tc -o -s -d filter show dev ovs-p0 ingress |
+  sed -n 's/.*\(pkts_rate [[0-9]]*[[a-zA-Z]]* pkts_burst [[0-9]]*[[a-zA-Z]]*\).*/\1/; T; p; q'],
+  [0],[dnl
+pkts_rate 100000 pkts_burst 10240
+])
+AT_CHECK([tc -s -d filter show dev ovs-p0 ingress |
+  sed -n 's/.*\(matchall\).*/\1/; T; p; q'], [0], [dnl
+matchall
+])
+OVS_TRAFFIC_VSWITCHD_STOP
+AT_CLEANUP