Skip to content

Commit 1bb58d2

Browse files
committed
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 <[email protected]>
2 parents 90fed9c + 181d95f commit 1bb58d2

11 files changed

+754
-81
lines changed

tools/testing/selftests/net/forwarding/lib.sh

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,31 @@ tunnel_destroy()
340340
ip link del dev $name
341341
}
342342

343+
vlan_create()
344+
{
345+
local if_name=$1; shift
346+
local vid=$1; shift
347+
local vrf=$1; shift
348+
local ips=("${@}")
349+
local name=$if_name.$vid
350+
351+
ip link add name $name link $if_name type vlan id $vid
352+
if [ "$vrf" != "" ]; then
353+
ip link set dev $name master $vrf
354+
fi
355+
ip link set dev $name up
356+
__addr_add_del $name add "${ips[@]}"
357+
}
358+
359+
vlan_destroy()
360+
{
361+
local if_name=$1; shift
362+
local vid=$1; shift
363+
local name=$if_name.$vid
364+
365+
ip link del dev $name
366+
}
367+
343368
master_name_get()
344369
{
345370
local if_name=$1
@@ -423,26 +448,35 @@ tc_offload_check()
423448
return 0
424449
}
425450

426-
slow_path_trap_install()
451+
trap_install()
427452
{
428453
local dev=$1; shift
429454
local direction=$1; shift
430455

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

439-
slow_path_trap_uninstall()
461+
trap_uninstall()
440462
{
441463
local dev=$1; shift
442464
local direction=$1; shift
443465

466+
tc filter del dev $dev $direction pref 1 flower skip_sw
467+
}
468+
469+
slow_path_trap_install()
470+
{
471+
if [ "${tcflags/skip_hw}" != "$tcflags" ]; then
472+
trap_install "$@"
473+
fi
474+
}
475+
476+
slow_path_trap_uninstall()
477+
{
444478
if [ "${tcflags/skip_hw}" != "$tcflags" ]; then
445-
tc filter del dev $dev $direction pref 1 flower skip_sw
479+
trap_uninstall "$@"
446480
fi
447481
}
448482

tools/testing/selftests/net/forwarding/mirror_gre.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,13 @@ test_span_gre_mac()
7272
RET=0
7373

7474
mirror_install $swp1 $direction $tundev "matchall $tcflags"
75-
tc qdisc add dev $h3 clsact
7675
tc filter add dev $h3 ingress pref 77 prot $prot \
7776
flower ip_proto 0x2f src_mac $swp3mac dst_mac $h3mac \
7877
action pass
7978

8079
mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 10
8180

8281
tc filter del dev $h3 ingress pref 77
83-
tc qdisc del dev $h3 clsact
8482
mirror_uninstall $swp1 $direction
8583

8684
log_test "$direction $what: envelope MAC ($tcflags)"
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
# This test uses standard topology for testing gretap. See
5+
# mirror_gre_topo_lib.sh for more details.
6+
#
7+
# Test for "tc action mirred egress mirror" when the underlay route points at a
8+
# bridge device without vlan filtering (802.1d). The device attached to that
9+
# bridge is a VLAN.
10+
11+
ALL_TESTS="
12+
test_gretap
13+
test_ip6gretap
14+
"
15+
16+
NUM_NETIFS=6
17+
source lib.sh
18+
source mirror_lib.sh
19+
source mirror_gre_lib.sh
20+
source mirror_gre_topo_lib.sh
21+
22+
setup_prepare()
23+
{
24+
h1=${NETIFS[p1]}
25+
swp1=${NETIFS[p2]}
26+
27+
swp2=${NETIFS[p3]}
28+
h2=${NETIFS[p4]}
29+
30+
swp3=${NETIFS[p5]}
31+
h3=${NETIFS[p6]}
32+
33+
vrf_prepare
34+
mirror_gre_topo_create
35+
36+
ip link add name br2 type bridge vlan_filtering 0
37+
ip link set dev br2 up
38+
39+
vlan_create $swp3 555
40+
41+
ip link set dev $swp3.555 master br2
42+
ip route add 192.0.2.130/32 dev br2
43+
ip -6 route add 2001:db8:2::2/128 dev br2
44+
45+
ip address add dev br2 192.0.2.129/32
46+
ip address add dev br2 2001:db8:2::1/128
47+
48+
vlan_create $h3 555 v$h3 192.0.2.130/28 2001:db8:2::2/64
49+
}
50+
51+
cleanup()
52+
{
53+
pre_cleanup
54+
55+
vlan_destroy $h3 555
56+
ip link del dev br2
57+
vlan_destroy $swp3 555
58+
59+
mirror_gre_topo_destroy
60+
vrf_cleanup
61+
}
62+
63+
test_vlan_match()
64+
{
65+
local tundev=$1; shift
66+
local vlan_match=$1; shift
67+
local what=$1; shift
68+
69+
full_test_span_gre_dir_vlan $tundev ingress "$vlan_match" 8 0 "$what"
70+
full_test_span_gre_dir_vlan $tundev egress "$vlan_match" 0 8 "$what"
71+
}
72+
73+
test_gretap()
74+
{
75+
test_vlan_match gt4 'vlan_id 555 vlan_ethtype ip' "mirror to gretap"
76+
}
77+
78+
test_ip6gretap()
79+
{
80+
test_vlan_match gt6 'vlan_id 555 vlan_ethtype ipv6' "mirror to ip6gretap"
81+
}
82+
83+
test_all()
84+
{
85+
slow_path_trap_install $swp1 ingress
86+
slow_path_trap_install $swp1 egress
87+
88+
tests_run
89+
90+
slow_path_trap_uninstall $swp1 egress
91+
slow_path_trap_uninstall $swp1 ingress
92+
}
93+
94+
trap cleanup EXIT
95+
96+
setup_prepare
97+
setup_wait
98+
99+
tcflags="skip_hw"
100+
test_all
101+
102+
if ! tc_offload_check; then
103+
echo "WARN: Could not test offloaded functionality"
104+
else
105+
tcflags="skip_sw"
106+
test_all
107+
fi
108+
109+
exit $EXIT_STATUS

tools/testing/selftests/net/forwarding/mirror_gre_changes.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ test_span_gre_ttl()
7373
RET=0
7474

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

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

8584
ip link set dev $tundev type $type ttl 100
8685
tc filter del dev $h3 ingress pref 77
87-
tc qdisc del dev $h3 clsact
8886
mirror_uninstall $swp1 ingress
8987

9088
log_test "$what: TTL change ($tcflags)"
Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
# SPDX-License-Identifier: GPL-2.0
22

3-
do_test_span_gre_dir_ips()
3+
source mirror_lib.sh
4+
5+
quick_test_span_gre_dir_ips()
46
{
5-
local expect=$1; shift
67
local tundev=$1; shift
7-
local direction=$1; shift
8-
local ip1=$1; shift
9-
local ip2=$1; shift
108

11-
icmp_capture_install h3-$tundev
12-
mirror_test v$h1 $ip1 $ip2 h3-$tundev 100 $expect
13-
mirror_test v$h2 $ip2 $ip1 h3-$tundev 100 $expect
14-
icmp_capture_uninstall h3-$tundev
9+
do_test_span_dir_ips 10 h3-$tundev "$@"
1510
}
1611

17-
quick_test_span_gre_dir_ips()
12+
fail_test_span_gre_dir_ips()
1813
{
19-
do_test_span_gre_dir_ips 10 "$@"
14+
local tundev=$1; shift
15+
16+
do_test_span_dir_ips 0 h3-$tundev "$@"
2017
}
2118

22-
fail_test_span_gre_dir_ips()
19+
test_span_gre_dir_ips()
2320
{
24-
do_test_span_gre_dir_ips 0 "$@"
21+
local tundev=$1; shift
22+
23+
test_span_dir_ips h3-$tundev "$@"
2524
}
2625

27-
test_span_gre_dir_ips()
26+
full_test_span_gre_dir_ips()
2827
{
2928
local tundev=$1; shift
3029
local direction=$1; shift
3130
local forward_type=$1; shift
3231
local backward_type=$1; shift
32+
local what=$1; shift
3333
local ip1=$1; shift
3434
local ip2=$1; shift
3535

36-
quick_test_span_gre_dir_ips "$tundev" "$direction" "$ip1" "$ip2"
36+
RET=0
3737

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

42-
icmp_capture_install h3-$tundev "type $backward_type"
43-
mirror_test v$h2 $ip2 $ip1 h3-$tundev 100 10
44-
icmp_capture_uninstall h3-$tundev
43+
log_test "$direction $what ($tcflags)"
4544
}
4645

47-
full_test_span_gre_dir_ips()
46+
full_test_span_gre_dir_vlan_ips()
4847
{
4948
local tundev=$1; shift
5049
local direction=$1; shift
50+
local vlan_match=$1; shift
5151
local forward_type=$1; shift
5252
local backward_type=$1; shift
5353
local what=$1; shift
@@ -57,8 +57,16 @@ full_test_span_gre_dir_ips()
5757
RET=0
5858

5959
mirror_install $swp1 $direction $tundev "matchall $tcflags"
60-
test_span_gre_dir_ips "$tundev" "$direction" "$forward_type" \
61-
"$backward_type" "$ip1" "$ip2"
60+
61+
test_span_dir_ips "h3-$tundev" "$direction" "$forward_type" \
62+
"$backward_type" "$ip1" "$ip2"
63+
64+
tc filter add dev $h3 ingress pref 77 prot 802.1q \
65+
flower $vlan_match ip_proto 0x2f \
66+
action pass
67+
mirror_test v$h1 $ip1 $ip2 $h3 77 10
68+
tc filter del dev $h3 ingress pref 77
69+
6270
mirror_uninstall $swp1 $direction
6371

6472
log_test "$direction $what ($tcflags)"
@@ -83,3 +91,8 @@ full_test_span_gre_dir()
8391
{
8492
full_test_span_gre_dir_ips "$@" 192.0.2.1 192.0.2.2
8593
}
94+
95+
full_test_span_gre_dir_vlan()
96+
{
97+
full_test_span_gre_dir_vlan_ips "$@" 192.0.2.1 192.0.2.2
98+
}

0 commit comments

Comments
 (0)