-
Notifications
You must be signed in to change notification settings - Fork 13
/
common-br-helpers.sh
276 lines (215 loc) · 8.16 KB
/
common-br-helpers.sh
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
276
#!/bin/bash
function cleanup_br() {
ip link del name $br type bridge
ip -netns $namespace1 link set dev $VF netns 1
ip -netns $namespace2 link set dev $VF2 netns 1
ip netns del $namespace1
ip netns del $namespace2
}
function test_no_vlan() {
create_bridge_with_interfaces $br $REP $REP2
config_vf $namespace1 $VF $REP $VF1_IP $VF1_MAC
config_vf $namespace2 $VF2 $REP2 $VF2_IP $VF2_MAC
${1:+ip link set $br type bridge vlan_filtering 1}
sleep 1
flush_bridge $br
verify_ping_ns $namespace1 $VF $br $VF2_IP $time $npackets
cleanup_br
}
function test_trunk_to_trunk_vlan() {
create_bridge_with_interfaces $br $REP $REP2
config_vf $namespace1 $VF $REP
add_vf_vlan $namespace1 $VF $REP $VF1_IP_VLAN2 2 $VF1_MAC_VLAN2
config_vf $namespace2 $VF2 $REP2
add_vf_vlan $namespace2 $VF2 $REP2 $VF2_IP_VLAN2 2 $VF2_MAC_VLAN2
bridge vlan add dev $REP vid 2
bridge vlan add dev $REP2 vid 2
ip link set $br type bridge vlan_filtering 1
sleep 1
flush_bridge $br
verify_ping_ns $namespace1 $VF.2 $br $VF2_IP_VLAN2 $time $npackets
cleanup_br
}
function test_trunk_to_access_vlan() {
create_bridge_with_interfaces $br $REP $REP2
config_vf $namespace1 $VF $REP
add_vf_vlan $namespace1 $VF $REP $VF1_IP_VLAN3 3 $VF1_MAC_VLAN3
config_vf $namespace2 $VF2 $REP2 $VF2_IP_UNTAGGED $VF2_MAC
bridge vlan add dev $REP vid 3
bridge vlan add dev $REP2 vid 3 pvid untagged
ip link set $br type bridge vlan_filtering 1
sleep 1
flush_bridge $br
verify_ping_ns $namespace1 $VF.3 $br $VF2_IP_UNTAGGED $time $npackets
cleanup_br
}
function test_access_to_trunk_vlan() {
create_bridge_with_interfaces $br $REP $REP2
config_vf $namespace1 $VF $REP $VF1_IP_VLAN2 $VF1_MAC_VLAN2
config_vf $namespace2 $VF2 $REP2
add_vf_vlan $namespace2 $VF2 $REP2 $VF2_IP_VLAN2 2 $VF2_MAC_VLAN2
bridge vlan add dev $REP vid 2 pvid untagged
bridge vlan add dev $REP2 vid 2
ip link set $br type bridge vlan_filtering 1
sleep 1
flush_bridge $br
verify_ping_ns $namespace1 $VF $br $VF2_IP_VLAN2 $time $npackets
cleanup_br
}
function test_trunk_to_trunk_qinq() {
create_bridge_with_interfaces $br $REP $REP2
config_vf $namespace1 $VF $REP
add_vf_qinq $namespace1 $VF $REP $VF1_IP_VLAN2 3 2 $VF1_MAC_VLAN2
config_vf $namespace2 $VF2 $REP2
add_vf_qinq $namespace2 $VF2 $REP2 $VF2_IP_VLAN2 3 2 $VF2_MAC_VLAN2
bridge vlan add dev $REP vid 3
bridge vlan add dev $REP2 vid 3
ip link set $br type bridge vlan_filtering 1 vlan_protocol 802.1ad
sleep 1
flush_bridge $br
verify_ping_ns $namespace1 $VF.3.2 $br $VF2_IP_VLAN2 $time $npackets 'vlan and vlan and icmp'
cleanup_br
}
function test_trunk_to_access_qinq() {
create_bridge_with_interfaces $br $REP $REP2
config_vf $namespace1 $VF $REP
add_vf_qinq $namespace1 $VF $REP $VF1_IP_VLAN2 3 2 $VF1_MAC_VLAN2
config_vf $namespace2 $VF2 $REP2
add_vf_vlan $namespace2 $VF2 $REP2 $VF2_IP_VLAN2 2 $VF2_MAC_VLAN2
bridge vlan add dev $REP vid 3
bridge vlan add dev $REP2 vid 3 pvid untagged
ip link set $br type bridge vlan_filtering 1 vlan_protocol 802.1ad
sleep 1
flush_bridge $br
verify_ping_ns $namespace1 $VF.3.2 $br $VF2_IP_VLAN2 $time $npackets 'vlan and vlan and icmp'
cleanup_br
}
function test_access_to_trunk_qinq() {
create_bridge_with_interfaces $br $REP $REP2
config_vf $namespace1 $VF $REP
add_vf_vlan $namespace1 $VF $REP $VF1_IP_VLAN2 2 $VF1_MAC_VLAN2
config_vf $namespace2 $VF2 $REP2
add_vf_qinq $namespace2 $VF2 $REP2 $VF2_IP_VLAN2 3 2 $VF2_MAC_VLAN2
bridge vlan add dev $REP vid 3 pvid untagged
bridge vlan add dev $REP2 vid 3
ip link set $br type bridge vlan_filtering 1 vlan_protocol 802.1ad
sleep 1
flush_bridge $br
verify_ping_ns $namespace1 $VF.2 $br $VF2_IP_VLAN2 $time $npackets 'vlan and vlan and icmp'
cleanup_br
}
function test_access_to_access_qinq() {
create_bridge_with_interfaces $br $REP $REP2
config_vf $namespace1 $VF $REP
add_vf_vlan $namespace1 $VF $REP $VF1_IP_VLAN2 2 $VF1_MAC_VLAN2
config_vf $namespace2 $VF2 $REP2
add_vf_vlan $namespace2 $VF2 $REP2 $VF2_IP_VLAN2 2 $VF2_MAC_VLAN2
bridge vlan add dev $REP vid 3 pvid untagged
bridge vlan add dev $REP2 vid 3 pvid untagged
ip link set $br type bridge vlan_filtering 1 vlan_protocol 802.1ad
sleep 1
flush_bridge $br
verify_ping_ns $namespace1 $VF.2 $br $VF2_IP_VLAN2 $time $npackets 'vlan and vlan and icmp'
cleanup_br
}
function test_vf_to_vf_vlan() {
title "test ping (no VLAN)"
test_no_vlan
title "test ping (VLAN untagged<->untagged)"
test_no_vlan filtering
title "test ping (VLAN tagged<->tagged)"
test_trunk_to_trunk_vlan
title "test ping (VLAN tagged<->untagged)"
test_trunk_to_access_vlan
title "test ping (VLAN untagged<->tagged)"
test_access_to_trunk_vlan
}
function test_vf_to_vf_qinq() {
title "test ping (QinQ tagged<->tagged)"
test_trunk_to_trunk_qinq
title "test ping (QinQ tagged<->untagged)"
test_trunk_to_access_qinq
title "test ping (QinQ untagged<->tagged)"
test_access_to_trunk_qinq
title "test ping (QinQ untagged<->untagged)"
test_access_to_access_qinq
}
function __test_remote_no_vlan_mcast() {
local remote_dev=$1
config_vf $namespace1 $VF $REP $VF1_IP $VF1_MAC
add_vf_mcast $namespace1 $VF $MCAST_IP
config_vf $namespace2 $VF2 $REP2 $VF2_IP $VF2_MAC
add_vf_mcast $namespace2 $VF2 $MCAST_IP
config_vf $namespace3 $VF3 $REP3 $VF3_IP $VF3_MAC
add_vf_mcast $namespace3 $VF3 $MCAST_IP
flush_bridge $br
sleep 10
bridge mdb show
verify_ping_remote_mcast $remote_dev $br $MCAST_IP $time $ndups $npackets
ip netns del $namespace1
ip netns del $namespace2
ip netns del $namespace3
sleep 1
}
function test_remote_no_vlan_mcast() {
create_bridge_with_mcast $br $NIC $REP $REP2 $REP3
ip addr flush dev $NIC
ip link set dev $NIC up
on_remote "ip a add dev $REMOTE_NIC $REMOTE_IP/24
ip link set $REMOTE_NIC up"
__test_remote_no_vlan_mcast $REMOTE_NIC
on_remote "ip a flush dev $REMOTE_NIC &>/dev/null"
ip link del name $br type bridge
ip addr flush dev $NIC
sleep 1
}
function __test_remote_trunk_to_mixed_vlan_mcast() {
local remote_dev=$1
local nic=$2
local vlan_proto=$3
ip link set $br type bridge vlan_filtering 1 mcast_vlan_snooping 1 vlan_protocol $vlan_proto
bridge vlan add dev $REP vid 2 pvid untagged
bridge vlan add dev $REP2 vid 2
bridge vlan add dev $REP3 vid 2 pvid untagged
bridge vlan add dev $nic vid 2 pvid untagged
bridge vlan global set dev $br vid 2 mcast_querier 1
config_vf $namespace1 $VF $REP $VF1_IP_VLAN2 $VF1_MAC
add_vf_mcast $namespace1 $VF $MCAST_IP
config_vf $namespace2 $VF2 $REP2
add_vf_vlan $namespace2 $VF2 $REP2 $VF2_IP_VLAN2 2 $VF2_MAC_VLAN2 $vlan_proto
add_vf_mcast $namespace2 ${VF2}.2 $MCAST_IP
config_vf $namespace3 $VF3 $REP3 $VF3_IP_VLAN2 $VF3_MAC
add_vf_mcast $namespace3 $VF3 $MCAST_IP
flush_bridge $br
sleep 10
bridge mdb show
verify_ping_remote_mcast $remote_dev $br $MCAST_IP $time $ndups $npackets
ip netns del $namespace1
ip netns del $namespace2
ip netns del $namespace3
sleep 1
}
function test_remote_trunk_to_mixed_vlan_mcast() {
create_bridge_with_mcast $br $NIC $REP $REP2 $REP3
ip addr flush dev $NIC
ip link set dev $NIC up
on_remote "ip a add dev $REMOTE_NIC $REMOTE_IP_VLAN2/24
ip link set $REMOTE_NIC up"
__test_remote_trunk_to_mixed_vlan_mcast $REMOTE_NIC $NIC 802.1Q
on_remote "ip a flush dev $REMOTE_NIC &>/dev/null"
ip link del name $br type bridge
ip addr flush dev $NIC
sleep 1
}
function test_remote_trunk_to_mixed_qinq_mcast() {
create_bridge_with_mcast $br $NIC $REP $REP2 $REP3
ip addr flush dev $NIC
ip link set dev $NIC up
on_remote "ip a add dev $REMOTE_NIC $REMOTE_IP_VLAN2/24
ip link set $REMOTE_NIC up"
__test_remote_trunk_to_mixed_vlan_mcast $REMOTE_NIC $NIC 802.1ad
on_remote "ip a flush dev $REMOTE_NIC &>/dev/null"
ip link del name $br type bridge
ip addr flush dev $NIC
sleep 1
}