mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-13 15:53:56 +08:00
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: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
1bb58d2d3c
@ -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
|
||||
tc filter add dev $dev $direction pref 1 flower skip_sw action trap
|
||||
}
|
||||
|
||||
trap_uninstall()
|
||||
{
|
||||
local dev=$1; shift
|
||||
local direction=$1; shift
|
||||
|
||||
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()
|
||||
{
|
||||
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
|
||||
trap_uninstall "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -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
tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh
Executable file
109
tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh
Executable file
@ -0,0 +1,109 @@
|
||||
#!/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
|
@ -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)"
|
||||
|
@ -1,47 +1,26 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
do_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
|
||||
}
|
||||
source mirror_lib.sh
|
||||
|
||||
quick_test_span_gre_dir_ips()
|
||||
{
|
||||
do_test_span_gre_dir_ips 10 "$@"
|
||||
local tundev=$1; shift
|
||||
|
||||
do_test_span_dir_ips 10 h3-$tundev "$@"
|
||||
}
|
||||
|
||||
fail_test_span_gre_dir_ips()
|
||||
{
|
||||
do_test_span_gre_dir_ips 0 "$@"
|
||||
local tundev=$1; shift
|
||||
|
||||
do_test_span_dir_ips 0 h3-$tundev "$@"
|
||||
}
|
||||
|
||||
test_span_gre_dir_ips()
|
||||
{
|
||||
local tundev=$1; shift
|
||||
local direction=$1; shift
|
||||
local forward_type=$1; shift
|
||||
local backward_type=$1; shift
|
||||
local ip1=$1; shift
|
||||
local ip2=$1; shift
|
||||
|
||||
quick_test_span_gre_dir_ips "$tundev" "$direction" "$ip1" "$ip2"
|
||||
|
||||
icmp_capture_install h3-$tundev "type $forward_type"
|
||||
mirror_test v$h1 $ip1 $ip2 h3-$tundev 100 10
|
||||
icmp_capture_uninstall h3-$tundev
|
||||
|
||||
icmp_capture_install h3-$tundev "type $backward_type"
|
||||
mirror_test v$h2 $ip2 $ip1 h3-$tundev 100 10
|
||||
icmp_capture_uninstall h3-$tundev
|
||||
test_span_dir_ips h3-$tundev "$@"
|
||||
}
|
||||
|
||||
full_test_span_gre_dir_ips()
|
||||
@ -57,13 +36,42 @@ 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"
|
||||
mirror_uninstall $swp1 $direction
|
||||
|
||||
log_test "$direction $what ($tcflags)"
|
||||
}
|
||||
|
||||
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
|
||||
local ip1=$1; shift
|
||||
local ip2=$1; shift
|
||||
|
||||
RET=0
|
||||
|
||||
mirror_install $swp1 $direction $tundev "matchall $tcflags"
|
||||
|
||||
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)"
|
||||
}
|
||||
|
||||
quick_test_span_gre_dir()
|
||||
{
|
||||
quick_test_span_gre_dir_ips "$@" 192.0.2.1 192.0.2.2
|
||||
@ -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
|
||||
}
|
||||
|
@ -33,29 +33,11 @@
|
||||
# | |
|
||||
# +-------------------------------------------------------------------------+
|
||||
|
||||
mirror_gre_topo_h1_create()
|
||||
{
|
||||
simple_if_init $h1 192.0.2.1/28
|
||||
}
|
||||
|
||||
mirror_gre_topo_h1_destroy()
|
||||
{
|
||||
simple_if_fini $h1 192.0.2.1/28
|
||||
}
|
||||
|
||||
mirror_gre_topo_h2_create()
|
||||
{
|
||||
simple_if_init $h2 192.0.2.2/28
|
||||
}
|
||||
|
||||
mirror_gre_topo_h2_destroy()
|
||||
{
|
||||
simple_if_fini $h2 192.0.2.2/28
|
||||
}
|
||||
source mirror_topo_lib.sh
|
||||
|
||||
mirror_gre_topo_h3_create()
|
||||
{
|
||||
simple_if_init $h3
|
||||
mirror_topo_h3_create
|
||||
|
||||
tunnel_create h3-gt4 gretap 192.0.2.130 192.0.2.129
|
||||
ip link set h3-gt4 vrf v$h3
|
||||
@ -71,49 +53,32 @@ mirror_gre_topo_h3_destroy()
|
||||
tunnel_destroy h3-gt6
|
||||
tunnel_destroy h3-gt4
|
||||
|
||||
simple_if_fini $h3
|
||||
mirror_topo_h3_destroy
|
||||
}
|
||||
|
||||
mirror_gre_topo_switch_create()
|
||||
{
|
||||
ip link set dev $swp3 up
|
||||
|
||||
ip link add name br1 type bridge vlan_filtering 1
|
||||
ip link set dev br1 up
|
||||
|
||||
ip link set dev $swp1 master br1
|
||||
ip link set dev $swp1 up
|
||||
|
||||
ip link set dev $swp2 master br1
|
||||
ip link set dev $swp2 up
|
||||
mirror_topo_switch_create
|
||||
|
||||
tunnel_create gt4 gretap 192.0.2.129 192.0.2.130 \
|
||||
ttl 100 tos inherit
|
||||
|
||||
tunnel_create gt6 ip6gretap 2001:db8:2::1 2001:db8:2::2 \
|
||||
ttl 100 tos inherit allow-localremote
|
||||
|
||||
tc qdisc add dev $swp1 clsact
|
||||
}
|
||||
|
||||
mirror_gre_topo_switch_destroy()
|
||||
{
|
||||
tc qdisc del dev $swp1 clsact
|
||||
|
||||
tunnel_destroy gt6
|
||||
tunnel_destroy gt4
|
||||
|
||||
ip link set dev $swp1 down
|
||||
ip link set dev $swp2 down
|
||||
ip link del dev br1
|
||||
|
||||
ip link set dev $swp3 down
|
||||
mirror_topo_switch_destroy
|
||||
}
|
||||
|
||||
mirror_gre_topo_create()
|
||||
{
|
||||
mirror_gre_topo_h1_create
|
||||
mirror_gre_topo_h2_create
|
||||
mirror_topo_h1_create
|
||||
mirror_topo_h2_create
|
||||
mirror_gre_topo_h3_create
|
||||
|
||||
mirror_gre_topo_switch_create
|
||||
@ -124,6 +89,6 @@ mirror_gre_topo_destroy()
|
||||
mirror_gre_topo_switch_destroy
|
||||
|
||||
mirror_gre_topo_h3_destroy
|
||||
mirror_gre_topo_h2_destroy
|
||||
mirror_gre_topo_h1_destroy
|
||||
mirror_topo_h2_destroy
|
||||
mirror_topo_h1_destroy
|
||||
}
|
||||
|
92
tools/testing/selftests/net/forwarding/mirror_gre_vlan.sh
Executable file
92
tools/testing/selftests/net/forwarding/mirror_gre_vlan.sh
Executable file
@ -0,0 +1,92 @@
|
||||
#!/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" that mirrors to a gretap netdevice
|
||||
# whose underlay route points at a vlan device.
|
||||
|
||||
ALL_TESTS="
|
||||
test_gretap
|
||||
"
|
||||
|
||||
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 $swp3.555 link $swp3 type vlan id 555
|
||||
ip address add dev $swp3.555 192.0.2.129/32
|
||||
ip address add dev $swp3.555 2001:db8:2::1/128
|
||||
ip link set dev $swp3.555 up
|
||||
|
||||
ip route add 192.0.2.130/32 dev $swp3.555
|
||||
ip -6 route add 2001:db8:2::2/128 dev $swp3.555
|
||||
|
||||
ip link add name $h3.555 link $h3 type vlan id 555
|
||||
ip link set dev $h3.555 master v$h3
|
||||
ip address add dev $h3.555 192.0.2.130/28
|
||||
ip address add dev $h3.555 2001:db8:2::2/64
|
||||
ip link set dev $h3.555 up
|
||||
}
|
||||
|
||||
cleanup()
|
||||
{
|
||||
pre_cleanup
|
||||
|
||||
ip link del dev $h3.555
|
||||
ip link del dev $swp3.555
|
||||
|
||||
mirror_gre_topo_destroy
|
||||
vrf_cleanup
|
||||
}
|
||||
|
||||
test_gretap()
|
||||
{
|
||||
full_test_span_gre_dir gt4 ingress 8 0 "mirror to gretap"
|
||||
full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap"
|
||||
}
|
||||
|
||||
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
|
140
tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
Executable file
140
tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
Executable file
@ -0,0 +1,140 @@
|
||||
#!/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
|
||||
# vlan device on top of a bridge device with vlan filtering (802.1q).
|
||||
|
||||
ALL_TESTS="
|
||||
test_gretap
|
||||
test_ip6gretap
|
||||
test_gretap_forbidden
|
||||
test_ip6gretap_forbidden
|
||||
"
|
||||
|
||||
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
|
||||
|
||||
vlan_create br1 555 "" 192.0.2.129/32 2001:db8:2::1/128
|
||||
bridge vlan add dev br1 vid 555 self
|
||||
ip route rep 192.0.2.130/32 dev br1.555
|
||||
ip -6 route rep 2001:db8:2::2/128 dev br1.555
|
||||
|
||||
vlan_create $h3 555 v$h3 192.0.2.130/28 2001:db8:2::2/64
|
||||
|
||||
ip link set dev $swp3 master br1
|
||||
bridge vlan add dev $swp3 vid 555
|
||||
}
|
||||
|
||||
cleanup()
|
||||
{
|
||||
pre_cleanup
|
||||
|
||||
ip link set dev $swp3 nomaster
|
||||
vlan_destroy $h3 555
|
||||
vlan_destroy br1 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_span_gre_forbidden()
|
||||
{
|
||||
local tundev=$1; shift
|
||||
local what=$1; shift
|
||||
|
||||
RET=0
|
||||
|
||||
# Run the pass-test first, to prime neighbor table.
|
||||
mirror_install $swp1 ingress $tundev "matchall $tcflags"
|
||||
quick_test_span_gre_dir $tundev ingress
|
||||
|
||||
# Now forbid the VLAN at the bridge and see it fail.
|
||||
bridge vlan del dev br1 vid 555 self
|
||||
sleep 1
|
||||
|
||||
fail_test_span_gre_dir $tundev ingress
|
||||
mirror_uninstall $swp1 ingress
|
||||
|
||||
bridge vlan add dev br1 vid 555 self
|
||||
sleep 1
|
||||
|
||||
log_test "$what: vlan forbidden at a bridge ($tcflags)"
|
||||
}
|
||||
|
||||
test_gretap_forbidden()
|
||||
{
|
||||
test_span_gre_forbidden gt4 "mirror to gretap"
|
||||
}
|
||||
|
||||
test_ip6gretap_forbidden()
|
||||
{
|
||||
test_span_gre_forbidden gt4 "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
|
@ -38,3 +38,57 @@ mirror_test()
|
||||
((expect <= delta && delta <= expect + 2))
|
||||
check_err $? "Expected to capture $expect packets, got $delta."
|
||||
}
|
||||
|
||||
do_test_span_dir_ips()
|
||||
{
|
||||
local expect=$1; shift
|
||||
local dev=$1; shift
|
||||
local direction=$1; shift
|
||||
local ip1=$1; shift
|
||||
local ip2=$1; shift
|
||||
|
||||
icmp_capture_install $dev
|
||||
mirror_test v$h1 $ip1 $ip2 $dev 100 $expect
|
||||
mirror_test v$h2 $ip2 $ip1 $dev 100 $expect
|
||||
icmp_capture_uninstall $dev
|
||||
}
|
||||
|
||||
quick_test_span_dir_ips()
|
||||
{
|
||||
do_test_span_dir_ips 10 "$@"
|
||||
}
|
||||
|
||||
fail_test_span_dir_ips()
|
||||
{
|
||||
do_test_span_dir_ips 0 "$@"
|
||||
}
|
||||
|
||||
test_span_dir_ips()
|
||||
{
|
||||
local dev=$1; shift
|
||||
local direction=$1; shift
|
||||
local forward_type=$1; shift
|
||||
local backward_type=$1; shift
|
||||
local ip1=$1; shift
|
||||
local ip2=$1; shift
|
||||
|
||||
quick_test_span_dir_ips "$dev" "$direction" "$ip1" "$ip2"
|
||||
|
||||
icmp_capture_install $dev "type $forward_type"
|
||||
mirror_test v$h1 $ip1 $ip2 $dev 100 10
|
||||
icmp_capture_uninstall $dev
|
||||
|
||||
icmp_capture_install $dev "type $backward_type"
|
||||
mirror_test v$h2 $ip2 $ip1 $dev 100 10
|
||||
icmp_capture_uninstall $dev
|
||||
}
|
||||
|
||||
fail_test_span_dir()
|
||||
{
|
||||
fail_test_span_dir_ips "$@" 192.0.2.1 192.0.2.2
|
||||
}
|
||||
|
||||
test_span_dir()
|
||||
{
|
||||
test_span_dir_ips "$@" 192.0.2.1 192.0.2.2
|
||||
}
|
||||
|
101
tools/testing/selftests/net/forwarding/mirror_topo_lib.sh
Normal file
101
tools/testing/selftests/net/forwarding/mirror_topo_lib.sh
Normal file
@ -0,0 +1,101 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
# This is the standard topology for testing mirroring. The tests that use it
|
||||
# tweak it in one way or another--typically add more devices to the topology.
|
||||
#
|
||||
# +---------------------+ +---------------------+
|
||||
# | H1 | | H2 |
|
||||
# | + $h1 | | $h2 + |
|
||||
# | | 192.0.2.1/28 | | 192.0.2.2/28 | |
|
||||
# +-----|---------------+ +---------------|-----+
|
||||
# | |
|
||||
# +-----|-------------------------------------------------------------|-----+
|
||||
# | SW o--> mirror | |
|
||||
# | +---|-------------------------------------------------------------|---+ |
|
||||
# | | + $swp1 BR $swp2 + | |
|
||||
# | +---------------------------------------------------------------------+ |
|
||||
# | |
|
||||
# | + $swp3 |
|
||||
# +-----|-------------------------------------------------------------------+
|
||||
# |
|
||||
# +-----|-------------------------------------------------------------------+
|
||||
# | H3 + $h3 |
|
||||
# | |
|
||||
# +-------------------------------------------------------------------------+
|
||||
|
||||
mirror_topo_h1_create()
|
||||
{
|
||||
simple_if_init $h1 192.0.2.1/28
|
||||
}
|
||||
|
||||
mirror_topo_h1_destroy()
|
||||
{
|
||||
simple_if_fini $h1 192.0.2.1/28
|
||||
}
|
||||
|
||||
mirror_topo_h2_create()
|
||||
{
|
||||
simple_if_init $h2 192.0.2.2/28
|
||||
}
|
||||
|
||||
mirror_topo_h2_destroy()
|
||||
{
|
||||
simple_if_fini $h2 192.0.2.2/28
|
||||
}
|
||||
|
||||
mirror_topo_h3_create()
|
||||
{
|
||||
simple_if_init $h3
|
||||
tc qdisc add dev $h3 clsact
|
||||
}
|
||||
|
||||
mirror_topo_h3_destroy()
|
||||
{
|
||||
tc qdisc del dev $h3 clsact
|
||||
simple_if_fini $h3
|
||||
}
|
||||
|
||||
mirror_topo_switch_create()
|
||||
{
|
||||
ip link set dev $swp3 up
|
||||
|
||||
ip link add name br1 type bridge vlan_filtering 1
|
||||
ip link set dev br1 up
|
||||
|
||||
ip link set dev $swp1 master br1
|
||||
ip link set dev $swp1 up
|
||||
|
||||
ip link set dev $swp2 master br1
|
||||
ip link set dev $swp2 up
|
||||
|
||||
tc qdisc add dev $swp1 clsact
|
||||
}
|
||||
|
||||
mirror_topo_switch_destroy()
|
||||
{
|
||||
tc qdisc del dev $swp1 clsact
|
||||
|
||||
ip link set dev $swp1 down
|
||||
ip link set dev $swp2 down
|
||||
ip link del dev br1
|
||||
|
||||
ip link set dev $swp3 down
|
||||
}
|
||||
|
||||
mirror_topo_create()
|
||||
{
|
||||
mirror_topo_h1_create
|
||||
mirror_topo_h2_create
|
||||
mirror_topo_h3_create
|
||||
|
||||
mirror_topo_switch_create
|
||||
}
|
||||
|
||||
mirror_topo_destroy()
|
||||
{
|
||||
mirror_topo_switch_destroy
|
||||
|
||||
mirror_topo_h3_destroy
|
||||
mirror_topo_h2_destroy
|
||||
mirror_topo_h1_destroy
|
||||
}
|
169
tools/testing/selftests/net/forwarding/mirror_vlan.sh
Executable file
169
tools/testing/selftests/net/forwarding/mirror_vlan.sh
Executable file
@ -0,0 +1,169 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
# This test uses standard topology for testing mirroring. See mirror_topo_lib.sh
|
||||
# for more details.
|
||||
#
|
||||
# Test for "tc action mirred egress mirror" that mirrors to a vlan device.
|
||||
|
||||
ALL_TESTS="
|
||||
test_vlan
|
||||
test_tagged_vlan
|
||||
"
|
||||
|
||||
NUM_NETIFS=6
|
||||
source lib.sh
|
||||
source mirror_lib.sh
|
||||
source mirror_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_topo_create
|
||||
|
||||
vlan_create $swp3 555
|
||||
|
||||
vlan_create $h3 555 v$h3
|
||||
matchall_sink_create $h3.555
|
||||
|
||||
vlan_create $h1 111 v$h1 192.0.2.17/28
|
||||
bridge vlan add dev $swp1 vid 111
|
||||
|
||||
vlan_create $h2 111 v$h2 192.0.2.18/28
|
||||
bridge vlan add dev $swp2 vid 111
|
||||
}
|
||||
|
||||
cleanup()
|
||||
{
|
||||
pre_cleanup
|
||||
|
||||
vlan_destroy $h2 111
|
||||
vlan_destroy $h1 111
|
||||
vlan_destroy $h3 555
|
||||
vlan_destroy $swp3 555
|
||||
|
||||
mirror_topo_destroy
|
||||
vrf_cleanup
|
||||
}
|
||||
|
||||
test_vlan_dir()
|
||||
{
|
||||
local direction=$1; shift
|
||||
local forward_type=$1; shift
|
||||
local backward_type=$1; shift
|
||||
|
||||
RET=0
|
||||
|
||||
mirror_install $swp1 $direction $swp3.555 "matchall $tcflags"
|
||||
test_span_dir "$h3.555" "$direction" "$forward_type" "$backward_type"
|
||||
mirror_uninstall $swp1 $direction
|
||||
|
||||
log_test "$direction mirror to vlan ($tcflags)"
|
||||
}
|
||||
|
||||
test_vlan()
|
||||
{
|
||||
test_vlan_dir ingress 8 0
|
||||
test_vlan_dir egress 0 8
|
||||
}
|
||||
|
||||
vlan_capture_add_del()
|
||||
{
|
||||
local add_del=$1; shift
|
||||
local pref=$1; shift
|
||||
local dev=$1; shift
|
||||
local filter=$1; shift
|
||||
|
||||
tc filter $add_del dev "$dev" ingress \
|
||||
proto 802.1q pref $pref \
|
||||
flower $filter \
|
||||
action pass
|
||||
}
|
||||
|
||||
vlan_capture_install()
|
||||
{
|
||||
vlan_capture_add_del add 100 "$@"
|
||||
}
|
||||
|
||||
vlan_capture_uninstall()
|
||||
{
|
||||
vlan_capture_add_del del 100 "$@"
|
||||
}
|
||||
|
||||
do_test_span_vlan_dir_ips()
|
||||
{
|
||||
local expect=$1; shift
|
||||
local dev=$1; shift
|
||||
local vid=$1; shift
|
||||
local direction=$1; shift
|
||||
local ip1=$1; shift
|
||||
local ip2=$1; shift
|
||||
|
||||
vlan_capture_install $dev "vlan_id $vid"
|
||||
mirror_test v$h1 $ip1 $ip2 $dev 100 $expect
|
||||
mirror_test v$h2 $ip2 $ip1 $dev 100 $expect
|
||||
vlan_capture_uninstall $dev
|
||||
}
|
||||
|
||||
test_tagged_vlan_dir()
|
||||
{
|
||||
local direction=$1; shift
|
||||
local forward_type=$1; shift
|
||||
local backward_type=$1; shift
|
||||
|
||||
RET=0
|
||||
|
||||
mirror_install $swp1 $direction $swp3.555 "matchall $tcflags"
|
||||
do_test_span_vlan_dir_ips 10 "$h3.555" 111 "$direction" \
|
||||
192.0.2.17 192.0.2.18
|
||||
do_test_span_vlan_dir_ips 0 "$h3.555" 555 "$direction" \
|
||||
192.0.2.17 192.0.2.18
|
||||
mirror_uninstall $swp1 $direction
|
||||
|
||||
log_test "$direction mirror to vlan ($tcflags)"
|
||||
}
|
||||
|
||||
test_tagged_vlan()
|
||||
{
|
||||
test_tagged_vlan_dir ingress 8 0
|
||||
test_tagged_vlan_dir egress 0 8
|
||||
}
|
||||
|
||||
test_all()
|
||||
{
|
||||
slow_path_trap_install $swp1 ingress
|
||||
slow_path_trap_install $swp1 egress
|
||||
trap_install $h3 ingress
|
||||
|
||||
tests_run
|
||||
|
||||
trap_install $h3 ingress
|
||||
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
|
Loading…
Reference in New Issue
Block a user