Skip to content

Commit 0056042

Browse files
pmachatadavem330
authored andcommitted
selftests: forwarding: Test mirror-to-gre w/ UL VLAN+802.1q
Test for "tc action mirred egress mirror" that mirrors to GRE when the underlay route points at a vlan device on top of a bridge device with vlan filtering (802.1q). Signed-off-by: Petr Machata <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 35388a6 commit 0056042

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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+
# vlan device on top of a bridge device with vlan filtering (802.1q).
9+
10+
ALL_TESTS="
11+
test_gretap
12+
test_ip6gretap
13+
test_gretap_forbidden
14+
test_ip6gretap_forbidden
15+
"
16+
17+
NUM_NETIFS=6
18+
source lib.sh
19+
source mirror_lib.sh
20+
source mirror_gre_lib.sh
21+
source mirror_gre_topo_lib.sh
22+
23+
setup_prepare()
24+
{
25+
h1=${NETIFS[p1]}
26+
swp1=${NETIFS[p2]}
27+
28+
swp2=${NETIFS[p3]}
29+
h2=${NETIFS[p4]}
30+
31+
swp3=${NETIFS[p5]}
32+
h3=${NETIFS[p6]}
33+
34+
vrf_prepare
35+
mirror_gre_topo_create
36+
37+
vlan_create br1 555 "" 192.0.2.129/32 2001:db8:2::1/128
38+
bridge vlan add dev br1 vid 555 self
39+
ip route rep 192.0.2.130/32 dev br1.555
40+
ip -6 route rep 2001:db8:2::2/128 dev br1.555
41+
42+
vlan_create $h3 555 v$h3 192.0.2.130/28 2001:db8:2::2/64
43+
44+
ip link set dev $swp3 master br1
45+
bridge vlan add dev $swp3 vid 555
46+
}
47+
48+
cleanup()
49+
{
50+
pre_cleanup
51+
52+
ip link set dev $swp3 nomaster
53+
vlan_destroy $h3 555
54+
vlan_destroy br1 555
55+
56+
mirror_gre_topo_destroy
57+
vrf_cleanup
58+
}
59+
60+
test_vlan_match()
61+
{
62+
local tundev=$1; shift
63+
local vlan_match=$1; shift
64+
local what=$1; shift
65+
66+
full_test_span_gre_dir_vlan $tundev ingress "$vlan_match" 8 0 "$what"
67+
full_test_span_gre_dir_vlan $tundev egress "$vlan_match" 0 8 "$what"
68+
}
69+
70+
test_gretap()
71+
{
72+
test_vlan_match gt4 'vlan_id 555 vlan_ethtype ip' "mirror to gretap"
73+
}
74+
75+
test_ip6gretap()
76+
{
77+
test_vlan_match gt6 'vlan_id 555 vlan_ethtype ipv6' "mirror to ip6gretap"
78+
}
79+
80+
test_span_gre_forbidden()
81+
{
82+
local tundev=$1; shift
83+
local what=$1; shift
84+
85+
RET=0
86+
87+
# Run the pass-test first, to prime neighbor table.
88+
mirror_install $swp1 ingress $tundev "matchall $tcflags"
89+
quick_test_span_gre_dir $tundev ingress
90+
91+
# Now forbid the VLAN at the bridge and see it fail.
92+
bridge vlan del dev br1 vid 555 self
93+
sleep 1
94+
95+
fail_test_span_gre_dir $tundev ingress
96+
mirror_uninstall $swp1 ingress
97+
98+
bridge vlan add dev br1 vid 555 self
99+
sleep 1
100+
101+
log_test "$what: vlan forbidden at a bridge ($tcflags)"
102+
}
103+
104+
test_gretap_forbidden()
105+
{
106+
test_span_gre_forbidden gt4 "mirror to gretap"
107+
}
108+
109+
test_ip6gretap_forbidden()
110+
{
111+
test_span_gre_forbidden gt4 "mirror to ip6gretap"
112+
}
113+
114+
test_all()
115+
{
116+
slow_path_trap_install $swp1 ingress
117+
slow_path_trap_install $swp1 egress
118+
119+
tests_run
120+
121+
slow_path_trap_uninstall $swp1 egress
122+
slow_path_trap_uninstall $swp1 ingress
123+
}
124+
125+
trap cleanup EXIT
126+
127+
setup_prepare
128+
setup_wait
129+
130+
tcflags="skip_hw"
131+
test_all
132+
133+
if ! tc_offload_check; then
134+
echo "WARN: Could not test offloaded functionality"
135+
else
136+
tcflags="skip_sw"
137+
test_all
138+
fi
139+
140+
exit $EXIT_STATUS

0 commit comments

Comments
 (0)