2 # SPDX-License-Identifier: GPL-2.0
4 # Check that route PMTU values match expectations, and that initial device MTU
5 # values are assigned correctly
7 # Tests currently implemented:
10 # Set up two namespaces, A and B, with two paths between them over routers
11 # R1 and R2 (also implemented with namespaces), with different MTUs:
13 # segment a_r1 segment b_r1 a_r1: 2000
14 # .--------------R1--------------. b_r1: 1400
16 # '--------------R2--------------' b_r2: 1500
17 # segment a_r2 segment b_r2
19 # Check that PMTU exceptions with the correct PMTU are created. Then
20 # decrease and increase the MTU of the local link for one of the paths,
21 # A to R1, checking that route exception PMTU changes accordingly over
22 # this path. Also check that locked exceptions are created when an ICMP
23 # message advertising a PMTU smaller than net.ipv4.route.min_pmtu is
27 # Same as pmtu_ipv4, except for locked PMTU tests, using IPv6
29 # - pmtu_ipv4_vxlan4_exception
30 # Set up the same network topology as pmtu_ipv4, create a VXLAN tunnel
31 # over IPv4 between A and B, routed via R1. On the link between R1 and B,
32 # set a MTU lower than the VXLAN MTU and the MTU on the link between A and
33 # R1. Send IPv4 packets, exceeding the MTU between R1 and B, over VXLAN
34 # from A to B and check that the PMTU exception is created with the right
37 # - pmtu_ipv6_vxlan4_exception
38 # Same as pmtu_ipv4_vxlan4_exception, but send IPv6 packets from A to B
40 # - pmtu_ipv4_vxlan6_exception
41 # Same as pmtu_ipv4_vxlan4_exception, but use IPv6 transport from A to B
43 # - pmtu_ipv6_vxlan6_exception
44 # Same as pmtu_ipv4_vxlan6_exception, but send IPv6 packets from A to B
46 # - pmtu_ipv4_geneve4_exception
47 # Same as pmtu_ipv4_vxlan4_exception, but using a GENEVE tunnel instead of
50 # - pmtu_ipv6_geneve4_exception
51 # Same as pmtu_ipv6_vxlan4_exception, but using a GENEVE tunnel instead of
54 # - pmtu_ipv4_geneve6_exception
55 # Same as pmtu_ipv4_vxlan6_exception, but using a GENEVE tunnel instead of
58 # - pmtu_ipv6_geneve6_exception
59 # Same as pmtu_ipv6_vxlan6_exception, but using a GENEVE tunnel instead of
62 # - pmtu_ipv{4,6}_br_vxlan{4,6}_exception
63 # Set up three namespaces, A, B, and C, with routing between A and B over
64 # R1. R2 is unused in these tests. A has a veth connection to C, and is
65 # connected to B via a VXLAN endpoint, which is directly bridged to C.
66 # MTU on the B-R1 link is lower than other MTUs.
68 # Check that both C and A are able to communicate with B over the VXLAN
69 # tunnel, and that PMTU exceptions with the correct values are created.
71 # segment a_r1 segment b_r1 b_r1: 4000
72 # .--------------R1--------------. everything
73 # C---veth A B else: 5000
75 # '---- - - - - - VXLAN - - - - - - - '
77 # - pmtu_ipv{4,6}_br_geneve{4,6}_exception
78 # Same as pmtu_ipv{4,6}_br_vxlan{4,6}_exception, with a GENEVE tunnel
81 # - pmtu_ipv{4,6}_ovs_vxlan{4,6}_exception
82 # Set up two namespaces, B, and C, with routing between the init namespace
83 # and B over R1. A and R2 are unused in these tests. The init namespace
84 # has a veth connection to C, and is connected to B via a VXLAN endpoint,
85 # which is handled by Open vSwitch and bridged to C. MTU on the B-R1 link
86 # is lower than other MTUs.
88 # Check that C is able to communicate with B over the VXLAN tunnel, and
89 # that PMTU exceptions with the correct values are created.
91 # segment a_r1 segment b_r1 b_r1: 4000
92 # .--------------R1--------------. everything
93 # C---veth init B else: 5000
95 # '---- - - - - - VXLAN - - - - - - - '
97 # - pmtu_ipv{4,6}_ovs_geneve{4,6}_exception
98 # Same as pmtu_ipv{4,6}_ovs_vxlan{4,6}_exception, with a GENEVE tunnel
101 # - pmtu_ipv{4,6}_fou{4,6}_exception
102 # Same as pmtu_ipv4_vxlan4, but using a direct IPv4/IPv6 encapsulation
103 # (FoU) over IPv4/IPv6, instead of VXLAN
105 # - pmtu_ipv{4,6}_fou{4,6}_exception
106 # Same as pmtu_ipv4_vxlan4, but using a generic UDP IPv4/IPv6
107 # encapsulation (GUE) over IPv4/IPv6, instead of VXLAN
109 # - pmtu_ipv{4,6}_ipv{4,6}_exception
110 # Same as pmtu_ipv4_vxlan4, but using a IPv4/IPv6 tunnel over IPv4/IPv6,
113 # - pmtu_vti4_exception
114 # Set up vti tunnel on top of veth, with xfrm states and policies, in two
115 # namespaces with matching endpoints. Check that route exception is not
116 # created if link layer MTU is not exceeded, then exceed it and check that
117 # exception is created with the expected PMTU. The approach described
118 # below for IPv6 doesn't apply here, because, on IPv4, administrative MTU
119 # changes alone won't affect PMTU
121 # - pmtu_vti6_exception
122 # Set up vti6 tunnel on top of veth, with xfrm states and policies, in two
123 # namespaces with matching endpoints. Check that route exception is
124 # created by exceeding link layer MTU with ping to other endpoint. Then
125 # decrease and increase MTU of tunnel, checking that route exception PMTU
126 # changes accordingly
128 # - pmtu_vti4_default_mtu
129 # Set up vti4 tunnel on top of veth, in two namespaces with matching
130 # endpoints. Check that MTU assigned to vti interface is the MTU of the
131 # lower layer (veth) minus additional lower layer headers (zero, for veth)
132 # minus IPv4 header length
134 # - pmtu_vti6_default_mtu
135 # Same as above, for IPv6
137 # - pmtu_vti4_link_add_mtu
138 # Set up vti4 interface passing MTU value at link creation, check MTU is
139 # configured, and that link is not created with invalid MTU values
141 # - pmtu_vti6_link_add_mtu
142 # Same as above, for IPv6
144 # - pmtu_vti6_link_change_mtu
145 # Set up two dummy interfaces with different MTUs, create a vti6 tunnel
146 # and check that configured MTU is used on link creation and changes, and
147 # that MTU is properly calculated instead when MTU is not configured from
150 # - cleanup_ipv4_exception
151 # Similar to pmtu_ipv4_vxlan4_exception, but explicitly generate PMTU
152 # exceptions on multiple CPUs and check that the veth device tear-down
153 # happens in a timely manner
155 # - cleanup_ipv6_exception
156 # Same as above, but use IPv6 transport from A to B
158 # - list_flush_ipv4_exception
159 # Using the same topology as in pmtu_ipv4, create exceptions, and check
160 # they are shown when listing exception caches, gone after flushing them
162 # - list_flush_ipv6_exception
163 # Using the same topology as in pmtu_ipv6, create exceptions, and check
164 # they are shown when listing exception caches, gone after flushing them
166 # - pmtu_ipv4_route_change
167 # Use the same topology as in pmtu_ipv4, but issue a route replacement
168 # command and delete the corresponding device afterward. This tests for
169 # proper cleanup of the PMTU exceptions by the route replacement path.
170 # Device unregistration should complete successfully
172 # - pmtu_ipv6_route_change
173 # Same as above but with IPv6
175 # Kselftest framework requirement - SKIP code is 4.
182 # Some systems don't have a ping6 binary anymore
183 which ping6
> /dev
/null
2>&1 && ping6
=$
(which ping6
) || ping6
=$
(which ping)
185 # Name Description re-run with nh
187 pmtu_ipv4_exception ipv4: PMTU exceptions 1
188 pmtu_ipv6_exception ipv6: PMTU exceptions 1
189 pmtu_ipv4_vxlan4_exception IPv4 over vxlan4: PMTU exceptions 1
190 pmtu_ipv6_vxlan4_exception IPv6 over vxlan4: PMTU exceptions 1
191 pmtu_ipv4_vxlan6_exception IPv4 over vxlan6: PMTU exceptions 1
192 pmtu_ipv6_vxlan6_exception IPv6 over vxlan6: PMTU exceptions 1
193 pmtu_ipv4_geneve4_exception IPv4 over geneve4: PMTU exceptions 1
194 pmtu_ipv6_geneve4_exception IPv6 over geneve4: PMTU exceptions 1
195 pmtu_ipv4_geneve6_exception IPv4 over geneve6: PMTU exceptions 1
196 pmtu_ipv6_geneve6_exception IPv6 over geneve6: PMTU exceptions 1
197 pmtu_ipv4_br_vxlan4_exception IPv4, bridged vxlan4: PMTU exceptions 1
198 pmtu_ipv6_br_vxlan4_exception IPv6, bridged vxlan4: PMTU exceptions 1
199 pmtu_ipv4_br_vxlan6_exception IPv4, bridged vxlan6: PMTU exceptions 1
200 pmtu_ipv6_br_vxlan6_exception IPv6, bridged vxlan6: PMTU exceptions 1
201 pmtu_ipv4_br_geneve4_exception IPv4, bridged geneve4: PMTU exceptions 1
202 pmtu_ipv6_br_geneve4_exception IPv6, bridged geneve4: PMTU exceptions 1
203 pmtu_ipv4_br_geneve6_exception IPv4, bridged geneve6: PMTU exceptions 1
204 pmtu_ipv6_br_geneve6_exception IPv6, bridged geneve6: PMTU exceptions 1
205 pmtu_ipv4_ovs_vxlan4_exception IPv4, OVS vxlan4: PMTU exceptions 1
206 pmtu_ipv6_ovs_vxlan4_exception IPv6, OVS vxlan4: PMTU exceptions 1
207 pmtu_ipv4_ovs_vxlan6_exception IPv4, OVS vxlan6: PMTU exceptions 1
208 pmtu_ipv6_ovs_vxlan6_exception IPv6, OVS vxlan6: PMTU exceptions 1
209 pmtu_ipv4_ovs_geneve4_exception IPv4, OVS geneve4: PMTU exceptions 1
210 pmtu_ipv6_ovs_geneve4_exception IPv6, OVS geneve4: PMTU exceptions 1
211 pmtu_ipv4_ovs_geneve6_exception IPv4, OVS geneve6: PMTU exceptions 1
212 pmtu_ipv6_ovs_geneve6_exception IPv6, OVS geneve6: PMTU exceptions 1
213 pmtu_ipv4_fou4_exception IPv4 over fou4: PMTU exceptions 1
214 pmtu_ipv6_fou4_exception IPv6 over fou4: PMTU exceptions 1
215 pmtu_ipv4_fou6_exception IPv4 over fou6: PMTU exceptions 1
216 pmtu_ipv6_fou6_exception IPv6 over fou6: PMTU exceptions 1
217 pmtu_ipv4_gue4_exception IPv4 over gue4: PMTU exceptions 1
218 pmtu_ipv6_gue4_exception IPv6 over gue4: PMTU exceptions 1
219 pmtu_ipv4_gue6_exception IPv4 over gue6: PMTU exceptions 1
220 pmtu_ipv6_gue6_exception IPv6 over gue6: PMTU exceptions 1
221 pmtu_ipv4_ipv4_exception IPv4 over IPv4: PMTU exceptions 1
222 pmtu_ipv6_ipv4_exception IPv6 over IPv4: PMTU exceptions 1
223 pmtu_ipv4_ipv6_exception IPv4 over IPv6: PMTU exceptions 1
224 pmtu_ipv6_ipv6_exception IPv6 over IPv6: PMTU exceptions 1
225 pmtu_vti6_exception vti6: PMTU exceptions 0
226 pmtu_vti4_exception vti4: PMTU exceptions 0
227 pmtu_vti4_default_mtu vti4: default MTU assignment 0
228 pmtu_vti6_default_mtu vti6: default MTU assignment 0
229 pmtu_vti4_link_add_mtu vti4: MTU setting on link creation 0
230 pmtu_vti6_link_add_mtu vti6: MTU setting on link creation 0
231 pmtu_vti6_link_change_mtu vti6: MTU changes on link changes 0
232 cleanup_ipv4_exception ipv4: cleanup of cached exceptions 1
233 cleanup_ipv6_exception ipv6: cleanup of cached exceptions 1
234 list_flush_ipv4_exception ipv4: list and flush cached exceptions 1
235 list_flush_ipv6_exception ipv6: list and flush cached exceptions 1
236 pmtu_ipv4_route_change ipv4: PMTU exception w/route replace 1
237 pmtu_ipv6_route_change ipv6: PMTU exception w/route replace 1"
244 ns_a
="ip netns exec ${NS_A}"
245 ns_b
="ip netns exec ${NS_B}"
246 ns_c
="ip netns exec ${NS_C}"
247 ns_r1
="ip netns exec ${NS_R1}"
248 ns_r2
="ip netns exec ${NS_R2}"
250 # Addressing and routing for tests with routers: four network segments, with
251 # index SEGMENT between 1 and 4, a common prefix (PREFIX4 or PREFIX6) and an
252 # identifier ID, which is 1 for hosts (A and B), 2 for routers (R1 and R2).
254 # - IPv4: PREFIX4.SEGMENT.ID (/24)
255 # - IPv6: PREFIX6:SEGMENT::ID (/64)
269 # Traffic from A to B goes through R1 by default, and through R2, if destined to
270 # B's address on the b_r2 segment.
271 # Traffic from B to A goes through R1.
272 # ns destination gateway
274 A default ${prefix4}.${a_r1}.2
275 A ${prefix4}.${b_r2}.1 ${prefix4}.${a_r2}.2
276 B default ${prefix4}.${b_r1}.2
278 A default ${prefix6}:${a_r1}::2
279 A ${prefix6}:${b_r2}::1 ${prefix6}:${a_r2}::2
280 B default ${prefix6}:${b_r1}::2
284 # ns family nh id destination gateway
286 A 4 41 ${prefix4}.${a_r1}.2 veth_A-R1
287 A 4 42 ${prefix4}.${a_r2}.2 veth_A-R2
288 B 4 41 ${prefix4}.${b_r1}.2 veth_B-R1
290 A 6 61 ${prefix6}:${a_r1}::2 veth_A-R1
291 A 6 62 ${prefix6}:${a_r2}::2 veth_A-R2
292 B 6 61 ${prefix6}:${b_r1}::2 veth_B-R1
295 # nexthop id correlates to id in nexthops config above
296 # ns family prefix nh id
299 A 4 ${prefix4}.${b_r2}.1 42
303 A 6 ${prefix6}:${b_r2}::1 62
307 veth4_a_addr
="192.168.1.1"
308 veth4_b_addr
="192.168.1.2"
309 veth4_c_addr
="192.168.2.10"
311 veth6_a_addr
="fd00:1::a"
312 veth6_b_addr
="fd00:1::b"
313 veth6_c_addr
="fd00:2::c"
316 tunnel4_a_addr
="192.168.2.1"
317 tunnel4_b_addr
="192.168.2.2"
319 tunnel6_a_addr
="fd00:2::a"
320 tunnel6_b_addr
="fd00:2::b"
323 dummy6_0_prefix
="fc00:1000::"
324 dummy6_1_prefix
="fc00:1001::"
331 err_buf
="${err_buf}${1}
343 if [ "$VERBOSE" = "1" ]; then
344 printf " COMMAND: $cmd\n"
349 if [ "$VERBOSE" = "1" -a -n "$out" ]; then
357 # Find the auto-generated name for this namespace
367 if [ "${outer}" = "4" ]; then
368 modprobe fou ||
return $ksft_skip
369 a_addr
="${prefix4}.${a_r1}.1"
370 b_addr
="${prefix4}.${b_r1}.1"
371 if [ "${inner}" = "4" ]; then
379 modprobe fou6 ||
return $ksft_skip
380 a_addr
="${prefix6}:${a_r1}::1"
381 b_addr
="${prefix6}:${b_r1}::1"
382 if [ "${inner}" = "4" ]; then
393 run_cmd
${ns_a} ip fou add port
5555 ipproto
${ipproto} ||
return $ksft_skip
394 run_cmd
${ns_a} ip link add ${encap}_a type ${type} ${mode} local ${a_addr} remote ${b_addr} encap ${encap} encap-sport auto encap-dport
5556 ||
return $ksft_skip
396 run_cmd
${ns_b} ip fou add port
5556 ipproto
${ipproto}
397 run_cmd
${ns_b} ip link add ${encap}_b type ${type} ${mode} local ${b_addr} remote ${a_addr} encap ${encap} encap-sport auto encap-dport
5555
399 if [ "${inner}" = "4" ]; then
400 run_cmd
${ns_a} ip addr add ${tunnel4_a_addr}/${tunnel4_mask} dev ${encap}_a
401 run_cmd
${ns_b} ip addr add ${tunnel4_b_addr}/${tunnel4_mask} dev ${encap}_b
403 run_cmd
${ns_a} ip addr add ${tunnel6_a_addr}/${tunnel6_mask} dev ${encap}_a
404 run_cmd
${ns_b} ip addr add ${tunnel6_b_addr}/${tunnel6_mask} dev ${encap}_b
407 run_cmd
${ns_a} ip link
set ${encap}_a up
408 run_cmd
${ns_b} ip link
set ${encap}_b up
412 setup_fou_or_gue
4 4 fou
416 setup_fou_or_gue
4 6 fou
420 setup_fou_or_gue
6 4 fou
424 setup_fou_or_gue
6 6 fou
428 setup_fou_or_gue
4 4 gue
432 setup_fou_or_gue
4 6 gue
436 setup_fou_or_gue
6 4 gue
440 setup_fou_or_gue
6 6 gue
443 setup_ipvX_over_ipvY
() {
447 if [ "${outer}" -eq 4 ]; then
448 a_addr
="${prefix4}.${a_r1}.1"
449 b_addr
="${prefix4}.${b_r1}.1"
450 if [ "${inner}" -eq 4 ]; then
458 a_addr
="${prefix6}:${a_r1}::1"
459 b_addr
="${prefix6}:${b_r1}::1"
461 if [ "${inner}" -eq 4 ]; then
468 run_cmd
${ns_a} ip link add ip_a type ${type} local ${a_addr} remote ${b_addr} mode ${mode} ||
return $ksft_skip
469 run_cmd
${ns_b} ip link add ip_b type ${type} local ${b_addr} remote ${a_addr} mode ${mode}
471 run_cmd
${ns_a} ip link
set ip_a up
472 run_cmd
${ns_b} ip link
set ip_b up
474 if [ "${inner}" = "4" ]; then
475 run_cmd
${ns_a} ip addr add ${tunnel4_a_addr}/${tunnel4_mask} dev ip_a
476 run_cmd
${ns_b} ip addr add ${tunnel4_b_addr}/${tunnel4_mask} dev ip_b
478 run_cmd
${ns_a} ip addr add ${tunnel6_a_addr}/${tunnel6_mask} dev ip_a
479 run_cmd
${ns_b} ip addr add ${tunnel6_b_addr}/${tunnel6_mask} dev ip_b
484 setup_ipvX_over_ipvY
4 4
488 setup_ipvX_over_ipvY
6 4
492 setup_ipvX_over_ipvY
4 6
496 setup_ipvX_over_ipvY
6 6
500 for n
in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do
501 ip netns add
${n} ||
return 1
503 # Disable DAD, so that we don't have to wait to use the
504 # configured IPv6 addresses
505 ip netns
exec ${n} sysctl
-q net
/ipv
6/conf
/default
/accept_dad
=0
510 run_cmd
${ns_a} ip link add veth_a
type veth peer name veth_b ||
return 1
511 run_cmd
${ns_a} ip link
set veth_b netns
${NS_B}
513 run_cmd
${ns_a} ip addr add ${veth4_a_addr}/${veth4_mask} dev veth_a
514 run_cmd
${ns_b} ip addr add ${veth4_b_addr}/${veth4_mask} dev veth_b
516 run_cmd
${ns_a} ip addr add ${veth6_a_addr}/${veth6_mask} dev veth_a
517 run_cmd
${ns_b} ip addr add ${veth6_b_addr}/${veth6_mask} dev veth_b
519 run_cmd
${ns_a} ip link
set veth_a up
520 run_cmd
${ns_b} ip link
set veth_b up
531 [ ${proto} -eq 6 ] && vti_type
="vti6" || vti_type
="vti"
533 run_cmd
${ns_a} ip link add vti${proto}_a type ${vti_type} local ${veth_a_addr} remote ${veth_b_addr} key
10 ||
return 1
534 run_cmd
${ns_b} ip link add vti${proto}_b type ${vti_type} local ${veth_b_addr} remote ${veth_a_addr} key
10
536 run_cmd
${ns_a} ip addr add ${vti_a_addr}/${vti_mask} dev vti${proto}_a
537 run_cmd
${ns_b} ip addr add ${vti_b_addr}/${vti_mask} dev vti${proto}_b
539 run_cmd
${ns_a} ip link
set vti
${proto}_a up
540 run_cmd
${ns_b} ip link
set vti
${proto}_b up
544 setup_vti
4 ${veth4_a_addr} ${veth4_b_addr} ${tunnel4_a_addr} ${tunnel4_b_addr} ${tunnel4_mask}
548 setup_vti
6 ${veth6_a_addr} ${veth6_b_addr} ${tunnel6_a_addr} ${tunnel6_b_addr} ${tunnel6_mask}
551 setup_vxlan_or_geneve
() {
558 if [ "${type}" = "vxlan" ]; then
559 opts
="${opts} ttl 64 dstport 4789"
560 opts_a
="local ${a_addr}"
561 opts_b
="local ${b_addr}"
567 run_cmd
${ns_a} ip link add ${type}_a type ${type} id 1 ${opts_a} remote ${b_addr} ${opts} ||
return 1
568 run_cmd
${ns_b} ip link add ${type}_b type ${type} id 1 ${opts_b} remote ${a_addr} ${opts}
570 if [ -n "${br_if_a}" ]; then
571 run_cmd
${ns_a} ip addr add ${tunnel4_a_addr}/${tunnel4_mask} dev ${br_if_a}
572 run_cmd
${ns_a} ip addr add ${tunnel6_a_addr}/${tunnel6_mask} dev ${br_if_a}
573 run_cmd
${ns_a} ip link set ${type}_a master ${br_if_a}
575 run_cmd
${ns_a} ip addr add ${tunnel4_a_addr}/${tunnel4_mask} dev ${type}_a
576 run_cmd
${ns_a} ip addr add ${tunnel6_a_addr}/${tunnel6_mask} dev ${type}_a
579 run_cmd
${ns_b} ip addr add ${tunnel4_b_addr}/${tunnel4_mask} dev ${type}_b
580 run_cmd
${ns_b} ip addr add ${tunnel6_b_addr}/${tunnel6_mask} dev ${type}_b
582 run_cmd
${ns_a} ip link
set ${type}_a up
583 run_cmd
${ns_b} ip link
set ${type}_b up
587 setup_vxlan_or_geneve geneve
${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1 "df set"
591 setup_vxlan_or_geneve vxlan
${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1 "df set"
595 setup_vxlan_or_geneve geneve
${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1 ""
599 setup_vxlan_or_geneve vxlan
${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1 ""
602 setup_bridged_geneve4
() {
603 setup_vxlan_or_geneve geneve
${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1 "df set" "br0"
606 setup_bridged_vxlan4
() {
607 setup_vxlan_or_geneve vxlan
${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1 "df set" "br0"
610 setup_bridged_geneve6
() {
611 setup_vxlan_or_geneve geneve
${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1 "" "br0"
614 setup_bridged_vxlan6
() {
615 setup_vxlan_or_geneve vxlan
${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1 "" "br0"
623 run_cmd
${ns_a} ip -${proto} xfrm state add src ${veth_a_addr} dst ${veth_b_addr} spi
0x1000 proto esp aead
'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel ||
return 1
624 run_cmd
${ns_a} ip -${proto} xfrm state add src ${veth_b_addr} dst ${veth_a_addr} spi
0x1001 proto esp aead
'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel
625 run_cmd
${ns_a} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel
626 run_cmd
${ns_a} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel
628 run_cmd
${ns_b} ip -${proto} xfrm state add src ${veth_a_addr} dst ${veth_b_addr} spi
0x1000 proto esp aead
'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel
629 run_cmd
${ns_b} ip -${proto} xfrm state add src ${veth_b_addr} dst ${veth_a_addr} spi
0x1001 proto esp aead
'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel
630 run_cmd
${ns_b} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel
631 run_cmd
${ns_b} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel
635 setup_xfrm
4 ${veth4_a_addr} ${veth4_b_addr}
639 setup_xfrm
6 ${veth6_a_addr} ${veth6_b_addr}
642 setup_routing_old
() {
643 for i
in ${routes}; do
644 [ "${ns}" = "" ] && ns
="${i}" && continue
645 [ "${addr}" = "" ] && addr
="${i}" && continue
646 [ "${gw}" = "" ] && gw
="${i}"
648 ns_name
="$(nsname ${ns})"
650 ip
-n ${ns_name} route add ${addr} via ${gw}
652 ns
=""; addr
=""; gw
=""
656 setup_routing_new
() {
657 for i
in ${nexthops}; do
658 [ "${ns}" = "" ] && ns
="${i}" && continue
659 [ "${fam}" = "" ] && fam
="${i}" && continue
660 [ "${nhid}" = "" ] && nhid
="${i}" && continue
661 [ "${gw}" = "" ] && gw
="${i}" && continue
662 [ "${dev}" = "" ] && dev
="${i}"
664 ns_name
="$(nsname ${ns})"
666 ip
-n ${ns_name} -${fam} nexthop add id ${nhid} via ${gw} dev ${dev}
668 ns
=""; fam
=""; nhid
=""; gw
=""; dev
=""
672 for i
in ${routes_nh}; do
673 [ "${ns}" = "" ] && ns
="${i}" && continue
674 [ "${fam}" = "" ] && fam
="${i}" && continue
675 [ "${addr}" = "" ] && addr
="${i}" && continue
676 [ "${nhid}" = "" ] && nhid
="${i}"
678 ns_name
="$(nsname ${ns})"
680 ip
-n ${ns_name} -${fam} route add ${addr} nhid ${nhid}
682 ns
=""; fam
=""; addr
=""; nhid
=""
687 for i
in ${NS_R1} ${NS_R2}; do
688 ip netns
exec ${i} sysctl
-q net
/ipv
4/ip_forward
=1
689 ip netns
exec ${i} sysctl
-q net
/ipv
6/conf
/all
/forwarding
=1
692 for i
in ${routing_addrs}; do
693 [ "${ns}" = "" ] && ns
="${i}" && continue
694 [ "${peer}" = "" ] && peer
="${i}" && continue
695 [ "${segment}" = "" ] && segment
="${i}"
697 ns_name
="$(nsname ${ns})"
698 peer_name
="$(nsname ${peer})"
699 if="veth_${ns}-${peer}"
700 ifpeer
="veth_${peer}-${ns}"
703 ip link add
${if} up netns ${ns_name} type veth peer name ${ifpeer} netns ${peer_name} ||
return 1
704 ip
-n ${peer_name} link
set dev
${ifpeer} up
707 ip
-n ${ns_name} addr add ${prefix4}.${segment}.1/24 dev ${if}
708 ip
-n ${ns_name} addr add ${prefix6}:${segment}::1/64 dev ${if}
710 ip
-n ${peer_name} addr add ${prefix4}.${segment}.2/24 dev ${ifpeer}
711 ip
-n ${peer_name} addr add ${prefix6}:${segment}::2/64 dev ${ifpeer}
713 ns
=""; peer
=""; segment
=""
716 if [ "$USE_NH" = "yes" ]; then
726 run_cmd
${ns_a} ip link add br0
type bridge ||
return $ksft_skip
727 run_cmd
${ns_a} ip link
set br0 up
729 run_cmd
${ns_c} ip link add veth_C-A
type veth peer name veth_A-C
730 run_cmd
${ns_c} ip link
set veth_A-C netns ns-A
732 run_cmd
${ns_a} ip link
set veth_A-C up
733 run_cmd
${ns_c} ip link
set veth_C-A up
734 run_cmd
${ns_c} ip addr add ${veth4_c_addr}/${veth4_mask} dev veth_C-A
735 run_cmd
${ns_c} ip addr add ${veth6_c_addr}/${veth6_mask} dev veth_C-A
736 run_cmd
${ns_a} ip link
set veth_A-C master br0
739 setup_ovs_vxlan_or_geneve
() {
744 if [ "${type}" = "vxlan" ]; then
745 opts
="${opts} ttl 64 dstport 4789"
746 opts_b
="local ${b_addr}"
749 run_cmd ovs-vsctl add-port ovs_br0
${type}_a
-- \
750 set interface
${type}_a
type=${type} \
751 options
:remote_ip
=${b_addr} options
:key
=1 options
:csum
=true ||
return 1
753 run_cmd
${ns_b} ip link add ${type}_b type ${type} id 1 ${opts_b} remote ${a_addr} ${opts} ||
return 1
755 run_cmd
${ns_b} ip addr add ${tunnel4_b_addr}/${tunnel4_mask} dev ${type}_b
756 run_cmd
${ns_b} ip addr add ${tunnel6_b_addr}/${tunnel6_mask} dev ${type}_b
758 run_cmd
${ns_b} ip link
set ${type}_b up
761 setup_ovs_geneve4
() {
762 setup_ovs_vxlan_or_geneve geneve
${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1
766 setup_ovs_vxlan_or_geneve vxlan
${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1
769 setup_ovs_geneve6
() {
770 setup_ovs_vxlan_or_geneve geneve
${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1
774 setup_ovs_vxlan_or_geneve vxlan
${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1
778 run_cmd ovs-vsctl add-br ovs_br0 ||
return $ksft_skip
779 run_cmd ip link
set ovs_br0 up
781 run_cmd
${ns_c} ip link add veth_C-A
type veth peer name veth_A-C
782 run_cmd
${ns_c} ip link
set veth_A-C netns
1
784 run_cmd ip link
set veth_A-C up
785 run_cmd
${ns_c} ip link
set veth_C-A up
786 run_cmd
${ns_c} ip addr add ${veth4_c_addr}/${veth4_mask} dev veth_C-A
787 run_cmd
${ns_c} ip addr add ${veth6_c_addr}/${veth6_mask} dev veth_C-A
788 run_cmd ovs-vsctl add-port ovs_br0 veth_A-C
790 # Move veth_A-R1 to init
791 run_cmd
${ns_a} ip link
set veth_A-R1 netns
1
792 run_cmd ip addr add
${prefix4}.${a_r1}.1/${veth4_mask} dev veth_A-R1
793 run_cmd ip addr add
${prefix6}:${a_r1}::1/${veth6_mask} dev veth_A-R1
794 run_cmd ip link
set veth_A-R1 up
795 run_cmd ip route add
${prefix4}.${b_r1}.1 via ${prefix4}.${a_r1}.2
796 run_cmd ip route add
${prefix6}:${b_r1}::1 via ${prefix6}:${a_r1}::2
800 [ "$(id -u)" -ne 0 ] && echo " need to run as root" && return $ksft_skip
804 eval setup_
${arg} || { echo " ${arg} not supported"; return 1; }
809 [ $TRACING -eq 0 ] && return
812 [ "${ns_cmd}" = "" ] && ns_cmd
="${arg}" && continue
813 ${ns_cmd} tcpdump -s 0 -i "${arg}" -w "${name}_${arg}.pcap
" 2> /dev/null &
814 tcpdump_pids="${tcpdump_pids} $
!"
821 for pid in ${tcpdump_pids}; do
826 for n in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do
827 ip netns del ${n} 2> /dev/null
830 ip link del veth_A-C 2>/dev/null
831 ip link del veth_A-R1 2>/dev/null
832 ovs-vsctl --if-exists del-port vxlan_a 2>/dev/null
833 ovs-vsctl --if-exists del-br ovs_br0 2>/dev/null
841 ${ns_cmd} ip link set dev ${dev} mtu ${mtu}
848 for i in ${input}; do
849 [ ${next} -eq 1 -a "${i}" = "lock
" ] && next=2 && continue
850 [ ${next} -eq 1 ] && echo "${i}" && return
851 [ ${next} -eq 2 ] && echo "lock
${i}" && return
852 [ "${i}" = "mtu
" ] && next=1
860 ${ns_cmd} ip link show dev "${name}"
867 mtu_parse "$
(link_get
"${ns_cmd}" ${name})"
870 route_get_dst_exception() {
874 ${ns_cmd} ip route get "${dst}"
877 route_get_dst_pmtu_from_exception() {
881 mtu_parse "$
(route_get_dst_exception
"${ns_cmd}" ${dst})"
889 [ "${expected}" = "any
" ] && [ -n "${value}" ] && return 0
890 [ "${value}" = "${expected}" ] && return 0
891 [ -z "${value}" ] && err " PMTU exception wasn
't created after ${event}" && return 1
892 [ -z "${expected}" ] && err " PMTU exception shouldn't exist after
${event}" && return 1
893 err " found PMTU exception with incorrect MTU
${value}, expected ${expected}, after ${event}"
900 setup namespaces routing || return $ksft_skip
901 trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
902 "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \
903 "${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \
904 "${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2
906 if [ ${family} -eq 4 ]; then
908 dst1="${prefix4}.
${b_r1}.1"
909 dst2="${prefix4}.
${b_r2}.1"
912 dst1="${prefix6}:${b_r1}::1"
913 dst2="${prefix6}:${b_r2}::1"
916 # Set up initial MTU values
917 mtu "${ns_a}" veth_A-R1 2000
918 mtu "${ns_r1}" veth_R1-A 2000
919 mtu "${ns_r1}" veth_R1-B 1400
920 mtu "${ns_b}" veth_B-R1 1400
922 mtu "${ns_a}" veth_A-R2 2000
923 mtu "${ns_r2}" veth_R2-A 2000
924 mtu "${ns_r2}" veth_R2-B 1500
925 mtu "${ns_b}" veth_B-R2 1500
927 # Create route exceptions
928 run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1800 ${dst1}
929 run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1800 ${dst2}
931 # Check that exceptions have been created with the correct PMTU
932 pmtu_1="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst1})"
933 check_pmtu_value "1400" "${pmtu_1}" "exceeding MTU
" || return 1
934 pmtu_2="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst2})"
935 check_pmtu_value "1500" "${pmtu_2}" "exceeding MTU
" || return 1
937 # Decrease local MTU below PMTU, check for PMTU decrease in route exception
938 mtu "${ns_a}" veth_A-R1 1300
939 mtu "${ns_r1}" veth_R1-A 1300
940 pmtu_1="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst1})"
941 check_pmtu_value "1300" "${pmtu_1}" "decreasing
local MTU
" || return 1
942 # Second exception shouldn't be modified
943 pmtu_2="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst2})"
944 check_pmtu_value "1500" "${pmtu_2}" "changing
local MTU on a link not on this path
" || return 1
946 # Increase MTU, check for PMTU increase in route exception
947 mtu "${ns_a}" veth_A-R1 1700
948 mtu "${ns_r1}" veth_R1-A 1700
949 pmtu_1="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst1})"
950 check_pmtu_value "1700" "${pmtu_1}" "increasing
local MTU
" || return 1
951 # Second exception shouldn't be modified
952 pmtu_2="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst2})"
953 check_pmtu_value "1500" "${pmtu_2}" "changing
local MTU on a link not on this path
" || return 1
955 # Skip PMTU locking tests for IPv6
956 [ $family -eq 6 ] && return 0
958 # Decrease remote MTU on path via R2, get new exception
959 mtu "${ns_r2}" veth_R2-B 400
960 mtu "${ns_b}" veth_B-R2 400
961 run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1400 ${dst2}
962 pmtu_2="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst2})"
963 check_pmtu_value "lock
552" "${pmtu_2}" "exceeding MTU
, with MTU
< min_pmtu
" || return 1
965 # Decrease local MTU below PMTU
966 mtu "${ns_a}" veth_A-R2 500
967 mtu "${ns_r2}" veth_R2-A 500
968 pmtu_2="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst2})"
969 check_pmtu_value "500" "${pmtu_2}" "decreasing
local MTU
" || return 1
972 mtu "${ns_a}" veth_A-R2 1500
973 mtu "${ns_r2}" veth_R2-A 1500
974 pmtu_2="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst2})"
975 check_pmtu_value "1500" "${pmtu_2}" "increasing
local MTU
" || return 1
978 run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1400 ${dst2}
979 pmtu_2="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst2})"
980 check_pmtu_value "lock
552" "${pmtu_2}" "exceeding MTU
, with MTU
< min_pmtu
" || return 1
983 test_pmtu_ipv4_exception() {
987 test_pmtu_ipv6_exception() {
991 test_pmtu_ipvX_over_vxlanY_or_geneveY_exception() {
997 if [ ${outer_family} -eq 4 ]; then
998 setup namespaces routing ${type}4 || return $ksft_skip
999 # IPv4 header UDP header VXLAN/GENEVE header Ethernet header
1000 exp_mtu=$((${ll_mtu} - 20 - 8 - 8 - 14))
1002 setup namespaces routing ${type}6 || return $ksft_skip
1003 # IPv6 header UDP header VXLAN/GENEVE header Ethernet header
1004 exp_mtu=$((${ll_mtu} - 40 - 8 - 8 - 14))
1007 trace "${ns_a}" ${type}_a "${ns_b}" ${type}_b \
1008 "${ns_a}" veth_A-R1
"${ns_r1}" veth_R1-A \
1009 "${ns_b}" veth_B-R1
"${ns_r1}" veth_R1-B
1011 if [ ${family} -eq 4 ]; then
1013 dst
=${tunnel4_b_addr}
1016 dst
=${tunnel6_b_addr}
1019 # Create route exception by exceeding link layer MTU
1020 mtu
"${ns_a}" veth_A-R1 $
((${ll_mtu} + 1000))
1021 mtu
"${ns_r1}" veth_R1-A $
((${ll_mtu} + 1000))
1022 mtu
"${ns_b}" veth_B-R1
${ll_mtu}
1023 mtu
"${ns_r1}" veth_R1-B
${ll_mtu}
1025 mtu
"${ns_a}" ${type}_a $((${ll_mtu} + 1000))
1026 mtu "${ns_b}" ${type}_b $((${ll_mtu} + 1000))
1027 run_cmd
${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst}
1029 # Check that exception was created
1030 pmtu
="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
1031 check_pmtu_value
${exp_mtu} "${pmtu}" "exceeding link layer MTU on ${type} interface
"
1034 test_pmtu_ipv4_vxlan4_exception() {
1035 test_pmtu_ipvX_over_vxlanY_or_geneveY_exception vxlan 4 4
1038 test_pmtu_ipv6_vxlan4_exception() {
1039 test_pmtu_ipvX_over_vxlanY_or_geneveY_exception vxlan 6 4
1042 test_pmtu_ipv4_geneve4_exception() {
1043 test_pmtu_ipvX_over_vxlanY_or_geneveY_exception geneve 4 4
1046 test_pmtu_ipv6_geneve4_exception() {
1047 test_pmtu_ipvX_over_vxlanY_or_geneveY_exception geneve 6 4
1050 test_pmtu_ipv4_vxlan6_exception() {
1051 test_pmtu_ipvX_over_vxlanY_or_geneveY_exception vxlan 4 6
1054 test_pmtu_ipv6_vxlan6_exception() {
1055 test_pmtu_ipvX_over_vxlanY_or_geneveY_exception vxlan 6 6
1058 test_pmtu_ipv4_geneve6_exception() {
1059 test_pmtu_ipvX_over_vxlanY_or_geneveY_exception geneve 4 6
1062 test_pmtu_ipv6_geneve6_exception() {
1063 test_pmtu_ipvX_over_vxlanY_or_geneveY_exception geneve 6 6
1066 test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception() {
1072 if [ ${outer_family} -eq 4 ]; then
1073 setup namespaces routing bridge bridged_${type}4 || return $ksft_skip
1074 # IPv4 header UDP header VXLAN/GENEVE header Ethernet header
1075 exp_mtu=$((${ll_mtu} - 20 - 8 - 8 - 14))
1077 setup namespaces routing bridge bridged_${type}6 || return $ksft_skip
1078 # IPv6 header UDP header VXLAN/GENEVE header Ethernet header
1079 exp_mtu=$((${ll_mtu} - 40 - 8 - 8 - 14))
1082 trace "${ns_a}" ${type}_a "${ns_b}" ${type}_b \
1083 "${ns_a}" veth_A-R1
"${ns_r1}" veth_R1-A \
1084 "${ns_b}" veth_B-R1
"${ns_r1}" veth_R1-B \
1085 "${ns_a}" br0
"${ns_a}" veth-A-C \
1088 if [ ${family} -eq 4 ]; then
1090 dst
=${tunnel4_b_addr}
1093 dst
=${tunnel6_b_addr}
1096 # Create route exception by exceeding link layer MTU
1097 mtu
"${ns_a}" veth_A-R1 $
((${ll_mtu} + 1000))
1098 mtu
"${ns_a}" br0 $
((${ll_mtu} + 1000))
1099 mtu
"${ns_a}" veth_A-C $
((${ll_mtu} + 1000))
1100 mtu
"${ns_c}" veth_C-A $
((${ll_mtu} + 1000))
1101 mtu
"${ns_r1}" veth_R1-A $
((${ll_mtu} + 1000))
1102 mtu
"${ns_b}" veth_B-R1
${ll_mtu}
1103 mtu
"${ns_r1}" veth_R1-B
${ll_mtu}
1105 mtu
"${ns_a}" ${type}_a $((${ll_mtu} + 1000))
1106 mtu "${ns_b}" ${type}_b $((${ll_mtu} + 1000))
1108 run_cmd
${ns_c} ${ping} -q -M want -i 0.1 -c 10 -s $((${ll_mtu} + 500)) ${dst} ||
return 1
1109 run_cmd
${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst} ||
return 1
1111 # Check that exceptions were created
1112 pmtu
="$(route_get_dst_pmtu_from_exception "${ns_c}" ${dst})"
1113 check_pmtu_value
${exp_mtu} "${pmtu}" "exceeding link layer MTU on bridged ${type} interface
"
1114 pmtu="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst})"
1115 check_pmtu_value ${exp_mtu} "${pmtu}" "exceeding link layer MTU on locally bridged ${type} interface"
1118 test_pmtu_ipv4_br_vxlan4_exception
() {
1119 test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception vxlan
4 4
1122 test_pmtu_ipv6_br_vxlan4_exception
() {
1123 test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception vxlan
6 4
1126 test_pmtu_ipv4_br_geneve4_exception
() {
1127 test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve
4 4
1130 test_pmtu_ipv6_br_geneve4_exception
() {
1131 test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve
6 4
1134 test_pmtu_ipv4_br_vxlan6_exception
() {
1135 test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception vxlan
4 6
1138 test_pmtu_ipv6_br_vxlan6_exception
() {
1139 test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception vxlan
6 6
1142 test_pmtu_ipv4_br_geneve6_exception
() {
1143 test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve
4 6
1146 test_pmtu_ipv6_br_geneve6_exception
() {
1147 test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve
6 6
1150 test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception
() {
1156 if [ ${outer_family} -eq 4 ]; then
1157 setup namespaces routing ovs_bridge ovs_
${type}4 ||
return $ksft_skip
1158 # IPv4 header UDP header VXLAN/GENEVE header Ethernet header
1159 exp_mtu
=$
((${ll_mtu} - 20 - 8 - 8 - 14))
1161 setup namespaces routing ovs_bridge ovs_
${type}6 ||
return $ksft_skip
1162 # IPv6 header UDP header VXLAN/GENEVE header Ethernet header
1163 exp_mtu
=$
((${ll_mtu} - 40 - 8 - 8 - 14))
1166 if [ "${type}" = "vxlan" ]; then
1167 tun_a
="vxlan_sys_4789"
1168 elif [ "${type}" = "geneve" ]; then
1169 tun_a
="genev_sys_6081"
1172 trace
"" "${tun_a}" "${ns_b}" ${type}_b \
1173 "" veth_A-R1 "${ns_r1}" veth_R1-A \
1174 "${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B \
1175 "" ovs_br0 "" veth-A-C \
1178 if [ ${family} -eq 4 ]; then
1180 dst=${tunnel4_b_addr}
1183 dst=${tunnel6_b_addr}
1186 # Create route exception by exceeding link layer MTU
1187 mtu "" veth_A-R1 $((${ll_mtu} + 1000))
1188 mtu "" ovs_br0 $((${ll_mtu} + 1000))
1189 mtu "" veth_A-C $((${ll_mtu} + 1000))
1190 mtu "${ns_c}" veth_C-A $((${ll_mtu} + 1000))
1191 mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
1192 mtu "${ns_b}" veth_B-R1 ${ll_mtu}
1193 mtu "${ns_r1}" veth_R1-B ${ll_mtu}
1195 mtu "" ${tun_a} $((${ll_mtu} + 1000))
1196 mtu "${ns_b}" ${type}_b $((${ll_mtu} + 1000))
1198 run_cmd
${ns_c} ${ping} -q -M want -i 0.1 -c 20 -s $((${ll_mtu} + 500)) ${dst} ||
return 1
1200 # Check that exceptions were created
1201 pmtu
="$(route_get_dst_pmtu_from_exception "${ns_c}" ${dst})"
1202 check_pmtu_value
${exp_mtu} "${pmtu}" "exceeding link layer MTU on Open vSwitch ${type} interface
"
1205 test_pmtu_ipv4_ovs_vxlan4_exception() {
1206 test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception vxlan 4 4
1209 test_pmtu_ipv6_ovs_vxlan4_exception() {
1210 test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception vxlan 6 4
1213 test_pmtu_ipv4_ovs_geneve4_exception() {
1214 test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception geneve 4 4
1217 test_pmtu_ipv6_ovs_geneve4_exception() {
1218 test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception geneve 6 4
1221 test_pmtu_ipv4_ovs_vxlan6_exception() {
1222 test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception vxlan 4 6
1225 test_pmtu_ipv6_ovs_vxlan6_exception() {
1226 test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception vxlan 6 6
1229 test_pmtu_ipv4_ovs_geneve6_exception() {
1230 test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception geneve 4 6
1233 test_pmtu_ipv6_ovs_geneve6_exception() {
1234 test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception geneve 6 6
1237 test_pmtu_ipvX_over_fouY_or_gueY() {
1243 setup namespaces routing ${encap}${outer_family}${inner_family} || return $ksft_skip
1244 trace "${ns_a}" ${encap}_a "${ns_b}" ${encap}_b \
1245 "${ns_a}" veth_A-R1
"${ns_r1}" veth_R1-A \
1246 "${ns_b}" veth_B-R1
"${ns_r1}" veth_R1-B
1248 if [ ${inner_family} -eq 4 ]; then
1250 dst
=${tunnel4_b_addr}
1253 dst
=${tunnel6_b_addr}
1256 if [ "${encap}" = "gue" ]; then
1262 if [ ${outer_family} -eq 4 ]; then
1263 # IPv4 header UDP header
1264 exp_mtu
=$
((${ll_mtu} - 20 - 8 - ${encap_overhead}))
1266 # IPv6 header Option 4 UDP header
1267 exp_mtu
=$
((${ll_mtu} - 40 - 8 - 8 - ${encap_overhead}))
1270 # Create route exception by exceeding link layer MTU
1271 mtu
"${ns_a}" veth_A-R1 $
((${ll_mtu} + 1000))
1272 mtu
"${ns_r1}" veth_R1-A $
((${ll_mtu} + 1000))
1273 mtu
"${ns_b}" veth_B-R1
${ll_mtu}
1274 mtu
"${ns_r1}" veth_R1-B
${ll_mtu}
1276 mtu
"${ns_a}" ${encap}_a $((${ll_mtu} + 1000))
1277 mtu "${ns_b}" ${encap}_b $((${ll_mtu} + 1000))
1278 run_cmd
${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst}
1280 # Check that exception was created
1281 pmtu
="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
1282 check_pmtu_value
${exp_mtu} "${pmtu}" "exceeding link layer MTU on ${encap} interface
"
1285 test_pmtu_ipv4_fou4_exception() {
1286 test_pmtu_ipvX_over_fouY_or_gueY 4 4 fou
1289 test_pmtu_ipv6_fou4_exception() {
1290 test_pmtu_ipvX_over_fouY_or_gueY 6 4 fou
1293 test_pmtu_ipv4_fou6_exception() {
1294 test_pmtu_ipvX_over_fouY_or_gueY 4 6 fou
1297 test_pmtu_ipv6_fou6_exception() {
1298 test_pmtu_ipvX_over_fouY_or_gueY 6 6 fou
1301 test_pmtu_ipv4_gue4_exception() {
1302 test_pmtu_ipvX_over_fouY_or_gueY 4 4 gue
1305 test_pmtu_ipv6_gue4_exception() {
1306 test_pmtu_ipvX_over_fouY_or_gueY 6 4 gue
1309 test_pmtu_ipv4_gue6_exception() {
1310 test_pmtu_ipvX_over_fouY_or_gueY 4 6 gue
1313 test_pmtu_ipv6_gue6_exception() {
1314 test_pmtu_ipvX_over_fouY_or_gueY 6 6 gue
1317 test_pmtu_ipvX_over_ipvY_exception() {
1322 setup namespaces routing ip${inner}ip${outer} || return $ksft_skip
1324 trace "${ns_a}" ip_a "${ns_b}" ip_b \
1325 "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
1326 "${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B
1328 if [ ${inner} -eq 4 ]; then
1330 dst=${tunnel4_b_addr}
1333 dst=${tunnel6_b_addr}
1336 if [ ${outer} -eq 4 ]; then
1338 exp_mtu=$((${ll_mtu} - 20))
1340 # IPv6 header Option 4
1341 exp_mtu=$((${ll_mtu} - 40 - 8))
1344 # Create route exception by exceeding link layer MTU
1345 mtu "${ns_a}" veth_A-R1 $((${ll_mtu} + 1000))
1346 mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
1347 mtu "${ns_b}" veth_B-R1 ${ll_mtu}
1348 mtu "${ns_r1}" veth_R1-B ${ll_mtu}
1350 mtu "${ns_a}" ip_a $((${ll_mtu} + 1000)) || return
1351 mtu "${ns_b}" ip_b $((${ll_mtu} + 1000)) || return
1352 run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst}
1354 # Check that exception was created
1355 pmtu="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst})"
1356 check_pmtu_value ${exp_mtu} "${pmtu}" "exceeding link layer MTU on ip${inner}ip${outer} interface"
1359 test_pmtu_ipv4_ipv4_exception
() {
1360 test_pmtu_ipvX_over_ipvY_exception
4 4
1363 test_pmtu_ipv6_ipv4_exception
() {
1364 test_pmtu_ipvX_over_ipvY_exception
6 4
1367 test_pmtu_ipv4_ipv6_exception
() {
1368 test_pmtu_ipvX_over_ipvY_exception
4 6
1371 test_pmtu_ipv6_ipv6_exception
() {
1372 test_pmtu_ipvX_over_ipvY_exception
6 6
1375 test_pmtu_vti4_exception
() {
1376 setup namespaces veth vti4 xfrm4 ||
return $ksft_skip
1377 trace
"${ns_a}" veth_a
"${ns_b}" veth_b \
1378 "${ns_a}" vti4_a
"${ns_b}" vti4_b
1381 vti_mtu
=$
((veth_mtu
- 20))
1383 # SPI SN IV ICV pad length next header
1384 esp_payload_rfc4106
=$
((vti_mtu
- 4 - 4 - 8 - 16 - 1 - 1))
1385 ping_payload
=$
((esp_payload_rfc4106
- 28))
1387 mtu
"${ns_a}" veth_a
${veth_mtu}
1388 mtu
"${ns_b}" veth_b
${veth_mtu}
1389 mtu
"${ns_a}" vti4_a
${vti_mtu}
1390 mtu
"${ns_b}" vti4_b
${vti_mtu}
1392 # Send DF packet without exceeding link layer MTU, check that no
1393 # exception is created
1394 run_cmd
${ns_a} ping -q -M want -i 0.1 -w 1 -s ${ping_payload} ${tunnel4_b_addr}
1395 pmtu
="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel4_b_addr})"
1396 check_pmtu_value
"" "${pmtu}" "sending packet smaller than PMTU (IP payload length ${esp_payload_rfc4106})" ||
return 1
1398 # Now exceed link layer MTU by one byte, check that exception is created
1399 # with the right PMTU value
1400 run_cmd
${ns_a} ping -q -M want
-i 0.1 -w 1 -s $
((ping_payload
+ 1)) ${tunnel4_b_addr}
1401 pmtu
="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel4_b_addr})"
1402 check_pmtu_value
"${esp_payload_rfc4106}" "${pmtu}" "exceeding PMTU (IP payload length $((esp_payload_rfc4106 + 1)))"
1405 test_pmtu_vti6_exception
() {
1406 setup namespaces veth vti6 xfrm6 ||
return $ksft_skip
1407 trace
"${ns_a}" veth_a
"${ns_b}" veth_b \
1408 "${ns_a}" vti6_a
"${ns_b}" vti6_b
1411 # Create route exception by exceeding link layer MTU
1412 mtu
"${ns_a}" veth_a
4000
1413 mtu
"${ns_b}" veth_b
4000
1414 mtu
"${ns_a}" vti6_a
5000
1415 mtu
"${ns_b}" vti6_b
5000
1416 run_cmd
${ns_a} ${ping6} -q -i 0.1 -w 1 -s 60000 ${tunnel6_b_addr}
1418 # Check that exception was created
1419 pmtu
="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel6_b_addr})"
1420 check_pmtu_value any
"${pmtu}" "creating tunnel exceeding link layer MTU" ||
return 1
1422 # Decrease tunnel MTU, check for PMTU decrease in route exception
1423 mtu
"${ns_a}" vti6_a
3000
1424 pmtu
="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel6_b_addr})"
1425 check_pmtu_value
"3000" "${pmtu}" "decreasing tunnel MTU" || fail
=1
1427 # Increase tunnel MTU, check for PMTU increase in route exception
1428 mtu
"${ns_a}" vti6_a
9000
1429 pmtu
="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel6_b_addr})"
1430 check_pmtu_value
"9000" "${pmtu}" "increasing tunnel MTU" || fail
=1
1435 test_pmtu_vti4_default_mtu
() {
1436 setup namespaces veth vti4 ||
return $ksft_skip
1438 # Check that MTU of vti device is MTU of veth minus IPv4 header length
1439 veth_mtu
="$(link_get_mtu "${ns_a}" veth_a)"
1440 vti4_mtu
="$(link_get_mtu "${ns_a}" vti4_a)"
1441 if [ $
((veth_mtu
- vti4_mtu
)) -ne 20 ]; then
1442 err
" vti MTU ${vti4_mtu} is not veth MTU ${veth_mtu} minus IPv4 header length"
1447 test_pmtu_vti6_default_mtu
() {
1448 setup namespaces veth vti6 ||
return $ksft_skip
1450 # Check that MTU of vti device is MTU of veth minus IPv6 header length
1451 veth_mtu
="$(link_get_mtu "${ns_a}" veth_a)"
1452 vti6_mtu
="$(link_get_mtu "${ns_a}" vti6_a)"
1453 if [ $
((veth_mtu
- vti6_mtu
)) -ne 40 ]; then
1454 err
" vti MTU ${vti6_mtu} is not veth MTU ${veth_mtu} minus IPv6 header length"
1459 test_pmtu_vti4_link_add_mtu
() {
1460 setup namespaces ||
return $ksft_skip
1462 run_cmd
${ns_a} ip link add vti4_a type vti local ${veth4_a_addr} remote ${veth4_b_addr} key
10
1463 [ $?
-ne 0 ] && err
" vti not supported" && return $ksft_skip
1464 run_cmd
${ns_a} ip link del vti4_a
1470 # Check invalid values first
1471 for v
in $
((min
- 1)) $
((max
+ 1)); do
1472 run_cmd
${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key
10
1473 # This can fail, or MTU can be adjusted to a proper value
1474 [ $?
-ne 0 ] && continue
1475 mtu
="$(link_get_mtu "${ns_a}" vti4_a)"
1476 if [ ${mtu} -lt ${min} -o ${mtu} -gt ${max} ]; then
1477 err
" vti tunnel created with invalid MTU ${mtu}"
1480 run_cmd
${ns_a} ip link del vti4_a
1483 # Now check valid values
1484 for v
in ${min} 1300 ${max}; do
1485 run_cmd
${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key
10
1486 mtu
="$(link_get_mtu "${ns_a}" vti4_a)"
1487 run_cmd
${ns_a} ip link del vti4_a
1488 if [ "${mtu}" != "${v}" ]; then
1489 err
" vti MTU ${mtu} doesn't match configured value ${v}"
1497 test_pmtu_vti6_link_add_mtu
() {
1498 setup namespaces ||
return $ksft_skip
1500 run_cmd
${ns_a} ip link add vti6_a type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key
10
1501 [ $?
-ne 0 ] && err
" vti6 not supported" && return $ksft_skip
1502 run_cmd
${ns_a} ip link del vti6_a
1506 min
=68 # vti6 can carry IPv4 packets too
1508 # Check invalid values first
1509 for v
in $
((min
- 1)) $
((max
+ 1)); do
1510 run_cmd
${ns_a} ip link add vti6_a mtu ${v} type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key
10
1511 # This can fail, or MTU can be adjusted to a proper value
1512 [ $?
-ne 0 ] && continue
1513 mtu
="$(link_get_mtu "${ns_a}" vti6_a)"
1514 if [ ${mtu} -lt ${min} -o ${mtu} -gt ${max} ]; then
1515 err
" vti6 tunnel created with invalid MTU ${v}"
1518 run_cmd
${ns_a} ip link del vti6_a
1521 # Now check valid values
1522 for v
in 68 1280 1300 $
((65535 - 40)); do
1523 run_cmd
${ns_a} ip link add vti6_a mtu ${v} type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key
10
1524 mtu
="$(link_get_mtu "${ns_a}" vti6_a)"
1525 run_cmd
${ns_a} ip link del vti6_a
1526 if [ "${mtu}" != "${v}" ]; then
1527 err
" vti6 MTU ${mtu} doesn't match configured value ${v}"
1535 test_pmtu_vti6_link_change_mtu
() {
1536 setup namespaces ||
return $ksft_skip
1538 run_cmd
${ns_a} ip link add dummy0 mtu
1500 type dummy
1539 [ $?
-ne 0 ] && err
" dummy not supported" && return $ksft_skip
1540 run_cmd
${ns_a} ip link add dummy1 mtu
3000 type dummy
1541 run_cmd
${ns_a} ip link
set dummy0 up
1542 run_cmd
${ns_a} ip link
set dummy1 up
1544 run_cmd
${ns_a} ip addr add ${dummy6_0_prefix}1/${dummy6_mask} dev dummy0
1545 run_cmd
${ns_a} ip addr add ${dummy6_1_prefix}1/${dummy6_mask} dev dummy1
1549 # Create vti6 interface bound to device, passing MTU, check it
1550 run_cmd
${ns_a} ip link add vti6_a mtu 1300 type vti6 remote ${dummy6_0_prefix}2 local ${dummy6_0_prefix}1
1551 mtu
="$(link_get_mtu "${ns_a}" vti6_a)"
1552 if [ ${mtu} -ne 1300 ]; then
1553 err
" vti6 MTU ${mtu} doesn't match configured value 1300"
1557 # Move to another device with different MTU, without passing MTU, check
1559 run_cmd
${ns_a} ip link set vti6_a type vti6 remote ${dummy6_1_prefix}2 local ${dummy6_1_prefix}1
1560 mtu
="$(link_get_mtu "${ns_a}" vti6_a)"
1561 if [ ${mtu} -ne $
((3000 - 40)) ]; then
1562 err
" vti MTU ${mtu} is not dummy MTU 3000 minus IPv6 header length"
1566 # Move it back, passing MTU, check MTU is not overridden
1567 run_cmd
${ns_a} ip link set vti6_a mtu 1280 type vti6 remote ${dummy6_0_prefix}2 local ${dummy6_0_prefix}1
1568 mtu
="$(link_get_mtu "${ns_a}" vti6_a)"
1569 if [ ${mtu} -ne 1280 ]; then
1570 err
" vti6 MTU ${mtu} doesn't match configured value 1280"
1580 if ! which ${cmd} > /dev
/null
2>&1; then
1581 err
" missing required command: '${cmd}'"
1587 test_cleanup_vxlanX_exception
() {
1592 check_command taskset ||
return $ksft_skip
1593 cpu_list
=$
(grep -m 2 processor
/proc
/cpuinfo | cut
-d ' ' -f 2)
1595 setup namespaces routing
${encap}${outer} ||
return $ksft_skip
1596 trace
"${ns_a}" ${encap}_a "${ns_b}" ${encap}_b \
1597 "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
1598 "${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B
1600 # Create route exception by exceeding link layer MTU
1601 mtu "${ns_a}" veth_A-R1 $((${ll_mtu} + 1000))
1602 mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
1603 mtu "${ns_b}" veth_B-R1 ${ll_mtu}
1604 mtu "${ns_r1}" veth_R1-B ${ll_mtu}
1606 mtu "${ns_a}" ${encap}_a $((${ll_mtu} + 1000))
1607 mtu
"${ns_b}" ${encap}_b $((${ll_mtu} + 1000))
1609 # Fill exception cache for multiple CPUs (2)
1610 # we can always use inner IPv4 for that
1611 for cpu in ${cpu_list}; do
1612 run_cmd taskset --cpu-list ${cpu} ${ns_a} ping -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${tunnel4_b_addr}
1615 ${ns_a} ip link del dev veth_A-R1 &
1618 if [ "$
(cat /proc
/${iplink_pid}/cmdline
2>/dev
/null |
tr -d '\0')" = "iplinkdeldevveth_A-R1
" ]; then
1619 err " can
't delete veth device in a timely manner, PMTU dst likely leaked"
1624 test_cleanup_ipv6_exception() {
1625 test_cleanup_vxlanX_exception 6
1628 test_cleanup_ipv4_exception() {
1629 test_cleanup_vxlanX_exception 4
1639 if [ "$VERBOSE" = "1" ]; then
1640 printf "\n##########################################################################\n\n"
1646 if [ $ret -eq 0 ]; then
1647 printf "TEST: %-60s [ OK ]\n" "${tdesc}"
1648 elif [ $ret -eq 1 ]; then
1649 printf "TEST: %-60s [FAIL]\n" "${tdesc}"
1650 if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
1652 echo "Pausing. Hit enter to continue"
1657 elif [ $ret -eq $ksft_skip ]; then
1658 printf "TEST: %-60s [SKIP]\n" "${tdesc}"
1668 [ $exitcode=$ksft_skip ] && exitcode=0
1671 [ $all_skipped = true ] && exitcode=$ksft_skip
1687 run_test "${tname}" "${tdesc} - nexthop objects"
1691 test_list_flush_ipv4_exception() {
1692 setup namespaces routing || return $ksft_skip
1693 trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
1694 "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \
1695 "${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \
1696 "${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2
1698 dst_prefix1="${prefix4}.${b_r1}."
1699 dst2="${prefix4}.${b_r2}.1"
1701 # Set up initial MTU values
1702 mtu "${ns_a}" veth_A-R1 2000
1703 mtu "${ns_r1}" veth_R1-A 2000
1704 mtu "${ns_r1}" veth_R1-B 1500
1705 mtu "${ns_b}" veth_B-R1 1500
1707 mtu "${ns_a}" veth_A-R2 2000
1708 mtu "${ns_r2}" veth_R2-A 2000
1709 mtu "${ns_r2}" veth_R2-B 1500
1710 mtu "${ns_b}" veth_B-R2 1500
1714 # Add 100 addresses for veth endpoint on B reached by default A route
1715 for i in $(seq 100 199); do
1716 run_cmd ${ns_b} ip addr add "${dst_prefix1}${i}" dev veth_B-R1
1719 # Create 100 cached route exceptions for path via R1, one via R2. Note
1720 # that with IPv4 we need to actually cause a route lookup that matches
1721 # the exception caused by ICMP, in order to actually have a cached
1722 # route, so we need to ping each destination twice
1723 for i in $(seq 100 199); do
1724 run_cmd ${ns_a} ping -q -M want -i 0.1 -c 2 -s 1800 "${dst_prefix1}${i}"
1726 run_cmd ${ns_a} ping -q -M want -i 0.1 -c 2 -s 1800 "${dst2}"
1728 if [ "$(${ns_a} ip -oneline route list cache | wc -l)" -ne 101 ]; then
1729 err " can't list cached exceptions
"
1733 run_cmd ${ns_a} ip route flush cache
1734 pmtu1="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst_prefix}1)"
1735 pmtu2="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst_prefix}2)"
1736 if [ -n "${pmtu1}" ] || [ -n "${pmtu2}" ] || \
1737 [ -n "$
(${ns_a} ip route list cache
)" ]; then
1738 err " can
't flush cached exceptions"
1745 test_list_flush_ipv6_exception() {
1746 setup namespaces routing || return $ksft_skip
1747 trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
1748 "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \
1749 "${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \
1750 "${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2
1752 dst_prefix1="${prefix6}:${b_r1}::"
1753 dst2="${prefix6}:${b_r2}::1"
1755 # Set up initial MTU values
1756 mtu "${ns_a}" veth_A-R1 2000
1757 mtu "${ns_r1}" veth_R1-A 2000
1758 mtu "${ns_r1}" veth_R1-B 1500
1759 mtu "${ns_b}" veth_B-R1 1500
1761 mtu "${ns_a}" veth_A-R2 2000
1762 mtu "${ns_r2}" veth_R2-A 2000
1763 mtu "${ns_r2}" veth_R2-B 1500
1764 mtu "${ns_b}" veth_B-R2 1500
1768 # Add 100 addresses for veth endpoint on B reached by default A route
1769 for i in $(seq 100 199); do
1770 run_cmd ${ns_b} ip addr add "${dst_prefix1}${i}" dev veth_B-R1
1773 # Create 100 cached route exceptions for path via R1, one via R2
1774 for i in $(seq 100 199); do
1775 run_cmd ${ns_a} ping -q -M want -i 0.1 -w 1 -s 1800 "${dst_prefix1}${i}"
1777 run_cmd ${ns_a} ping -q -M want -i 0.1 -w 1 -s 1800 "${dst2}"
1778 if [ "$(${ns_a} ip -oneline -6 route list cache | wc -l)" -ne 101 ]; then
1779 err " can't list cached exceptions
"
1783 run_cmd ${ns_a} ip -6 route flush cache
1784 pmtu1="$
(route_get_dst_pmtu_from_exception
"${ns_a}" "${dst_prefix1}100")"
1785 pmtu2="$
(route_get_dst_pmtu_from_exception
"${ns_a}" ${dst2})"
1786 if [ -n "${pmtu1}" ] || [ -n "${pmtu2}" ] || \
1787 [ -n "$
(${ns_a} ip
-6 route list cache
)" ]; then
1788 err " can
't flush cached exceptions"
1795 test_pmtu_ipvX_route_change() {
1798 setup namespaces routing || return 2
1799 trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
1800 "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \
1801 "${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \
1802 "${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2
1804 if [ ${family} -eq 4 ]; then
1806 dst1="${prefix4}.${b_r1}.1"
1807 dst2="${prefix4}.${b_r2}.1"
1808 gw="${prefix4}.${a_r1}.2"
1811 dst1="${prefix6}:${b_r1}::1"
1812 dst2="${prefix6}:${b_r2}::1"
1813 gw="${prefix6}:${a_r1}::2"
1816 # Set up initial MTU values
1817 mtu "${ns_a}" veth_A-R1 2000
1818 mtu "${ns_r1}" veth_R1-A 2000
1819 mtu "${ns_r1}" veth_R1-B 1400
1820 mtu "${ns_b}" veth_B-R1 1400
1822 mtu "${ns_a}" veth_A-R2 2000
1823 mtu "${ns_r2}" veth_R2-A 2000
1824 mtu "${ns_r2}" veth_R2-B 1500
1825 mtu "${ns_b}" veth_B-R2 1500
1827 # Create route exceptions
1828 run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1800 ${dst1}
1829 run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1800 ${dst2}
1831 # Check that exceptions have been created with the correct PMTU
1832 pmtu_1="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst1})"
1833 check_pmtu_value "1400" "${pmtu_1}" "exceeding MTU" || return 1
1834 pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
1835 check_pmtu_value "1500" "${pmtu_2}" "exceeding MTU" || return 1
1837 # Replace the route from A to R1
1838 run_cmd ${ns_a} ip route change default via ${gw}
1840 # Delete the device in A
1841 run_cmd ${ns_a} ip link del "veth_A-R1"
1844 test_pmtu_ipv4_route_change() {
1845 test_pmtu_ipvX_route_change 4
1848 test_pmtu_ipv6_route_change() {
1849 test_pmtu_ipvX_route_change 6
1854 echo "$0 [OPTIONS] [TEST]..."
1855 echo "If no TEST argument is given, all tests will be run."
1858 echo " --trace: capture traffic to TEST_INTERFACE.pcap"
1860 echo "Available tests${tests}"
1864 ################################################################################
1870 while getopts :ptv o
1873 p) PAUSE_ON_FAIL=yes;;
1875 t) if which tcpdump > /dev/null 2>&1; then
1878 echo "=== tcpdump not available, tracing disabled"
1884 shift $(($OPTIND-1))
1890 # Check first that all requested tests are available before running any
1891 command -v > /dev/null "test_${arg}" || { echo "=== Test ${arg} not found"; usage; }
1900 ip nexthop ls >/dev/null 2>&1
1901 [ $? -eq 0 ] && HAVE_NH=yes
1906 for t in ${tests}; do
1907 [ "${name}" = "" ] && name="${t}" && continue
1908 [ "${desc}" = "" ] && desc="${t}" && continue
1910 if [ "${HAVE_NH}" = "yes" ]; then
1916 [ "${arg}" != "${arg#--*}" ] && continue
1917 [ "${arg}" = "${name}" ] && run_this=1 && break
1920 if [ $run_this -eq 1 ]; then
1921 run_test "${name}" "${desc}"
1922 # if test was skipped no need to retry with nexthop objects
1923 [ $? -eq $ksft_skip ] && rerun_nh=0
1925 if [ "${rerun_nh}" = "1" ]; then
1926 run_test_nh "${name}" "${desc}"