Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1bb58d2d authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'Mirroring-tests-involving-VLAN'



Petr Machata says:

====================
Mirroring tests involving VLAN

This patchset tests mirror-to-gretap with various underlay
configurations involving VLAN netdevice in particular. Some of the tests
involve bridges as well, but tests aimed specifically at testing bridges
(i.e. FDB, STP) are not part of this patchset.

In patches #1-#6, the codebase is adapted to support the new tests.

In patch #7, a test for mirroring to VLAN is introduced.

Patches #8-#10 add three tests where VLAN is part of underlay path after
gretap encapsulation.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 90fed9c9 181d95f8
Loading
Loading
Loading
Loading
+43 −9
Original line number Diff line number Diff line
@@ -340,6 +340,31 @@ tunnel_destroy()
	ip link del dev $name
}

vlan_create()
{
	local if_name=$1; shift
	local vid=$1; shift
	local vrf=$1; shift
	local ips=("${@}")
	local name=$if_name.$vid

	ip link add name $name link $if_name type vlan id $vid
	if [ "$vrf" != "" ]; then
		ip link set dev $name master $vrf
	fi
	ip link set dev $name up
	__addr_add_del $name add "${ips[@]}"
}

vlan_destroy()
{
	local if_name=$1; shift
	local vid=$1; shift
	local name=$if_name.$vid

	ip link del dev $name
}

master_name_get()
{
	local if_name=$1
@@ -423,26 +448,35 @@ tc_offload_check()
	return 0
}

slow_path_trap_install()
trap_install()
{
	local dev=$1; shift
	local direction=$1; shift

	if [ "${tcflags/skip_hw}" != "$tcflags" ]; then
	# For slow-path testing, we need to install a trap to get to
	# slow path the packets that would otherwise be switched in HW.
		tc filter add dev $dev $direction pref 1 \
		   flower skip_sw action trap
	fi
	tc filter add dev $dev $direction pref 1 flower skip_sw action trap
}

slow_path_trap_uninstall()
trap_uninstall()
{
	local dev=$1; shift
	local direction=$1; shift

	if [ "${tcflags/skip_hw}" != "$tcflags" ]; then
	tc filter del dev $dev $direction pref 1 flower skip_sw
}

slow_path_trap_install()
{
	if [ "${tcflags/skip_hw}" != "$tcflags" ]; then
		trap_install "$@"
	fi
}

slow_path_trap_uninstall()
{
	if [ "${tcflags/skip_hw}" != "$tcflags" ]; then
		trap_uninstall "$@"
	fi
}

+0 −2
Original line number Diff line number Diff line
@@ -72,7 +72,6 @@ test_span_gre_mac()
	RET=0

	mirror_install $swp1 $direction $tundev "matchall $tcflags"
	tc qdisc add dev $h3 clsact
	tc filter add dev $h3 ingress pref 77 prot $prot \
		flower ip_proto 0x2f src_mac $swp3mac dst_mac $h3mac \
		action pass
@@ -80,7 +79,6 @@ test_span_gre_mac()
	mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 10

	tc filter del dev $h3 ingress pref 77
	tc qdisc del dev $h3 clsact
	mirror_uninstall $swp1 $direction

	log_test "$direction $what: envelope MAC ($tcflags)"
+109 −0
Original line number Diff line number Diff line
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

# This test uses standard topology for testing gretap. See
# mirror_gre_topo_lib.sh for more details.
#
# Test for "tc action mirred egress mirror" when the underlay route points at a
# bridge device without vlan filtering (802.1d). The device attached to that
# bridge is a VLAN.

ALL_TESTS="
	test_gretap
	test_ip6gretap
"

NUM_NETIFS=6
source lib.sh
source mirror_lib.sh
source mirror_gre_lib.sh
source mirror_gre_topo_lib.sh

setup_prepare()
{
	h1=${NETIFS[p1]}
	swp1=${NETIFS[p2]}

	swp2=${NETIFS[p3]}
	h2=${NETIFS[p4]}

	swp3=${NETIFS[p5]}
	h3=${NETIFS[p6]}

	vrf_prepare
	mirror_gre_topo_create

	ip link add name br2 type bridge vlan_filtering 0
	ip link set dev br2 up

	vlan_create $swp3 555

	ip link set dev $swp3.555 master br2
	ip route add 192.0.2.130/32 dev br2
	ip -6 route add 2001:db8:2::2/128 dev br2

	ip address add dev br2 192.0.2.129/32
	ip address add dev br2 2001:db8:2::1/128

	vlan_create $h3 555 v$h3 192.0.2.130/28 2001:db8:2::2/64
}

cleanup()
{
	pre_cleanup

	vlan_destroy $h3 555
	ip link del dev br2
	vlan_destroy $swp3 555

	mirror_gre_topo_destroy
	vrf_cleanup
}

test_vlan_match()
{
	local tundev=$1; shift
	local vlan_match=$1; shift
	local what=$1; shift

	full_test_span_gre_dir_vlan $tundev ingress "$vlan_match" 8 0 "$what"
	full_test_span_gre_dir_vlan $tundev egress "$vlan_match" 0 8 "$what"
}

test_gretap()
{
	test_vlan_match gt4 'vlan_id 555 vlan_ethtype ip' "mirror to gretap"
}

test_ip6gretap()
{
	test_vlan_match gt6 'vlan_id 555 vlan_ethtype ipv6' "mirror to ip6gretap"
}

test_all()
{
	slow_path_trap_install $swp1 ingress
	slow_path_trap_install $swp1 egress

	tests_run

	slow_path_trap_uninstall $swp1 egress
	slow_path_trap_uninstall $swp1 ingress
}

trap cleanup EXIT

setup_prepare
setup_wait

tcflags="skip_hw"
test_all

if ! tc_offload_check; then
	echo "WARN: Could not test offloaded functionality"
else
	tcflags="skip_sw"
	test_all
fi

exit $EXIT_STATUS
+0 −2
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ test_span_gre_ttl()
	RET=0

	mirror_install $swp1 ingress $tundev "matchall $tcflags"
	tc qdisc add dev $h3 clsact
	tc filter add dev $h3 ingress pref 77 prot $prot \
		flower ip_ttl 50 action pass

@@ -84,7 +83,6 @@ test_span_gre_ttl()

	ip link set dev $tundev type $type ttl 100
	tc filter del dev $h3 ingress pref 77
	tc qdisc del dev $h3 clsact
	mirror_uninstall $swp1 ingress

	log_test "$what: TTL change ($tcflags)"
+37 −24
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0

do_test_span_gre_dir_ips()
source mirror_lib.sh

quick_test_span_gre_dir_ips()
{
	local expect=$1; shift
	local tundev=$1; shift
	local direction=$1; shift
	local ip1=$1; shift
	local ip2=$1; shift

	icmp_capture_install h3-$tundev
	mirror_test v$h1 $ip1 $ip2 h3-$tundev 100 $expect
	mirror_test v$h2 $ip2 $ip1 h3-$tundev 100 $expect
	icmp_capture_uninstall h3-$tundev
	do_test_span_dir_ips 10 h3-$tundev "$@"
}

quick_test_span_gre_dir_ips()
fail_test_span_gre_dir_ips()
{
	do_test_span_gre_dir_ips 10 "$@"
	local tundev=$1; shift

	do_test_span_dir_ips 0 h3-$tundev "$@"
}

fail_test_span_gre_dir_ips()
test_span_gre_dir_ips()
{
	do_test_span_gre_dir_ips 0 "$@"
	local tundev=$1; shift

	test_span_dir_ips h3-$tundev "$@"
}

test_span_gre_dir_ips()
full_test_span_gre_dir_ips()
{
	local tundev=$1; shift
	local direction=$1; shift
	local forward_type=$1; shift
	local backward_type=$1; shift
	local what=$1; shift
	local ip1=$1; shift
	local ip2=$1; shift

	quick_test_span_gre_dir_ips "$tundev" "$direction" "$ip1" "$ip2"
	RET=0

	icmp_capture_install h3-$tundev "type $forward_type"
	mirror_test v$h1 $ip1 $ip2 h3-$tundev 100 10
	icmp_capture_uninstall h3-$tundev
	mirror_install $swp1 $direction $tundev "matchall $tcflags"
	test_span_dir_ips "h3-$tundev" "$direction" "$forward_type" \
			  "$backward_type" "$ip1" "$ip2"
	mirror_uninstall $swp1 $direction

	icmp_capture_install h3-$tundev "type $backward_type"
	mirror_test v$h2 $ip2 $ip1 h3-$tundev 100 10
	icmp_capture_uninstall h3-$tundev
	log_test "$direction $what ($tcflags)"
}

full_test_span_gre_dir_ips()
full_test_span_gre_dir_vlan_ips()
{
	local tundev=$1; shift
	local direction=$1; shift
	local vlan_match=$1; shift
	local forward_type=$1; shift
	local backward_type=$1; shift
	local what=$1; shift
@@ -57,8 +57,16 @@ full_test_span_gre_dir_ips()
	RET=0

	mirror_install $swp1 $direction $tundev "matchall $tcflags"
	test_span_gre_dir_ips "$tundev" "$direction" "$forward_type" \

	test_span_dir_ips "h3-$tundev" "$direction" "$forward_type" \
			  "$backward_type" "$ip1" "$ip2"

	tc filter add dev $h3 ingress pref 77 prot 802.1q \
		flower $vlan_match ip_proto 0x2f \
		action pass
	mirror_test v$h1 $ip1 $ip2 $h3 77 10
	tc filter del dev $h3 ingress pref 77

	mirror_uninstall $swp1 $direction

	log_test "$direction $what ($tcflags)"
@@ -83,3 +91,8 @@ full_test_span_gre_dir()
{
	full_test_span_gre_dir_ips "$@" 192.0.2.1 192.0.2.2
}

full_test_span_gre_dir_vlan()
{
	full_test_span_gre_dir_vlan_ips "$@" 192.0.2.1 192.0.2.2
}
Loading