Commit 075c8aa7 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller
Browse files

selftests: forwarding: tc_actions.sh: add matchall mirror test



Add test for matchall classifier with mirred egress mirror action.

Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 19f06771
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@
# SPDX-License-Identifier: GPL-2.0

ALL_TESTS="gact_drop_and_ok_test mirred_egress_redirect_test \
	mirred_egress_mirror_test gact_trap_test"
	mirred_egress_mirror_test matchall_mirred_egress_mirror_test \
	gact_trap_test"
NUM_NETIFS=4
source tc_common.sh
source lib.sh
@@ -50,6 +51,9 @@ switch_destroy()
mirred_egress_test()
{
	local action=$1
	local protocol=$2
	local classifier=$3
	local classifier_args=$4

	RET=0

@@ -62,9 +66,9 @@ mirred_egress_test()
	tc_check_packets "dev $h2 ingress" 101 1
	check_fail $? "Matched without redirect rule inserted"

	tc filter add dev $swp1 ingress protocol ip pref 1 handle 101 flower \
		$tcflags dst_ip 192.0.2.2 action mirred egress $action \
		dev $swp2
	tc filter add dev $swp1 ingress protocol $protocol pref 1 handle 101 \
		$classifier $tcflags $classifier_args \
		action mirred egress $action dev $swp2

	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
		-t ip -q
@@ -72,10 +76,11 @@ mirred_egress_test()
	tc_check_packets "dev $h2 ingress" 101 1
	check_err $? "Did not match incoming $action packet"

	tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower
	tc filter del dev $swp1 ingress protocol $protocol pref 1 handle 101 \
		$classifier
	tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower

	log_test "mirred egress $action ($tcflags)"
	log_test "mirred egress $classifier $action ($tcflags)"
}

gact_drop_and_ok_test()
@@ -187,12 +192,17 @@ cleanup()

mirred_egress_redirect_test()
{
	mirred_egress_test "redirect"
	mirred_egress_test "redirect" "ip" "flower" "dst_ip 192.0.2.2"
}

mirred_egress_mirror_test()
{
	mirred_egress_test "mirror"
	mirred_egress_test "mirror" "ip" "flower" "dst_ip 192.0.2.2"
}

matchall_mirred_egress_mirror_test()
{
	mirred_egress_test "mirror" "all" "matchall" ""
}

trap cleanup EXIT