aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtools/testing/selftests/net/pmtu.sh96
1 files changed, 80 insertions, 16 deletions
diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
index e2c94e47707c..912b2dc50be3 100755
--- a/tools/testing/selftests/net/pmtu.sh
+++ b/tools/testing/selftests/net/pmtu.sh
@@ -103,6 +103,15 @@
103# and check that configured MTU is used on link creation and changes, and 103# and check that configured MTU is used on link creation and changes, and
104# that MTU is properly calculated instead when MTU is not configured from 104# that MTU is properly calculated instead when MTU is not configured from
105# userspace 105# 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
106 115
107# Kselftest framework requirement - SKIP code is 4. 116# Kselftest framework requirement - SKIP code is 4.
108ksft_skip=4 117ksft_skip=4
@@ -135,7 +144,9 @@ tests="
135 pmtu_vti6_default_mtu vti6: default MTU assignment 144 pmtu_vti6_default_mtu vti6: default MTU assignment
136 pmtu_vti4_link_add_mtu vti4: MTU setting on link creation 145 pmtu_vti4_link_add_mtu vti4: MTU setting on link creation
137 pmtu_vti6_link_add_mtu vti6: MTU setting on link creation 146 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"
139 150
140NS_A="ns-$(mktemp -u XXXXXX)" 151NS_A="ns-$(mktemp -u XXXXXX)"
141NS_B="ns-$(mktemp -u XXXXXX)" 152NS_B="ns-$(mktemp -u XXXXXX)"
@@ -263,8 +274,6 @@ setup_fou_or_gue() {
263 274
264 ${ns_a} ip link set ${encap}_a up 275 ${ns_a} ip link set ${encap}_a up
265 ${ns_b} ip link set ${encap}_b up 276 ${ns_b} ip link set ${encap}_b up
266
267 sleep 1
268} 277}
269 278
270setup_fou44() { 279setup_fou44() {
@@ -302,6 +311,10 @@ setup_gue66() {
302setup_namespaces() { 311setup_namespaces() {
303 for n in ${NS_A} ${NS_B} ${NS_R1} ${NS_R2}; do 312 for n in ${NS_A} ${NS_B} ${NS_R1} ${NS_R2}; do
304 ip netns add ${n} || return 1 313 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
305 done 318 done
306} 319}
307 320
@@ -337,8 +350,6 @@ setup_vti() {
337 350
338 ${ns_a} ip link set vti${proto}_a up 351 ${ns_a} ip link set vti${proto}_a up
339 ${ns_b} ip link set vti${proto}_b up 352 ${ns_b} ip link set vti${proto}_b up
340
341 sleep 1
342} 353}
343 354
344setup_vti4() { 355setup_vti4() {
@@ -375,8 +386,6 @@ setup_vxlan_or_geneve() {
375 386
376 ${ns_a} ip link set ${type}_a up 387 ${ns_a} ip link set ${type}_a up
377 ${ns_b} ip link set ${type}_b up 388 ${ns_b} ip link set ${type}_b up
378
379 sleep 1
380} 389}
381 390
382setup_geneve4() { 391setup_geneve4() {
@@ -588,8 +597,8 @@ test_pmtu_ipvX() {
588 mtu "${ns_b}" veth_B-R2 1500 597 mtu "${ns_b}" veth_B-R2 1500
589 598
590 # Create route exceptions 599 # Create route exceptions
591 ${ns_a} ${ping} -q -M want -i 0.1 -w 2 -s 1800 ${dst1} > /dev/null 600 ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1800 ${dst1} > /dev/null
592 ${ns_a} ${ping} -q -M want -i 0.1 -w 2 -s 1800 ${dst2} > /dev/null 601 ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1800 ${dst2} > /dev/null
593 602
594 # Check that exceptions have been created with the correct PMTU 603 # Check that exceptions have been created with the correct PMTU
595 pmtu_1="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst1})" 604 pmtu_1="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst1})"
@@ -621,7 +630,7 @@ test_pmtu_ipvX() {
621 # Decrease remote MTU on path via R2, get new exception 630 # Decrease remote MTU on path via R2, get new exception
622 mtu "${ns_r2}" veth_R2-B 400 631 mtu "${ns_r2}" veth_R2-B 400
623 mtu "${ns_b}" veth_B-R2 400 632 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
625 pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})" 634 pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
626 check_pmtu_value "lock 552" "${pmtu_2}" "exceeding MTU, with MTU < min_pmtu" || return 1 635 check_pmtu_value "lock 552" "${pmtu_2}" "exceeding MTU, with MTU < min_pmtu" || return 1
627 636
@@ -638,7 +647,7 @@ test_pmtu_ipvX() {
638 check_pmtu_value "1500" "${pmtu_2}" "increasing local MTU" || return 1 647 check_pmtu_value "1500" "${pmtu_2}" "increasing local MTU" || return 1
639 648
640 # Get new exception 649 # 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
642 pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})" 651 pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
643 check_pmtu_value "lock 552" "${pmtu_2}" "exceeding MTU, with MTU < min_pmtu" || return 1 652 check_pmtu_value "lock 552" "${pmtu_2}" "exceeding MTU, with MTU < min_pmtu" || return 1
644} 653}
@@ -687,7 +696,7 @@ test_pmtu_ipvX_over_vxlanY_or_geneveY_exception() {
687 696
688 mtu "${ns_a}" ${type}_a $((${ll_mtu} + 1000)) 697 mtu "${ns_a}" ${type}_a $((${ll_mtu} + 1000))
689 mtu "${ns_b}" ${type}_b $((${ll_mtu} + 1000)) 698 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
691 700
692 # Check that exception was created 701 # Check that exception was created
693 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})" 702 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
@@ -767,7 +776,7 @@ test_pmtu_ipvX_over_fouY_or_gueY() {
767 776
768 mtu "${ns_a}" ${encap}_a $((${ll_mtu} + 1000)) 777 mtu "${ns_a}" ${encap}_a $((${ll_mtu} + 1000))
769 mtu "${ns_b}" ${encap}_b $((${ll_mtu} + 1000)) 778 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
771 780
772 # Check that exception was created 781 # Check that exception was created
773 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})" 782 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
@@ -825,13 +834,13 @@ test_pmtu_vti4_exception() {
825 834
826 # Send DF packet without exceeding link layer MTU, check that no 835 # Send DF packet without exceeding link layer MTU, check that no
827 # exception is created 836 # 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
829 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel4_b_addr})" 838 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel4_b_addr})"
830 check_pmtu_value "" "${pmtu}" "sending packet smaller than PMTU (IP payload length ${esp_payload_rfc4106})" || return 1 839 check_pmtu_value "" "${pmtu}" "sending packet smaller than PMTU (IP payload length ${esp_payload_rfc4106})" || return 1
831 840
832 # Now exceed link layer MTU by one byte, check that exception is created 841 # Now exceed link layer MTU by one byte, check that exception is created
833 # with the right PMTU value 842 # 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
835 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel4_b_addr})" 844 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel4_b_addr})"
836 check_pmtu_value "${esp_payload_rfc4106}" "${pmtu}" "exceeding PMTU (IP payload length $((esp_payload_rfc4106 + 1)))" 845 check_pmtu_value "${esp_payload_rfc4106}" "${pmtu}" "exceeding PMTU (IP payload length $((esp_payload_rfc4106 + 1)))"
837} 846}
@@ -847,7 +856,7 @@ test_pmtu_vti6_exception() {
847 mtu "${ns_b}" veth_b 4000 856 mtu "${ns_b}" veth_b 4000
848 mtu "${ns_a}" vti6_a 5000 857 mtu "${ns_a}" vti6_a 5000
849 mtu "${ns_b}" vti6_b 5000 858 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
851 860
852 # Check that exception was created 861 # Check that exception was created
853 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel6_b_addr})" 862 pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel6_b_addr})"
@@ -1008,6 +1017,61 @@ test_pmtu_vti6_link_change_mtu() {
1008 return ${fail} 1017 return ${fail}
1009} 1018}
1010 1019
1020check_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
1030test_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
1067test_cleanup_ipv6_exception() {
1068 test_cleanup_vxlanX_exception 6
1069}
1070
1071test_cleanup_ipv4_exception() {
1072 test_cleanup_vxlanX_exception 4
1073}
1074
1011usage() { 1075usage() {
1012 echo 1076 echo
1013 echo "$0 [OPTIONS] [TEST]..." 1077 echo "$0 [OPTIONS] [TEST]..."