103103# and check that configured MTU is used on link creation and changes, and
104104# that MTU is properly calculated instead when MTU is not configured from
105105# userspace
106+ #
107+ # - cleanup_ipv4_exception
108+ # Similar to pmtu_ipv4_vxlan4_exception, but explicitly generate PMTU
109+ # exceptions on multiple CPUs and check that the veth device tear-down
110+ # happens in a timely manner
111+ #
112+ # - cleanup_ipv6_exception
113+ # Same as above, but use IPv6 transport from A to B
114+
106115
107116# Kselftest framework requirement - SKIP code is 4.
108117ksft_skip=4
@@ -135,7 +144,9 @@ tests="
135144 pmtu_vti6_default_mtu vti6: default MTU assignment
136145 pmtu_vti4_link_add_mtu vti4: MTU setting on link creation
137146 pmtu_vti6_link_add_mtu vti6: MTU setting on link creation
138- pmtu_vti6_link_change_mtu vti6: MTU changes on link changes"
147+ pmtu_vti6_link_change_mtu vti6: MTU changes on link changes
148+ cleanup_ipv4_exception ipv4: cleanup of cached exceptions
149+ cleanup_ipv6_exception ipv6: cleanup of cached exceptions"
139150
140151NS_A=" ns-$( mktemp -u XXXXXX) "
141152NS_B=" ns-$( mktemp -u XXXXXX) "
@@ -263,8 +274,6 @@ setup_fou_or_gue() {
263274
264275 ${ns_a} ip link set ${encap} _a up
265276 ${ns_b} ip link set ${encap} _b up
266-
267- sleep 1
268277}
269278
270279setup_fou44 () {
@@ -302,6 +311,10 @@ setup_gue66() {
302311setup_namespaces () {
303312 for n in ${NS_A} ${NS_B} ${NS_R1} ${NS_R2} ; do
304313 ip netns add ${n} || return 1
314+
315+ # Disable DAD, so that we don't have to wait to use the
316+ # configured IPv6 addresses
317+ ip netns exec ${n} sysctl -q net/ipv6/conf/default/accept_dad=0
305318 done
306319}
307320
@@ -337,8 +350,6 @@ setup_vti() {
337350
338351 ${ns_a} ip link set vti${proto} _a up
339352 ${ns_b} ip link set vti${proto} _b up
340-
341- sleep 1
342353}
343354
344355setup_vti4 () {
@@ -375,8 +386,6 @@ setup_vxlan_or_geneve() {
375386
376387 ${ns_a} ip link set ${type} _a up
377388 ${ns_b} ip link set ${type} _b up
378-
379- sleep 1
380389}
381390
382391setup_geneve4 () {
@@ -588,8 +597,8 @@ test_pmtu_ipvX() {
588597 mtu " ${ns_b} " veth_B-R2 1500
589598
590599 # Create route exceptions
591- ${ns_a} ${ping} -q -M want -i 0.1 -w 2 -s 1800 ${dst1} > /dev/null
592- ${ns_a} ${ping} -q -M want -i 0.1 -w 2 -s 1800 ${dst2} > /dev/null
600+ ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1800 ${dst1} > /dev/null
601+ ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1800 ${dst2} > /dev/null
593602
594603 # Check that exceptions have been created with the correct PMTU
595604 pmtu_1=" $( route_get_dst_pmtu_from_exception " ${ns_a} " ${dst1} ) "
@@ -621,7 +630,7 @@ test_pmtu_ipvX() {
621630 # Decrease remote MTU on path via R2, get new exception
622631 mtu " ${ns_r2} " veth_R2-B 400
623632 mtu " ${ns_b} " veth_B-R2 400
624- ${ns_a} ${ping} -q -M want -i 0.1 -w 2 -s 1400 ${dst2} > /dev/null
633+ ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1400 ${dst2} > /dev/null
625634 pmtu_2=" $( route_get_dst_pmtu_from_exception " ${ns_a} " ${dst2} ) "
626635 check_pmtu_value " lock 552" " ${pmtu_2} " " exceeding MTU, with MTU < min_pmtu" || return 1
627636
@@ -638,7 +647,7 @@ test_pmtu_ipvX() {
638647 check_pmtu_value " 1500" " ${pmtu_2} " " increasing local MTU" || return 1
639648
640649 # Get new exception
641- ${ns_a} ${ping} -q -M want -i 0.1 -w 2 -s 1400 ${dst2} > /dev/null
650+ ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1400 ${dst2} > /dev/null
642651 pmtu_2=" $( route_get_dst_pmtu_from_exception " ${ns_a} " ${dst2} ) "
643652 check_pmtu_value " lock 552" " ${pmtu_2} " " exceeding MTU, with MTU < min_pmtu" || return 1
644653}
@@ -687,7 +696,7 @@ test_pmtu_ipvX_over_vxlanY_or_geneveY_exception() {
687696
688697 mtu " ${ns_a} " ${type} _a $(( ${ll_mtu} + 1000 ))
689698 mtu " ${ns_b} " ${type} _b $(( ${ll_mtu} + 1000 ))
690- ${ns_a} ${ping} -q -M want -i 0.1 -w 2 -s $(( ${ll_mtu} + 500 )) ${dst} > /dev/null
699+ ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $(( ${ll_mtu} + 500 )) ${dst} > /dev/null
691700
692701 # Check that exception was created
693702 pmtu=" $( route_get_dst_pmtu_from_exception " ${ns_a} " ${dst} ) "
@@ -767,7 +776,7 @@ test_pmtu_ipvX_over_fouY_or_gueY() {
767776
768777 mtu " ${ns_a} " ${encap} _a $(( ${ll_mtu} + 1000 ))
769778 mtu " ${ns_b} " ${encap} _b $(( ${ll_mtu} + 1000 ))
770- ${ns_a} ${ping} -q -M want -i 0.1 -w 2 -s $(( ${ll_mtu} + 500 )) ${dst} > /dev/null
779+ ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $(( ${ll_mtu} + 500 )) ${dst} > /dev/null
771780
772781 # Check that exception was created
773782 pmtu=" $( route_get_dst_pmtu_from_exception " ${ns_a} " ${dst} ) "
@@ -825,13 +834,13 @@ test_pmtu_vti4_exception() {
825834
826835 # Send DF packet without exceeding link layer MTU, check that no
827836 # exception is created
828- ${ns_a} ping -q -M want -i 0.1 -w 2 -s ${ping_payload} ${tunnel4_b_addr} > /dev/null
837+ ${ns_a} ping -q -M want -i 0.1 -w 1 -s ${ping_payload} ${tunnel4_b_addr} > /dev/null
829838 pmtu=" $( route_get_dst_pmtu_from_exception " ${ns_a} " ${tunnel4_b_addr} ) "
830839 check_pmtu_value " " " ${pmtu} " " sending packet smaller than PMTU (IP payload length ${esp_payload_rfc4106} )" || return 1
831840
832841 # Now exceed link layer MTU by one byte, check that exception is created
833842 # with the right PMTU value
834- ${ns_a} ping -q -M want -i 0.1 -w 2 -s $(( ping_payload + 1 )) ${tunnel4_b_addr} > /dev/null
843+ ${ns_a} ping -q -M want -i 0.1 -w 1 -s $(( ping_payload + 1 )) ${tunnel4_b_addr} > /dev/null
835844 pmtu=" $( route_get_dst_pmtu_from_exception " ${ns_a} " ${tunnel4_b_addr} ) "
836845 check_pmtu_value " ${esp_payload_rfc4106} " " ${pmtu} " " exceeding PMTU (IP payload length $(( esp_payload_rfc4106 + 1 )) )"
837846}
@@ -847,7 +856,7 @@ test_pmtu_vti6_exception() {
847856 mtu " ${ns_b} " veth_b 4000
848857 mtu " ${ns_a} " vti6_a 5000
849858 mtu " ${ns_b} " vti6_b 5000
850- ${ns_a} ${ping6} -q -i 0.1 -w 2 -s 60000 ${tunnel6_b_addr} > /dev/null
859+ ${ns_a} ${ping6} -q -i 0.1 -w 1 -s 60000 ${tunnel6_b_addr} > /dev/null
851860
852861 # Check that exception was created
853862 pmtu=" $( route_get_dst_pmtu_from_exception " ${ns_a} " ${tunnel6_b_addr} ) "
@@ -1008,6 +1017,61 @@ test_pmtu_vti6_link_change_mtu() {
10081017 return ${fail}
10091018}
10101019
1020+ check_command () {
1021+ cmd=${1}
1022+
1023+ if ! which ${cmd} > /dev/null 2>&1 ; then
1024+ err " missing required command: '${cmd} '"
1025+ return 1
1026+ fi
1027+ return 0
1028+ }
1029+
1030+ test_cleanup_vxlanX_exception () {
1031+ outer=" ${1} "
1032+ encap=" vxlan"
1033+ ll_mtu=4000
1034+
1035+ check_command taskset || return 2
1036+ cpu_list=$( grep -m 2 processor /proc/cpuinfo | cut -d ' ' -f 2)
1037+
1038+ setup namespaces routing ${encap}${outer} || return 2
1039+ trace " ${ns_a} " ${encap} _a " ${ns_b} " ${encap} _b \
1040+ " ${ns_a} " veth_A-R1 " ${ns_r1} " veth_R1-A \
1041+ " ${ns_b} " veth_B-R1 " ${ns_r1} " veth_R1-B
1042+
1043+ # Create route exception by exceeding link layer MTU
1044+ mtu " ${ns_a} " veth_A-R1 $(( ${ll_mtu} + 1000 ))
1045+ mtu " ${ns_r1} " veth_R1-A $(( ${ll_mtu} + 1000 ))
1046+ mtu " ${ns_b} " veth_B-R1 ${ll_mtu}
1047+ mtu " ${ns_r1} " veth_R1-B ${ll_mtu}
1048+
1049+ mtu " ${ns_a} " ${encap} _a $(( ${ll_mtu} + 1000 ))
1050+ mtu " ${ns_b} " ${encap} _b $(( ${ll_mtu} + 1000 ))
1051+
1052+ # Fill exception cache for multiple CPUs (2)
1053+ # we can always use inner IPv4 for that
1054+ for cpu in ${cpu_list} ; do
1055+ taskset --cpu-list ${cpu} ${ns_a} ping -q -M want -i 0.1 -w 1 -s $(( ${ll_mtu} + 500 )) ${tunnel4_b_addr} > /dev/null
1056+ done
1057+
1058+ ${ns_a} ip link del dev veth_A-R1 &
1059+ iplink_pid=$!
1060+ sleep 1
1061+ if [ " $( cat /proc/${iplink_pid} /cmdline 2> /dev/null | tr -d ' \0' ) " = " iplinkdeldevveth_A-R1" ]; then
1062+ err " can't delete veth device in a timely manner, PMTU dst likely leaked"
1063+ return 1
1064+ fi
1065+ }
1066+
1067+ test_cleanup_ipv6_exception () {
1068+ test_cleanup_vxlanX_exception 6
1069+ }
1070+
1071+ test_cleanup_ipv4_exception () {
1072+ test_cleanup_vxlanX_exception 4
1073+ }
1074+
10111075usage () {
10121076 echo
10131077 echo " $0 [OPTIONS] [TEST]..."
0 commit comments