selftests: add a mirror test to mlxsw tc flower restrictions
authorJiri Pirko <jiri@mellanox.com>
Thu, 27 Feb 2020 07:50:09 +0000 (08:50 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 27 Feb 2020 19:10:14 +0000 (11:10 -0800)
Include test of forbidding to have multiple mirror actions.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/drivers/net/mlxsw/tc_flower_restrictions.sh

index 67e0c25..68c80d0 100755 (executable)
@@ -6,6 +6,7 @@ lib_dir=$(dirname $0)/../../../net/forwarding
 ALL_TESTS="
        shared_block_drop_test
        egress_redirect_test
+       multi_mirror_test
 "
 NUM_NETIFS=2
 
@@ -127,6 +128,33 @@ egress_redirect_test()
        log_test "shared block drop"
 }
 
+multi_mirror_test()
+{
+       RET=0
+
+       # It is forbidden in mlxsw driver to have multiple mirror
+       # actions in a single rule.
+
+       tc qdisc add dev $swp1 clsact
+
+       tc filter add dev $swp1 ingress protocol ip pref 1 handle 101 flower \
+               skip_sw dst_ip 192.0.2.2 \
+               action mirred egress mirror dev $swp2
+       check_err $? "Failed to add rule with single mirror action"
+
+       tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower
+
+       tc filter add dev $swp1 ingress protocol ip pref 1 handle 101 flower \
+               skip_sw dst_ip 192.0.2.2 \
+               action mirred egress mirror dev $swp2 \
+               action mirred egress mirror dev $swp1
+       check_fail $? "Incorrect success to add rule with two mirror actions"
+
+       tc qdisc del dev $swp1 clsact
+
+       log_test "multi mirror"
+}
+
 setup_prepare()
 {
        swp1=${NETIFS[p1]}