blob: fe4d7c906a708c600bac13d2efd676cdac67e353 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Test for "tc action mirred egress mirror" when the underlay route points at a
# bridge device with vlan filtering (802.1q), and the egress device is a team
# device.
#
# +----------------------+ +----------------------+
# | H1 | | H2 |
# | + $h1.333 | | $h1.555 + |
# | | 192.0.2.1/28 | | 192.0.2.18/28 | |
# +-----|----------------+ +----------------|-----+
# | $h1 |
# +--------------------------------+------------------------------+
# |
# +--------------------------------------|------------------------------------+
# | SW o---> mirror |
# | | |
# | +--------------------------------+------------------------------+ |
# | | $swp1 | |
# | + $swp1.333 $swp1.555 + |
# | 192.0.2.2/28 192.0.2.17/28 |
# | |
# | +-----------------------------------------------------------------------+ |
# | | BR1 (802.1q) | |
# | | + lag (team) 192.0.2.129/28 | |
# | | / \ 2001:db8:2::1/64 | |
# | +---/---\---------------------------------------------------------------+ |
# | / \ ^ |
# | | \ + gt4 (gretap) | |
# | | \ loc=192.0.2.129 | |
# | | \ rem=192.0.2.130 -+ |
# | | \ ttl=100 |
# | | \ tos=inherit |
# | | \ |
# | | \_________________________________ |
# | | \ |
# | + $swp3 + $swp4 |
# +---|------------------------------------------------|----------------------+
# | |
# +---|----------------------+ +---|----------------------+
# | + $h3 H3 | | + $h4 H4 |
# | 192.0.2.130/28 | | 192.0.2.130/28 |
# | 2001:db8:2::2/64 | | 2001:db8:2::2/64 |
# +--------------------------+ +--------------------------+
ALL_TESTS="
test_mirror_gretap_first
test_mirror_gretap_second
"
NUM_NETIFS=6
source lib.sh
source mirror_lib.sh
source mirror_gre_lib.sh
require_command $ARPING
vlan_host_create()
{
local if_name=$1; shift
local vid=$1; shift
local vrf_name=$1; shift
local ips=("${@}")
vrf_create $vrf_name
ip link set dev $vrf_name up
vlan_create $if_name $vid $vrf_name "${ips[@]}"
}
vlan_host_destroy()
{
local if_name=$1; shift
local vid=$1; shift
local vrf_name=$1; shift
vlan_destroy $if_name $vid
ip link set dev $vrf_name down
vrf_destroy $vrf_name
}
h1_create()
{
vlan_host_create $h1 333 vrf-h1 192.0.2.1/28
ip -4 route add 192.0.2.16/28 vrf vrf-h1 nexthop via 192.0.2.2
}
h1_destroy()
{
ip -4 route del 192.0.2.16/28 vrf vrf-h1
vlan_host_destroy $h1 333 vrf-h1
}
h2_create()
{
vlan_host_create $h1 555 vrf-h2 192.0.2.18/28
ip -4 route add 192.0.2.0/28 vrf vrf-h2 nexthop via 192.0.2.17
}
h2_destroy()
{
ip -4 route del 192.0.2.0/28 vrf vrf-h2
vlan_host_destroy $h1 555 vrf-h2
}
h3_create()
{
simple_if_init $h3 192.0.2.130/28
tc qdisc add dev $h3 clsact
}
h3_destroy()
{
tc qdisc del dev $h3 clsact
simple_if_fini $h3 192.0.2.130/28
}
h4_create()
{
simple_if_init $h4 192.0.2.130/28
tc qdisc add dev $h4 clsact
}
h4_destroy()
{
tc qdisc del dev $h4 clsact
simple_if_fini $h4 192.0.2.130/28
}
switch_create()
{
ip link set dev $swp1 up
tc qdisc add dev $swp1 clsact
vlan_create $swp1 333 "" 192.0.2.2/28
vlan_create $swp1 555 "" 192.0.2.17/28
tunnel_create gt4 gretap 192.0.2.129 192.0.2.130 \
ttl 100 tos inherit
ip link set dev $swp3 up
ip link set dev $swp4 up
ip link add name br1 address $(mac_get $swp3) \
type bridge vlan_filtering 1
team_create lag loadbalance $swp3 $swp4
ip link set dev lag master br1
ip link set dev br1 up
__addr_add_del br1 add 192.0.2.129/32
ip -4 route add 192.0.2.130/32 dev br1
}
switch_destroy()
{
ip link set dev lag nomaster
team_destroy lag
ip -4 route del 192.0.2.130/32 dev br1
__addr_add_del br1 del 192.0.2.129/32
ip link set dev br1 down
ip link del dev br1
ip link set dev $swp4 down
ip link set dev $swp3 down
tunnel_destroy gt4
vlan_destroy $swp1 555
vlan_destroy $swp1 333
tc qdisc del dev $swp1 clsact
ip link set dev $swp1 down
}
setup_prepare()
{
h1=${NETIFS[p1]}
swp1=${NETIFS[p2]}
swp3=${NETIFS[p3]}
h3=${NETIFS[p4]}
swp4=${NETIFS[p5]}
h4=${NETIFS[p6]}
vrf_prepare
ip link set dev $h1 up
h1_create
h2_create
h3_create
h4_create
switch_create
forwarding_enable
trap_install $h3 ingress
trap_install $h4 ingress
}
cleanup()
{
pre_cleanup
trap_uninstall $h4 ingress
trap_uninstall $h3 ingress
forwarding_restore
switch_destroy
h4_destroy
h3_destroy
h2_destroy
h1_destroy
ip link set dev $h1 down
vrf_cleanup
}
test_lag_slave()
{
local host_dev=$1; shift
local up_dev=$1; shift
local down_dev=$1; shift
local what=$1; shift
RET=0
tc filter add dev $swp1 ingress pref 999 \
proto 802.1q flower vlan_ethtype arp \
action pass
mirror_install $swp1 ingress gt4 \
"proto 802.1q flower vlan_id 333"
# Test connectivity through $up_dev when $down_dev is set down.
ip link set dev $down_dev down
ip neigh flush dev br1
setup_wait_dev $up_dev
setup_wait_dev $host_dev
$ARPING -I br1 192.0.2.130 -qfc 1
sleep 2
mirror_test vrf-h1 192.0.2.1 192.0.2.18 $host_dev 1 ">= 10"
# Test lack of connectivity when both slaves are down.
ip link set dev $up_dev down
sleep 2
mirror_test vrf-h1 192.0.2.1 192.0.2.18 $h3 1 0
mirror_test vrf-h1 192.0.2.1 192.0.2.18 $h4 1 0
ip link set dev $up_dev up
ip link set dev $down_dev up
mirror_uninstall $swp1 ingress
tc filter del dev $swp1 ingress pref 999
log_test "$what"
}
test_mirror_gretap_first()
{
test_lag_slave $h3 $swp3 $swp4 "mirror to gretap: LAG first slave"
}
test_mirror_gretap_second()
{
test_lag_slave $h4 $swp4 $swp3 "mirror to gretap: LAG second slave"
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
|