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--------------. a_r2: 1500
16 # '--------------R2--------------' a_r4: 1400
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_vti4_exception
30 # Set up vti tunnel on top of veth, with xfrm states and policies, in two
31 # namespaces with matching endpoints. Check that route exception is not
32 # created if link layer MTU is not exceeded, then exceed it and check that
33 # exception is created with the expected PMTU. The approach described
34 # below for IPv6 doesn't apply here, because, on IPv4, administrative MTU
35 # changes alone won't affect PMTU
37 # - pmtu_vti6_exception
38 # Set up vti6 tunnel on top of veth, with xfrm states and policies, in two
39 # namespaces with matching endpoints. Check that route exception is
40 # created by exceeding link layer MTU with ping to other endpoint. Then
41 # decrease and increase MTU of tunnel, checking that route exception PMTU
44 # - pmtu_vti4_default_mtu
45 # Set up vti4 tunnel on top of veth, in two namespaces with matching
46 # endpoints. Check that MTU assigned to vti interface is the MTU of the
47 # lower layer (veth) minus additional lower layer headers (zero, for veth)
48 # minus IPv4 header length
50 # - pmtu_vti6_default_mtu
51 # Same as above, for IPv6
53 # - pmtu_vti4_link_add_mtu
54 # Set up vti4 interface passing MTU value at link creation, check MTU is
55 # configured, and that link is not created with invalid MTU values
57 # - pmtu_vti6_link_add_mtu
58 # Same as above, for IPv6
60 # - pmtu_vti6_link_change_mtu
61 # Set up two dummy interfaces with different MTUs, create a vti6 tunnel
62 # and check that configured MTU is used on link creation and changes, and
63 # that MTU is properly calculated instead when MTU is not configured from
66 # Kselftest framework requirement - SKIP code is 4.
69 # Some systems don't have a ping6 binary anymore
70 which ping6 > /dev/null 2>&1 && ping6=$(which ping6) || ping6=$(which ping)
73 pmtu_ipv4_exception ipv4: PMTU exceptions
74 pmtu_ipv6_exception ipv6: PMTU exceptions
75 pmtu_vti6_exception vti6: PMTU exceptions
76 pmtu_vti4_exception vti4: PMTU exceptions
77 pmtu_vti4_default_mtu vti4: default MTU assignment
78 pmtu_vti6_default_mtu vti6: default MTU assignment
79 pmtu_vti4_link_add_mtu vti4: MTU setting on link creation
80 pmtu_vti6_link_add_mtu vti6: MTU setting on link creation
81 pmtu_vti6_link_change_mtu vti6: MTU changes on link changes"
83 NS_A="ns-$(mktemp -u XXXXXX)"
84 NS_B="ns-$(mktemp -u XXXXXX)"
85 NS_R1="ns-$(mktemp -u XXXXXX)"
86 NS_R2="ns-$(mktemp -u XXXXXX)"
87 ns_a="ip netns exec ${NS_A}"
88 ns_b="ip netns exec ${NS_B}"
89 ns_r1="ip netns exec ${NS_R1}"
90 ns_r2="ip netns exec ${NS_R2}"
92 # Addressing and routing for tests with routers: four network segments, with
93 # index SEGMENT between 1 and 4, a common prefix (PREFIX4 or PREFIX6) and an
94 # identifier ID, which is 1 for hosts (A and B), 2 for routers (R1 and R2).
96 # - IPv4: PREFIX4.SEGMENT.ID (/24)
97 # - IPv6: PREFIX6:SEGMENT::ID (/64)
111 # Traffic from A to B goes through R1 by default, and through R2, if destined to
112 # B's address on the b_r2 segment.
113 # Traffic from B to A goes through R1.
114 # ns destination gateway
116 A default ${prefix4}.${a_r1}.2
117 A ${prefix4}.${b_r2}.1 ${prefix4}.${a_r2}.2
118 B default ${prefix4}.${b_r1}.2
120 A default ${prefix6}:${a_r1}::2
121 A ${prefix6}:${b_r2}::1 ${prefix6}:${a_r2}::2
122 B default ${prefix6}:${b_r1}::2
125 veth4_a_addr="192.168.1.1"
126 veth4_b_addr="192.168.1.2"
128 veth6_a_addr="fd00:1::a"
129 veth6_b_addr="fd00:1::b"
132 vti4_a_addr="192.168.2.1"
133 vti4_b_addr="192.168.2.2"
135 vti6_a_addr="fd00:2::a"
136 vti6_b_addr="fd00:2::b"
139 dummy6_0_addr="fc00:1000::0"
140 dummy6_1_addr="fc00:1001::0"
148 err_buf="${err_buf}${1}
157 # Find the auto-generated name for this namespace
163 for n in ${NS_A} ${NS_B} ${NS_R1} ${NS_R2}; do
164 ip netns add ${n} || return 1
169 ${ns_a} ip link add veth_a type veth peer name veth_b || return 1
170 ${ns_a} ip link set veth_b netns ${NS_B}
172 ${ns_a} ip addr add ${veth4_a_addr}/${veth4_mask} dev veth_a
173 ${ns_b} ip addr add ${veth4_b_addr}/${veth4_mask} dev veth_b
175 ${ns_a} ip addr add ${veth6_a_addr}/${veth6_mask} dev veth_a
176 ${ns_b} ip addr add ${veth6_b_addr}/${veth6_mask} dev veth_b
178 ${ns_a} ip link set veth_a up
179 ${ns_b} ip link set veth_b up
190 [ ${proto} -eq 6 ] && vti_type="vti6" || vti_type="vti"
192 ${ns_a} ip link add vti${proto}_a type ${vti_type} local ${veth_a_addr} remote ${veth_b_addr} key 10 || return 1
193 ${ns_b} ip link add vti${proto}_b type ${vti_type} local ${veth_b_addr} remote ${veth_a_addr} key 10
195 ${ns_a} ip addr add ${vti_a_addr}/${vti_mask} dev vti${proto}_a
196 ${ns_b} ip addr add ${vti_b_addr}/${vti_mask} dev vti${proto}_b
198 ${ns_a} ip link set vti${proto}_a up
199 ${ns_b} ip link set vti${proto}_b up
205 setup_vti 4 ${veth4_a_addr} ${veth4_b_addr} ${vti4_a_addr} ${vti4_b_addr} ${vti4_mask}
209 setup_vti 6 ${veth6_a_addr} ${veth6_b_addr} ${vti6_a_addr} ${vti6_b_addr} ${vti6_mask}
217 ${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
218 ${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
219 ${ns_a} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel
220 ${ns_a} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel
222 ${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
223 ${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
224 ${ns_b} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel
225 ${ns_b} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel
229 setup_xfrm 4 ${veth4_a_addr} ${veth4_b_addr}
233 setup_xfrm 6 ${veth6_a_addr} ${veth6_b_addr}
237 for i in ${NS_R1} ${NS_R2}; do
238 ip netns exec ${i} sysctl -q net/ipv4/ip_forward=1
239 ip netns exec ${i} sysctl -q net/ipv6/conf/all/forwarding=1
242 for i in ${routing_addrs}; do
243 [ "${ns}" = "" ] && ns="${i}" && continue
244 [ "${peer}" = "" ] && peer="${i}" && continue
245 [ "${segment}" = "" ] && segment="${i}"
247 ns_name="$(nsname ${ns})"
248 peer_name="$(nsname ${peer})"
249 if="veth_${ns}-${peer}"
250 ifpeer="veth_${peer}-${ns}"
253 ip link add ${if} up netns ${ns_name} type veth peer name ${ifpeer} netns ${peer_name} || return 1
254 ip -n ${peer_name} link set dev ${ifpeer} up
257 ip -n ${ns_name} addr add ${prefix4}.${segment}.1/24 dev ${if}
258 ip -n ${ns_name} addr add ${prefix6}:${segment}::1/64 dev ${if}
260 ip -n ${peer_name} addr add ${prefix4}.${segment}.2/24 dev ${ifpeer}
261 ip -n ${peer_name} addr add ${prefix6}:${segment}::2/64 dev ${ifpeer}
263 ns=""; peer=""; segment=""
266 for i in ${routes}; do
267 [ "${ns}" = "" ] && ns="${i}" && continue
268 [ "${addr}" = "" ] && addr="${i}" && continue
269 [ "${gw}" = "" ] && gw="${i}"
271 ns_name="$(nsname ${ns})"
273 ip -n ${ns_name} route add ${addr} via ${gw}
275 ns=""; addr=""; gw=""
280 [ "$(id -u)" -ne 0 ] && echo " need to run as root" && return $ksft_skip
284 eval setup_${arg} || { echo " ${arg} not supported"; return 1; }
289 [ $tracing -eq 0 ] && return
292 [ "${ns_cmd}" = "" ] && ns_cmd="${arg}" && continue
293 ${ns_cmd} tcpdump -s 0 -i "${arg}" -w "${name}_${arg}.pcap" 2> /dev/null &
294 tcpdump_pids="${tcpdump_pids} $!"
301 for pid in ${tcpdump_pids}; do
306 [ ${cleanup_done} -eq 1 ] && return
307 for n in ${NS_A} ${NS_B} ${NS_R1} ${NS_R2}; do
308 ip netns del ${n} 2> /dev/null
318 ${ns_cmd} ip link set dev ${dev} mtu ${mtu}
325 for i in ${input}; do
326 [ ${next} -eq 1 -a "${i}" = "lock" ] && next=2 && continue
327 [ ${next} -eq 1 ] && echo "${i}" && return
328 [ ${next} -eq 2 ] && echo "lock ${i}" && return
329 [ "${i}" = "mtu" ] && next=1
337 ${ns_cmd} ip link show dev "${name}"
344 mtu_parse "$(link_get "${ns_cmd}" ${name})"
347 route_get_dst_exception() {
351 ${ns_cmd} ip route get "${dst}"
354 route_get_dst_pmtu_from_exception() {
358 mtu_parse "$(route_get_dst_exception "${ns_cmd}" ${dst})"
366 [ "${expected}" = "any" ] && [ -n "${value}" ] && return 0
367 [ "${value}" = "${expected}" ] && return 0
368 [ -z "${value}" ] && err " PMTU exception wasn't created after ${event}" && return 1
369 [ -z "${expected}" ] && err " PMTU exception shouldn't exist after ${event}" && return 1
370 err " found PMTU exception with incorrect MTU ${value}, expected ${expected}, after ${event}"
377 setup namespaces routing || return 2
378 trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
379 "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \
380 "${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \
381 "${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2
383 if [ ${family} -eq 4 ]; then
385 dst1="${prefix4}.${b_r1}.1"
386 dst2="${prefix4}.${b_r2}.1"
389 dst1="${prefix6}:${b_r1}::1"
390 dst2="${prefix6}:${b_r2}::1"
393 # Set up initial MTU values
394 mtu "${ns_a}" veth_A-R1 2000
395 mtu "${ns_r1}" veth_R1-A 2000
396 mtu "${ns_r1}" veth_R1-B 1400
397 mtu "${ns_b}" veth_B-R1 1400
399 mtu "${ns_a}" veth_A-R2 2000
400 mtu "${ns_r2}" veth_R2-A 2000
401 mtu "${ns_r2}" veth_R2-B 1500
402 mtu "${ns_b}" veth_B-R2 1500
404 # Create route exceptions
405 ${ns_a} ${ping} -q -M want -i 0.1 -w 2 -s 1800 ${dst1} > /dev/null
406 ${ns_a} ${ping} -q -M want -i 0.1 -w 2 -s 1800 ${dst2} > /dev/null
408 # Check that exceptions have been created with the correct PMTU
409 pmtu_1="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst1})"
410 check_pmtu_value "1400" "${pmtu_1}" "exceeding MTU" || return 1
411 pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
412 check_pmtu_value "1500" "${pmtu_2}" "exceeding MTU" || return 1
414 # Decrease local MTU below PMTU, check for PMTU decrease in route exception
415 mtu "${ns_a}" veth_A-R1 1300
416 mtu "${ns_r1}" veth_R1-A 1300
417 pmtu_1="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst1})"
418 check_pmtu_value "1300" "${pmtu_1}" "decreasing local MTU" || return 1
419 # Second exception shouldn't be modified
420 pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
421 check_pmtu_value "1500" "${pmtu_2}" "changing local MTU on a link not on this path" || return 1
423 # Increase MTU, check for PMTU increase in route exception
424 mtu "${ns_a}" veth_A-R1 1700
425 mtu "${ns_r1}" veth_R1-A 1700
426 pmtu_1="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst1})"
427 check_pmtu_value "1700" "${pmtu_1}" "increasing local MTU" || return 1
428 # Second exception shouldn't be modified
429 pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
430 check_pmtu_value "1500" "${pmtu_2}" "changing local MTU on a link not on this path" || return 1
432 # Skip PMTU locking tests for IPv6
433 [ $family -eq 6 ] && return 0
435 # Decrease remote MTU on path via R2, get new exception
436 mtu "${ns_r2}" veth_R2-B 400
437 mtu "${ns_b}" veth_B-R2 400
438 ${ns_a} ${ping} -q -M want -i 0.1 -w 2 -s 1400 ${dst2} > /dev/null
439 pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
440 check_pmtu_value "lock 552" "${pmtu_2}" "exceeding MTU, with MTU < min_pmtu" || return 1
442 # Decrease local MTU below PMTU
443 mtu "${ns_a}" veth_A-R2 500
444 mtu "${ns_r2}" veth_R2-A 500
445 pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
446 check_pmtu_value "500" "${pmtu_2}" "decreasing local MTU" || return 1
449 mtu "${ns_a}" veth_A-R2 1500
450 mtu "${ns_r2}" veth_R2-A 1500
451 pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
452 check_pmtu_value "1500" "${pmtu_2}" "increasing local MTU" || return 1
455 ${ns_a} ${ping} -q -M want -i 0.1 -w 2 -s 1400 ${dst2} > /dev/null
456 pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
457 check_pmtu_value "lock 552" "${pmtu_2}" "exceeding MTU, with MTU < min_pmtu" || return 1
460 test_pmtu_ipv4_exception() {
464 test_pmtu_ipv6_exception() {
468 test_pmtu_vti4_exception() {
469 setup namespaces veth vti4 xfrm4 || return 2
470 trace "${ns_a}" veth_a "${ns_b}" veth_b \
471 "${ns_a}" vti4_a "${ns_b}" vti4_b
474 vti_mtu=$((veth_mtu - 20))
476 # SPI SN IV ICV pad length next header
477 esp_payload_rfc4106=$((vti_mtu - 4 - 4 - 8 - 16 - 1 - 1))
478 ping_payload=$((esp_payload_rfc4106 - 28))
480 mtu "${ns_a}" veth_a ${veth_mtu}
481 mtu "${ns_b}" veth_b ${veth_mtu}
482 mtu "${ns_a}" vti4_a ${vti_mtu}
483 mtu "${ns_b}" vti4_b ${vti_mtu}
485 # Send DF packet without exceeding link layer MTU, check that no
486 # exception is created
487 ${ns_a} ping -q -M want -i 0.1 -w 2 -s ${ping_payload} ${vti4_b_addr} > /dev/null
488 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti4_b_addr})"
489 check_pmtu_value "" "${pmtu}" "sending packet smaller than PMTU (IP payload length ${esp_payload_rfc4106})" || return 1
491 # Now exceed link layer MTU by one byte, check that exception is created
492 # with the right PMTU value
493 ${ns_a} ping -q -M want -i 0.1 -w 2 -s $((ping_payload + 1)) ${vti4_b_addr} > /dev/null
494 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti4_b_addr})"
495 check_pmtu_value "${esp_payload_rfc4106}" "${pmtu}" "exceeding PMTU (IP payload length $((esp_payload_rfc4106 + 1)))"
498 test_pmtu_vti6_exception() {
499 setup namespaces veth vti6 xfrm6 || return 2
500 trace "${ns_a}" veth_a "${ns_b}" veth_b \
501 "${ns_a}" vti6_a "${ns_b}" vti6_b
504 # Create route exception by exceeding link layer MTU
505 mtu "${ns_a}" veth_a 4000
506 mtu "${ns_b}" veth_b 4000
507 mtu "${ns_a}" vti6_a 5000
508 mtu "${ns_b}" vti6_b 5000
509 ${ns_a} ${ping6} -q -i 0.1 -w 2 -s 60000 ${vti6_b_addr} > /dev/null
511 # Check that exception was created
512 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})"
513 check_pmtu_value any "${pmtu}" "creating tunnel exceeding link layer MTU" || return 1
515 # Decrease tunnel MTU, check for PMTU decrease in route exception
516 mtu "${ns_a}" vti6_a 3000
517 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})"
518 check_pmtu_value "3000" "${pmtu}" "decreasing tunnel MTU" || fail=1
520 # Increase tunnel MTU, check for PMTU increase in route exception
521 mtu "${ns_a}" vti6_a 9000
522 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})"
523 check_pmtu_value "9000" "${pmtu}" "increasing tunnel MTU" || fail=1
528 test_pmtu_vti4_default_mtu() {
529 setup namespaces veth vti4 || return 2
531 # Check that MTU of vti device is MTU of veth minus IPv4 header length
532 veth_mtu="$(link_get_mtu "${ns_a}" veth_a)"
533 vti4_mtu="$(link_get_mtu "${ns_a}" vti4_a)"
534 if [ $((veth_mtu - vti4_mtu)) -ne 20 ]; then
535 err " vti MTU ${vti4_mtu} is not veth MTU ${veth_mtu} minus IPv4 header length"
540 test_pmtu_vti6_default_mtu() {
541 setup namespaces veth vti6 || return 2
543 # Check that MTU of vti device is MTU of veth minus IPv6 header length
544 veth_mtu="$(link_get_mtu "${ns_a}" veth_a)"
545 vti6_mtu="$(link_get_mtu "${ns_a}" vti6_a)"
546 if [ $((veth_mtu - vti6_mtu)) -ne 40 ]; then
547 err " vti MTU ${vti6_mtu} is not veth MTU ${veth_mtu} minus IPv6 header length"
552 test_pmtu_vti4_link_add_mtu() {
553 setup namespaces || return 2
555 ${ns_a} ip link add vti4_a type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10
556 [ $? -ne 0 ] && err " vti not supported" && return 2
557 ${ns_a} ip link del vti4_a
563 # Check invalid values first
564 for v in $((min - 1)) $((max + 1)); do
565 ${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10 2>/dev/null
566 # This can fail, or MTU can be adjusted to a proper value
567 [ $? -ne 0 ] && continue
568 mtu="$(link_get_mtu "${ns_a}" vti4_a)"
569 if [ ${mtu} -lt ${min} -o ${mtu} -gt ${max} ]; then
570 err " vti tunnel created with invalid MTU ${mtu}"
573 ${ns_a} ip link del vti4_a
576 # Now check valid values
577 for v in ${min} 1300 ${max}; do
578 ${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10
579 mtu="$(link_get_mtu "${ns_a}" vti4_a)"
580 ${ns_a} ip link del vti4_a
581 if [ "${mtu}" != "${v}" ]; then
582 err " vti MTU ${mtu} doesn't match configured value ${v}"
590 test_pmtu_vti6_link_add_mtu() {
591 setup namespaces || return 2
593 ${ns_a} ip link add vti6_a type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key 10
594 [ $? -ne 0 ] && err " vti6 not supported" && return 2
595 ${ns_a} ip link del vti6_a
599 min=68 # vti6 can carry IPv4 packets too
601 # Check invalid values first
602 for v in $((min - 1)) $((max + 1)); do
603 ${ns_a} ip link add vti6_a mtu ${v} type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key 10 2>/dev/null
604 # This can fail, or MTU can be adjusted to a proper value
605 [ $? -ne 0 ] && continue
606 mtu="$(link_get_mtu "${ns_a}" vti6_a)"
607 if [ ${mtu} -lt ${min} -o ${mtu} -gt ${max} ]; then
608 err " vti6 tunnel created with invalid MTU ${v}"
611 ${ns_a} ip link del vti6_a
614 # Now check valid values
615 for v in 68 1280 1300 $((65535 - 40)); do
616 ${ns_a} ip link add vti6_a mtu ${v} type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key 10
617 mtu="$(link_get_mtu "${ns_a}" vti6_a)"
618 ${ns_a} ip link del vti6_a
619 if [ "${mtu}" != "${v}" ]; then
620 err " vti6 MTU ${mtu} doesn't match configured value ${v}"
628 test_pmtu_vti6_link_change_mtu() {
629 setup namespaces || return 2
631 ${ns_a} ip link add dummy0 mtu 1500 type dummy
632 [ $? -ne 0 ] && err " dummy not supported" && return 2
633 ${ns_a} ip link add dummy1 mtu 3000 type dummy
634 ${ns_a} ip link set dummy0 up
635 ${ns_a} ip link set dummy1 up
637 ${ns_a} ip addr add ${dummy6_0_addr}/${dummy6_mask} dev dummy0
638 ${ns_a} ip addr add ${dummy6_1_addr}/${dummy6_mask} dev dummy1
642 # Create vti6 interface bound to device, passing MTU, check it
643 ${ns_a} ip link add vti6_a mtu 1300 type vti6 remote ${dummy6_0_addr} local ${dummy6_0_addr}
644 mtu="$(link_get_mtu "${ns_a}" vti6_a)"
645 if [ ${mtu} -ne 1300 ]; then
646 err " vti6 MTU ${mtu} doesn't match configured value 1300"
650 # Move to another device with different MTU, without passing MTU, check
652 ${ns_a} ip link set vti6_a type vti6 remote ${dummy6_1_addr} local ${dummy6_1_addr}
653 mtu="$(link_get_mtu "${ns_a}" vti6_a)"
654 if [ ${mtu} -ne $((3000 - 40)) ]; then
655 err " vti MTU ${mtu} is not dummy MTU 3000 minus IPv6 header length"
659 # Move it back, passing MTU, check MTU is not overridden
660 ${ns_a} ip link set vti6_a mtu 1280 type vti6 remote ${dummy6_0_addr} local ${dummy6_0_addr}
661 mtu="$(link_get_mtu "${ns_a}" vti6_a)"
662 if [ ${mtu} -ne 1280 ]; then
663 err " vti6 MTU ${mtu} doesn't match configured value 1280"
672 echo "$0 [OPTIONS] [TEST]..."
673 echo "If no TEST argument is given, all tests will be run."
676 echo " --trace: capture traffic to TEST_INTERFACE.pcap"
678 echo "Available tests${tests}"
689 if [ "${arg}" != "${arg#--*}" ]; then
691 if [ "${opt}" = "trace" ]; then
692 if which tcpdump > /dev/null 2>&1; then
695 echo "=== tcpdump not available, tracing disabled"
701 # Check first that all requested tests are available before
703 command -v > /dev/null "test_${arg}" || { echo "=== Test ${arg} not found"; usage; }
709 for t in ${tests}; do
710 [ $desc -eq 0 ] && name="${t}" && desc=1 && continue || desc=0
714 [ "${arg}" != "${arg#--*}" ] && continue
715 [ "${arg}" = "${name}" ] && run_this=1 && break
718 [ $run_this -eq 0 ] && continue
726 if [ $ret -eq 0 ]; then
727 printf "TEST: %-60s [ OK ]\n" "${t}"
728 elif [ $ret -eq 1 ]; then
729 printf "TEST: %-60s [FAIL]\n" "${t}"
732 elif [ $ret -eq 2 ]; then
733 printf "TEST: %-60s [SKIP]\n" "${t}"
737 [ $? -ne 0 ] && exitcode=1