2 # SPDX-License-Identifier: GPL-2.0
4 # Handles creation and destruction of IP-in-IP or GRE tunnels over the given
5 # topology. Supports both flat and hierarchical models.
8 # Overlay and underlay share the same VRF.
9 # SW1 uses default VRF so tunnel has no bound dev.
10 # SW2 uses non-default VRF tunnel has a bound dev.
11 # +-------------------------+
15 # +-------------------|-----+
17 # +-------------------|-----+
24 # | rem=192.0.2.66 --. |
26 # | .------------------' |
29 # | + $ul1.111 (vlan) |
30 # | | 192.0.2.129/28 |
34 # |VRF default + $ul1 |
35 # +------------|------------+
37 # +------------|------------+
42 # | + $ul2.111 (vlan) |
43 # | ^ 192.0.2.130/28 |
46 # | '------------------. |
48 # | loc=192.0.2.66 | |
49 # | rem=192.0.2.65 --' |
55 # +-------------------|-----+
57 # +-------------------|-----+
61 # +-------------------------+
64 # The tunnel is bound to a device in a different VRF
66 # +---------------------------+
70 # +-------------------|-------+
72 # +-------------------|-------+
74 # | +-----------------|-----+ |
76 # | | 192.0.2.2/28 | |
79 # | | rem=192.0.2.66 | |
81 # | | loc=192.0.2.65 | |
84 # | +-----------|-----------+ |
86 # | +-----------|-----------+ |
96 # | | + $ul1.111 (vlan) | |
97 # | | | 192.0.2.129/28 | |
102 # | +----------|------------+ |
103 # +------------|--------------+
105 # +------------|--------------+
107 # | +----------|------------+ |
112 # | | | $ul2.111 (vlan) | |
113 # | | + 192.0.2.130/28 | |
122 # | | VRF v$ul2 | | |
123 # | +-----------|-----------+ |
125 # | +-----------|-----------+ |
126 # | | VRF v$ol2 | | |
130 # | | loc=192.0.2.66 | |
131 # | | rem=192.0.2.65 | |
132 # | | tos=inherit | |
135 # | | 192.0.2.17/28 | | |
136 # | +-----------------|-----+ |
137 # +-------------------|-------+
139 # +-------------------|-------+
143 # +---------------------------+
147 simple_if_init
$h1 192.0.2.1/28 2001:db8
:1::1/64
148 ip route add vrf v
$h1 192.0.2.16/28 via
192.0.2.2
153 ip route del vrf v
$h1 192.0.2.16/28 via
192.0.2.2
154 simple_if_fini
$h1 192.0.2.1/28
159 simple_if_init
$h2 192.0.2.18/28
160 ip route add vrf v
$h2 192.0.2.0/28 via
192.0.2.17
165 ip route del vrf v
$h2 192.0.2.0/28 via
192.0.2.17
166 simple_if_fini
$h2 192.0.2.18/28
175 ip link
set dev
$ol1 up
176 __addr_add_del
$ol1 add
"192.0.2.2/28"
178 ip link
set dev
$ul1 up
179 vlan_create
$ul1 111 "" 192.0.2.129/28
181 tunnel_create g1a
$type 192.0.2.65 192.0.2.66 tos inherit
"$@"
182 ip link
set dev g1a up
183 __addr_add_del g1a add
"192.0.2.65/32"
185 ip route add
192.0.2.66/32 via
192.0.2.130
187 ip route add
192.0.2.16/28 nexthop dev g1a
195 ip route del
192.0.2.16/28
197 ip route del
192.0.2.66/32 via
192.0.2.130
198 __simple_if_fini g1a
192.0.2.65/32
201 vlan_destroy
$ul1 111
202 __simple_if_fini
$ul1
203 __simple_if_fini
$ol1 192.0.2.2/28
212 simple_if_init
$ol2 192.0.2.17/28
213 __simple_if_init
$ul2 v
$ol2
214 vlan_create
$ul2 111 v
$ol2 192.0.2.130/28
216 tunnel_create g2a
$type 192.0.2.66 192.0.2.65 tos inherit dev v
$ol2 \
218 __simple_if_init g2a v
$ol2 192.0.2.66/32
220 ip route add vrf v
$ol2 192.0.2.65/32 via
192.0.2.129
221 ip route add vrf v
$ol2 192.0.2.0/28 nexthop dev g2a
229 ip route del vrf v
$ol2 192.0.2.0/28
231 ip route del vrf v
$ol2 192.0.2.65/32 via
192.0.2.129
232 __simple_if_fini g2a
192.0.2.66/32
235 vlan_destroy
$ul2 111
236 __simple_if_fini
$ul2
237 simple_if_fini
$ol2 192.0.2.17/28
240 sw1_hierarchical_create
()
246 simple_if_init
$ol1 192.0.2.2/28
248 ip link add name dummy1
type dummy
249 __simple_if_init dummy1 v
$ul1 192.0.2.65/32
251 vlan_create
$ul1 111 v
$ul1 192.0.2.129/28
252 tunnel_create g1a
$type 192.0.2.65 192.0.2.66 tos inherit dev dummy1 \
254 ip link
set dev g1a master v
$ol1
256 ip route add vrf v
$ul1 192.0.2.66/32 via
192.0.2.130
257 ip route add vrf v
$ol1 192.0.2.16/28 nexthop dev g1a
260 sw1_hierarchical_destroy
()
265 ip route del vrf v
$ol1 192.0.2.16/28
266 ip route del vrf v
$ul1 192.0.2.66/32
269 vlan_destroy
$ul1 111
271 __simple_if_fini dummy1
192.0.2.65/32
272 ip link del dev dummy1
275 simple_if_fini
$ol1 192.0.2.2/28
278 sw2_hierarchical_create
()
284 simple_if_init
$ol2 192.0.2.17/28
287 ip link add name dummy2
type dummy
288 __simple_if_init dummy2 v
$ul2 192.0.2.66/32
290 vlan_create
$ul2 111 v
$ul2 192.0.2.130/28
291 tunnel_create g2a
$type 192.0.2.66 192.0.2.65 tos inherit dev dummy2 \
293 ip link
set dev g2a master v
$ol2
295 ip route add vrf v
$ul2 192.0.2.65/32 via
192.0.2.129
296 ip route add vrf v
$ol2 192.0.2.0/28 nexthop dev g2a
299 sw2_hierarchical_destroy
()
304 ip route del vrf v
$ol2 192.0.2.0/28
305 ip route del vrf v
$ul2 192.0.2.65/32
308 vlan_destroy
$ul2 111
310 __simple_if_fini dummy2
192.0.2.66/32
311 ip link del dev dummy2
314 simple_if_fini
$ol2 192.0.2.17/28
321 ip link
set mtu
$mtu dev
$h1
322 ip link
set mtu
$mtu dev
$ol1
323 ip link
set mtu
$mtu dev g1a
324 ip link
set mtu
$mtu dev
$ul1
325 ip link
set mtu
$mtu dev
$ul1.111
326 ip link
set mtu
$mtu dev
$h2
327 ip link
set mtu
$mtu dev
$ol2
328 ip link
set mtu
$mtu dev g2a
329 ip link
set mtu
$mtu dev
$ul2
330 ip link
set mtu
$mtu dev
$ul2.111
335 local encap
=$1; shift
339 ping_do
$h1 192.0.2.18 "-s 1800 -w 3"
340 check_fail $?
"ping $encap should not pass with size 1800"
345 ping_do
$h1 192.0.2.18 "-s 1800 -w 3"
347 log_test
"ping $encap packet size 1800 after MTU change"