2 # SPDX-License-Identifier: GPL-2.0
4 # +--------------------+ +----------------------+
5 # | H1 (vrf) | | H2 (vrf) |
6 # | + h1.10 | | + h2.20 |
7 # | | 192.0.2.1/28 | | | 192.0.2.2/28 |
11 # +----|---------------+ +--|-------------------+
13 # +----|--------------------------------------------------|--------------------+
15 # | +--|-------------------------------+ +----------------|------------------+ |
16 # | | + $swp1 BR1 (802.1ad) | | BR2 (802.1d) + $swp2 | |
17 # | | vid 100 pvid untagged | | | | |
18 # | | | | + $swp2.20 | |
20 # | | + vx100 (vxlan) | | + vx200 (vxlan) | |
21 # | | local 192.0.2.17 | | local 192.0.2.17 | |
22 # | | remote 192.0.2.34 | | remote 192.0.2.50 | |
23 # | | id 1000 dstport $VXPORT | | id 2000 dstport $VXPORT | |
24 # | | vid 100 pvid untagged | | | |
25 # | +--------------------------------- + +-----------------------------------+ |
27 # | 192.0.2.32/28 via 192.0.2.18 |
28 # | 192.0.2.48/28 via 192.0.2.18 |
32 # +----|-----------------------------------------------------------------------+
34 # +----|--------------------------------------------------------+
39 # =============================================================================
41 # | + v1 (veth) + v3 (veth) |
42 # | | 192.0.2.33/28 | 192.0.2.49/28 |
43 # +----|---------------------------------------|----------------+
45 # +----|------------------------------+ +----|------------------------------+
46 # | + v2 (veth) NS1 (netns) | | + v4 (veth) NS2 (netns) |
47 # | 192.0.2.34/28 | | 192.0.2.50/28 |
49 # | 192.0.2.16/28 via 192.0.2.33 | | 192.0.2.16/28 via 192.0.2.49 |
50 # | 192.0.2.50/32 via 192.0.2.33 | | 192.0.2.34/32 via 192.0.2.49 |
52 # | +-------------------------------+ | | +-------------------------------+ |
53 # | | BR3 (802.1ad) | | | | BR3 (802.1d) | |
54 # | | + vx100 (vxlan) | | | | + vx200 (vxlan) | |
55 # | | local 192.0.2.34 | | | | local 192.0.2.50 | |
56 # | | remote 192.0.2.17 | | | | remote 192.0.2.17 | |
57 # | | remote 192.0.2.50 | | | | remote 192.0.2.34 | |
58 # | | id 1000 dstport $VXPORT | | | | id 2000 dstport $VXPORT | |
59 # | | vid 100 pvid untagged | | | | | |
60 # | | | | | | + w1.20 | |
62 # | | + w1 (veth) | | | | + w1 (veth) | |
63 # | | | vid 100 pvid untagged | | | | | | |
64 # | +--|----------------------------+ | | +--|----------------------------+ |
66 # | +--|----------------------------+ | | +--|----------------------------+ |
67 # | | | VW2 (vrf) | | | | | VW2 (vrf) | |
68 # | | + w2 (veth) | | | | + w2 (veth) | |
71 # | | + w2.10 | | | | + w2.20 | |
72 # | | 192.0.2.3/28 | | | | 192.0.2.4/28 | |
73 # | +-------------------------------+ | | +-------------------------------+ |
74 # +-----------------------------------+ +-----------------------------------+
89 tc qdisc add dev
$h1 clsact
90 vlan_create
$h1 10 v
$h1 192.0.2.1/28
96 tc qdisc del dev
$h1 clsact
103 tc qdisc add dev
$h2 clsact
104 vlan_create
$h2 20 v
$h2 192.0.2.2/28
110 tc qdisc del dev
$h2 clsact
116 ip address add dev
$rp1 192.0.2.17/28
118 ip route add
192.0.2.32/28 nexthop via
192.0.2.18
119 ip route add
192.0.2.48/28 nexthop via
192.0.2.18
124 ip route del
192.0.2.48/28 nexthop via
192.0.2.18
125 ip route del
192.0.2.32/28 nexthop via
192.0.2.18
127 ip address del dev
$rp1 192.0.2.17/28
133 ip link add name br1
type bridge vlan_filtering
1 \
134 vlan_protocol
802.1ad vlan_default_pvid
0 mcast_snooping
0
135 ip link
set dev br1 addrgenmode none
136 # Make sure the bridge uses the MAC address of the local port and not
137 # that of the VxLAN's device.
138 ip link
set dev br1 address $
(mac_get
$swp1)
139 ip link
set dev br1 up
142 ip link add name br2
type bridge vlan_filtering
0 mcast_snooping
0
143 # Make sure the bridge uses the MAC address of the local port and not
144 # that of the VxLAN's device.
145 ip link
set dev br2 address $
(mac_get
$swp2)
146 ip link
set dev br2 up
148 ip link
set dev
$rp1 up
152 ip link add name vx100
type vxlan id
1000 local 192.0.2.17 \
153 dstport
"$VXPORT" nolearning noudpcsum tos inherit ttl
100
154 ip link
set dev vx100 up
156 ip link
set dev vx100 master br1
157 bridge vlan add vid
100 dev vx100 pvid untagged
159 ip link
set dev
$swp1 master br1
160 ip link
set dev
$swp1 up
161 bridge vlan add vid
100 dev
$swp1 pvid untagged
164 ip link add name vx200
type vxlan id
2000 local 192.0.2.17 \
165 dstport
"$VXPORT" nolearning noudpcsum tos inherit ttl
100
166 ip link
set dev vx200 up
168 ip link
set dev vx200 master br2
170 ip link
set dev
$swp2 up
171 ip link add name
$swp2.20 link
$swp2 type vlan id
20
172 ip link
set dev
$swp2.20 master br2
173 ip link
set dev
$swp2.20 up
175 bridge fdb append dev vx100
00:00:00:00:00:00 dst
192.0.2.34 self
176 bridge fdb append dev vx200
00:00:00:00:00:00 dst
192.0.2.50 self
181 bridge fdb del dev vx200
00:00:00:00:00:00 dst
192.0.2.50 self
182 bridge fdb del dev vx100
00:00:00:00:00:00 dst
192.0.2.34 self
184 ip link
set dev vx200 nomaster
185 ip link
set dev vx200 down
186 ip link del dev vx200
188 ip link del dev
$swp2.20
189 ip link
set dev
$swp2 down
190 ip link
set dev
$swp2 nomaster
192 bridge vlan del vid
100 dev
$swp1
193 ip link
set dev
$swp1 down
194 ip link
set dev
$swp1 nomaster
196 ip link
set dev vx100 nomaster
197 ip link
set dev vx100 down
198 ip link del dev vx100
201 ip link
set dev
$rp1 down
203 ip link
set dev br2 down
206 ip link
set dev br1 down
212 simple_if_init
$rp2 192.0.2.18/28
213 __simple_if_init v1 v
$rp2 192.0.2.33/28
214 __simple_if_init v3 v
$rp2 192.0.2.49/28
215 tc qdisc add dev v1 clsact
220 tc qdisc del dev v1 clsact
221 __simple_if_fini v3
192.0.2.49/28
222 __simple_if_fini v1
192.0.2.33/28
223 simple_if_fini
$rp2 192.0.2.18/28
228 local in_if
=$1; shift
229 local in_addr
=$1; shift
230 local other_in_addr
=$1; shift
231 local vxlan_name
=$1; shift
232 local vxlan_id
=$1; shift
233 local vlan_id
=$1; shift
234 local host_addr
=$1; shift
235 local nh_addr
=$1; shift
237 ip link
set dev
$in_if up
238 ip address add dev
$in_if $in_addr/28
239 tc qdisc add dev
$in_if clsact
241 ip link add name br3
type bridge vlan_filtering
0
242 ip link
set dev br3 up
244 ip link add name w1
type veth peer name w2
246 ip link
set dev w1 master br3
247 ip link
set dev w1 up
249 ip link add name
$vxlan_name type vxlan id
$vxlan_id local $in_addr \
251 ip link
set dev
$vxlan_name up
252 bridge fdb append dev
$vxlan_name 00:00:00:00:00:00 dst
192.0.2.17 self
253 bridge fdb append dev
$vxlan_name 00:00:00:00:00:00 dst
$other_in_addr self
255 ip link
set dev
$vxlan_name master br3
256 tc qdisc add dev
$vxlan_name clsact
259 vlan_create w2
$vlan_id vw2
$host_addr/28
261 ip route add
192.0.2.16/28 nexthop via
$nh_addr
262 ip route add
$other_in_addr/32 nexthop via
$nh_addr
264 export -f ns_init_common
269 ip link
set dev v2 netns ns1
271 ns_init_common v2
192.0.2.34 192.0.2.50 vx100
1000 10 192.0.2.3 \
274 in_ns ns1 bridge vlan add vid
100 dev vx100 pvid untagged
279 ip netns
exec ns1 ip link
set dev v2 netns
1
286 ip link
set dev v4 netns ns2
288 ns_init_common v4
192.0.2.50 192.0.2.34 vx200
2000 20 192.0.2.4 \
291 in_ns ns2 ip link add name w1.20 link w1
type vlan id
20
292 in_ns ns2 ip link
set dev w1.20 master br3
293 in_ns ns2 ip link
set dev w1.20 up
298 ip netns
exec ns2 ip link
set dev v4 netns
1
320 ip link add name v1
type veth peer name v2
321 ip link add name v3
type veth peer name v4
326 r1_mac
=$
(in_ns ns1 mac_get w2
)
327 r2_mac
=$
(in_ns ns2 mac_get w2
)
328 h2_mac
=$
(mac_get
$h2)
351 ping_test
$h1 192.0.2.3 ": local->remote 1 through VxLAN with an 802.1ad bridge"
352 ping_test
$h2 192.0.2.4 ": local->remote 2 through VxLAN with an 802.1d bridge"
357 echo "Running tests with UDP port $VXPORT"