2 # SPDX-License-Identifier: GPL-2.0
4 # +-----------------------+ +------------------------+
5 # | H1 (vrf) | | H2 (vrf) |
6 # | + $h1.10 | | + $h2.10 |
7 # | | 192.0.2.1/28 | | | 192.0.2.2/28 |
9 # | | + $h1.20 | | | + $h2.20 |
10 # | \ | 198.51.100.1/24 | | \ | 198.51.100.2/24 |
13 # +----|------------------+ +----|-------------------+
15 # +----|--------------------------------------------------|-------------------+
17 # | +--|--------------------------------------------------|-----------------+ |
18 # | | + $swp1 BR1 (802.1ad) + $swp2 | |
19 # | | vid 100 pvid untagged vid 100 pvid | |
21 # | | + vx100 (vxlan) | |
22 # | | local 192.0.2.17 | |
23 # | | remote 192.0.2.34 192.0.2.50 | |
24 # | | id 1000 dstport $VXPORT | |
25 # | | vid 100 pvid untagged | |
26 # | +-----------------------------------------------------------------------+ |
28 # | 192.0.2.32/28 via 192.0.2.18 |
29 # | 192.0.2.48/28 via 192.0.2.18 |
33 # +----|----------------------------------------------------------------------+
35 # +----|--------------------------------------------------------+
40 # =============================================================================
42 # | + v1 (veth) + v3 (veth) |
43 # | | 192.0.2.33/28 | 192.0.2.49/28 |
44 # +----|---------------------------------------|----------------+
46 # +----|------------------------------+ +----|------------------------------+
47 # | + v2 (veth) NS1 (netns) | | + v4 (veth) NS2 (netns) |
48 # | 192.0.2.34/28 | | 192.0.2.50/28 |
50 # | 192.0.2.16/28 via 192.0.2.33 | | 192.0.2.16/28 via 192.0.2.49 |
51 # | 192.0.2.50/32 via 192.0.2.33 | | 192.0.2.34/32 via 192.0.2.49 |
53 # | +-------------------------------+ | | +-------------------------------+ |
54 # | | BR2 (802.1ad) | | | | BR2 (802.1ad) | |
55 # | | + vx100 (vxlan) | | | | + vx100 (vxlan) | |
56 # | | local 192.0.2.34 | | | | local 192.0.2.50 | |
57 # | | remote 192.0.2.17 | | | | remote 192.0.2.17 | |
58 # | | remote 192.0.2.50 | | | | remote 192.0.2.34 | |
59 # | | id 1000 dstport $VXPORT | | | | id 1000 dstport $VXPORT | |
60 # | | vid 100 pvid untagged | | | | vid 100 pvid untagged | |
62 # | | + w1 (veth) | | | | + w1 (veth) | |
63 # | | | vid 100 pvid untagged | | | | | vid 100 pvid untagged | |
64 # | +--|----------------------------+ | | +--|----------------------------+ |
66 # | +--|----------------------------+ | | +--|----------------------------+ |
67 # | | | VW2 (vrf) | | | | | VW2 (vrf) | |
68 # | | + w2 (veth) | | | | + w2 (veth) | |
69 # | | |\ | | | | |\ | |
70 # | | | + w2.10 | | | | | + w2.10 | |
71 # | | | 192.0.2.3/28 | | | | | 192.0.2.4/28 | |
73 # | | + w2.20 | | | | + w2.20 | |
74 # | | 198.51.100.3/24 | | | | 198.51.100.4/24 | |
75 # | +-------------------------------+ | | +-------------------------------+ |
76 # +-----------------------------------+ +-----------------------------------+
91 tc qdisc add dev
$h1 clsact
92 vlan_create
$h1 10 v
$h1 192.0.2.1/28
93 vlan_create
$h1 20 v
$h1 198.51.100.1/24
100 tc qdisc del dev
$h1 clsact
107 tc qdisc add dev
$h2 clsact
108 vlan_create
$h2 10 v
$h2 192.0.2.2/28
109 vlan_create
$h2 20 v
$h2 198.51.100.2/24
116 tc qdisc del dev
$h2 clsact
122 ip address add dev
$rp1 192.0.2.17/28
124 ip route add
192.0.2.32/28 nexthop via
192.0.2.18
125 ip route add
192.0.2.48/28 nexthop via
192.0.2.18
130 ip route del
192.0.2.48/28 nexthop via
192.0.2.18
131 ip route del
192.0.2.32/28 nexthop via
192.0.2.18
133 ip address del dev
$rp1 192.0.2.17/28
138 ip link add name br1
type bridge vlan_filtering
1 vlan_protocol
802.1ad \
139 vlan_default_pvid
0 mcast_snooping
0
140 # Make sure the bridge uses the MAC address of the local port and not
141 # that of the VxLAN's device.
142 ip link
set dev br1 address $
(mac_get
$swp1)
143 ip link
set dev br1 up
145 ip link
set dev
$rp1 up
148 ip link add name vx100
type vxlan id
1000 \
149 local 192.0.2.17 dstport
"$VXPORT" \
150 nolearning noudpcsum tos inherit ttl
100
151 ip link
set dev vx100 up
153 ip link
set dev vx100 master br1
154 bridge vlan add vid
100 dev vx100 pvid untagged
156 ip link
set dev
$swp1 master br1
157 ip link
set dev
$swp1 up
158 bridge vlan add vid
100 dev
$swp1 pvid untagged
160 ip link
set dev
$swp2 master br1
161 ip link
set dev
$swp2 up
162 bridge vlan add vid
100 dev
$swp2 pvid untagged
164 bridge fdb append dev vx100
00:00:00:00:00:00 dst
192.0.2.34 self
165 bridge fdb append dev vx100
00:00:00:00:00:00 dst
192.0.2.50 self
170 bridge fdb del dev vx100
00:00:00:00:00:00 dst
192.0.2.50 self
171 bridge fdb del dev vx100
00:00:00:00:00:00 dst
192.0.2.34 self
173 bridge vlan del vid
100 dev
$swp2
174 ip link
set dev
$swp2 down
175 ip link
set dev
$swp2 nomaster
177 bridge vlan del vid
100 dev
$swp1
178 ip link
set dev
$swp1 down
179 ip link
set dev
$swp1 nomaster
181 ip link
set dev vx100 nomaster
182 ip link
set dev vx100 down
183 ip link del dev vx100
186 ip link
set dev
$rp1 down
188 ip link
set dev br1 down
194 simple_if_init
$rp2 192.0.2.18/28
195 __simple_if_init v1 v
$rp2 192.0.2.33/28
196 __simple_if_init v3 v
$rp2 192.0.2.49/28
197 tc qdisc add dev v1 clsact
202 tc qdisc del dev v1 clsact
203 __simple_if_fini v3
192.0.2.49/28
204 __simple_if_fini v1
192.0.2.33/28
205 simple_if_fini
$rp2 192.0.2.18/28
210 local in_if
=$1; shift
211 local in_addr
=$1; shift
212 local other_in_addr
=$1; shift
213 local nh_addr
=$1; shift
214 local host_addr1
=$1; shift
215 local host_addr2
=$1; shift
217 ip link
set dev
$in_if up
218 ip address add dev
$in_if $in_addr/28
219 tc qdisc add dev
$in_if clsact
221 ip link add name br2
type bridge vlan_filtering
1 vlan_protocol
802.1ad \
223 ip link
set dev br2 up
225 ip link add name w1
type veth peer name w2
227 ip link
set dev w1 master br2
228 ip link
set dev w1 up
229 bridge vlan add vid
100 dev w1 pvid untagged
231 ip link add name vx100
type vxlan id
1000 local $in_addr \
233 ip link
set dev vx100 up
234 bridge fdb append dev vx100
00:00:00:00:00:00 dst
192.0.2.17 self
235 bridge fdb append dev vx100
00:00:00:00:00:00 dst
$other_in_addr self
237 ip link
set dev vx100 master br2
238 tc qdisc add dev vx100 clsact
240 bridge vlan add vid
100 dev vx100 pvid untagged
243 vlan_create w2
10 vw2
$host_addr1/28
244 vlan_create w2
20 vw2
$host_addr2/24
246 ip route add
192.0.2.16/28 nexthop via
$nh_addr
247 ip route add
$other_in_addr/32 nexthop via
$nh_addr
249 export -f ns_init_common
254 ip link
set dev v2 netns ns1
256 ns_init_common v2
192.0.2.34 192.0.2.50 192.0.2.33 \
257 192.0.2.3 198.51.100.3
262 ip netns
exec ns1 ip link
set dev v2 netns
1
269 ip link
set dev v4 netns ns2
271 ns_init_common v4
192.0.2.50 192.0.2.34 192.0.2.49 \
272 192.0.2.4 198.51.100.4
277 ip netns
exec ns2 ip link
set dev v4 netns
1
299 ip link add name v1
type veth peer name v2
300 ip link add name v3
type veth peer name v4
305 r1_mac
=$
(in_ns ns1 mac_get w2
)
306 r2_mac
=$
(in_ns ns2 mac_get w2
)
307 h2_mac
=$
(mac_get
$h2)
330 ping_test
$h1 192.0.2.2 ": local->local"
331 ping_test
$h1 192.0.2.3 ": local->remote 1"
332 ping_test
$h1 192.0.2.4 ": local->remote 2"
337 echo "Running tests with UDP port $VXPORT"