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 # +---------------------------+
148 simple_if_init
$h1 192.0.2.1/28 2001:db8
:1::1/64
149 ip route add vrf v
$h1 192.0.2.16/28 via
192.0.2.2
154 ip route del vrf v
$h1 192.0.2.16/28 via
192.0.2.2
155 simple_if_fini
$h1 192.0.2.1/28
160 simple_if_init
$h2 192.0.2.18/28
161 ip route add vrf v
$h2 192.0.2.0/28 via
192.0.2.17
166 ip route del vrf v
$h2 192.0.2.0/28 via
192.0.2.17
167 simple_if_fini
$h2 192.0.2.18/28
176 ip link
set dev
$ol1 up
177 __addr_add_del
$ol1 add
"192.0.2.2/28"
179 ip link
set dev
$ul1 up
180 vlan_create
$ul1 111 "" 192.0.2.129/28
182 tunnel_create g1a
$type 192.0.2.65 192.0.2.66 tos inherit
"$@"
183 ip link
set dev g1a up
184 __addr_add_del g1a add
"192.0.2.65/32"
186 ip route add
192.0.2.66/32 via
192.0.2.130
188 ip route add
192.0.2.16/28 nexthop dev g1a
196 ip route del
192.0.2.16/28
198 ip route del
192.0.2.66/32 via
192.0.2.130
199 __simple_if_fini g1a
192.0.2.65/32
202 vlan_destroy
$ul1 111
203 __simple_if_fini
$ul1
204 __simple_if_fini
$ol1 192.0.2.2/28
213 simple_if_init
$ol2 192.0.2.17/28
214 __simple_if_init
$ul2 v
$ol2
215 vlan_create
$ul2 111 v
$ol2 192.0.2.130/28
217 tunnel_create g2a
$type 192.0.2.66 192.0.2.65 tos inherit dev v
$ol2 \
219 __simple_if_init g2a v
$ol2 192.0.2.66/32
221 ip route add vrf v
$ol2 192.0.2.65/32 via
192.0.2.129
222 ip route add vrf v
$ol2 192.0.2.0/28 nexthop dev g2a
230 ip route del vrf v
$ol2 192.0.2.0/28
232 ip route del vrf v
$ol2 192.0.2.65/32 via
192.0.2.129
233 __simple_if_fini g2a
192.0.2.66/32
236 vlan_destroy
$ul2 111
237 __simple_if_fini
$ul2
238 simple_if_fini
$ol2 192.0.2.17/28
241 sw1_hierarchical_create
()
247 simple_if_init
$ol1 192.0.2.2/28
249 ip link add name dummy1
type dummy
250 __simple_if_init dummy1 v
$ul1 192.0.2.65/32
252 vlan_create
$ul1 111 v
$ul1 192.0.2.129/28
253 tunnel_create g1a
$type 192.0.2.65 192.0.2.66 tos inherit dev dummy1 \
255 ip link
set dev g1a master v
$ol1
257 ip route add vrf v
$ul1 192.0.2.66/32 via
192.0.2.130
258 ip route add vrf v
$ol1 192.0.2.16/28 nexthop dev g1a
261 sw1_hierarchical_destroy
()
266 ip route del vrf v
$ol1 192.0.2.16/28
267 ip route del vrf v
$ul1 192.0.2.66/32
270 vlan_destroy
$ul1 111
272 __simple_if_fini dummy1
192.0.2.65/32
273 ip link del dev dummy1
276 simple_if_fini
$ol1 192.0.2.2/28
279 sw2_hierarchical_create
()
285 simple_if_init
$ol2 192.0.2.17/28
288 ip link add name dummy2
type dummy
289 __simple_if_init dummy2 v
$ul2 192.0.2.66/32
291 vlan_create
$ul2 111 v
$ul2 192.0.2.130/28
292 tunnel_create g2a
$type 192.0.2.66 192.0.2.65 tos inherit dev dummy2 \
294 ip link
set dev g2a master v
$ol2
296 ip route add vrf v
$ul2 192.0.2.65/32 via
192.0.2.129
297 ip route add vrf v
$ol2 192.0.2.0/28 nexthop dev g2a
300 sw2_hierarchical_destroy
()
305 ip route del vrf v
$ol2 192.0.2.0/28
306 ip route del vrf v
$ul2 192.0.2.65/32
309 vlan_destroy
$ul2 111
311 __simple_if_fini dummy2
192.0.2.66/32
312 ip link del dev dummy2
315 simple_if_fini
$ol2 192.0.2.17/28
322 ip link
set mtu
$mtu dev
$h1
323 ip link
set mtu
$mtu dev
$ol1
324 ip link
set mtu
$mtu dev g1a
325 ip link
set mtu
$mtu dev
$ul1
326 ip link
set mtu
$mtu dev
$ul1.111
327 ip link
set mtu
$mtu dev
$h2
328 ip link
set mtu
$mtu dev
$ol2
329 ip link
set mtu
$mtu dev g2a
330 ip link
set mtu
$mtu dev
$ul2
331 ip link
set mtu
$mtu dev
$ul2.111
336 local encap
=$1; shift
340 ping_do
$h1 192.0.2.18 "-s 1800 -w 3"
341 check_fail $?
"ping $encap should not pass with size 1800"
346 ping_do
$h1 192.0.2.18 "-s 1800 -w 3"
348 log_test
"ping $encap packet size 1800 after MTU change"