2 # SPDX-License-Identifier: GPL-2.0
4 # +--------------------------------+ +-----------------------------+
5 # | vrf-h1 | | vrf-h2 |
7 # | | 2001:db8:1::1/64 | | | 2001:db8:2::1/64 |
8 # | | default via 2001:db8:1::3 | | | default via 2001:db8:2::3 |
9 # +----|---------------------------+ +-|---------------------------+
11 # +----|------------------------------------------|---------------------------+
13 # | +--|------------------------------------------|-------------------------+ |
14 # | | + $swp1 br1 + $swp2 | |
15 # | | vid 10 pvid untagged vid 20 pvid untagged | |
17 # | | + vx10 + vx20 | |
18 # | | local 2001:db8:3::1 local 2001:db8:3::1 | |
19 # | | remote 2001:db8:3::2 remote 2001:db8:3::2 | |
20 # | | id 1000 id 2000 | |
21 # | | dstport 4789 dstport 4789 | |
22 # | | vid 10 pvid untagged vid 20 pvid untagged | |
24 # | +-----------------------------------+-----------------------------------+ |
26 # | +-----------------------------------|-----------------------------------+ |
28 # | | +--------------------------------+--------------------------------+ | |
30 # | | + vlan10 vlan20 + | |
31 # | | | 2001:db8:1::2/64 2001:db8:2::2/64 | | |
33 # | | + vlan10-v (macvlan) vlan20-v (macvlan) + | |
34 # | | 2001:db8:1::3/64 2001:db8:2::3/64 | |
35 # | | 00:00:5e:00:01:01 00:00:5e:00:01:01 | |
37 # | +-----------------------------------------------------------------------+ |
40 # | | 2001:db8:4::1/64 2001:db8:3::1/128 |
41 # +----|----------------------------------------------------------------------+
43 # +----|--------------------------------------------------------+
46 # | 2001:db8:4::2/64 |
48 # =============================================================================
52 # | | 2001:db8:5::2/64 |
53 # +----|--------------------------------------------------------+
55 # +----|----------------------------------------------------------------------+
56 # | + v2 (veth) +lo NS1 (netns) |
57 # | 2001:db8:5::1/64 2001:db8:3::2/128 |
59 # | +-----------------------------------------------------------------------+ |
61 # | | + vlan10-v (macvlan) vlan20-v (macvlan) + | |
62 # | | | 2001:db8:1::3/64 2001:db8:2::3/64 | | |
63 # | | | 00:00:5e:00:01:01 00:00:5e:00:01:01 | | |
65 # | | + vlan10 vlan20 + | |
66 # | | | 2001:db8:1::3/64 2001:db8:2::3/64 | | |
68 # | | +--------------------------------+--------------------------------+ | |
70 # | +-----------------------------------|-----------------------------------+ |
72 # | +-----------------------------------+-----------------------------------+ |
74 # | | + vx10 + vx20 | |
75 # | | local 2001:db8:3::2 local 2001:db8:3::2 | |
76 # | | remote 2001:db8:3::1 remote 2001:db8:3::1 | |
77 # | | id 1000 id 2000 | |
78 # | | dstport 4789 dstport 4789 | |
79 # | | vid 10 pvid untagged vid 20 pvid untagged | |
81 # | | + w1 (veth) + w3 (veth) | |
82 # | | | vid 10 pvid untagged br1 | vid 20 pvid untagged | |
83 # | +--|------------------------------------------|-------------------------+ |
86 # | +--|----------------------+ +--|-------------------------+ |
87 # | | | vrf-h1 | | | vrf-h2 | |
88 # | | + w2 (veth) | | + w4 (veth) | |
89 # | | 2001:db8:1::4/64 | | 2001:db8:2::4/64 | |
90 # | | default via | | default via | |
91 # | | 2001:db8:1::3/64 | | 2001:db8:2::3/64 | |
92 # | +-------------------------+ +----------------------------+ |
93 # +---------------------------------------------------------------------------+
102 require_command
$ARPING
106 local vrf_name
=$1; shift
107 local if_name
=$1; shift
108 local ip_addr
=$1; shift
109 local gw_ip
=$1; shift
112 ip link
set dev
$if_name master
$vrf_name
113 ip link
set dev
$vrf_name up
114 ip link
set dev
$if_name up
116 ip address add
$ip_addr/64 dev
$if_name
117 ip neigh replace
$gw_ip lladdr
00:00:5e
:00:01:01 nud permanent \
119 ip route add default vrf
$vrf_name nexthop via
$gw_ip
125 local vrf_name
=$1; shift
126 local if_name
=$1; shift
127 local ip_addr
=$1; shift
128 local gw_ip
=$1; shift
130 ip route del default vrf
$vrf_name nexthop via
$gw_ip
131 ip neigh del
$gw_ip dev
$if_name
132 ip address del
$ip_addr/64 dev
$if_name
134 ip link
set dev
$if_name down
135 vrf_destroy
$vrf_name
140 hx_create
"vrf-h1" $h1 2001:db8
:1::1 2001:db8
:1::3
145 hx_destroy
"vrf-h1" $h1 2001:db8
:1::1 2001:db8
:1::3
150 hx_create
"vrf-h2" $h2 2001:db8
:2::1 2001:db8
:2::3
155 hx_destroy
"vrf-h2" $h2 2001:db8
:2::1 2001:db8
:2::3
160 ip link add name br1
type bridge vlan_filtering
1 vlan_default_pvid
0 \
162 # Make sure the bridge uses the MAC address of the local port and not
163 # that of the VxLAN's device.
164 ip link
set dev br1 address $
(mac_get
$swp1)
165 ip link
set dev br1 up
167 ip link
set dev
$rp1 up
168 ip address add dev
$rp1 2001:db8
:4::1/64
169 ip route add
2001:db8
:3::2/128 nexthop via
2001:db8
:4::2
171 ip link add name vx10
type vxlan id
1000 \
172 local 2001:db8
:3::1 remote
2001:db8
:3::2 dstport
4789 \
173 nolearning udp6zerocsumrx udp6zerocsumtx tos inherit ttl
100
174 ip link
set dev vx10 up
176 ip link
set dev vx10 master br1
177 bridge vlan add vid
10 dev vx10 pvid untagged
179 ip link add name vx20
type vxlan id
2000 \
180 local 2001:db8
:3::1 remote
2001:db8
:3::2 dstport
4789 \
181 nolearning udp6zerocsumrx udp6zerocsumtx tos inherit ttl
100
182 ip link
set dev vx20 up
184 ip link
set dev vx20 master br1
185 bridge vlan add vid
20 dev vx20 pvid untagged
187 ip link
set dev
$swp1 master br1
188 ip link
set dev
$swp1 up
189 bridge vlan add vid
10 dev
$swp1 pvid untagged
191 ip link
set dev
$swp2 master br1
192 ip link
set dev
$swp2 up
193 bridge vlan add vid
20 dev
$swp2 pvid untagged
195 ip address add
2001:db8
:3::1/128 dev lo
198 vrf_create
"vrf-green"
199 ip link
set dev vrf-green up
201 ip link add link br1 name vlan10 up master vrf-green
type vlan id
10
202 ip address add
2001:db8
:1::2/64 dev vlan10
203 ip link add link vlan10 name vlan10-v up master vrf-green \
204 address
00:00:5e
:00:01:01 type macvlan mode private
205 ip address add
2001:db8
:1::3/64 dev vlan10-v
207 ip link add link br1 name vlan20 up master vrf-green
type vlan id
20
208 ip address add
2001:db8
:2::2/64 dev vlan20
209 ip link add link vlan20 name vlan20-v up master vrf-green \
210 address
00:00:5e
:00:01:01 type macvlan mode private
211 ip address add
2001:db8
:2::3/64 dev vlan20-v
213 bridge vlan add vid
10 dev br1 self
214 bridge vlan add vid
20 dev br1 self
216 bridge fdb add
00:00:5e
:00:01:01 dev br1 self
local vlan
10
217 bridge fdb add
00:00:5e
:00:01:01 dev br1 self
local vlan
20
223 bridge fdb del
00:00:5e
:00:01:01 dev br1 self
local vlan
20
224 bridge fdb del
00:00:5e
:00:01:01 dev br1 self
local vlan
10
226 bridge vlan del vid
20 dev br1 self
227 bridge vlan del vid
10 dev br1 self
229 ip link del dev vlan20
231 ip link del dev vlan10
233 vrf_destroy
"vrf-green"
235 ip address del
2001:db8
:3::1/128 dev lo
237 bridge vlan del vid
20 dev
$swp2
238 ip link
set dev
$swp2 down
239 ip link
set dev
$swp2 nomaster
241 bridge vlan del vid
10 dev
$swp1
242 ip link
set dev
$swp1 down
243 ip link
set dev
$swp1 nomaster
245 bridge vlan del vid
20 dev vx20
246 ip link
set dev vx20 nomaster
248 ip link
set dev vx20 down
251 bridge vlan del vid
10 dev vx10
252 ip link
set dev vx10 nomaster
254 ip link
set dev vx10 down
257 ip route del
2001:db8
:3::2 nexthop via
2001:db8
:4::2
258 ip address del dev
$rp1 2001:db8
:4::1/64
259 ip link
set dev
$rp1 down
261 ip link
set dev br1 down
267 vrf_create
"vrf-spine"
268 ip link
set dev
$rp2 master vrf-spine
269 ip link
set dev v1 master vrf-spine
270 ip link
set dev vrf-spine up
271 ip link
set dev
$rp2 up
272 ip link
set dev v1 up
274 ip address add
2001:db8
:4::2/64 dev
$rp2
275 ip address add
2001:db8
:5::2/64 dev v1
277 ip route add
2001:db8
:3::1/128 vrf vrf-spine nexthop via \
279 ip route add
2001:db8
:3::2/128 vrf vrf-spine nexthop via \
285 ip route del
2001:db8
:3::2/128 vrf vrf-spine nexthop via \
287 ip route del
2001:db8
:3::1/128 vrf vrf-spine nexthop via \
290 ip address del
2001:db8
:5::2/64 dev v1
291 ip address del
2001:db8
:4::2/64 dev
$rp2
293 ip link
set dev v1 down
294 ip link
set dev
$rp2 down
295 vrf_destroy
"vrf-spine"
300 hx_create
"vrf-h1" w2
2001:db8
:1::4 2001:db8
:1::3
302 export -f ns_h1_create
306 hx_create
"vrf-h2" w4
2001:db8
:2::4 2001:db8
:2::3
308 export -f ns_h2_create
312 ip link add name br1
type bridge vlan_filtering
1 vlan_default_pvid
0 \
314 ip link
set dev br1 up
316 ip link
set dev v2 up
317 ip address add dev v2
2001:db8
:5::1/64
318 ip route add
2001:db8
:3::1 nexthop via
2001:db8
:5::2
320 ip link add name vx10
type vxlan id
1000 \
321 local 2001:db8
:3::2 remote
2001:db8
:3::1 dstport
4789 \
322 nolearning udp6zerocsumrx udp6zerocsumtx tos inherit ttl
100
323 ip link
set dev vx10 up
325 ip link
set dev vx10 master br1
326 bridge vlan add vid
10 dev vx10 pvid untagged
328 ip link add name vx20
type vxlan id
2000 \
329 local 2001:db8
:3::2 remote
2001:db8
:3::1 dstport
4789 \
330 nolearning udp6zerocsumrx udp6zerocsumtx tos inherit ttl
100
331 ip link
set dev vx20 up
333 ip link
set dev vx20 master br1
334 bridge vlan add vid
20 dev vx20 pvid untagged
336 ip link
set dev w1 master br1
337 ip link
set dev w1 up
338 bridge vlan add vid
10 dev w1 pvid untagged
340 ip link
set dev w3 master br1
341 ip link
set dev w3 up
342 bridge vlan add vid
20 dev w3 pvid untagged
344 ip address add
2001:db8
:3::2/128 dev lo
347 vrf_create
"vrf-green"
348 ip link
set dev vrf-green up
350 ip link add link br1 name vlan10 up master vrf-green
type vlan id
10
351 ip address add
2001:db8
:1::3/64 dev vlan10
352 ip link add link vlan10 name vlan10-v up master vrf-green \
353 address
00:00:5e
:00:01:01 type macvlan mode private
354 ip address add
2001:db8
:1::3/64 dev vlan10-v
356 ip link add link br1 name vlan20 up master vrf-green
type vlan id
20
357 ip address add
2001:db8
:2::3/64 dev vlan20
358 ip link add link vlan20 name vlan20-v up master vrf-green \
359 address
00:00:5e
:00:01:01 type macvlan mode private
360 ip address add
2001:db8
:2::3/64 dev vlan20-v
362 bridge vlan add vid
10 dev br1 self
363 bridge vlan add vid
20 dev br1 self
365 bridge fdb add
00:00:5e
:00:01:01 dev br1 self
local vlan
10
366 bridge fdb add
00:00:5e
:00:01:01 dev br1 self
local vlan
20
368 export -f ns_switch_create
372 ip link add name w1
type veth peer name w2
373 ip link add name w3
type veth peer name w4
375 ip link
set dev lo up
386 ip link
set dev v2 netns ns1
392 ip netns
exec ns1 ip link
set dev v2 netns
1
404 bridge fdb add
$mac1 dev vx10 self master extern_learn static \
406 bridge fdb add
$mac2 dev vx20 self master extern_learn static \
409 ip neigh add
$ip1 lladdr
$mac1 nud noarp dev vlan10 \
411 ip neigh add
$ip2 lladdr
$mac2 nud noarp dev vlan20 \
414 export -f macs_populate
418 local h1_ns_mac
=$
(in_ns ns1 mac_get w2
)
419 local h2_ns_mac
=$
(in_ns ns1 mac_get w4
)
420 local h1_mac
=$
(mac_get
$h1)
421 local h2_mac
=$
(mac_get
$h2)
423 macs_populate
$h1_ns_mac $h2_ns_mac 2001:db8
:1::4 2001:db8
:2::4 \
425 in_ns ns1 macs_populate
$h1_mac $h2_mac 2001:db8
:1::1 2001:db8
:2::1 \
447 ip link add name v1
type veth peer name v2
450 in_ns ns1 forwarding_enable
473 ping6_test
$h1 2001:db8
:2::1 ": local->local vid 10->vid 20"
474 ping6_test
$h1 2001:db8
:1::4 ": local->remote vid 10->vid 10"
475 ping6_test
$h2 2001:db8
:2::4 ": local->remote vid 20->vid 20"
476 ping6_test
$h1 2001:db8
:2::4 ": local->remote vid 10->vid 20"
477 ping6_test
$h2 2001:db8
:1::4 ": local->remote vid 20->vid 10"
482 # Repeat the ping tests, but without populating the neighbours. This
483 # makes sure we correctly decapsulate ARP packets
484 log_info
"deleting neighbours from vlan interfaces"
486 ip neigh del
2001:db8
:1::4 dev vlan10
487 ip neigh del
2001:db8
:2::4 dev vlan20
491 ip neigh replace
2001:db8
:1::4 lladdr $
(in_ns ns1 mac_get w2
) \
492 nud noarp dev vlan10 extern_learn
493 ip neigh replace
2001:db8
:2::4 lladdr $
(in_ns ns1 mac_get w4
) \
494 nud noarp dev vlan20 extern_learn