2 # SPDX-License-Identifier: GPL-2.0
4 # Double quotes to prevent globbing and word splitting is recommended in new
5 # code but we accept it, especially because there were too many before having
6 # address all other issues detected by shellcheck.
7 #shellcheck disable=SC2086
9 # ShellCheck incorrectly believes that most of the code here is unreachable
10 # because it's invoked by variable name, see how the "tests" array is used
11 #shellcheck disable=SC2317
13 . "$(dirname "${0}")/mptcp_lib.sh"
31 timeout_test=$((timeout_poll * 2 + 1))
47 declare -a only_tests_ids
48 declare -a only_tests_names
49 declare -A failed_tests
54 # These var are used only in some tests, make sure they are not already set
64 # generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) ||
65 # (ip6 && (ip6[74] & 0xf0) == 0x30)'"
66 CBPF_MPTCP_SUBOPTION_ADD_ADDR="14,
88 rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
94 for netns in "$ns1" "$ns2"; do
95 ip netns add $netns || exit $ksft_skip
96 ip -net $netns link set lo up
97 ip netns exec $netns sysctl -q net.mptcp.enabled=1
98 ip netns exec $netns sysctl -q net.mptcp.pm_type=0 2>/dev/null || true
99 ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0
100 ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0
101 if [ $checksum -eq 1 ]; then
102 ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1
107 validate_checksum=$checksum
116 for i in $(seq 1 4); do
117 ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2"
118 ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i
119 ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad
120 ip -net "$ns1" link set ns1eth$i up
122 ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i
123 ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad
124 ip -net "$ns2" link set ns2eth$i up
126 # let $ns2 reach any $ns1 address from any interface
127 ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i
128 ip -net "$ns2" route add default via dead:beef:$i::1 dev ns2eth$i metric 10$i
135 for i in $(seq 1 4); do
136 tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1
137 tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1
146 for netns in "$ns1" "$ns2"; do
148 rm -f /tmp/$netns.{nstat,out}
154 mptcp_lib_check_mptcp
155 mptcp_lib_check_kallsyms
157 if ! ip -Version &> /dev/null; then
158 echo "SKIP: Could not run test without ip tool"
162 # Use the legacy version if available to support old kernel versions
163 if iptables-legacy -V &> /dev/null; then
164 iptables="iptables-legacy"
165 ip6tables="ip6tables-legacy"
166 elif ! iptables -V &> /dev/null; then
167 echo "SKIP: Could not run all tests without iptables tool"
169 elif ! ip6tables -V &> /dev/null; then
170 echo "SKIP: Could not run all tests without ip6tables tool"
190 make_file "$cin" "client" 1 >/dev/null
191 make_file "$sin" "server" 1 >/dev/null
196 rm -f "$cin" "$cout" "$sinfail"
197 rm -f "$sin" "$sout" "$cinsent" "$cinfail"
199 rm -rf $evts_ns1 $evts_ns2
205 printf "%03u %s\n" "${TEST_COUNT}" "${TEST_NAME}"
210 printf "%-${nr_blank}s%-36s" " " "${*}"
215 # It can be empty, no need to print anything then
216 [ -z "${1}" ] && return
218 mptcp_lib_print_info " Info: ${*}"
223 mptcp_lib_print_ok "[ ok ]${1:+ ${*}}"
228 mptcp_lib_print_err "[fail]${1:+ ${*}}"
233 mptcp_lib_print_warn "[skip]${1:+ ${*}}"
239 local msg="${1:-"Feature not supported"}"
241 mptcp_lib_fail_if_expected_feature "${msg}"
260 if [ "${#only_tests_ids[@]}" -eq 0 ] && [ "${#only_tests_names[@]}" -eq 0 ]; then
265 for i in "${only_tests_ids[@]}"; do
266 if [ "${TEST_COUNT}" -eq "${i}" ]; then
270 for i in "${only_tests_names[@]}"; do
271 if [ "${TEST_NAME}" = "${i}" ]; then
279 append_prev_results()
281 if [ ${last_test_failed} -eq 1 ]; then
282 mptcp_lib_result_fail "${TEST_NAME}"
283 elif [ ${last_test_skipped} -eq 1 ]; then
284 mptcp_lib_result_skip "${TEST_NAME}"
285 elif [ ${last_test_ignored} -ne 1 ]; then
286 mptcp_lib_result_pass "${TEST_NAME}"
301 TEST_COUNT=$((TEST_COUNT+1))
310 if [ "${init}" != "1" ]; then
321 # $1: test name ; $2: counter to check
322 reset_check_counter()
324 reset "${1}" || return 1
328 if ! nstat -asz "${counter}" | grep -wq "${counter}"; then
329 mark_as_skipped "counter '${counter}' is not available"
337 reset "${1}" || return 1
340 for netns in "$ns1" "$ns2"; do
341 ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2
346 reset_with_add_addr_timeout()
351 reset "${1}" || return 1
354 if [ $ip -eq 6 ]; then
355 tables="${ip6tables}"
358 ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
360 if ! ip netns exec $ns2 $tables -A OUTPUT -p tcp \
361 -m tcp --tcp-option 30 \
363 "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \
365 mark_as_skipped "unable to set the 'add addr' rule"
371 reset_with_checksum()
376 reset "checksum test ${1} ${2}" || return 1
378 ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=$ns1_enable
379 ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=$ns2_enable
384 reset_with_allow_join_id0()
389 reset "${1}" || return 1
391 ip netns exec $ns1 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns1_enable
392 ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable
395 # Modify TCP payload without corrupting the TCP packet
397 # This rule inverts a 8-bit word at byte offset 148 for the 2nd TCP ACK packets
398 # carrying enough data.
399 # Once it is done, the TCP Checksum field is updated so the packet is still
400 # considered as valid at the TCP level.
401 # Because the MPTCP checksum, covering the TCP options and data, has not been
402 # updated, the modification will be detected and an MP_FAIL will be emitted:
403 # what we want to validate here without corrupting "random" MPTCP options.
405 # To avoid having tc producing this pr_info() message for each TCP ACK packets
406 # not carrying enough data:
408 # tc action pedit offset 162 out of bounds
410 # Netfilter is used to mark packets with enough data.
420 if [ $ip -eq 6 ]; then
421 tables="${ip6tables}"
424 ip netns exec $ns2 $tables \
429 -m length --length 150:9999 \
430 -m statistic --mode nth --packet 1 --every 99999 \
431 -j MARK --set-mark 42 || return ${ksft_skip}
433 tc -n $ns2 qdisc add dev ns2eth$i clsact || return ${ksft_skip}
434 tc -n $ns2 filter add dev ns2eth$i egress \
435 protocol ip prio 1000 \
437 action pedit munge offset 148 u8 invert \
439 index 100 || return ${ksft_skip}
444 reset_check_counter "${1}" "MPTcpExtInfiniteMapTx" || return 1
447 ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=1
448 ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=1
451 setup_fail_rules "${@}" || rc=$?
453 if [ ${rc} -eq ${ksft_skip} ]; then
454 mark_as_skipped "unable to set the 'fail' rules"
461 reset "${1}" || return 1
465 ip netns exec $ns1 ./pm_nl_ctl events >> "$evts_ns1" 2>&1 &
467 ip netns exec $ns2 ./pm_nl_ctl events >> "$evts_ns2" 2>&1 &
471 reset_with_tcp_filter()
473 reset "${1}" || return 1
480 if ! ip netns exec "${ns}" ${iptables} \
485 mark_as_skipped "unable to set the filter rules"
497 # just in case a test is marked twice as failed
498 if [ ${last_test_failed} -eq 0 ]; then
499 failed_tests[${TEST_COUNT}]="${TEST_NAME}"
505 get_failed_tests_ids()
509 for i in "${!failed_tests[@]}"; do
517 echo -n "Trailing bytes are: "
530 if [ -n "$bytes" ]; then
532 # when truncating we must check the size explicitly
533 out_size=$(wc -c $out | awk '{print $1}')
534 if [ $out_size -ne $bytes ]; then
535 fail_test "$what output file has wrong size ($out_size, $bytes)"
539 # note: BusyBox's "cmp" command doesn't support --bytes
541 head --bytes="$bytes" "$in" > "$tmpfile"
543 head --bytes="$bytes" "$out" > "$tmpfile"
547 cmp -l "$in" "$out" | while read -r i a b; do
548 local sum=$((0${a} + 0${b}))
549 if [ $check_invert -eq 0 ] || [ $sum -ne $((0xff)) ]; then
550 fail_test "$what does not match (in, out):"
552 print_file_err "$out"
556 print_info "$what has inverted byte at ${i}"
565 local listener_ns="$1"
566 local connector_ns="$2"
567 local connect_addr="$3"
569 if ! ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null; then
570 fail_test "$listener_ns -> $connect_addr connectivity"
578 if [ -z "$FAILING_LINKS" ]; then
580 FAILING_LINKS=$((l+1))
584 for l in $FAILING_LINKS; do
585 local veth="ns1eth$l"
586 ip -net "$ns" link set "$veth" down
597 wait_local_port_listen()
599 local listener_ns="${1}"
603 port_hex="$(printf "%04X" "${port}")"
606 for i in $(seq 10); do
607 ip netns exec "${listener_ns}" cat /proc/net/tcp* | \
608 awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" &&
614 # $1: ns ; $2: counter
621 count=$(ip netns exec ${ns} nstat -asz "${counter}" | awk 'NR==1 {next} {print $2}')
622 if [ -z "${count}" ]; then
623 mptcp_lib_fail_if_expected_feature "${counter} counter"
632 get_counter "${1}" "MPTcpExtRmAddr"
635 # $1: ns, $2: old rm_addr counter in $ns
643 for i in $(seq 10); do
644 cnt=$(rm_addr_count ${ns})
645 [ "$cnt" = "${old_cnt}" ] || break
652 get_counter "${1}" "MPTcpExtRmSubflow"
655 # $1: ns, $2: old rm_sf counter in $ns
663 for i in $(seq 10); do
664 cnt=$(rm_sf_count ${ns})
665 [ "$cnt" = "${old_cnt}" ] || break
675 old_cnt=$(get_counter ${ns} "MPTcpExtMPJoinAckRx")
678 for i in $(seq 10); do
679 cnt=$(get_counter ${ns} "MPTcpExtMPJoinAckRx")
680 [ "$cnt" = "${old_cnt}" ] || break
687 kill $1 > /dev/null 2>&1
693 kill_wait $evts_ns1_pid
694 kill_wait $evts_ns2_pid
699 #shellcheck disable=SC2046
700 kill -SIGUSR1 $(ip netns pids $ns2) $(ip netns pids $ns1)
710 if [ $ip_mptcp -eq 1 ]; then
711 ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows
713 ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows
730 if [ $p = "flags" ]; then
732 [ -n "$_flags" ]; flags="flags $_flags"
734 if [ $p = "dev" ]; then
736 [ -n "$_dev" ]; dev="dev $_dev"
738 if [ $p = "id" ]; then
740 [ -n "$_id" ]; id="id $_id"
742 if [ $p = "port" ]; then
744 [ -n "$_port" ]; port="port $_port"
750 if [ $ip_mptcp -eq 1 ]; then
751 ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port
753 ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port
763 if [ $ip_mptcp -eq 1 ]; then
764 [ $id -ne 0 ] && addr=''
765 ip -n $ns mptcp endpoint delete id $id $addr
767 ip netns exec $ns ./pm_nl_ctl del $id $addr
771 pm_nl_flush_endpoint()
775 if [ $ip_mptcp -eq 1 ]; then
776 ip -n $ns mptcp endpoint flush
778 ip netns exec $ns ./pm_nl_ctl flush
782 pm_nl_show_endpoints()
786 if [ $ip_mptcp -eq 1 ]; then
787 ip -n $ns mptcp endpoint show
789 ip netns exec $ns ./pm_nl_ctl dump
793 pm_nl_change_endpoint()
799 if [ $ip_mptcp -eq 1 ]; then
800 ip -n $ns mptcp endpoint change id $id ${flags//","/" "}
802 ip netns exec $ns ./pm_nl_ctl set id $id flags $flags
806 pm_nl_check_endpoint()
808 local line expected_line
823 while [ -n "$1" ]; do
824 if [ $1 = "flags" ]; then
826 [ -n "$_flags" ]; flags="flags $_flags"
828 elif [ $1 = "dev" ]; then
829 [ -n "$2" ]; dev="dev $1"
831 elif [ $1 = "id" ]; then
833 [ -n "$_id" ]; id="id $_id"
835 elif [ $1 = "port" ]; then
837 [ -n "$_port" ]; port=" port $_port"
844 if [ -z "$id" ]; then
845 test_fail "bad test - missing endpoint id"
849 if [ $ip_mptcp -eq 1 ]; then
850 # get line and trim trailing whitespace
851 line=$(ip -n $ns mptcp endpoint show $id)
853 # the dump order is: address id flags port dev
854 [ -n "$addr" ] && expected_line="$addr"
855 expected_line="$expected_line $id"
856 [ -n "$_flags" ] && expected_line="$expected_line ${_flags//","/" "}"
857 [ -n "$dev" ] && expected_line="$expected_line $dev"
858 [ -n "$port" ] && expected_line="$expected_line $port"
860 line=$(ip netns exec $ns ./pm_nl_ctl get $_id)
861 # the dump order is: id flags dev address port
863 [ -n "$flags" ] && expected_line="$expected_line $flags"
864 [ -n "$dev" ] && expected_line="$expected_line $dev"
865 [ -n "$addr" ] && expected_line="$expected_line $addr"
866 [ -n "$_port" ] && expected_line="$expected_line $_port"
868 if [ "$line" = "$expected_line" ]; then
871 fail_test "expected '$expected_line' found '$line'"
877 local listener_ns="$1"
878 local connector_ns="$2"
879 local connect_addr="$3"
881 local addr_nr_ns1=${addr_nr_ns1:-0}
882 local addr_nr_ns2=${addr_nr_ns2:-0}
883 local sflags=${sflags:-""}
884 local fullmesh=${fullmesh:-""}
886 local flags="subflow"
887 if [ -n "${fullmesh}" ]; then
888 flags="${flags},fullmesh"
889 addr_nr_ns2=${fullmesh}
892 # let the mptcp subflow be established in background before
893 # do endpoint manipulation
894 if [ $addr_nr_ns1 != "0" ] || [ $addr_nr_ns2 != "0" ]; then
898 if [ $addr_nr_ns1 -gt 0 ]; then
900 local add_nr_ns1=${addr_nr_ns1}
902 while [ $add_nr_ns1 -gt 0 ]; do
904 if is_v6 "${connect_addr}"; then
905 addr="dead:beef:$counter::1"
907 addr="10.0.$counter.1"
909 pm_nl_add_endpoint $ns1 $addr flags signal
910 counter=$((counter + 1))
911 add_nr_ns1=$((add_nr_ns1 - 1))
914 elif [ $addr_nr_ns1 -lt 0 ]; then
915 local rm_nr_ns1=$((-addr_nr_ns1))
916 if [ $rm_nr_ns1 -lt 8 ]; then
919 pm_nl_show_endpoints ${listener_ns} | while read -r line; do
920 # shellcheck disable=SC2206 # we do want to split per word
925 for i in "${arr[@]}"; do
926 if [ $i = "id" ]; then
927 if [ $counter -eq $rm_nr_ns1 ]; then
931 rm_addr=$(rm_addr_count ${connector_ns})
932 pm_nl_del_endpoint ${listener_ns} $id
933 wait_rm_addr ${connector_ns} ${rm_addr}
934 counter=$((counter + 1))
939 elif [ $rm_nr_ns1 -eq 8 ]; then
940 pm_nl_flush_endpoint ${listener_ns}
941 elif [ $rm_nr_ns1 -eq 9 ]; then
942 pm_nl_del_endpoint ${listener_ns} 0 ${connect_addr}
946 # if newly added endpoints must be deleted, give the background msk
947 # some time to created them
948 [ $addr_nr_ns1 -gt 0 ] && [ $addr_nr_ns2 -lt 0 ] && sleep 1
950 if [ $addr_nr_ns2 -gt 0 ]; then
951 local add_nr_ns2=${addr_nr_ns2}
954 while [ $add_nr_ns2 -gt 0 ]; do
956 if is_v6 "${connect_addr}"; then
957 addr="dead:beef:$counter::2"
959 addr="10.0.$counter.2"
961 pm_nl_add_endpoint $ns2 $addr flags $flags
962 counter=$((counter + 1))
963 add_nr_ns2=$((add_nr_ns2 - 1))
966 elif [ $addr_nr_ns2 -lt 0 ]; then
967 local rm_nr_ns2=$((-addr_nr_ns2))
968 if [ $rm_nr_ns2 -lt 8 ]; then
971 pm_nl_show_endpoints ${connector_ns} | while read -r line; do
972 # shellcheck disable=SC2206 # we do want to split per word
977 for i in "${arr[@]}"; do
978 if [ $i = "id" ]; then
979 if [ $counter -eq $rm_nr_ns2 ]; then
983 # rm_addr are serialized, allow the previous one to
986 rm_addr=$(rm_addr_count ${listener_ns})
987 pm_nl_del_endpoint ${connector_ns} $id
988 wait_rm_addr ${listener_ns} ${rm_addr}
989 counter=$((counter + 1))
994 elif [ $rm_nr_ns2 -eq 8 ]; then
995 pm_nl_flush_endpoint ${connector_ns}
996 elif [ $rm_nr_ns2 -eq 9 ]; then
998 if is_v6 "${connect_addr}"; then
999 addr="dead:beef:1::2"
1003 pm_nl_del_endpoint ${connector_ns} 0 $addr
1007 if [ -n "${sflags}" ]; then
1011 for netns in "$ns1" "$ns2"; do
1013 pm_nl_show_endpoints $netns | while read -r line; do
1014 # shellcheck disable=SC2206 # we do want to split per word
1020 for i in "${arr[@]}"; do
1021 if [ $i = "id" ]; then
1026 pm_nl_change_endpoint $netns $id $sflags
1034 local listener_ns="$1"
1035 local connector_ns="$2"
1037 local srv_proto="$4"
1038 local connect_addr="$5"
1040 local port=$((10000 + TEST_COUNT - 1))
1042 local FAILING_LINKS=${FAILING_LINKS:-""}
1043 local fastclose=${fastclose:-""}
1044 local speed=${speed:-"fast"}
1050 if [ $capture -eq 1 ]; then
1052 if [ -z $SUDO_USER ] ; then
1055 capuser="-Z $SUDO_USER"
1058 capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}")
1060 echo "Capturing traffic for test $TEST_COUNT into $capfile"
1061 ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 &
1067 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \
1069 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \
1073 if [ $speed = "fast" ]; then
1075 elif [ $speed = "slow" ]; then
1077 elif [ $speed -gt 0 ]; then
1078 extra_args="-r ${speed}"
1081 local extra_cl_args=""
1082 local extra_srv_args=""
1084 if [ -n "${fastclose}" ]; then
1085 if [ ${test_linkfail} -le 1 ]; then
1086 fail_test "fastclose tests need test_linkfail argument"
1091 trunc_size=${test_linkfail}
1092 local side=${fastclose}
1094 if [ ${side} = "client" ]; then
1095 extra_cl_args="-f ${test_linkfail}"
1096 extra_srv_args="-f -1"
1097 elif [ ${side} = "server" ]; then
1098 extra_srv_args="-f ${test_linkfail}"
1099 extra_cl_args="-f -1"
1101 fail_test "wrong/unknown fastclose spec ${side}"
1106 extra_srv_args="$extra_args $extra_srv_args"
1107 if [ "$test_linkfail" -gt 1 ];then
1108 timeout ${timeout_test} \
1109 ip netns exec ${listener_ns} \
1110 ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \
1111 $extra_srv_args "::" < "$sinfail" > "$sout" &
1113 timeout ${timeout_test} \
1114 ip netns exec ${listener_ns} \
1115 ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \
1116 $extra_srv_args "::" < "$sin" > "$sout" &
1120 wait_local_port_listen "${listener_ns}" "${port}"
1122 extra_cl_args="$extra_args $extra_cl_args"
1123 if [ "$test_linkfail" -eq 0 ];then
1124 timeout ${timeout_test} \
1125 ip netns exec ${connector_ns} \
1126 ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
1127 $extra_cl_args $connect_addr < "$cin" > "$cout" &
1128 elif [ "$test_linkfail" -eq 1 ] || [ "$test_linkfail" -eq 2 ];then
1129 ( cat "$cinfail" ; sleep 2; link_failure $listener_ns ; cat "$cinfail" ) | \
1131 timeout ${timeout_test} \
1132 ip netns exec ${connector_ns} \
1133 ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
1134 $extra_cl_args $connect_addr > "$cout" &
1136 tee "$cinsent" < "$cinfail" | \
1137 timeout ${timeout_test} \
1138 ip netns exec ${connector_ns} \
1139 ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
1140 $extra_cl_args $connect_addr > "$cout" &
1144 pm_nl_set_endpoint $listener_ns $connector_ns $connect_addr
1151 if [ $capture -eq 1 ]; then
1156 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \
1157 nstat | grep Tcp > /tmp/${listener_ns}.out
1158 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \
1159 nstat | grep Tcp > /tmp/${connector_ns}.out
1161 if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
1162 fail_test "client exit code $retc, server $rets"
1163 echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2
1164 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port"
1165 cat /tmp/${listener_ns}.out
1166 echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2
1167 ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port"
1168 cat /tmp/${connector_ns}.out
1174 if [ "$test_linkfail" -gt 1 ];then
1175 check_transfer $sinfail $cout "file received by client" $trunc_size
1177 check_transfer $sin $cout "file received by client" $trunc_size
1180 if [ "$test_linkfail" -eq 0 ];then
1181 check_transfer $cin $sout "file received by server" $trunc_size
1183 check_transfer $cinsent $sout "file received by server" $trunc_size
1187 if [ $retc -eq 0 ] && [ $rets -eq 0 ];then
1202 dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null
1203 echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
1205 print_info "Test file (size $size KB) for $who"
1210 local listener_ns="$1"
1211 local connector_ns="$2"
1212 local connect_addr="$3"
1215 local test_linkfail=${test_linkfail:-0}
1217 # The values above 2 are reused to make test files
1218 # with the given sizes (KB)
1219 if [ "$test_linkfail" -gt 2 ]; then
1222 if [ -z "$cinfail" ]; then
1225 make_file "$cinfail" "client" $size
1226 # create the input file for the failure test when
1227 # the first failure test run
1228 elif [ "$test_linkfail" -ne 0 ] && [ -z "$cinfail" ]; then
1229 # the client file must be considerably larger
1230 # of the maximum expected cwin value, or the
1231 # link utilization will be not predicable
1235 size=$((size + ( RANDOM % 8192) ))
1238 make_file "$cinfail" "client" $size
1241 if [ "$test_linkfail" -gt 2 ]; then
1244 if [ -z "$sinfail" ]; then
1247 make_file "$sinfail" "server" $size
1248 elif [ "$test_linkfail" -eq 2 ] && [ -z "$sinfail" ]; then
1254 make_file "$sinfail" "server" $size
1257 do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr}
1262 echo Server ns stats
1263 ip netns exec $ns1 nstat -as | grep Tcp
1264 echo Client ns stats
1265 ip netns exec $ns2 nstat -as | grep Tcp
1270 local csum_ns1=${1:-0}
1271 local csum_ns2=${2:-0}
1274 local allow_multi_errors_ns1=0
1275 local allow_multi_errors_ns2=0
1277 if [[ "${csum_ns1}" = "+"* ]]; then
1278 allow_multi_errors_ns1=1
1279 csum_ns1=${csum_ns1:1}
1281 if [[ "${csum_ns2}" = "+"* ]]; then
1282 allow_multi_errors_ns2=1
1283 csum_ns2=${csum_ns2:1}
1287 count=$(get_counter ${ns1} "MPTcpExtDataCsumErr")
1288 if [ "$count" != "$csum_ns1" ]; then
1289 extra_msg="$extra_msg ns1=$count"
1291 if [ -z "$count" ]; then
1293 elif { [ "$count" != $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 0 ]; } ||
1294 { [ "$count" -lt $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 1 ]; }; then
1295 fail_test "got $count data checksum error[s] expected $csum_ns1"
1300 count=$(get_counter ${ns2} "MPTcpExtDataCsumErr")
1301 if [ "$count" != "$csum_ns2" ]; then
1302 extra_msg="$extra_msg ns2=$count"
1304 if [ -z "$count" ]; then
1306 elif { [ "$count" != $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 0 ]; } ||
1307 { [ "$count" -lt $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 1 ]; }; then
1308 fail_test "got $count data checksum error[s] expected $csum_ns2"
1313 print_info "$extra_msg"
1320 local ns_invert=${3:-""}
1325 local allow_tx_lost=0
1326 local allow_rx_lost=0
1328 if [[ $ns_invert = "invert" ]]; then
1334 if [[ "${fail_tx}" = "-"* ]]; then
1336 fail_tx=${fail_tx:1}
1338 if [[ "${fail_rx}" = "-"* ]]; then
1340 fail_rx=${fail_rx:1}
1344 count=$(get_counter ${ns_tx} "MPTcpExtMPFailTx")
1345 if [ "$count" != "$fail_tx" ]; then
1346 extra_msg="$extra_msg,tx=$count"
1348 if [ -z "$count" ]; then
1350 elif { [ "$count" != "$fail_tx" ] && [ $allow_tx_lost -eq 0 ]; } ||
1351 { [ "$count" -gt "$fail_tx" ] && [ $allow_tx_lost -eq 1 ]; }; then
1352 fail_test "got $count MP_FAIL[s] TX expected $fail_tx"
1357 print_check "failrx"
1358 count=$(get_counter ${ns_rx} "MPTcpExtMPFailRx")
1359 if [ "$count" != "$fail_rx" ]; then
1360 extra_msg="$extra_msg,rx=$count"
1362 if [ -z "$count" ]; then
1364 elif { [ "$count" != "$fail_rx" ] && [ $allow_rx_lost -eq 0 ]; } ||
1365 { [ "$count" -gt "$fail_rx" ] && [ $allow_rx_lost -eq 1 ]; }; then
1366 fail_test "got $count MP_FAIL[s] RX expected $fail_rx"
1371 print_info "$extra_msg"
1384 if [[ $ns_invert = "invert" ]]; then
1391 count=$(get_counter ${ns_tx} "MPTcpExtMPFastcloseTx")
1392 if [ -z "$count" ]; then
1394 elif [ "$count" != "$fclose_tx" ]; then
1395 extra_msg="$extra_msg,tx=$count"
1396 fail_test "got $count MP_FASTCLOSE[s] TX expected $fclose_tx"
1401 print_check "fclzrx"
1402 count=$(get_counter ${ns_rx} "MPTcpExtMPFastcloseRx")
1403 if [ -z "$count" ]; then
1405 elif [ "$count" != "$fclose_rx" ]; then
1406 extra_msg="$extra_msg,rx=$count"
1407 fail_test "got $count MP_FASTCLOSE[s] RX expected $fclose_rx"
1412 print_info "$extra_msg"
1419 local ns_invert=${3:-""}
1425 if [[ $ns_invert = "invert" ]]; then
1432 count=$(get_counter ${ns_tx} "MPTcpExtMPRstTx")
1433 if [ -z "$count" ]; then
1435 elif [ $count -lt $rst_tx ]; then
1436 fail_test "got $count MP_RST[s] TX expected $rst_tx"
1442 count=$(get_counter ${ns_rx} "MPTcpExtMPRstRx")
1443 if [ -z "$count" ]; then
1445 elif [ "$count" -lt "$rst_rx" ]; then
1446 fail_test "got $count MP_RST[s] RX expected $rst_rx"
1451 print_info "$extra_msg"
1461 count=$(get_counter ${ns2} "MPTcpExtInfiniteMapTx")
1462 if [ -z "$count" ]; then
1464 elif [ "$count" != "$infi_tx" ]; then
1465 fail_test "got $count infinite map[s] TX expected $infi_tx"
1470 print_check "infirx"
1471 count=$(get_counter ${ns1} "MPTcpExtInfiniteMapRx")
1472 if [ -z "$count" ]; then
1474 elif [ "$count" != "$infi_rx" ]; then
1475 fail_test "got $count infinite map[s] RX expected $infi_rx"
1486 local csum_ns1=${4:-0}
1487 local csum_ns2=${5:-0}
1488 local fail_nr=${6:-0}
1489 local rst_nr=${7:-0}
1490 local infi_nr=${8:-0}
1491 local corrupted_pkts=${9:-0}
1495 if [ "${corrupted_pkts}" -gt 0 ]; then
1496 print_info "${corrupted_pkts} corrupted pkts"
1500 count=$(get_counter ${ns1} "MPTcpExtMPJoinSynRx")
1501 if [ -z "$count" ]; then
1503 elif [ "$count" != "$syn_nr" ]; then
1504 fail_test "got $count JOIN[s] syn expected $syn_nr"
1509 print_check "synack"
1510 with_cookie=$(ip netns exec $ns2 sysctl -n net.ipv4.tcp_syncookies)
1511 count=$(get_counter ${ns2} "MPTcpExtMPJoinSynAckRx")
1512 if [ -z "$count" ]; then
1514 elif [ "$count" != "$syn_ack_nr" ]; then
1515 # simult connections exceeding the limit with cookie enabled could go up to
1516 # synack validation as the conn limit can be enforced reliably only after
1517 # the subflow creation
1518 if [ "$with_cookie" = 2 ] && [ "$count" -gt "$syn_ack_nr" ] && [ "$count" -le "$syn_nr" ]; then
1521 fail_test "got $count JOIN[s] synack expected $syn_ack_nr"
1528 count=$(get_counter ${ns1} "MPTcpExtMPJoinAckRx")
1529 if [ -z "$count" ]; then
1531 elif [ "$count" != "$ack_nr" ]; then
1532 fail_test "got $count JOIN[s] ack expected $ack_nr"
1536 if [ $validate_checksum -eq 1 ]; then
1537 chk_csum_nr $csum_ns1 $csum_ns2
1538 chk_fail_nr $fail_nr $fail_nr
1539 chk_rst_nr $rst_nr $rst_nr
1540 chk_infi_nr $infi_nr $infi_nr
1544 # a negative value for 'stale_max' means no upper bound:
1545 # for bidirectional transfer, if one peer sleep for a while
1546 # - as these tests do - we can have a quite high number of
1547 # stale/recover conversions, proportional to
1548 # sleep duration/ MPTCP-level RTX interval.
1554 local stale_delta=$4
1561 stale_nr=$(get_counter ${ns} "MPTcpExtSubflowStale")
1562 recover_nr=$(get_counter ${ns} "MPTcpExtSubflowRecover")
1563 if [ -z "$stale_nr" ] || [ -z "$recover_nr" ]; then
1565 elif [ $stale_nr -lt $stale_min ] ||
1566 { [ $stale_max -gt 0 ] && [ $stale_nr -gt $stale_max ]; } ||
1567 [ $((stale_nr - recover_nr)) -ne $stale_delta ]; then
1568 fail_test "got $stale_nr stale[s] $recover_nr recover[s], " \
1569 " expected stale in range [$stale_min..$stale_max]," \
1570 " stale-recover delta $stale_delta"
1576 if [ "${dump_stats}" = 1 ]; then
1578 ip netns exec $ns ip -s link show
1579 ip netns exec $ns nstat -as | grep MPTcp
1587 local port_nr=${3:-0}
1588 local syn_nr=${4:-$port_nr}
1589 local syn_ack_nr=${5:-$port_nr}
1590 local ack_nr=${6:-$port_nr}
1591 local mis_syn_nr=${7:-0}
1592 local mis_ack_nr=${8:-0}
1596 timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout)
1599 count=$(get_counter ${ns2} "MPTcpExtAddAddr")
1600 if [ -z "$count" ]; then
1602 # if the test configured a short timeout tolerate greater then expected
1603 # add addrs options, due to retransmissions
1604 elif [ "$count" != "$add_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_nr" ]; }; then
1605 fail_test "got $count ADD_ADDR[s] expected $add_nr"
1611 count=$(get_counter ${ns1} "MPTcpExtEchoAdd")
1612 if [ -z "$count" ]; then
1614 elif [ "$count" != "$echo_nr" ]; then
1615 fail_test "got $count ADD_ADDR echo[s] expected $echo_nr"
1620 if [ $port_nr -gt 0 ]; then
1622 count=$(get_counter ${ns2} "MPTcpExtPortAdd")
1623 if [ -z "$count" ]; then
1625 elif [ "$count" != "$port_nr" ]; then
1626 fail_test "got $count ADD_ADDR[s] with a port-number expected $port_nr"
1632 count=$(get_counter ${ns1} "MPTcpExtMPJoinPortSynRx")
1633 if [ -z "$count" ]; then
1635 elif [ "$count" != "$syn_nr" ]; then
1636 fail_test "got $count JOIN[s] syn with a different \
1637 port-number expected $syn_nr"
1642 print_check "synack"
1643 count=$(get_counter ${ns2} "MPTcpExtMPJoinPortSynAckRx")
1644 if [ -z "$count" ]; then
1646 elif [ "$count" != "$syn_ack_nr" ]; then
1647 fail_test "got $count JOIN[s] synack with a different \
1648 port-number expected $syn_ack_nr"
1654 count=$(get_counter ${ns1} "MPTcpExtMPJoinPortAckRx")
1655 if [ -z "$count" ]; then
1657 elif [ "$count" != "$ack_nr" ]; then
1658 fail_test "got $count JOIN[s] ack with a different \
1659 port-number expected $ack_nr"
1665 count=$(get_counter ${ns1} "MPTcpExtMismatchPortSynRx")
1666 if [ -z "$count" ]; then
1668 elif [ "$count" != "$mis_syn_nr" ]; then
1669 fail_test "got $count JOIN[s] syn with a mismatched \
1670 port-number expected $mis_syn_nr"
1676 count=$(get_counter ${ns1} "MPTcpExtMismatchPortAckRx")
1677 if [ -z "$count" ]; then
1679 elif [ "$count" != "$mis_ack_nr" ]; then
1680 fail_test "got $count JOIN[s] ack with a mismatched \
1681 port-number expected $mis_ack_nr"
1695 timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout)
1697 print_check "add TX"
1698 count=$(get_counter ${ns1} "MPTcpExtAddAddrTx")
1699 if [ -z "$count" ]; then
1701 # if the test configured a short timeout tolerate greater then expected
1702 # add addrs options, due to retransmissions
1703 elif [ "$count" != "$add_tx_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_tx_nr" ]; }; then
1704 fail_test "got $count ADD_ADDR[s] TX, expected $add_tx_nr"
1709 print_check "echo TX"
1710 count=$(get_counter ${ns2} "MPTcpExtEchoAddTx")
1711 if [ -z "$count" ]; then
1713 elif [ "$count" != "$echo_tx_nr" ]; then
1714 fail_test "got $count ADD_ADDR echo[s] TX, expected $echo_tx_nr"
1723 local rm_subflow_nr=$2
1728 local subflow_ns=$ns2
1732 while [ -n "$1" ]; do
1733 [ "$1" = "invert" ] && invert=true
1734 [ "$1" = "simult" ] && simult=true
1738 if [ -z $invert ]; then
1741 elif [ $invert = "true" ]; then
1748 count=$(get_counter ${addr_ns} "MPTcpExtRmAddr")
1749 if [ -z "$count" ]; then
1751 elif [ "$count" != "$rm_addr_nr" ]; then
1752 fail_test "got $count RM_ADDR[s] expected $rm_addr_nr"
1758 count=$(get_counter ${subflow_ns} "MPTcpExtRmSubflow")
1759 if [ -z "$count" ]; then
1761 elif [ -n "$simult" ]; then
1764 cnt=$(get_counter ${addr_ns} "MPTcpExtRmSubflow")
1766 # in case of simult flush, the subflow removal count on each side is
1768 count=$((count + cnt))
1769 [ "$count" != "$rm_subflow_nr" ] && suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]"
1770 if [ $count -ge "$rm_subflow_nr" ] && \
1771 [ "$count" -le "$((rm_subflow_nr *2 ))" ]; then
1774 fail_test "got $count RM_SUBFLOW[s] expected in range [$rm_subflow_nr:$((rm_subflow_nr*2))]"
1776 elif [ "$count" != "$rm_subflow_nr" ]; then
1777 fail_test "got $count RM_SUBFLOW[s] expected $rm_subflow_nr"
1782 print_info "$extra_msg"
1787 local rm_addr_tx_nr=$1
1790 count=$(get_counter ${ns2} "MPTcpExtRmAddrTx")
1791 if [ -z "$count" ]; then
1793 elif [ "$count" != "$rm_addr_tx_nr" ]; then
1794 fail_test "got $count RM_ADDR[s] expected $rm_addr_tx_nr"
1802 local mp_prio_nr_tx=$1
1803 local mp_prio_nr_rx=$2
1807 count=$(get_counter ${ns1} "MPTcpExtMPPrioTx")
1808 if [ -z "$count" ]; then
1810 elif [ "$count" != "$mp_prio_nr_tx" ]; then
1811 fail_test "got $count MP_PRIO[s] TX expected $mp_prio_nr_tx"
1817 count=$(get_counter ${ns1} "MPTcpExtMPPrioRx")
1818 if [ -z "$count" ]; then
1820 elif [ "$count" != "$mp_prio_nr_rx" ]; then
1821 fail_test "got $count MP_PRIO[s] RX expected $mp_prio_nr_rx"
1835 print_check "${msg}"
1837 cnt1=$(ss -N $ns1 -tOni | grep -c token)
1838 cnt2=$(ss -N $ns2 -tOni | grep -c token)
1839 if [ "$cnt1" != "$subflow_nr" ] || [ "$cnt2" != "$subflow_nr" ]; then
1840 fail_test "got $cnt1:$cnt2 subflows expected $subflow_nr"
1846 if [ "${dump_stats}" = 1 ]; then
1848 ss -N $ns1 -tOni | grep token
1849 ip -n $ns1 mptcp endpoint
1863 print_check "mptcp_info ${info1:0:8}=$exp1:$exp2"
1865 cnt1=$(ss -N $ns1 -inmHM | grep "$info1:" |
1866 sed -n 's/.*\('"$info1"':\)\([[:digit:]]*\).*$/\2/p;q')
1867 cnt2=$(ss -N $ns2 -inmHM | grep "$info2:" |
1868 sed -n 's/.*\('"$info2"':\)\([[:digit:]]*\).*$/\2/p;q')
1869 # 'ss' only display active connections and counters that are not 0.
1870 [ -z "$cnt1" ] && cnt1=0
1871 [ -z "$cnt2" ] && cnt2=0
1873 if [ "$cnt1" != "$exp1" ] || [ "$cnt2" != "$exp2" ]; then
1874 fail_test "got $cnt1:$cnt2 $info1:$info2 expected $exp1:$exp2"
1880 if [ "$dump_stats" = 1 ]; then
1891 local expected_rate=$4
1893 local tx_link tx_total
1894 tx_link=$(ip netns exec $ns cat /sys/class/net/$link/statistics/tx_bytes)
1895 tx_total=$(stat --format=%s $out)
1896 local tx_rate=$((tx_link * 100 / tx_total))
1899 print_check "link usage"
1900 if [ $tx_rate -lt $((expected_rate - tolerance)) ] || \
1901 [ $tx_rate -gt $((expected_rate + tolerance)) ]; then
1902 fail_test "got $tx_rate% usage, expected $expected_rate%"
1910 local timeout_ms=$((timeout_poll * 1000))
1914 while [ $time -lt $timeout_ms ]; do
1917 cnt=$(get_counter ${ns} "TcpAttemptFails")
1919 [ "$cnt" = 1 ] && return 1
1920 time=$((time + 100))
1930 ip netns exec $ns sysctl -q net.mptcp.pm_type=1
1935 if reset "no JOIN"; then
1936 run_tests $ns1 $ns2 10.0.1.1
1940 # subflow limited by client
1941 if reset "single subflow, limited by client"; then
1942 pm_nl_set_limits $ns1 0 0
1943 pm_nl_set_limits $ns2 0 0
1944 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1945 run_tests $ns1 $ns2 10.0.1.1
1949 # subflow limited by server
1950 if reset "single subflow, limited by server"; then
1951 pm_nl_set_limits $ns1 0 0
1952 pm_nl_set_limits $ns2 0 1
1953 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1954 run_tests $ns1 $ns2 10.0.1.1
1959 if reset "single subflow"; then
1960 pm_nl_set_limits $ns1 0 1
1961 pm_nl_set_limits $ns2 0 1
1962 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1963 run_tests $ns1 $ns2 10.0.1.1
1968 if reset "multiple subflows"; then
1969 pm_nl_set_limits $ns1 0 2
1970 pm_nl_set_limits $ns2 0 2
1971 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1972 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1973 run_tests $ns1 $ns2 10.0.1.1
1977 # multiple subflows limited by server
1978 if reset "multiple subflows, limited by server"; then
1979 pm_nl_set_limits $ns1 0 1
1980 pm_nl_set_limits $ns2 0 2
1981 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1982 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1983 run_tests $ns1 $ns2 10.0.1.1
1987 # single subflow, dev
1988 if reset "single subflow, dev"; then
1989 pm_nl_set_limits $ns1 0 1
1990 pm_nl_set_limits $ns2 0 1
1991 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow dev ns2eth3
1992 run_tests $ns1 $ns2 10.0.1.1
1997 subflows_error_tests()
1999 # If a single subflow is configured, and matches the MPC src
2000 # address, no additional subflow should be created
2001 if reset "no MPC reuse with single endpoint"; then
2002 pm_nl_set_limits $ns1 0 1
2003 pm_nl_set_limits $ns2 0 1
2004 pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow
2006 run_tests $ns1 $ns2 10.0.1.1
2010 # multiple subflows, with subflow creation error
2011 if reset_with_tcp_filter "multi subflows, with failing subflow" ns1 10.0.3.2 REJECT &&
2012 continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then
2013 pm_nl_set_limits $ns1 0 2
2014 pm_nl_set_limits $ns2 0 2
2015 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2016 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
2018 run_tests $ns1 $ns2 10.0.1.1
2022 # multiple subflows, with subflow timeout on MPJ
2023 if reset_with_tcp_filter "multi subflows, with subflow timeout" ns1 10.0.3.2 DROP &&
2024 continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then
2025 pm_nl_set_limits $ns1 0 2
2026 pm_nl_set_limits $ns2 0 2
2027 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2028 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
2030 run_tests $ns1 $ns2 10.0.1.1
2034 # multiple subflows, check that the endpoint corresponding to
2035 # closed subflow (due to reset) is not reused if additional
2036 # subflows are added later
2037 if reset_with_tcp_filter "multi subflows, fair usage on close" ns1 10.0.3.2 REJECT &&
2038 continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then
2039 pm_nl_set_limits $ns1 0 1
2040 pm_nl_set_limits $ns2 0 1
2041 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2043 run_tests $ns1 $ns2 10.0.1.1 &
2045 # mpj subflow will be in TW after the reset
2046 wait_attempt_fail $ns2
2047 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
2050 # additional subflow could be created only if the PM select
2051 # the later endpoint, skipping the already used one
2056 signal_address_tests()
2058 # add_address, unused
2059 if reset "unused signal address"; then
2060 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2061 run_tests $ns1 $ns2 10.0.1.1
2067 # accept and use add_addr
2068 if reset "signal address"; then
2069 pm_nl_set_limits $ns1 0 1
2070 pm_nl_set_limits $ns2 1 1
2071 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2072 run_tests $ns1 $ns2 10.0.1.1
2077 # accept and use add_addr with an additional subflow
2078 # note: signal address in server ns and local addresses in client ns must
2079 # belong to different subnets or one of the listed local address could be
2080 # used for 'add_addr' subflow
2081 if reset "subflow and signal"; then
2082 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2083 pm_nl_set_limits $ns1 0 2
2084 pm_nl_set_limits $ns2 1 2
2085 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2086 run_tests $ns1 $ns2 10.0.1.1
2091 # accept and use add_addr with additional subflows
2092 if reset "multiple subflows and signal"; then
2093 pm_nl_set_limits $ns1 0 3
2094 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2095 pm_nl_set_limits $ns2 1 3
2096 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2097 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
2098 run_tests $ns1 $ns2 10.0.1.1
2104 if reset "signal addresses"; then
2105 pm_nl_set_limits $ns1 3 3
2106 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2107 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2108 pm_nl_add_endpoint $ns1 10.0.4.1 flags signal
2109 pm_nl_set_limits $ns2 3 3
2110 run_tests $ns1 $ns2 10.0.1.1
2115 # signal invalid addresses
2116 if reset "signal invalid addresses"; then
2117 pm_nl_set_limits $ns1 3 3
2118 pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
2119 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2120 pm_nl_add_endpoint $ns1 10.0.14.1 flags signal
2121 pm_nl_set_limits $ns2 3 3
2122 run_tests $ns1 $ns2 10.0.1.1
2127 # signal addresses race test
2128 if reset "signal addresses race test"; then
2129 pm_nl_set_limits $ns1 4 4
2130 pm_nl_set_limits $ns2 4 4
2131 pm_nl_add_endpoint $ns1 10.0.1.1 flags signal
2132 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2133 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2134 pm_nl_add_endpoint $ns1 10.0.4.1 flags signal
2135 pm_nl_add_endpoint $ns2 10.0.1.2 flags signal
2136 pm_nl_add_endpoint $ns2 10.0.2.2 flags signal
2137 pm_nl_add_endpoint $ns2 10.0.3.2 flags signal
2138 pm_nl_add_endpoint $ns2 10.0.4.2 flags signal
2140 # the peer could possibly miss some addr notification, allow retransmission
2141 ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
2143 run_tests $ns1 $ns2 10.0.1.1
2145 # It is not directly linked to the commit introducing this
2146 # symbol but for the parent one which is linked anyway.
2147 if ! mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then
2152 # the server will not signal the address terminating
2159 link_failure_tests()
2161 # accept and use add_addr with additional subflows and link loss
2162 if reset "multiple flows, signal, link failure"; then
2163 # without any b/w limit each veth could spool the packets and get
2164 # them acked at xmit time, so that the corresponding subflow will
2165 # have almost always no outstanding pkts, the scheduler will pick
2166 # always the first subflow and we will have hard time testing
2167 # active backup and link switch-over.
2168 # Let's set some arbitrary (low) virtual link limits.
2170 pm_nl_set_limits $ns1 0 3
2171 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
2172 pm_nl_set_limits $ns2 1 3
2173 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow
2174 pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow
2176 run_tests $ns1 $ns2 10.0.1.1
2179 chk_stale_nr $ns2 1 5 1
2182 # accept and use add_addr with additional subflows and link loss
2183 # for bidirectional transfer
2184 if reset "multi flows, signal, bidi, link fail"; then
2186 pm_nl_set_limits $ns1 0 3
2187 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
2188 pm_nl_set_limits $ns2 1 3
2189 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow
2190 pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow
2192 run_tests $ns1 $ns2 10.0.1.1
2195 chk_stale_nr $ns2 1 -1 1
2198 # 2 subflows plus 1 backup subflow with a lossy link, backup
2199 # will never be used
2200 if reset "backup subflow unused, link failure"; then
2202 pm_nl_set_limits $ns1 0 2
2203 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
2204 pm_nl_set_limits $ns2 1 2
2205 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup
2206 FAILING_LINKS="1" test_linkfail=1 \
2207 run_tests $ns1 $ns2 10.0.1.1
2210 chk_link_usage $ns2 ns2eth3 $cinsent 0
2213 # 2 lossy links after half transfer, backup will get half of
2215 if reset "backup flow used, multi links fail"; then
2217 pm_nl_set_limits $ns1 0 2
2218 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
2219 pm_nl_set_limits $ns2 1 2
2220 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup
2221 FAILING_LINKS="1 2" test_linkfail=1 \
2222 run_tests $ns1 $ns2 10.0.1.1
2225 chk_stale_nr $ns2 2 4 2
2226 chk_link_usage $ns2 ns2eth3 $cinsent 50
2229 # use a backup subflow with the first subflow on a lossy link
2230 # for bidirectional transfer
2231 if reset "backup flow used, bidi, link failure"; then
2233 pm_nl_set_limits $ns1 0 2
2234 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
2235 pm_nl_set_limits $ns2 1 3
2236 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup
2237 FAILING_LINKS="1 2" test_linkfail=2 \
2238 run_tests $ns1 $ns2 10.0.1.1
2241 chk_stale_nr $ns2 1 -1 2
2242 chk_link_usage $ns2 ns2eth3 $cinsent 50
2246 add_addr_timeout_tests()
2249 if reset_with_add_addr_timeout "signal address, ADD_ADDR timeout"; then
2250 pm_nl_set_limits $ns1 0 1
2251 pm_nl_set_limits $ns2 1 1
2252 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2254 run_tests $ns1 $ns2 10.0.1.1
2260 # add_addr timeout IPv6
2261 if reset_with_add_addr_timeout "signal address, ADD_ADDR6 timeout" 6; then
2262 pm_nl_set_limits $ns1 0 1
2263 pm_nl_set_limits $ns2 1 1
2264 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
2266 run_tests $ns1 $ns2 dead:beef:1::1
2271 # signal addresses timeout
2272 if reset_with_add_addr_timeout "signal addresses, ADD_ADDR timeout"; then
2273 pm_nl_set_limits $ns1 2 2
2274 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2275 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2276 pm_nl_set_limits $ns2 2 2
2278 run_tests $ns1 $ns2 10.0.1.1
2283 # signal invalid addresses timeout
2284 if reset_with_add_addr_timeout "invalid address, ADD_ADDR timeout"; then
2285 pm_nl_set_limits $ns1 2 2
2286 pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
2287 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2288 pm_nl_set_limits $ns2 2 2
2290 run_tests $ns1 $ns2 10.0.1.1
2298 # single subflow, remove
2299 if reset "remove single subflow"; then
2300 pm_nl_set_limits $ns1 0 1
2301 pm_nl_set_limits $ns2 0 1
2302 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2303 addr_nr_ns2=-1 speed=slow \
2304 run_tests $ns1 $ns2 10.0.1.1
2310 # multiple subflows, remove
2311 if reset "remove multiple subflows"; then
2312 pm_nl_set_limits $ns1 0 2
2313 pm_nl_set_limits $ns2 0 2
2314 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
2315 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2316 addr_nr_ns2=-2 speed=slow \
2317 run_tests $ns1 $ns2 10.0.1.1
2322 # single address, remove
2323 if reset "remove single address"; then
2324 pm_nl_set_limits $ns1 0 1
2325 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2326 pm_nl_set_limits $ns2 1 1
2327 addr_nr_ns1=-1 speed=slow \
2328 run_tests $ns1 $ns2 10.0.1.1
2331 chk_rm_nr 1 1 invert
2334 # subflow and signal, remove
2335 if reset "remove subflow and signal"; then
2336 pm_nl_set_limits $ns1 0 2
2337 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2338 pm_nl_set_limits $ns2 1 2
2339 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2340 addr_nr_ns1=-1 addr_nr_ns2=-1 speed=slow \
2341 run_tests $ns1 $ns2 10.0.1.1
2347 # subflows and signal, remove
2348 if reset "remove subflows and signal"; then
2349 pm_nl_set_limits $ns1 0 3
2350 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2351 pm_nl_set_limits $ns2 1 3
2352 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2353 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
2354 addr_nr_ns1=-1 addr_nr_ns2=-2 speed=10 \
2355 run_tests $ns1 $ns2 10.0.1.1
2362 if reset "remove addresses"; then
2363 pm_nl_set_limits $ns1 3 3
2364 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250
2365 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2366 pm_nl_add_endpoint $ns1 10.0.4.1 flags signal
2367 pm_nl_set_limits $ns2 3 3
2368 addr_nr_ns1=-3 speed=10 \
2369 run_tests $ns1 $ns2 10.0.1.1
2372 chk_rm_nr 3 3 invert
2375 # invalid addresses remove
2376 if reset "remove invalid addresses"; then
2377 pm_nl_set_limits $ns1 3 3
2378 pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
2379 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2380 pm_nl_add_endpoint $ns1 10.0.14.1 flags signal
2381 pm_nl_set_limits $ns2 3 3
2382 addr_nr_ns1=-3 speed=10 \
2383 run_tests $ns1 $ns2 10.0.1.1
2386 chk_rm_nr 3 1 invert
2389 # subflows and signal, flush
2390 if reset "flush subflows and signal"; then
2391 pm_nl_set_limits $ns1 0 3
2392 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2393 pm_nl_set_limits $ns2 1 3
2394 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2395 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
2396 addr_nr_ns1=-8 addr_nr_ns2=-8 speed=slow \
2397 run_tests $ns1 $ns2 10.0.1.1
2400 chk_rm_nr 1 3 invert simult
2404 if reset "flush subflows"; then
2405 pm_nl_set_limits $ns1 3 3
2406 pm_nl_set_limits $ns2 3 3
2407 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow id 150
2408 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2409 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
2410 addr_nr_ns1=-8 addr_nr_ns2=-8 speed=slow \
2411 run_tests $ns1 $ns2 10.0.1.1
2414 if mptcp_lib_kversion_ge 5.18; then
2416 chk_rm_nr 0 3 simult
2423 if reset "flush addresses"; then
2424 pm_nl_set_limits $ns1 3 3
2425 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250
2426 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2427 pm_nl_add_endpoint $ns1 10.0.4.1 flags signal
2428 pm_nl_set_limits $ns2 3 3
2429 addr_nr_ns1=-8 addr_nr_ns2=-8 speed=slow \
2430 run_tests $ns1 $ns2 10.0.1.1
2433 chk_rm_nr 3 3 invert simult
2436 # invalid addresses flush
2437 if reset "flush invalid addresses"; then
2438 pm_nl_set_limits $ns1 3 3
2439 pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
2440 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2441 pm_nl_add_endpoint $ns1 10.0.14.1 flags signal
2442 pm_nl_set_limits $ns2 3 3
2443 addr_nr_ns1=-8 speed=slow \
2444 run_tests $ns1 $ns2 10.0.1.1
2447 chk_rm_nr 3 1 invert
2450 # remove id 0 subflow
2451 if reset "remove id 0 subflow"; then
2452 pm_nl_set_limits $ns1 0 1
2453 pm_nl_set_limits $ns2 0 1
2454 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2455 addr_nr_ns2=-9 speed=slow \
2456 run_tests $ns1 $ns2 10.0.1.1
2461 # remove id 0 address
2462 if reset "remove id 0 address"; then
2463 pm_nl_set_limits $ns1 0 1
2464 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2465 pm_nl_set_limits $ns2 1 1
2466 addr_nr_ns1=-9 speed=slow \
2467 run_tests $ns1 $ns2 10.0.1.1
2470 chk_rm_nr 1 1 invert
2476 # add single subflow
2477 if reset "add single subflow"; then
2478 pm_nl_set_limits $ns1 0 1
2479 pm_nl_set_limits $ns2 0 1
2480 addr_nr_ns2=1 speed=slow \
2481 run_tests $ns1 $ns2 10.0.1.1
2485 # add signal address
2486 if reset "add signal address"; then
2487 pm_nl_set_limits $ns1 0 1
2488 pm_nl_set_limits $ns2 1 1
2489 addr_nr_ns1=1 speed=slow \
2490 run_tests $ns1 $ns2 10.0.1.1
2495 # add multiple subflows
2496 if reset "add multiple subflows"; then
2497 pm_nl_set_limits $ns1 0 2
2498 pm_nl_set_limits $ns2 0 2
2499 addr_nr_ns2=2 speed=slow \
2500 run_tests $ns1 $ns2 10.0.1.1
2504 # add multiple subflows IPv6
2505 if reset "add multiple subflows IPv6"; then
2506 pm_nl_set_limits $ns1 0 2
2507 pm_nl_set_limits $ns2 0 2
2508 addr_nr_ns2=2 speed=slow \
2509 run_tests $ns1 $ns2 dead:beef:1::1
2513 # add multiple addresses IPv6
2514 if reset "add multiple addresses IPv6"; then
2515 pm_nl_set_limits $ns1 0 2
2516 pm_nl_set_limits $ns2 2 2
2517 addr_nr_ns1=2 speed=slow \
2518 run_tests $ns1 $ns2 dead:beef:1::1
2527 if reset "single subflow IPv6"; then
2528 pm_nl_set_limits $ns1 0 1
2529 pm_nl_set_limits $ns2 0 1
2530 pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow
2532 run_tests $ns1 $ns2 dead:beef:1::1
2536 # add_address, unused IPv6
2537 if reset "unused signal address IPv6"; then
2538 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
2540 run_tests $ns1 $ns2 dead:beef:1::1
2545 # signal address IPv6
2546 if reset "single address IPv6"; then
2547 pm_nl_set_limits $ns1 0 1
2548 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
2549 pm_nl_set_limits $ns2 1 1
2551 run_tests $ns1 $ns2 dead:beef:1::1
2556 # single address IPv6, remove
2557 if reset "remove single address IPv6"; then
2558 pm_nl_set_limits $ns1 0 1
2559 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
2560 pm_nl_set_limits $ns2 1 1
2561 addr_nr_ns1=-1 speed=slow \
2562 run_tests $ns1 $ns2 dead:beef:1::1
2565 chk_rm_nr 1 1 invert
2568 # subflow and signal IPv6, remove
2569 if reset "remove subflow and signal IPv6"; then
2570 pm_nl_set_limits $ns1 0 2
2571 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
2572 pm_nl_set_limits $ns2 1 2
2573 pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow
2574 addr_nr_ns1=-1 addr_nr_ns2=-1 speed=slow \
2575 run_tests $ns1 $ns2 dead:beef:1::1
2584 # subflow IPv4-mapped to IPv4-mapped
2585 if reset "single subflow IPv4-mapped"; then
2586 pm_nl_set_limits $ns1 0 1
2587 pm_nl_set_limits $ns2 0 1
2588 pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow
2589 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
2593 # signal address IPv4-mapped with IPv4-mapped sk
2594 if reset "signal address IPv4-mapped"; then
2595 pm_nl_set_limits $ns1 0 1
2596 pm_nl_set_limits $ns2 1 1
2597 pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal
2598 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
2604 if reset "single subflow v4-map-v6"; then
2605 pm_nl_set_limits $ns1 0 1
2606 pm_nl_set_limits $ns2 0 1
2607 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2608 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
2612 # signal address v4-map-v6
2613 if reset "signal address v4-map-v6"; then
2614 pm_nl_set_limits $ns1 0 1
2615 pm_nl_set_limits $ns2 1 1
2616 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2617 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
2623 if reset "single subflow v6-map-v4"; then
2624 pm_nl_set_limits $ns1 0 1
2625 pm_nl_set_limits $ns2 0 1
2626 pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow
2627 run_tests $ns1 $ns2 10.0.1.1
2631 # signal address v6-map-v4
2632 if reset "signal address v6-map-v4"; then
2633 pm_nl_set_limits $ns1 0 1
2634 pm_nl_set_limits $ns2 1 1
2635 pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal
2636 run_tests $ns1 $ns2 10.0.1.1
2641 # no subflow IPv6 to v4 address
2642 if reset "no JOIN with diff families v4-v6"; then
2643 pm_nl_set_limits $ns1 0 1
2644 pm_nl_set_limits $ns2 0 1
2645 pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow
2646 run_tests $ns1 $ns2 10.0.1.1
2650 # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end
2651 if reset "no JOIN with diff families v4-v6-2"; then
2652 pm_nl_set_limits $ns1 0 1
2653 pm_nl_set_limits $ns2 0 1
2654 pm_nl_add_endpoint $ns2 dead:beef:2::10.0.3.2 flags subflow
2655 run_tests $ns1 $ns2 10.0.1.1
2659 # no subflow IPv4 to v6 address, no need to slow down too then
2660 if reset "no JOIN with diff families v6-v4"; then
2661 pm_nl_set_limits $ns1 0 1
2662 pm_nl_set_limits $ns2 0 1
2663 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2664 run_tests $ns1 $ns2 dead:beef:1::1
2671 if reset "IPv4 sockets do not use IPv6 addresses" &&
2672 continue_if mptcp_lib_kversion_ge 6.3; then
2673 pm_nl_set_limits $ns1 0 1
2674 pm_nl_set_limits $ns2 1 1
2675 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
2677 run_tests $ns1 $ns2 10.0.1.1
2681 # Need an IPv6 mptcp socket to allow subflows of both families
2682 if reset "simult IPv4 and IPv6 subflows" &&
2683 continue_if mptcp_lib_kversion_ge 6.3; then
2684 pm_nl_set_limits $ns1 0 1
2685 pm_nl_set_limits $ns2 1 1
2686 pm_nl_add_endpoint $ns1 10.0.1.1 flags signal
2688 run_tests $ns1 $ns2 dead:beef:2::1
2692 # cross families subflows will not be created even in fullmesh mode
2693 if reset "simult IPv4 and IPv6 subflows, fullmesh 1x1" &&
2694 continue_if mptcp_lib_kversion_ge 6.3; then
2695 pm_nl_set_limits $ns1 0 4
2696 pm_nl_set_limits $ns2 1 4
2697 pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow,fullmesh
2698 pm_nl_add_endpoint $ns1 10.0.1.1 flags signal
2700 run_tests $ns1 $ns2 dead:beef:2::1
2704 # fullmesh still tries to create all the possibly subflows with
2706 if reset "simult IPv4 and IPv6 subflows, fullmesh 2x2" &&
2707 continue_if mptcp_lib_kversion_ge 6.3; then
2708 pm_nl_set_limits $ns1 0 4
2709 pm_nl_set_limits $ns2 2 4
2710 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2711 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
2712 fullmesh=1 speed=slow \
2713 run_tests $ns1 $ns2 dead:beef:1::1
2720 # single subflow, backup
2721 if reset "single subflow, backup" &&
2722 continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
2723 pm_nl_set_limits $ns1 0 1
2724 pm_nl_set_limits $ns2 0 1
2725 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup
2726 sflags=nobackup speed=slow \
2727 run_tests $ns1 $ns2 10.0.1.1
2732 # single address, backup
2733 if reset "single address, backup" &&
2734 continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
2735 pm_nl_set_limits $ns1 0 1
2736 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2737 pm_nl_set_limits $ns2 1 1
2738 sflags=backup speed=slow \
2739 run_tests $ns1 $ns2 10.0.1.1
2745 # single address with port, backup
2746 if reset "single address with port, backup" &&
2747 continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
2748 pm_nl_set_limits $ns1 0 1
2749 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2750 pm_nl_set_limits $ns2 1 1
2751 sflags=backup speed=slow \
2752 run_tests $ns1 $ns2 10.0.1.1
2758 if reset "mpc backup" &&
2759 continue_if mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"; then
2760 pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,backup
2762 run_tests $ns1 $ns2 10.0.1.1
2767 if reset "mpc backup both sides" &&
2768 continue_if mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"; then
2769 pm_nl_add_endpoint $ns1 10.0.1.1 flags subflow,backup
2770 pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,backup
2772 run_tests $ns1 $ns2 10.0.1.1
2777 if reset "mpc switch to backup" &&
2778 continue_if mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"; then
2779 pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow
2780 sflags=backup speed=slow \
2781 run_tests $ns1 $ns2 10.0.1.1
2786 if reset "mpc switch to backup both sides" &&
2787 continue_if mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"; then
2788 pm_nl_add_endpoint $ns1 10.0.1.1 flags subflow
2789 pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow
2790 sflags=backup speed=slow \
2791 run_tests $ns1 $ns2 10.0.1.1
2797 LISTENER_CREATED=15 #MPTCP_EVENT_LISTENER_CREATED
2798 LISTENER_CLOSED=16 #MPTCP_EVENT_LISTENER_CLOSED
2803 verify_listener_events()
2816 if [ $e_type = $LISTENER_CREATED ]; then
2817 name="LISTENER_CREATED"
2818 elif [ $e_type = $LISTENER_CLOSED ]; then
2819 name="LISTENER_CLOSED "
2824 print_check "$name $e_saddr:$e_sport"
2826 if ! mptcp_lib_kallsyms_has "mptcp_event_pm_listener$"; then
2827 print_skip "event not supported"
2831 type=$(grep "type:$e_type," $evt | sed -n 's/.*\(type:\)\([[:digit:]]*\).*$/\2/p;q')
2832 family=$(grep "type:$e_type," $evt | sed -n 's/.*\(family:\)\([[:digit:]]*\).*$/\2/p;q')
2833 sport=$(grep "type:$e_type," $evt | sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q')
2834 if [ $family ] && [ $family = $AF_INET6 ]; then
2835 saddr=$(grep "type:$e_type," $evt | sed -n 's/.*\(saddr6:\)\([0-9a-f:.]*\).*$/\2/p;q')
2837 saddr=$(grep "type:$e_type," $evt | sed -n 's/.*\(saddr4:\)\([0-9.]*\).*$/\2/p;q')
2840 if [ $type ] && [ $type = $e_type ] &&
2841 [ $family ] && [ $family = $e_family ] &&
2842 [ $saddr ] && [ $saddr = $e_saddr ] &&
2843 [ $sport ] && [ $sport = $e_sport ]; then
2847 fail_test "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport"
2850 add_addr_ports_tests()
2852 # signal address with port
2853 if reset "signal address with port"; then
2854 pm_nl_set_limits $ns1 0 1
2855 pm_nl_set_limits $ns2 1 1
2856 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2857 run_tests $ns1 $ns2 10.0.1.1
2862 # subflow and signal with port
2863 if reset "subflow and signal with port"; then
2864 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2865 pm_nl_set_limits $ns1 0 2
2866 pm_nl_set_limits $ns2 1 2
2867 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2868 run_tests $ns1 $ns2 10.0.1.1
2873 # single address with port, remove
2874 # pm listener events
2875 if reset_with_events "remove single address with port"; then
2876 pm_nl_set_limits $ns1 0 1
2877 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2878 pm_nl_set_limits $ns2 1 1
2879 addr_nr_ns1=-1 speed=slow \
2880 run_tests $ns1 $ns2 10.0.1.1
2883 chk_rm_nr 1 1 invert
2885 verify_listener_events $evts_ns1 $LISTENER_CREATED $AF_INET 10.0.2.1 10100
2886 verify_listener_events $evts_ns1 $LISTENER_CLOSED $AF_INET 10.0.2.1 10100
2890 # subflow and signal with port, remove
2891 if reset "remove subflow and signal with port"; then
2892 pm_nl_set_limits $ns1 0 2
2893 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2894 pm_nl_set_limits $ns2 1 2
2895 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2896 addr_nr_ns1=-1 addr_nr_ns2=-1 speed=slow \
2897 run_tests $ns1 $ns2 10.0.1.1
2903 # subflows and signal with port, flush
2904 if reset "flush subflows and signal with port"; then
2905 pm_nl_set_limits $ns1 0 3
2906 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2907 pm_nl_set_limits $ns2 1 3
2908 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2909 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
2910 addr_nr_ns1=-8 addr_nr_ns2=-2 speed=slow \
2911 run_tests $ns1 $ns2 10.0.1.1
2914 chk_rm_nr 1 3 invert simult
2917 # multiple addresses with port
2918 if reset "multiple addresses with port"; then
2919 pm_nl_set_limits $ns1 2 2
2920 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2921 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10100
2922 pm_nl_set_limits $ns2 2 2
2923 run_tests $ns1 $ns2 10.0.1.1
2928 # multiple addresses with ports
2929 if reset "multiple addresses with ports"; then
2930 pm_nl_set_limits $ns1 2 2
2931 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2932 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10101
2933 pm_nl_set_limits $ns2 2 2
2934 run_tests $ns1 $ns2 10.0.1.1
2942 # single subflow, syncookies
2943 if reset_with_cookies "single subflow with syn cookies"; then
2944 pm_nl_set_limits $ns1 0 1
2945 pm_nl_set_limits $ns2 0 1
2946 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2947 run_tests $ns1 $ns2 10.0.1.1
2951 # multiple subflows with syn cookies
2952 if reset_with_cookies "multiple subflows with syn cookies"; then
2953 pm_nl_set_limits $ns1 0 2
2954 pm_nl_set_limits $ns2 0 2
2955 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2956 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
2957 run_tests $ns1 $ns2 10.0.1.1
2961 # multiple subflows limited by server
2962 if reset_with_cookies "subflows limited by server w cookies"; then
2963 pm_nl_set_limits $ns1 0 1
2964 pm_nl_set_limits $ns2 0 2
2965 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2966 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
2967 run_tests $ns1 $ns2 10.0.1.1
2971 # test signal address with cookies
2972 if reset_with_cookies "signal address with syn cookies"; then
2973 pm_nl_set_limits $ns1 0 1
2974 pm_nl_set_limits $ns2 1 1
2975 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2976 run_tests $ns1 $ns2 10.0.1.1
2981 # test cookie with subflow and signal
2982 if reset_with_cookies "subflow and signal w cookies"; then
2983 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2984 pm_nl_set_limits $ns1 0 2
2985 pm_nl_set_limits $ns2 1 2
2986 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2987 run_tests $ns1 $ns2 10.0.1.1
2992 # accept and use add_addr with additional subflows
2993 if reset_with_cookies "subflows and signal w. cookies"; then
2994 pm_nl_set_limits $ns1 0 3
2995 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2996 pm_nl_set_limits $ns2 1 3
2997 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2998 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
2999 run_tests $ns1 $ns2 10.0.1.1
3008 if reset_with_checksum 0 0; then
3009 pm_nl_set_limits $ns1 0 1
3010 pm_nl_set_limits $ns2 0 1
3011 run_tests $ns1 $ns2 10.0.1.1
3016 if reset_with_checksum 1 1; then
3017 pm_nl_set_limits $ns1 0 1
3018 pm_nl_set_limits $ns2 0 1
3019 run_tests $ns1 $ns2 10.0.1.1
3024 if reset_with_checksum 0 1; then
3025 pm_nl_set_limits $ns1 0 1
3026 pm_nl_set_limits $ns2 0 1
3027 run_tests $ns1 $ns2 10.0.1.1
3032 if reset_with_checksum 1 0; then
3033 pm_nl_set_limits $ns1 0 1
3034 pm_nl_set_limits $ns2 0 1
3035 run_tests $ns1 $ns2 10.0.1.1
3040 deny_join_id0_tests()
3042 # subflow allow join id0 ns1
3043 if reset_with_allow_join_id0 "single subflow allow join id0 ns1" 1 0; then
3044 pm_nl_set_limits $ns1 1 1
3045 pm_nl_set_limits $ns2 1 1
3046 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
3047 run_tests $ns1 $ns2 10.0.1.1
3051 # subflow allow join id0 ns2
3052 if reset_with_allow_join_id0 "single subflow allow join id0 ns2" 0 1; then
3053 pm_nl_set_limits $ns1 1 1
3054 pm_nl_set_limits $ns2 1 1
3055 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
3056 run_tests $ns1 $ns2 10.0.1.1
3060 # signal address allow join id0 ns1
3061 # ADD_ADDRs are not affected by allow_join_id0 value.
3062 if reset_with_allow_join_id0 "signal address allow join id0 ns1" 1 0; then
3063 pm_nl_set_limits $ns1 1 1
3064 pm_nl_set_limits $ns2 1 1
3065 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
3066 run_tests $ns1 $ns2 10.0.1.1
3071 # signal address allow join id0 ns2
3072 # ADD_ADDRs are not affected by allow_join_id0 value.
3073 if reset_with_allow_join_id0 "signal address allow join id0 ns2" 0 1; then
3074 pm_nl_set_limits $ns1 1 1
3075 pm_nl_set_limits $ns2 1 1
3076 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
3077 run_tests $ns1 $ns2 10.0.1.1
3082 # subflow and address allow join id0 ns1
3083 if reset_with_allow_join_id0 "subflow and address allow join id0 1" 1 0; then
3084 pm_nl_set_limits $ns1 2 2
3085 pm_nl_set_limits $ns2 2 2
3086 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
3087 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
3088 run_tests $ns1 $ns2 10.0.1.1
3092 # subflow and address allow join id0 ns2
3093 if reset_with_allow_join_id0 "subflow and address allow join id0 2" 0 1; then
3094 pm_nl_set_limits $ns1 2 2
3095 pm_nl_set_limits $ns2 2 2
3096 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
3097 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
3098 run_tests $ns1 $ns2 10.0.1.1
3106 # 2 fullmesh addrs in ns2, added before the connection,
3107 # 1 non-fullmesh addr in ns1, added during the connection.
3108 if reset "fullmesh test 2x1"; then
3109 pm_nl_set_limits $ns1 0 4
3110 pm_nl_set_limits $ns2 1 4
3111 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,fullmesh
3112 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,fullmesh
3113 addr_nr_ns1=1 speed=slow \
3114 run_tests $ns1 $ns2 10.0.1.1
3120 # 1 non-fullmesh addr in ns1, added before the connection,
3121 # 1 fullmesh addr in ns2, added during the connection.
3122 if reset "fullmesh test 1x1"; then
3123 pm_nl_set_limits $ns1 1 3
3124 pm_nl_set_limits $ns2 1 3
3125 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
3126 fullmesh=1 speed=slow \
3127 run_tests $ns1 $ns2 10.0.1.1
3133 # 1 non-fullmesh addr in ns1, added before the connection,
3134 # 2 fullmesh addrs in ns2, added during the connection.
3135 if reset "fullmesh test 1x2"; then
3136 pm_nl_set_limits $ns1 2 5
3137 pm_nl_set_limits $ns2 1 5
3138 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
3139 fullmesh=2 speed=slow \
3140 run_tests $ns1 $ns2 10.0.1.1
3146 # 1 non-fullmesh addr in ns1, added before the connection,
3147 # 2 fullmesh addrs in ns2, added during the connection,
3148 # limit max_subflows to 4.
3149 if reset "fullmesh test 1x2, limited"; then
3150 pm_nl_set_limits $ns1 2 4
3151 pm_nl_set_limits $ns2 1 4
3152 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
3153 fullmesh=2 speed=slow \
3154 run_tests $ns1 $ns2 10.0.1.1
3160 if reset "set fullmesh flag test" &&
3161 continue_if mptcp_lib_kversion_ge 5.18; then
3162 pm_nl_set_limits $ns1 4 4
3163 pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow
3164 pm_nl_set_limits $ns2 4 4
3165 addr_nr_ns2=1 sflags=fullmesh speed=slow \
3166 run_tests $ns1 $ns2 10.0.1.1
3171 # set nofullmesh flag
3172 if reset "set nofullmesh flag test" &&
3173 continue_if mptcp_lib_kversion_ge 5.18; then
3174 pm_nl_set_limits $ns1 4 4
3175 pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow,fullmesh
3176 pm_nl_set_limits $ns2 4 4
3177 fullmesh=1 sflags=nofullmesh speed=slow \
3178 run_tests $ns1 $ns2 10.0.1.1
3183 # set backup,fullmesh flags
3184 if reset "set backup,fullmesh flags test" &&
3185 continue_if mptcp_lib_kversion_ge 5.18; then
3186 pm_nl_set_limits $ns1 4 4
3187 pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow
3188 pm_nl_set_limits $ns2 4 4
3189 addr_nr_ns2=1 sflags=backup,fullmesh speed=slow \
3190 run_tests $ns1 $ns2 10.0.1.1
3196 # set nobackup,nofullmesh flags
3197 if reset "set nobackup,nofullmesh flags test" &&
3198 continue_if mptcp_lib_kversion_ge 5.18; then
3199 pm_nl_set_limits $ns1 4 4
3200 pm_nl_set_limits $ns2 4 4
3201 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,backup,fullmesh
3202 sflags=nobackup,nofullmesh speed=slow \
3203 run_tests $ns1 $ns2 10.0.1.1
3212 if reset_check_counter "fastclose test" "MPTcpExtMPFastcloseTx"; then
3213 test_linkfail=1024 fastclose=client \
3214 run_tests $ns1 $ns2 10.0.1.1
3217 chk_rst_nr 1 1 invert
3220 if reset_check_counter "fastclose server test" "MPTcpExtMPFastcloseRx"; then
3221 test_linkfail=1024 fastclose=server \
3222 run_tests $ns1 $ns2 10.0.1.1
3224 chk_fclose_nr 1 1 invert
3231 tc -n $ns2 -j -s action show action pedit index 100 | \
3233 sed 's/.*"packets":\([0-9]\+\),.*/\1/'
3239 if reset_with_fail "Infinite map" 1; then
3241 run_tests $ns1 $ns2 10.0.1.1
3242 chk_join_nr 0 0 0 +1 +0 1 0 1 "$(pedit_action_pkts)"
3243 chk_fail_nr 1 -1 invert
3247 if reset_with_fail "MP_FAIL MP_RST" 2; then
3248 tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit delay 5
3249 pm_nl_set_limits $ns1 0 1
3250 pm_nl_set_limits $ns2 0 1
3251 pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow
3252 test_linkfail=1024 \
3253 run_tests $ns1 $ns2 10.0.1.1
3254 chk_join_nr 1 1 1 1 0 1 1 0 "$(pedit_action_pkts)"
3258 userspace_pm_add_addr()
3264 tk=$(grep "type:1," "$evts_ns1" |
3265 sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q')
3266 ip netns exec $ns1 ./pm_nl_ctl ann $addr token $tk id $id
3270 userspace_pm_rm_sf_addr_ns1()
3276 tk=$(grep "type:1," "$evts_ns1" |
3277 sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q')
3278 sp=$(grep "type:10" "$evts_ns1" |
3279 sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q')
3280 da=$(grep "type:10" "$evts_ns1" |
3281 sed -n 's/.*\(daddr6:\)\([0-9a-f:.]*\).*$/\2/p;q')
3282 dp=$(grep "type:10" "$evts_ns1" |
3283 sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q')
3284 ip netns exec $ns1 ./pm_nl_ctl rem token $tk id $id
3285 ip netns exec $ns1 ./pm_nl_ctl dsf lip "::ffff:$addr" \
3286 lport $sp rip $da rport $dp token $tk
3291 userspace_pm_add_sf()
3297 tk=$(sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
3298 da=$(sed -n 's/.*\(daddr4:\)\([0-9.]*\).*$/\2/p;q' "$evts_ns2")
3299 dp=$(sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
3300 ip netns exec $ns2 ./pm_nl_ctl csf lip $addr lid $id \
3301 rip $da rport $dp token $tk
3305 userspace_pm_rm_sf_addr_ns2()
3311 tk=$(sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
3312 da=$(sed -n 's/.*\(daddr4:\)\([0-9.]*\).*$/\2/p;q' "$evts_ns2")
3313 dp=$(sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
3314 sp=$(grep "type:10" "$evts_ns2" |
3315 sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q')
3316 ip netns exec $ns2 ./pm_nl_ctl rem token $tk id $id
3317 ip netns exec $ns2 ./pm_nl_ctl dsf lip $addr lport $sp \
3318 rip $da rport $dp token $tk
3325 # userspace pm type prevents add_addr
3326 if reset "userspace pm type prevents add_addr" &&
3327 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
3328 set_userspace_pm $ns1
3329 pm_nl_set_limits $ns1 0 2
3330 pm_nl_set_limits $ns2 0 2
3331 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
3332 run_tests $ns1 $ns2 10.0.1.1
3337 # userspace pm type does not echo add_addr without daemon
3338 if reset "userspace pm no echo w/o daemon" &&
3339 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
3340 set_userspace_pm $ns2
3341 pm_nl_set_limits $ns1 0 2
3342 pm_nl_set_limits $ns2 0 2
3343 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
3344 run_tests $ns1 $ns2 10.0.1.1
3349 # userspace pm type rejects join
3350 if reset "userspace pm type rejects join" &&
3351 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
3352 set_userspace_pm $ns1
3353 pm_nl_set_limits $ns1 1 1
3354 pm_nl_set_limits $ns2 1 1
3355 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
3356 run_tests $ns1 $ns2 10.0.1.1
3360 # userspace pm type does not send join
3361 if reset "userspace pm type does not send join" &&
3362 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
3363 set_userspace_pm $ns2
3364 pm_nl_set_limits $ns1 1 1
3365 pm_nl_set_limits $ns2 1 1
3366 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
3367 run_tests $ns1 $ns2 10.0.1.1
3371 # userspace pm type prevents mp_prio
3372 if reset "userspace pm type prevents mp_prio" &&
3373 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
3374 set_userspace_pm $ns1
3375 pm_nl_set_limits $ns1 1 1
3376 pm_nl_set_limits $ns2 1 1
3377 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
3378 sflags=backup speed=slow \
3379 run_tests $ns1 $ns2 10.0.1.1
3384 # userspace pm type prevents rm_addr
3385 if reset "userspace pm type prevents rm_addr" &&
3386 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
3387 set_userspace_pm $ns1
3388 set_userspace_pm $ns2
3389 pm_nl_set_limits $ns1 0 1
3390 pm_nl_set_limits $ns2 0 1
3391 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
3392 addr_nr_ns2=-1 speed=slow \
3393 run_tests $ns1 $ns2 10.0.1.1
3398 # userspace pm add & remove address
3399 if reset_with_events "userspace pm add & remove address" &&
3400 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
3401 set_userspace_pm $ns1
3402 pm_nl_set_limits $ns2 1 1
3404 run_tests $ns1 $ns2 10.0.1.1 &
3407 userspace_pm_add_addr 10.0.2.1 10
3410 chk_mptcp_info subflows 1 subflows 1
3411 chk_mptcp_info add_addr_signal 1 add_addr_accepted 1
3412 userspace_pm_rm_sf_addr_ns1 10.0.2.1 10
3413 chk_rm_nr 1 1 invert
3414 chk_mptcp_info subflows 0 subflows 0
3419 # userspace pm create destroy subflow
3420 if reset_with_events "userspace pm create destroy subflow" &&
3421 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
3422 set_userspace_pm $ns2
3423 pm_nl_set_limits $ns1 0 1
3425 run_tests $ns1 $ns2 10.0.1.1 &
3428 userspace_pm_add_sf 10.0.3.2 20
3430 chk_mptcp_info subflows 1 subflows 1
3431 userspace_pm_rm_sf_addr_ns2 10.0.3.2 20
3433 chk_mptcp_info subflows 0 subflows 0
3441 # subflow_rebuild_header is needed to support the implicit flag
3442 # userspace pm type prevents add_addr
3443 if reset "implicit EP" &&
3444 mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
3445 pm_nl_set_limits $ns1 2 2
3446 pm_nl_set_limits $ns2 2 2
3447 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
3449 run_tests $ns1 $ns2 10.0.1.1 2>/dev/null &
3452 pm_nl_check_endpoint "creation" \
3453 $ns2 10.0.2.2 id 1 flags implicit
3454 chk_mptcp_info subflows 1 subflows 1
3455 chk_mptcp_info add_addr_signal 1 add_addr_accepted 1
3457 pm_nl_add_endpoint $ns2 10.0.2.2 id 33 2>/dev/null
3458 pm_nl_check_endpoint "ID change is prevented" \
3459 $ns2 10.0.2.2 id 1 flags implicit
3461 pm_nl_add_endpoint $ns2 10.0.2.2 flags signal
3462 pm_nl_check_endpoint "modif is allowed" \
3463 $ns2 10.0.2.2 id 1 flags signal
3467 if reset "delete and re-add" &&
3468 mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
3469 pm_nl_set_limits $ns1 1 1
3470 pm_nl_set_limits $ns2 1 1
3471 pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow
3472 test_linkfail=4 speed=20 \
3473 run_tests $ns1 $ns2 10.0.1.1 2>/dev/null &
3476 chk_subflow_nr "before delete" 2
3477 chk_mptcp_info subflows 1 subflows 1
3479 pm_nl_del_endpoint $ns2 2 10.0.2.2
3481 chk_subflow_nr "after delete" 1
3482 chk_mptcp_info subflows 0 subflows 0
3484 pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow
3486 chk_subflow_nr "after re-add" 2
3487 chk_mptcp_info subflows 1 subflows 1
3492 # [$1: error message]
3495 if [ -n "${1}" ]; then
3500 echo "mptcp_join usage:"
3503 for key in "${!all_tests[@]}"; do
3504 echo " -${key} ${all_tests[${key}]}"
3507 echo " -c capture pcap files"
3508 echo " -C enable data checksum"
3509 echo " -i use ip mptcp"
3512 echo "[test ids|names]"
3518 # Use a "simple" array to force an specific order we cannot have with an associative one
3521 e@subflows_error_tests
3522 s@signal_address_tests
3523 l@link_failure_tests
3524 t@add_addr_timeout_tests
3531 p@add_addr_ports_tests
3534 d@deny_join_id0_tests
3544 for subtests in "${all_tests_sorted[@]}"; do
3545 key="${subtests%@*}"
3546 value="${subtests#*@}"
3548 all_tests_args+="${key}"
3549 all_tests_names+=("${value}")
3550 all_tests[${key}]="${value}"
3554 while getopts "${all_tests_args}cCih" opt; do
3556 ["${all_tests_args}"])
3557 tests+=("${all_tests[${opt}]}")
3572 usage "Unknown option: -${opt}"
3577 shift $((OPTIND - 1))
3579 for arg in "${@}"; do
3580 if [[ "${arg}" =~ ^[0-9]+$ ]]; then
3581 only_tests_ids+=("${arg}")
3583 only_tests_names+=("${arg}")
3587 if [ ${#tests[@]} -eq 0 ]; then
3588 tests=("${all_tests_names[@]}")
3591 for subtests in "${tests[@]}"; do
3595 if [ ${ret} -ne 0 ]; then
3597 echo "${#failed_tests[@]} failure(s) has(ve) been detected:"
3598 for i in $(get_failed_tests_ids); do
3599 echo -e "\t- ${i}: ${failed_tests[${i}]}"
3605 mptcp_lib_result_print_all_tap