On Fri, Apr 9, 2021 at 7:52 PM Simon Horman <[email protected]> wrote:
>
> From: Tianyu Yuan <[email protected]>
>
> tests/ovs-vsctl.at: Add ingress_policing test in ovs-vsctl unit test
> tests/system-offloads-traffic.at: Check ingress_policing with offloads 
> enabled and disabled
>
> Exercise OVS setting of ingress_policing 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).
>
> Example invocation:
> make check TESTSUITEFLAGS='-k ingress_policing'
> make check-offloads TESTSUITEFLAGS='-k ingress_policing'
>
> Signed-off-by: Tianyu Yuan <[email protected]>
> Signed-off-by: Simon Horman <[email protected]>
> Signed-off-by: Louis Peens <[email protected]>
Reviewed-by: Tonghao Zhang <[email protected]>
> ---
> v3
> * Avoid use of tmp files using --columns
> * Simplify screen scraping commands using sed
> * Skip tests if tc is unavailable
> ---
>  tests/atlocal.in                 |  3 ++
>  tests/ovs-vsctl.at               | 23 +++++++++++++++
>  tests/system-offloads-traffic.at | 50 ++++++++++++++++++++++++++++++++
>  3 files changed, 76 insertions(+)
>
> diff --git a/tests/atlocal.in b/tests/atlocal.in
> index 02e2dc57f..cfca7e192 100644
> --- a/tests/atlocal.in
> +++ b/tests/atlocal.in
> @@ -175,6 +175,9 @@ 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
> diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at
> index 8f7916037..dccb11741 100644
> --- a/tests/ovs-vsctl.at
> +++ b/tests/ovs-vsctl.at
> @@ -1664,3 +1664,26 @@ AT_CHECK([grep "server name" ovsdb-server.log], [0],
>
>  OVS_VSCTL_CLEANUP
>  AT_CLEANUP
> +
> +dnl ----------------------------------------------------------------------
> +AT_BANNER([set ingress policing test])
> +
> +AT_SETUP([set ingress_policing_rate and ingress_policing_burst])
> +AT_KEYWORDS([ingress_policing])
> +OVS_VSCTL_SETUP
> +AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
> +   [add-br a],
> +   [add-port a a1],
> +   [set interface a1 ingress_policing_rate=100],
> +   [set interface a1 ingress_policing_burst=10],
> +   [--columns=ingress_policing_burst,ingress_policing_rate list interface 
> a1])],
> +   [0],
> +   [
> +
> +
> +
> +ingress_policing_burst: 10
> +ingress_policing_rate: 100
> +])
> +OVS_VSCTL_CLEANUP
> +AT_CLEANUP
> diff --git a/tests/system-offloads-traffic.at 
> b/tests/system-offloads-traffic.at
> index 4f601ef93..c8e4c68fa 100644
> --- a/tests/system-offloads-traffic.at
> +++ b/tests/system-offloads-traffic.at
> @@ -70,3 +70,53 @@ AT_CHECK([ovs-appctl upcall/show | grep -E "offloaded 
> flows : [[1-9]]"], [0], [i
>
>  OVS_TRAFFIC_VSWITCHD_STOP
>  AT_CLEANUP
> +
> +AT_SETUP([offloads - set ingress_policing_rate and ingress_policing_burst - 
> offloads disabled])
> +AT_KEYWORDS([ingress_policing])
> +AT_SKIP_IF([test $HAVE_TC = "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_rate=100])
> +AT_CHECK([ovs-vsctl set interface ovs-p0 ingress_policing_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/.*\(rate [[0-9]]*[[a-zA-Z]]* burst [[0-9]]*[[a-zA-Z]]*\).*/\1/; 
> T; p; q'],
> +  [0],[dnl
> +rate 100Kbit burst 1280b
> +])
> +AT_CHECK([tc -s -d filter show dev ovs-p0 ingress | grep basic |
> +  sed -n 's/.*\(basic\).*/\1/; T; p; q'], [0], [dnl
> +basic
> +])
> +OVS_TRAFFIC_VSWITCHD_STOP
> +AT_CLEANUP
> +
> +AT_SETUP([offloads - set ingress_policing_rate and ingress_policing_burst - 
> offloads enabled])
> +AT_KEYWORDS([ingress_policing])
> +AT_SKIP_IF([test $HAVE_TC = "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_rate=100])
> +AT_CHECK([ovs-vsctl set interface ovs-p0 ingress_policing_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/.*\(rate [[0-9]]*[[a-zA-Z]]* burst [[0-9]]*[[a-zA-Z]]*\).*/\1/; 
> T; p; q'],
> +  [0],[dnl
> +rate 100Kbit burst 1280b
> +])
> +AT_CHECK([tc -o -s -d filter show dev ovs-p0 ingress | grep matchall |
> +  sed -n 's/.*\(matchall\).*/\1/; T; p; q'], [0], [dnl
> +matchall
> +])
> +OVS_TRAFFIC_VSWITCHD_STOP
> +AT_CLEANUP
> --
> 2.20.1
>


-- 
Best regards, Tonghao
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to