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
22 timeout_test=$((timeout_poll * 2 + 1))
31 declare -a only_tests_ids
32 declare -a only_tests_names
33 declare -A failed_tests
38 export FAILING_LINKS=""
40 # generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) ||
41 # (ip6 && (ip6[74] & 0xf0) == 0x30)'"
42 CBPF_MPTCP_SUBOPTION_ADD_ADDR="14,
63 rndh=$(mktemp -u XXXXXX)
69 for netns in "$ns1" "$ns2"; do
70 ip netns add $netns || exit $ksft_skip
71 ip -net $netns link set lo up
72 ip netns exec $netns sysctl -q net.mptcp.enabled=1
73 ip netns exec $netns sysctl -q net.mptcp.pm_type=0
74 ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0
75 ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0
76 if [ $checksum -eq 1 ]; then
77 ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1
82 validate_checksum=$checksum
92 for i in $(seq 1 4); do
93 ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2"
94 ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i
95 ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad
96 ip -net "$ns1" link set ns1eth$i up
98 ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i
99 ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad
100 ip -net "$ns2" link set ns2eth$i up
102 # let $ns2 reach any $ns1 address from any interface
103 ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i
104 ip -net "$ns2" route add default via dead:beef:$i::1 dev ns2eth$i metric 10$i
111 for i in $(seq 1 4); do
112 tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1
113 tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1
122 for netns in "$ns1" "$ns2"; do
124 rm -f /tmp/$netns.{nstat,out}
130 if ! ip -Version &> /dev/null; then
131 echo "SKIP: Could not run test without ip tool"
135 if ! iptables -V &> /dev/null; then
136 echo "SKIP: Could not run all tests without iptables tool"
140 if ! ip6tables -V &> /dev/null; then
141 echo "SKIP: Could not run all tests without ip6tables tool"
159 make_file "$cin" "client" 1
160 make_file "$sin" "server" 1
165 rm -f "$cin" "$cout" "$sinfail"
166 rm -f "$sin" "$sout" "$cinsent" "$cinfail"
172 if [ "${#only_tests_ids[@]}" -eq 0 ] && [ "${#only_tests_names[@]}" -eq 0 ]; then
177 for i in "${only_tests_ids[@]}"; do
178 if [ "${TEST_COUNT}" -eq "${i}" ]; then
182 for i in "${only_tests_names[@]}"; do
183 if [ "${TEST_NAME}" = "${i}" ]; then
196 TEST_COUNT=$((TEST_COUNT+1))
202 if [ "${init}" != "1" ]; then
216 reset "${1}" || return 1
219 for netns in "$ns1" "$ns2"; do
220 ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2
225 reset_with_add_addr_timeout()
230 reset "${1}" || return 1
233 if [ $ip -eq 6 ]; then
237 ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
238 ip netns exec $ns2 $tables -A OUTPUT -p tcp \
239 -m tcp --tcp-option 30 \
241 "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \
246 reset_with_checksum()
251 reset "checksum test ${1} ${2}" || return 1
253 ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=$ns1_enable
254 ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=$ns2_enable
259 reset_with_allow_join_id0()
264 reset "${1}" || return 1
266 ip netns exec $ns1 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns1_enable
267 ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable
270 # Modify TCP payload without corrupting the TCP packet
272 # This rule inverts a 8-bit word at byte offset 148 for the 2nd TCP ACK packets
273 # carrying enough data.
274 # Once it is done, the TCP Checksum field is updated so the packet is still
275 # considered as valid at the TCP level.
276 # Because the MPTCP checksum, covering the TCP options and data, has not been
277 # updated, the modification will be detected and an MP_FAIL will be emitted:
278 # what we want to validate here without corrupting "random" MPTCP options.
280 # To avoid having tc producing this pr_info() message for each TCP ACK packets
281 # not carrying enough data:
283 # tc action pedit offset 162 out of bounds
285 # Netfilter is used to mark packets with enough data.
288 reset "${1}" || return 1
290 ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=1
291 ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=1
300 if [ $ip -eq 6 ]; then
304 ip netns exec $ns2 $tables \
309 -m length --length 150:9999 \
310 -m statistic --mode nth --packet 1 --every 99999 \
311 -j MARK --set-mark 42 || exit 1
313 tc -n $ns2 qdisc add dev ns2eth$i clsact || exit 1
314 tc -n $ns2 filter add dev ns2eth$i egress \
315 protocol ip prio 1000 \
317 action pedit munge offset 148 u8 invert \
325 failed_tests[${TEST_COUNT}]="${TEST_NAME}"
328 get_failed_tests_ids()
332 for i in "${!failed_tests[@]}"; do
340 echo "Trailing bytes are: "
352 cmp -l "$in" "$out" | while read -r i a b; do
353 local sum=$((0${a} + 0${b}))
354 if [ $check_invert -eq 0 ] || [ $sum -ne $((0xff)) ]; then
355 echo "[ FAIL ] $what does not match (in, out):"
357 print_file_err "$out"
362 echo "$what has inverted byte at ${i}"
371 local listener_ns="$1"
372 local connector_ns="$2"
373 local connect_addr="$3"
375 if ! ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null; then
376 echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2
385 if [ -z "$FAILING_LINKS" ]; then
387 FAILING_LINKS=$((l+1))
391 for l in $FAILING_LINKS; do
392 local veth="ns1eth$l"
393 ip -net "$ns" link set "$veth" down
404 wait_local_port_listen()
406 local listener_ns="${1}"
410 port_hex="$(printf "%04X" "${port}")"
413 for i in $(seq 10); do
414 ip netns exec "${listener_ns}" cat /proc/net/tcp* | \
415 awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" &&
425 ip netns exec ${ns} nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'
428 # $1: ns, $2: old rm_addr counter in $ns
436 for i in $(seq 10); do
437 cnt=$(rm_addr_count ${ns})
438 [ "$cnt" = "${old_cnt}" ] || break
448 old_cnt=$(ip netns exec ${ns} nstat -as | grep MPJoinAckRx | awk '{print $2}')
451 for i in $(seq 10); do
452 cnt=$(ip netns exec ${ns} nstat -as | grep MPJoinAckRx | awk '{print $2}')
453 [ "$cnt" = "${old_cnt}" ] || break
464 if [ $ip_mptcp -eq 1 ]; then
465 ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows
467 ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows
484 if [ $p = "flags" ]; then
486 [ -n "$_flags" ]; flags="flags $_flags"
488 if [ $p = "dev" ]; then
490 [ -n "$_dev" ]; dev="dev $_dev"
492 if [ $p = "id" ]; then
494 [ -n "$_id" ]; id="id $_id"
496 if [ $p = "port" ]; then
498 [ -n "$_port" ]; port="port $_port"
504 if [ $ip_mptcp -eq 1 ]; then
505 ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port
507 ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port
517 if [ $ip_mptcp -eq 1 ]; then
518 ip -n $ns mptcp endpoint delete id $id $addr
520 ip netns exec $ns ./pm_nl_ctl del $id $addr
524 pm_nl_flush_endpoint()
528 if [ $ip_mptcp -eq 1 ]; then
529 ip -n $ns mptcp endpoint flush
531 ip netns exec $ns ./pm_nl_ctl flush
535 pm_nl_show_endpoints()
539 if [ $ip_mptcp -eq 1 ]; then
540 ip -n $ns mptcp endpoint show
542 ip netns exec $ns ./pm_nl_ctl dump
546 pm_nl_change_endpoint()
552 if [ $ip_mptcp -eq 1 ]; then
553 ip -n $ns mptcp endpoint change id $id ${flags//","/" "}
555 ip netns exec $ns ./pm_nl_ctl set id $id flags $flags
559 pm_nl_check_endpoint()
561 local line expected_line
574 if [ "${need_title}" = 1 ]; then
575 printf "%03u %-36s %s" "${TEST_COUNT}" "${TEST_NAME}" "${msg}"
577 printf "%-${nr_blank}s %s" " " "${msg}"
581 while [ -n "$1" ]; do
582 if [ $1 = "flags" ]; then
584 [ -n "$_flags" ]; flags="flags $_flags"
586 elif [ $1 = "dev" ]; then
587 [ -n "$2" ]; dev="dev $1"
589 elif [ $1 = "id" ]; then
591 [ -n "$_id" ]; id="id $_id"
593 elif [ $1 = "port" ]; then
595 [ -n "$_port" ]; port=" port $_port"
602 if [ -z "$id" ]; then
603 echo "[skip] bad test - missing endpoint id"
607 if [ $ip_mptcp -eq 1 ]; then
608 line=$(ip -n $ns mptcp endpoint show $id)
609 # the dump order is: address id flags port dev
610 expected_line="$addr"
611 [ -n "$addr" ] && expected_line="$expected_line $addr"
612 expected_line="$expected_line $id"
613 [ -n "$_flags" ] && expected_line="$expected_line ${_flags//","/" "}"
614 [ -n "$dev" ] && expected_line="$expected_line $dev"
615 [ -n "$port" ] && expected_line="$expected_line $port"
617 line=$(ip netns exec $ns ./pm_nl_ctl get $_id)
618 # the dump order is: id flags dev address port
620 [ -n "$flags" ] && expected_line="$expected_line $flags"
621 [ -n "$dev" ] && expected_line="$expected_line $dev"
622 [ -n "$addr" ] && expected_line="$expected_line $addr"
623 [ -n "$_port" ] && expected_line="$expected_line $_port"
625 if [ "$line" = "$expected_line" ]; then
628 echo "[fail] expected '$expected_line' found '$line'"
639 ip netns exec "${ns}" iptables -A INPUT -s "${src}" -p tcp -j "${target}"
644 local listener_ns="$1"
645 local connector_ns="$2"
648 local connect_addr="$5"
649 local test_link_fail="$6"
650 local addr_nr_ns1="$7"
651 local addr_nr_ns2="$8"
655 local port=$((10000 + TEST_COUNT - 1))
662 if [ $capture -eq 1 ]; then
664 if [ -z $SUDO_USER ] ; then
667 capuser="-Z $SUDO_USER"
670 capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}")
672 echo "Capturing traffic for test $TEST_COUNT into $capfile"
673 ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 &
679 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \
681 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \
685 if [ $speed = "fast" ]; then
687 elif [ $speed = "slow" ]; then
689 elif [[ $speed = "speed_"* ]]; then
690 extra_args="-r ${speed:6}"
693 if [[ "${addr_nr_ns2}" = "fastclose_"* ]]; then
695 extra_args="$extra_args -I ${addr_nr_ns2:10}"
700 if is_v6 "${connect_addr}"; then
706 if [ "$test_link_fail" -gt 1 ];then
707 timeout ${timeout_test} \
708 ip netns exec ${listener_ns} \
709 ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \
710 $extra_args ${local_addr} < "$sinfail" > "$sout" &
712 timeout ${timeout_test} \
713 ip netns exec ${listener_ns} \
714 ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \
715 $extra_args ${local_addr} < "$sin" > "$sout" &
719 wait_local_port_listen "${listener_ns}" "${port}"
721 if [ "$test_link_fail" -eq 0 ];then
722 timeout ${timeout_test} \
723 ip netns exec ${connector_ns} \
724 ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
725 $extra_args $connect_addr < "$cin" > "$cout" &
726 elif [ "$test_link_fail" -eq 1 ] || [ "$test_link_fail" -eq 2 ];then
727 ( cat "$cinfail" ; sleep 2; link_failure $listener_ns ; cat "$cinfail" ) | \
729 timeout ${timeout_test} \
730 ip netns exec ${connector_ns} \
731 ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
732 $extra_args $connect_addr > "$cout" &
734 tee "$cinsent" < "$cinfail" | \
735 timeout ${timeout_test} \
736 ip netns exec ${connector_ns} \
737 ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
738 $extra_args $connect_addr > "$cout" &
742 # let the mptcp subflow be established in background before
743 # do endpoint manipulation
744 if [ $addr_nr_ns1 != "0" ] || [ $addr_nr_ns2 != "0" ]; then
748 if [ $addr_nr_ns1 -gt 0 ]; then
750 local add_nr_ns1=${addr_nr_ns1}
751 while [ $add_nr_ns1 -gt 0 ]; do
753 if is_v6 "${connect_addr}"; then
754 addr="dead:beef:$counter::1"
756 addr="10.0.$counter.1"
758 pm_nl_add_endpoint $ns1 $addr flags signal
759 counter=$((counter + 1))
760 add_nr_ns1=$((add_nr_ns1 - 1))
762 elif [ $addr_nr_ns1 -lt 0 ]; then
763 local rm_nr_ns1=$((-addr_nr_ns1))
764 if [ $rm_nr_ns1 -lt 8 ]; then
767 pm_nl_show_endpoints ${listener_ns} | while read -r line; do
768 # shellcheck disable=SC2206 # we do want to split per word
773 for i in "${arr[@]}"; do
774 if [ $i = "id" ]; then
775 if [ $counter -eq $rm_nr_ns1 ]; then
779 rm_addr=$(rm_addr_count ${connector_ns})
780 pm_nl_del_endpoint ${listener_ns} $id
781 wait_rm_addr ${connector_ns} ${rm_addr}
782 counter=$((counter + 1))
787 elif [ $rm_nr_ns1 -eq 8 ]; then
788 pm_nl_flush_endpoint ${listener_ns}
789 elif [ $rm_nr_ns1 -eq 9 ]; then
790 pm_nl_del_endpoint ${listener_ns} 0 ${connect_addr}
794 local flags="subflow"
795 if [[ "${addr_nr_ns2}" = "fullmesh_"* ]]; then
796 flags="${flags},fullmesh"
797 addr_nr_ns2=${addr_nr_ns2:9}
800 # if newly added endpoints must be deleted, give the background msk
801 # some time to created them
802 [ $addr_nr_ns1 -gt 0 ] && [ $addr_nr_ns2 -lt 0 ] && sleep 1
804 if [ $addr_nr_ns2 -gt 0 ]; then
805 local add_nr_ns2=${addr_nr_ns2}
807 while [ $add_nr_ns2 -gt 0 ]; do
809 if is_v6 "${connect_addr}"; then
810 addr="dead:beef:$counter::2"
812 addr="10.0.$counter.2"
814 pm_nl_add_endpoint $ns2 $addr flags $flags
815 counter=$((counter + 1))
816 add_nr_ns2=$((add_nr_ns2 - 1))
818 elif [ $addr_nr_ns2 -lt 0 ]; then
819 local rm_nr_ns2=$((-addr_nr_ns2))
820 if [ $rm_nr_ns2 -lt 8 ]; then
823 pm_nl_show_endpoints ${connector_ns} | while read -r line; do
824 # shellcheck disable=SC2206 # we do want to split per word
829 for i in "${arr[@]}"; do
830 if [ $i = "id" ]; then
831 if [ $counter -eq $rm_nr_ns2 ]; then
835 # rm_addr are serialized, allow the previous one to
838 rm_addr=$(rm_addr_count ${listener_ns})
839 pm_nl_del_endpoint ${connector_ns} $id
840 wait_rm_addr ${listener_ns} ${rm_addr}
841 counter=$((counter + 1))
846 elif [ $rm_nr_ns2 -eq 8 ]; then
847 pm_nl_flush_endpoint ${connector_ns}
848 elif [ $rm_nr_ns2 -eq 9 ]; then
850 if is_v6 "${connect_addr}"; then
851 addr="dead:beef:1::2"
855 pm_nl_del_endpoint ${connector_ns} 0 $addr
859 if [ -n "${sflags}" ]; then
863 for netns in "$ns1" "$ns2"; do
865 pm_nl_show_endpoints $netns | while read -r line; do
866 # shellcheck disable=SC2206 # we do want to split per word
872 for i in "${arr[@]}"; do
873 if [ $i = "id" ]; then
878 pm_nl_change_endpoint $netns $id $sflags
888 if [ $capture -eq 1 ]; then
893 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \
894 nstat | grep Tcp > /tmp/${listener_ns}.out
895 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \
896 nstat | grep Tcp > /tmp/${connector_ns}.out
898 if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
899 echo " client exit code $retc, server $rets" 1>&2
900 echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2
901 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port"
902 cat /tmp/${listener_ns}.out
903 echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2
904 ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port"
905 cat /tmp/${connector_ns}.out
912 if [ "$test_link_fail" -gt 1 ];then
913 check_transfer $sinfail $cout "file received by client"
915 check_transfer $sin $cout "file received by client"
918 if [ "$test_link_fail" -eq 0 ];then
919 check_transfer $cin $sout "file received by server"
921 check_transfer $cinsent $sout "file received by server"
925 if [ $retc -eq 0 ] && [ $rets -eq 0 ];then
940 dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null
941 echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
943 echo "Created $name (size $size KB) containing data sent by $who"
948 local listener_ns="$1"
949 local connector_ns="$2"
950 local connect_addr="$3"
951 local test_linkfail="${4:-0}"
952 local addr_nr_ns1="${5:-0}"
953 local addr_nr_ns2="${6:-0}"
954 local speed="${7:-fast}"
955 local sflags="${8:-""}"
959 # The values above 2 are reused to make test files
960 # with the given sizes (KB)
961 if [ "$test_linkfail" -gt 2 ]; then
964 if [ -z "$cinfail" ]; then
967 make_file "$cinfail" "client" $size
968 # create the input file for the failure test when
969 # the first failure test run
970 elif [ "$test_linkfail" -ne 0 ] && [ -z "$cinfail" ]; then
971 # the client file must be considerably larger
972 # of the maximum expected cwin value, or the
973 # link utilization will be not predicable
977 size=$((size + ( RANDOM % 8192) ))
980 make_file "$cinfail" "client" $size
983 if [ "$test_linkfail" -gt 2 ]; then
986 if [ -z "$sinfail" ]; then
989 make_file "$sinfail" "server" $size
990 elif [ "$test_linkfail" -eq 2 ] && [ -z "$sinfail" ]; then
996 make_file "$sinfail" "server" $size
999 do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \
1000 ${test_linkfail} ${addr_nr_ns1} ${addr_nr_ns2} ${speed} ${sflags}
1005 echo Server ns stats
1006 ip netns exec $ns1 nstat -as | grep Tcp
1007 echo Client ns stats
1008 ip netns exec $ns2 nstat -as | grep Tcp
1013 local csum_ns1=${1:-0}
1014 local csum_ns2=${2:-0}
1018 local allow_multi_errors_ns1=0
1019 local allow_multi_errors_ns2=0
1021 if [[ "${csum_ns1}" = "+"* ]]; then
1022 allow_multi_errors_ns1=1
1023 csum_ns1=${csum_ns1:1}
1025 if [[ "${csum_ns2}" = "+"* ]]; then
1026 allow_multi_errors_ns2=1
1027 csum_ns2=${csum_ns2:1}
1030 printf "%-${nr_blank}s %s" " " "sum"
1031 count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}')
1032 [ -z "$count" ] && count=0
1033 if [ "$count" != "$csum_ns1" ]; then
1034 extra_msg="$extra_msg ns1=$count"
1036 if { [ "$count" != $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 0 ]; } ||
1037 { [ "$count" -lt $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 1 ]; }; then
1038 echo "[fail] got $count data checksum error[s] expected $csum_ns1"
1045 count=$(ip netns exec $ns2 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}')
1046 [ -z "$count" ] && count=0
1047 if [ "$count" != "$csum_ns2" ]; then
1048 extra_msg="$extra_msg ns2=$count"
1050 if { [ "$count" != $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 0 ]; } ||
1051 { [ "$count" -lt $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 1 ]; }; then
1052 echo "[fail] got $count data checksum error[s] expected $csum_ns2"
1058 [ "${dump_stats}" = 1 ] && dump_stats
1067 local ns_invert=${3:-""}
1073 local allow_tx_lost=0
1074 local allow_rx_lost=0
1076 if [[ $ns_invert = "invert" ]]; then
1082 if [[ "${fail_tx}" = "-"* ]]; then
1084 fail_tx=${fail_tx:1}
1086 if [[ "${fail_rx}" = "-"* ]]; then
1088 fail_rx=${fail_rx:1}
1091 printf "%-${nr_blank}s %s" " " "ftx"
1092 count=$(ip netns exec $ns_tx nstat -as | grep MPTcpExtMPFailTx | awk '{print $2}')
1093 [ -z "$count" ] && count=0
1094 if [ "$count" != "$fail_tx" ]; then
1095 extra_msg="$extra_msg,tx=$count"
1097 if { [ "$count" != "$fail_tx" ] && [ $allow_tx_lost -eq 0 ]; } ||
1098 { [ "$count" -gt "$fail_tx" ] && [ $allow_tx_lost -eq 1 ]; }; then
1099 echo "[fail] got $count MP_FAIL[s] TX expected $fail_tx"
1107 count=$(ip netns exec $ns_rx nstat -as | grep MPTcpExtMPFailRx | awk '{print $2}')
1108 [ -z "$count" ] && count=0
1109 if [ "$count" != "$fail_rx" ]; then
1110 extra_msg="$extra_msg,rx=$count"
1112 if { [ "$count" != "$fail_rx" ] && [ $allow_rx_lost -eq 0 ]; } ||
1113 { [ "$count" -gt "$fail_rx" ] && [ $allow_rx_lost -eq 1 ]; }; then
1114 echo "[fail] got $count MP_FAIL[s] RX expected $fail_rx"
1121 [ "${dump_stats}" = 1 ] && dump_stats
1133 printf "%-${nr_blank}s %s" " " "ctx"
1134 count=$(ip netns exec $ns2 nstat -as | grep MPTcpExtMPFastcloseTx | awk '{print $2}')
1135 [ -z "$count" ] && count=0
1136 if [ "$count" != "$fclose_tx" ]; then
1137 echo "[fail] got $count MP_FASTCLOSE[s] TX expected $fclose_tx"
1145 count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPFastcloseRx | awk '{print $2}')
1146 [ -z "$count" ] && count=0
1147 if [ "$count" != "$fclose_rx" ]; then
1148 echo "[fail] got $count MP_FASTCLOSE[s] RX expected $fclose_rx"
1155 [ "${dump_stats}" = 1 ] && dump_stats
1162 local ns_invert=${3:-""}
1169 if [[ $ns_invert = "invert" ]]; then
1175 printf "%-${nr_blank}s %s" " " "rtx"
1176 count=$(ip netns exec $ns_tx nstat -as | grep MPTcpExtMPRstTx | awk '{print $2}')
1177 [ -z "$count" ] && count=0
1178 if [ "$count" != "$rst_tx" ]; then
1179 echo "[fail] got $count MP_RST[s] TX expected $rst_tx"
1187 count=$(ip netns exec $ns_rx nstat -as | grep MPTcpExtMPRstRx | awk '{print $2}')
1188 [ -z "$count" ] && count=0
1189 if [ "$count" != "$rst_rx" ]; then
1190 echo "[fail] got $count MP_RST[s] RX expected $rst_rx"
1197 [ "${dump_stats}" = 1 ] && dump_stats
1209 printf "%-${nr_blank}s %s" " " "itx"
1210 count=$(ip netns exec $ns2 nstat -as | grep InfiniteMapTx | awk '{print $2}')
1211 [ -z "$count" ] && count=0
1212 if [ "$count" != "$infi_tx" ]; then
1213 echo "[fail] got $count infinite map[s] TX expected $infi_tx"
1221 count=$(ip netns exec $ns1 nstat -as | grep InfiniteMapRx | awk '{print $2}')
1222 [ -z "$count" ] && count=0
1223 if [ "$count" != "$infi_rx" ]; then
1224 echo "[fail] got $count infinite map[s] RX expected $infi_rx"
1231 [ "${dump_stats}" = 1 ] && dump_stats
1239 local csum_ns1=${4:-0}
1240 local csum_ns2=${5:-0}
1241 local fail_nr=${6:-0}
1242 local rst_nr=${7:-0}
1243 local infi_nr=${8:-0}
1244 local corrupted_pkts=${9:-0}
1248 local title="${TEST_NAME}"
1250 if [ "${corrupted_pkts}" -gt 0 ]; then
1251 title+=": ${corrupted_pkts} corrupted pkts"
1254 printf "%03u %-36s %s" "${TEST_COUNT}" "${title}" "syn"
1255 count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}')
1256 [ -z "$count" ] && count=0
1257 if [ "$count" != "$syn_nr" ]; then
1258 echo "[fail] got $count JOIN[s] syn expected $syn_nr"
1266 with_cookie=$(ip netns exec $ns2 sysctl -n net.ipv4.tcp_syncookies)
1267 count=$(ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}')
1268 [ -z "$count" ] && count=0
1269 if [ "$count" != "$syn_ack_nr" ]; then
1270 # simult connections exceeding the limit with cookie enabled could go up to
1271 # synack validation as the conn limit can be enforced reliably only after
1272 # the subflow creation
1273 if [ "$with_cookie" = 2 ] && [ "$count" -gt "$syn_ack_nr" ] && [ "$count" -le "$syn_nr" ]; then
1276 echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr"
1285 count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}')
1286 [ -z "$count" ] && count=0
1287 if [ "$count" != "$ack_nr" ]; then
1288 echo "[fail] got $count JOIN[s] ack expected $ack_nr"
1294 [ "${dump_stats}" = 1 ] && dump_stats
1295 if [ $validate_checksum -eq 1 ]; then
1296 chk_csum_nr $csum_ns1 $csum_ns2
1297 chk_fail_nr $fail_nr $fail_nr
1298 chk_rst_nr $rst_nr $rst_nr
1299 chk_infi_nr $infi_nr $infi_nr
1303 # a negative value for 'stale_max' means no upper bound:
1304 # for bidirectional transfer, if one peer sleep for a while
1305 # - as these tests do - we can have a quite high number of
1306 # stale/recover conversions, proportional to
1307 # sleep duration/ MPTCP-level RTX interval.
1313 local stale_delta=$4
1318 printf "%-${nr_blank}s %-18s" " " "stale"
1319 stale_nr=$(ip netns exec $ns nstat -as | grep MPTcpExtSubflowStale | awk '{print $2}')
1320 [ -z "$stale_nr" ] && stale_nr=0
1321 recover_nr=$(ip netns exec $ns nstat -as | grep MPTcpExtSubflowRecover | awk '{print $2}')
1322 [ -z "$recover_nr" ] && recover_nr=0
1324 if [ $stale_nr -lt $stale_min ] ||
1325 { [ $stale_max -gt 0 ] && [ $stale_nr -gt $stale_max ]; } ||
1326 [ $((stale_nr - recover_nr)) -ne $stale_delta ]; then
1327 echo "[fail] got $stale_nr stale[s] $recover_nr recover[s], " \
1328 " expected stale in range [$stale_min..$stale_max]," \
1329 " stale-recover delta $stale_delta "
1336 if [ "${dump_stats}" = 1 ]; then
1338 ip netns exec $ns ip -s link show
1339 ip netns exec $ns nstat -as | grep MPTcp
1347 local port_nr=${3:-0}
1348 local syn_nr=${4:-$port_nr}
1349 local syn_ack_nr=${5:-$port_nr}
1350 local ack_nr=${6:-$port_nr}
1351 local mis_syn_nr=${7:-0}
1352 local mis_ack_nr=${8:-0}
1357 timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout)
1359 printf "%-${nr_blank}s %s" " " "add"
1360 count=$(ip netns exec $ns2 nstat -as MPTcpExtAddAddr | grep MPTcpExtAddAddr | awk '{print $2}')
1361 [ -z "$count" ] && count=0
1363 # if the test configured a short timeout tolerate greater then expected
1364 # add addrs options, due to retransmissions
1365 if [ "$count" != "$add_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_nr" ]; }; then
1366 echo "[fail] got $count ADD_ADDR[s] expected $add_nr"
1374 count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtEchoAdd | awk '{print $2}')
1375 [ -z "$count" ] && count=0
1376 if [ "$count" != "$echo_nr" ]; then
1377 echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr"
1384 if [ $port_nr -gt 0 ]; then
1386 count=$(ip netns exec $ns2 nstat -as | grep MPTcpExtPortAdd | awk '{print $2}')
1387 [ -z "$count" ] && count=0
1388 if [ "$count" != "$port_nr" ]; then
1389 echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr"
1396 printf "%-${nr_blank}s %s" " " "syn"
1397 count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortSynRx |
1399 [ -z "$count" ] && count=0
1400 if [ "$count" != "$syn_nr" ]; then
1401 echo "[fail] got $count JOIN[s] syn with a different \
1402 port-number expected $syn_nr"
1410 count=$(ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinPortSynAckRx |
1412 [ -z "$count" ] && count=0
1413 if [ "$count" != "$syn_ack_nr" ]; then
1414 echo "[fail] got $count JOIN[s] synack with a different \
1415 port-number expected $syn_ack_nr"
1423 count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortAckRx |
1425 [ -z "$count" ] && count=0
1426 if [ "$count" != "$ack_nr" ]; then
1427 echo "[fail] got $count JOIN[s] ack with a different \
1428 port-number expected $ack_nr"
1435 printf "%-${nr_blank}s %s" " " "syn"
1436 count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortSynRx |
1438 [ -z "$count" ] && count=0
1439 if [ "$count" != "$mis_syn_nr" ]; then
1440 echo "[fail] got $count JOIN[s] syn with a mismatched \
1441 port-number expected $mis_syn_nr"
1449 count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortAckRx |
1451 [ -z "$count" ] && count=0
1452 if [ "$count" != "$mis_ack_nr" ]; then
1453 echo "[fail] got $count JOIN[s] ack with a mismatched \
1454 port-number expected $mis_ack_nr"
1464 [ "${dump_stats}" = 1 ] && dump_stats
1470 local rm_subflow_nr=$2
1476 local subflow_ns=$ns2
1480 while [ -n "$1" ]; do
1481 [ "$1" = "invert" ] && invert=true
1482 [ "$1" = "simult" ] && simult=true
1486 if [ -z $invert ]; then
1489 elif [ $invert = "true" ]; then
1495 printf "%-${nr_blank}s %s" " " "rm "
1496 count=$(ip netns exec $addr_ns nstat -as | grep MPTcpExtRmAddr | awk '{print $2}')
1497 [ -z "$count" ] && count=0
1498 if [ "$count" != "$rm_addr_nr" ]; then
1499 echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr"
1507 count=$(ip netns exec $subflow_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}')
1508 [ -z "$count" ] && count=0
1509 if [ -n "$simult" ]; then
1512 cnt=$(ip netns exec $addr_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}')
1514 # in case of simult flush, the subflow removal count on each side is
1516 [ -z "$cnt" ] && cnt=0
1517 count=$((count + cnt))
1518 [ "$count" != "$rm_subflow_nr" ] && suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]"
1519 if [ $count -ge "$rm_subflow_nr" ] && \
1520 [ "$count" -le "$((rm_subflow_nr *2 ))" ]; then
1521 echo "[ ok ] $suffix"
1523 echo "[fail] got $count RM_SUBFLOW[s] expected in range [$rm_subflow_nr:$((rm_subflow_nr*2))]"
1529 if [ "$count" != "$rm_subflow_nr" ]; then
1530 echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr"
1537 [ "${dump_stats}" = 1 ] && dump_stats
1544 local mp_prio_nr_tx=$1
1545 local mp_prio_nr_rx=$2
1549 printf "%-${nr_blank}s %s" " " "ptx"
1550 count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}')
1551 [ -z "$count" ] && count=0
1552 if [ "$count" != "$mp_prio_nr_tx" ]; then
1553 echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx"
1561 count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}')
1562 [ -z "$count" ] && count=0
1563 if [ "$count" != "$mp_prio_nr_rx" ]; then
1564 echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx"
1571 [ "${dump_stats}" = 1 ] && dump_stats
1576 local need_title="$1"
1582 if [ -n "${need_title}" ]; then
1583 printf "%03u %-36s %s" "${TEST_COUNT}" "${TEST_NAME}" "${msg}"
1585 printf "%-${nr_blank}s %s" " " "${msg}"
1588 cnt1=$(ss -N $ns1 -tOni | grep -c token)
1589 cnt2=$(ss -N $ns2 -tOni | grep -c token)
1590 if [ "$cnt1" != "$subflow_nr" -o "$cnt2" != "$subflow_nr" ]; then
1591 echo "[fail] got $cnt1:$cnt2 subflows expected $subflow_nr"
1598 [ "${dump_stats}" = 1 ] && ( ss -N $ns1 -tOni ; ss -N $ns1 -tOni | grep token; ip -n $ns1 mptcp endpoint )
1606 local expected_rate=$4
1608 local tx_link tx_total
1609 tx_link=$(ip netns exec $ns cat /sys/class/net/$link/statistics/tx_bytes)
1610 tx_total=$(stat --format=%s $out)
1611 local tx_rate=$((tx_link * 100 / tx_total))
1614 printf "%-${nr_blank}s %-18s" " " "link usage"
1615 if [ $tx_rate -lt $((expected_rate - tolerance)) ] || \
1616 [ $tx_rate -gt $((expected_rate + tolerance)) ]; then
1617 echo "[fail] got $tx_rate% usage, expected $expected_rate%"
1626 local timeout_ms=$((timeout_poll * 1000))
1630 while [ $time -lt $timeout_ms ]; do
1633 cnt=$(ip netns exec $ns nstat -as TcpAttemptFails | grep TcpAttemptFails | awk '{print $2}')
1635 [ "$cnt" = 1 ] && return 1
1636 time=$((time + 100))
1646 ip netns exec $ns sysctl -q net.mptcp.pm_type=1
1651 if reset "no JOIN"; then
1652 run_tests $ns1 $ns2 10.0.1.1
1656 # subflow limited by client
1657 if reset "single subflow, limited by client"; then
1658 pm_nl_set_limits $ns1 0 0
1659 pm_nl_set_limits $ns2 0 0
1660 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1661 run_tests $ns1 $ns2 10.0.1.1
1665 # subflow limited by server
1666 if reset "single subflow, limited by server"; then
1667 pm_nl_set_limits $ns1 0 0
1668 pm_nl_set_limits $ns2 0 1
1669 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1670 run_tests $ns1 $ns2 10.0.1.1
1675 if reset "single subflow"; then
1676 pm_nl_set_limits $ns1 0 1
1677 pm_nl_set_limits $ns2 0 1
1678 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1679 run_tests $ns1 $ns2 10.0.1.1
1684 if reset "multiple subflows"; then
1685 pm_nl_set_limits $ns1 0 2
1686 pm_nl_set_limits $ns2 0 2
1687 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1688 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1689 run_tests $ns1 $ns2 10.0.1.1
1693 # multiple subflows limited by server
1694 if reset "multiple subflows, limited by server"; then
1695 pm_nl_set_limits $ns1 0 1
1696 pm_nl_set_limits $ns2 0 2
1697 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1698 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1699 run_tests $ns1 $ns2 10.0.1.1
1703 # single subflow, dev
1704 if reset "single subflow, dev"; then
1705 pm_nl_set_limits $ns1 0 1
1706 pm_nl_set_limits $ns2 0 1
1707 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow dev ns2eth3
1708 run_tests $ns1 $ns2 10.0.1.1
1713 subflows_error_tests()
1715 # If a single subflow is configured, and matches the MPC src
1716 # address, no additional subflow should be created
1717 if reset "no MPC reuse with single endpoint"; then
1718 pm_nl_set_limits $ns1 0 1
1719 pm_nl_set_limits $ns2 0 1
1720 pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow
1721 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
1725 # multiple subflows, with subflow creation error
1726 if reset "multi subflows, with failing subflow"; then
1727 pm_nl_set_limits $ns1 0 2
1728 pm_nl_set_limits $ns2 0 2
1729 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1730 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1731 filter_tcp_from $ns1 10.0.3.2 REJECT
1732 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
1736 # multiple subflows, with subflow timeout on MPJ
1737 if reset "multi subflows, with subflow timeout"; then
1738 pm_nl_set_limits $ns1 0 2
1739 pm_nl_set_limits $ns2 0 2
1740 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1741 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1742 filter_tcp_from $ns1 10.0.3.2 DROP
1743 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
1747 # multiple subflows, check that the endpoint corresponding to
1748 # closed subflow (due to reset) is not reused if additional
1749 # subflows are added later
1750 if reset "multi subflows, fair usage on close"; then
1751 pm_nl_set_limits $ns1 0 1
1752 pm_nl_set_limits $ns2 0 1
1753 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1754 filter_tcp_from $ns1 10.0.3.2 REJECT
1755 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow &
1757 # mpj subflow will be in TW after the reset
1758 wait_attempt_fail $ns2
1759 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1762 # additional subflow could be created only if the PM select
1763 # the later endpoint, skipping the already used one
1768 signal_address_tests()
1770 # add_address, unused
1771 if reset "unused signal address"; then
1772 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1773 run_tests $ns1 $ns2 10.0.1.1
1778 # accept and use add_addr
1779 if reset "signal address"; then
1780 pm_nl_set_limits $ns1 0 1
1781 pm_nl_set_limits $ns2 1 1
1782 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1783 run_tests $ns1 $ns2 10.0.1.1
1788 # accept and use add_addr with an additional subflow
1789 # note: signal address in server ns and local addresses in client ns must
1790 # belong to different subnets or one of the listed local address could be
1791 # used for 'add_addr' subflow
1792 if reset "subflow and signal"; then
1793 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1794 pm_nl_set_limits $ns1 0 2
1795 pm_nl_set_limits $ns2 1 2
1796 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1797 run_tests $ns1 $ns2 10.0.1.1
1802 # accept and use add_addr with additional subflows
1803 if reset "multiple subflows and signal"; then
1804 pm_nl_set_limits $ns1 0 3
1805 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1806 pm_nl_set_limits $ns2 1 3
1807 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1808 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
1809 run_tests $ns1 $ns2 10.0.1.1
1815 if reset "signal addresses"; then
1816 pm_nl_set_limits $ns1 3 3
1817 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1818 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1819 pm_nl_add_endpoint $ns1 10.0.4.1 flags signal
1820 pm_nl_set_limits $ns2 3 3
1821 run_tests $ns1 $ns2 10.0.1.1
1826 # signal invalid addresses
1827 if reset "signal invalid addresses"; then
1828 pm_nl_set_limits $ns1 3 3
1829 pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
1830 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1831 pm_nl_add_endpoint $ns1 10.0.14.1 flags signal
1832 pm_nl_set_limits $ns2 3 3
1833 run_tests $ns1 $ns2 10.0.1.1
1838 # signal addresses race test
1839 if reset "signal addresses race test"; then
1840 pm_nl_set_limits $ns1 4 4
1841 pm_nl_set_limits $ns2 4 4
1842 pm_nl_add_endpoint $ns1 10.0.1.1 flags signal
1843 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1844 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1845 pm_nl_add_endpoint $ns1 10.0.4.1 flags signal
1846 pm_nl_add_endpoint $ns2 10.0.1.2 flags signal
1847 pm_nl_add_endpoint $ns2 10.0.2.2 flags signal
1848 pm_nl_add_endpoint $ns2 10.0.3.2 flags signal
1849 pm_nl_add_endpoint $ns2 10.0.4.2 flags signal
1851 # the peer could possibly miss some addr notification, allow retransmission
1852 ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
1853 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
1856 # the server will not signal the address terminating
1862 link_failure_tests()
1864 # accept and use add_addr with additional subflows and link loss
1865 if reset "multiple flows, signal, link failure"; then
1866 # without any b/w limit each veth could spool the packets and get
1867 # them acked at xmit time, so that the corresponding subflow will
1868 # have almost always no outstanding pkts, the scheduler will pick
1869 # always the first subflow and we will have hard time testing
1870 # active backup and link switch-over.
1871 # Let's set some arbitrary (low) virtual link limits.
1873 pm_nl_set_limits $ns1 0 3
1874 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
1875 pm_nl_set_limits $ns2 1 3
1876 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow
1877 pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow
1878 run_tests $ns1 $ns2 10.0.1.1 1
1881 chk_stale_nr $ns2 1 5 1
1884 # accept and use add_addr with additional subflows and link loss
1885 # for bidirectional transfer
1886 if reset "multi flows, signal, bidi, link fail"; then
1888 pm_nl_set_limits $ns1 0 3
1889 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
1890 pm_nl_set_limits $ns2 1 3
1891 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow
1892 pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow
1893 run_tests $ns1 $ns2 10.0.1.1 2
1896 chk_stale_nr $ns2 1 -1 1
1899 # 2 subflows plus 1 backup subflow with a lossy link, backup
1900 # will never be used
1901 if reset "backup subflow unused, link failure"; then
1903 pm_nl_set_limits $ns1 0 2
1904 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
1905 pm_nl_set_limits $ns2 1 2
1907 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup
1908 run_tests $ns1 $ns2 10.0.1.1 1
1911 chk_link_usage $ns2 ns2eth3 $cinsent 0
1914 # 2 lossy links after half transfer, backup will get half of
1916 if reset "backup flow used, multi links fail"; then
1918 pm_nl_set_limits $ns1 0 2
1919 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
1920 pm_nl_set_limits $ns2 1 2
1921 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup
1923 run_tests $ns1 $ns2 10.0.1.1 1
1926 chk_stale_nr $ns2 2 4 2
1927 chk_link_usage $ns2 ns2eth3 $cinsent 50
1930 # use a backup subflow with the first subflow on a lossy link
1931 # for bidirectional transfer
1932 if reset "backup flow used, bidi, link failure"; then
1934 pm_nl_set_limits $ns1 0 2
1935 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
1936 pm_nl_set_limits $ns2 1 3
1937 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup
1939 run_tests $ns1 $ns2 10.0.1.1 2
1942 chk_stale_nr $ns2 1 -1 2
1943 chk_link_usage $ns2 ns2eth3 $cinsent 50
1947 add_addr_timeout_tests()
1950 if reset_with_add_addr_timeout "signal address, ADD_ADDR timeout"; then
1951 pm_nl_set_limits $ns1 0 1
1952 pm_nl_set_limits $ns2 1 1
1953 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1954 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
1959 # add_addr timeout IPv6
1960 if reset_with_add_addr_timeout "signal address, ADD_ADDR6 timeout" 6; then
1961 pm_nl_set_limits $ns1 0 1
1962 pm_nl_set_limits $ns2 1 1
1963 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
1964 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
1969 # signal addresses timeout
1970 if reset_with_add_addr_timeout "signal addresses, ADD_ADDR timeout"; then
1971 pm_nl_set_limits $ns1 2 2
1972 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1973 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1974 pm_nl_set_limits $ns2 2 2
1975 run_tests $ns1 $ns2 10.0.1.1 0 0 0 speed_10
1980 # signal invalid addresses timeout
1981 if reset_with_add_addr_timeout "invalid address, ADD_ADDR timeout"; then
1982 pm_nl_set_limits $ns1 2 2
1983 pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
1984 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1985 pm_nl_set_limits $ns2 2 2
1986 run_tests $ns1 $ns2 10.0.1.1 0 0 0 speed_10
1994 # single subflow, remove
1995 if reset "remove single subflow"; then
1996 pm_nl_set_limits $ns1 0 1
1997 pm_nl_set_limits $ns2 0 1
1998 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1999 run_tests $ns1 $ns2 10.0.1.1 0 0 -1 slow
2004 # multiple subflows, remove
2005 if reset "remove multiple subflows"; then
2006 pm_nl_set_limits $ns1 0 2
2007 pm_nl_set_limits $ns2 0 2
2008 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
2009 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2010 run_tests $ns1 $ns2 10.0.1.1 0 0 -2 slow
2015 # single address, remove
2016 if reset "remove single address"; then
2017 pm_nl_set_limits $ns1 0 1
2018 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2019 pm_nl_set_limits $ns2 1 1
2020 run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow
2023 chk_rm_nr 1 1 invert
2026 # subflow and signal, remove
2027 if reset "remove subflow and signal"; then
2028 pm_nl_set_limits $ns1 0 2
2029 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2030 pm_nl_set_limits $ns2 1 2
2031 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2032 run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow
2038 # subflows and signal, remove
2039 if reset "remove subflows and signal"; then
2040 pm_nl_set_limits $ns1 0 3
2041 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2042 pm_nl_set_limits $ns2 1 3
2043 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2044 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
2045 run_tests $ns1 $ns2 10.0.1.1 0 -1 -2 slow
2052 if reset "remove addresses"; then
2053 pm_nl_set_limits $ns1 3 3
2054 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250
2055 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2056 pm_nl_add_endpoint $ns1 10.0.4.1 flags signal
2057 pm_nl_set_limits $ns2 3 3
2058 run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow
2061 chk_rm_nr 3 3 invert
2064 # invalid addresses remove
2065 if reset "remove invalid addresses"; then
2066 pm_nl_set_limits $ns1 3 3
2067 pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
2068 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2069 pm_nl_add_endpoint $ns1 10.0.14.1 flags signal
2070 pm_nl_set_limits $ns2 3 3
2071 run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow
2074 chk_rm_nr 3 1 invert
2077 # subflows and signal, flush
2078 if reset "flush subflows and signal"; then
2079 pm_nl_set_limits $ns1 0 3
2080 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2081 pm_nl_set_limits $ns2 1 3
2082 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2083 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
2084 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow
2087 chk_rm_nr 1 3 invert simult
2091 if reset "flush subflows"; then
2092 pm_nl_set_limits $ns1 3 3
2093 pm_nl_set_limits $ns2 3 3
2094 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow id 150
2095 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2096 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
2097 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow
2099 chk_rm_nr 0 3 simult
2103 if reset "flush addresses"; then
2104 pm_nl_set_limits $ns1 3 3
2105 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250
2106 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2107 pm_nl_add_endpoint $ns1 10.0.4.1 flags signal
2108 pm_nl_set_limits $ns2 3 3
2109 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow
2112 chk_rm_nr 3 3 invert simult
2115 # invalid addresses flush
2116 if reset "flush 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 0 -8 0 slow
2125 chk_rm_nr 3 1 invert
2128 # remove id 0 subflow
2129 if reset "remove id 0 subflow"; then
2130 pm_nl_set_limits $ns1 0 1
2131 pm_nl_set_limits $ns2 0 1
2132 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2133 run_tests $ns1 $ns2 10.0.1.1 0 0 -9 slow
2138 # remove id 0 address
2139 if reset "remove id 0 address"; then
2140 pm_nl_set_limits $ns1 0 1
2141 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2142 pm_nl_set_limits $ns2 1 1
2143 run_tests $ns1 $ns2 10.0.1.1 0 -9 0 slow
2146 chk_rm_nr 1 1 invert
2152 # add single subflow
2153 if reset "add single subflow"; then
2154 pm_nl_set_limits $ns1 0 1
2155 pm_nl_set_limits $ns2 0 1
2156 run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow
2160 # add signal address
2161 if reset "add signal address"; then
2162 pm_nl_set_limits $ns1 0 1
2163 pm_nl_set_limits $ns2 1 1
2164 run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow
2169 # add multiple subflows
2170 if reset "add multiple subflows"; then
2171 pm_nl_set_limits $ns1 0 2
2172 pm_nl_set_limits $ns2 0 2
2173 run_tests $ns1 $ns2 10.0.1.1 0 0 2 slow
2177 # add multiple subflows IPv6
2178 if reset "add multiple subflows IPv6"; then
2179 pm_nl_set_limits $ns1 0 2
2180 pm_nl_set_limits $ns2 0 2
2181 run_tests $ns1 $ns2 dead:beef:1::1 0 0 2 slow
2185 # add multiple addresses IPv6
2186 if reset "add multiple addresses IPv6"; then
2187 pm_nl_set_limits $ns1 0 2
2188 pm_nl_set_limits $ns2 2 2
2189 run_tests $ns1 $ns2 dead:beef:1::1 0 2 0 slow
2198 if reset "single subflow IPv6"; then
2199 pm_nl_set_limits $ns1 0 1
2200 pm_nl_set_limits $ns2 0 1
2201 pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow
2202 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
2206 # add_address, unused IPv6
2207 if reset "unused signal address IPv6"; then
2208 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
2209 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
2214 # signal address IPv6
2215 if reset "single address IPv6"; then
2216 pm_nl_set_limits $ns1 0 1
2217 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
2218 pm_nl_set_limits $ns2 1 1
2219 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
2224 # single address IPv6, remove
2225 if reset "remove single address IPv6"; then
2226 pm_nl_set_limits $ns1 0 1
2227 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
2228 pm_nl_set_limits $ns2 1 1
2229 run_tests $ns1 $ns2 dead:beef:1::1 0 -1 0 slow
2232 chk_rm_nr 1 1 invert
2235 # subflow and signal IPv6, remove
2236 if reset "remove subflow and signal IPv6"; then
2237 pm_nl_set_limits $ns1 0 2
2238 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
2239 pm_nl_set_limits $ns2 1 2
2240 pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow
2241 run_tests $ns1 $ns2 dead:beef:1::1 0 -1 -1 slow
2250 # subflow IPv4-mapped to IPv4-mapped
2251 if reset "single subflow IPv4-mapped"; then
2252 pm_nl_set_limits $ns1 0 1
2253 pm_nl_set_limits $ns2 0 1
2254 pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow
2255 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
2259 # signal address IPv4-mapped with IPv4-mapped sk
2260 if reset "signal address IPv4-mapped"; then
2261 pm_nl_set_limits $ns1 0 1
2262 pm_nl_set_limits $ns2 1 1
2263 pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal
2264 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
2270 if reset "single subflow v4-map-v6"; then
2271 pm_nl_set_limits $ns1 0 1
2272 pm_nl_set_limits $ns2 0 1
2273 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2274 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
2278 # signal address v4-map-v6
2279 if reset "signal address v4-map-v6"; then
2280 pm_nl_set_limits $ns1 0 1
2281 pm_nl_set_limits $ns2 1 1
2282 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2283 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
2289 if reset "single subflow v6-map-v4"; then
2290 pm_nl_set_limits $ns1 0 1
2291 pm_nl_set_limits $ns2 0 1
2292 pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow
2293 run_tests $ns1 $ns2 10.0.1.1
2297 # signal address v6-map-v4
2298 if reset "signal address v6-map-v4"; then
2299 pm_nl_set_limits $ns1 0 1
2300 pm_nl_set_limits $ns2 1 1
2301 pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal
2302 run_tests $ns1 $ns2 10.0.1.1
2307 # no subflow IPv6 to v4 address
2308 if reset "no JOIN with diff families v4-v6"; then
2309 pm_nl_set_limits $ns1 0 1
2310 pm_nl_set_limits $ns2 0 1
2311 pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow
2312 run_tests $ns1 $ns2 10.0.1.1
2316 # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end
2317 if reset "no JOIN with diff families v4-v6-2"; then
2318 pm_nl_set_limits $ns1 0 1
2319 pm_nl_set_limits $ns2 0 1
2320 pm_nl_add_endpoint $ns2 dead:beef:2::10.0.3.2 flags subflow
2321 run_tests $ns1 $ns2 10.0.1.1
2325 # no subflow IPv4 to v6 address, no need to slow down too then
2326 if reset "no JOIN with diff families v6-v4"; then
2327 pm_nl_set_limits $ns1 0 1
2328 pm_nl_set_limits $ns2 0 1
2329 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2330 run_tests $ns1 $ns2 dead:beef:1::1
2337 # single subflow, backup
2338 if reset "single subflow, backup"; then
2339 pm_nl_set_limits $ns1 0 1
2340 pm_nl_set_limits $ns2 0 1
2341 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup
2342 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup
2347 # single address, backup
2348 if reset "single address, backup"; then
2349 pm_nl_set_limits $ns1 0 1
2350 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2351 pm_nl_set_limits $ns2 1 1
2352 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup
2358 # single address with port, backup
2359 if reset "single address with port, backup"; then
2360 pm_nl_set_limits $ns1 0 1
2361 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2362 pm_nl_set_limits $ns2 1 1
2363 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup
2370 add_addr_ports_tests()
2372 # signal address with port
2373 if reset "signal address with port"; then
2374 pm_nl_set_limits $ns1 0 1
2375 pm_nl_set_limits $ns2 1 1
2376 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2377 run_tests $ns1 $ns2 10.0.1.1
2382 # subflow and signal with port
2383 if reset "subflow and signal with port"; then
2384 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2385 pm_nl_set_limits $ns1 0 2
2386 pm_nl_set_limits $ns2 1 2
2387 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2388 run_tests $ns1 $ns2 10.0.1.1
2393 # single address with port, remove
2394 if reset "remove single address with port"; then
2395 pm_nl_set_limits $ns1 0 1
2396 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2397 pm_nl_set_limits $ns2 1 1
2398 run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow
2401 chk_rm_nr 1 1 invert
2404 # subflow and signal with port, remove
2405 if reset "remove subflow and signal with port"; then
2406 pm_nl_set_limits $ns1 0 2
2407 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2408 pm_nl_set_limits $ns2 1 2
2409 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2410 run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow
2416 # subflows and signal with port, flush
2417 if reset "flush subflows and signal with port"; then
2418 pm_nl_set_limits $ns1 0 3
2419 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2420 pm_nl_set_limits $ns2 1 3
2421 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2422 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
2423 run_tests $ns1 $ns2 10.0.1.1 0 -8 -2 slow
2426 chk_rm_nr 1 3 invert simult
2429 # multiple addresses with port
2430 if reset "multiple addresses with port"; then
2431 pm_nl_set_limits $ns1 2 2
2432 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2433 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10100
2434 pm_nl_set_limits $ns2 2 2
2435 run_tests $ns1 $ns2 10.0.1.1
2440 # multiple addresses with ports
2441 if reset "multiple addresses with ports"; then
2442 pm_nl_set_limits $ns1 2 2
2443 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
2444 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10101
2445 pm_nl_set_limits $ns2 2 2
2446 run_tests $ns1 $ns2 10.0.1.1
2454 # single subflow, syncookies
2455 if reset_with_cookies "single subflow with syn cookies"; then
2456 pm_nl_set_limits $ns1 0 1
2457 pm_nl_set_limits $ns2 0 1
2458 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2459 run_tests $ns1 $ns2 10.0.1.1
2463 # multiple subflows with syn cookies
2464 if reset_with_cookies "multiple subflows with syn cookies"; then
2465 pm_nl_set_limits $ns1 0 2
2466 pm_nl_set_limits $ns2 0 2
2467 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2468 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
2469 run_tests $ns1 $ns2 10.0.1.1
2473 # multiple subflows limited by server
2474 if reset_with_cookies "subflows limited by server w cookies"; then
2475 pm_nl_set_limits $ns1 0 1
2476 pm_nl_set_limits $ns2 0 2
2477 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2478 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
2479 run_tests $ns1 $ns2 10.0.1.1
2483 # test signal address with cookies
2484 if reset_with_cookies "signal address with syn cookies"; then
2485 pm_nl_set_limits $ns1 0 1
2486 pm_nl_set_limits $ns2 1 1
2487 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2488 run_tests $ns1 $ns2 10.0.1.1
2493 # test cookie with subflow and signal
2494 if reset_with_cookies "subflow and signal w cookies"; then
2495 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2496 pm_nl_set_limits $ns1 0 2
2497 pm_nl_set_limits $ns2 1 2
2498 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2499 run_tests $ns1 $ns2 10.0.1.1
2504 # accept and use add_addr with additional subflows
2505 if reset_with_cookies "subflows and signal w. cookies"; then
2506 pm_nl_set_limits $ns1 0 3
2507 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2508 pm_nl_set_limits $ns2 1 3
2509 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2510 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
2511 run_tests $ns1 $ns2 10.0.1.1
2520 if reset_with_checksum 0 0; then
2521 pm_nl_set_limits $ns1 0 1
2522 pm_nl_set_limits $ns2 0 1
2523 run_tests $ns1 $ns2 10.0.1.1
2528 if reset_with_checksum 1 1; then
2529 pm_nl_set_limits $ns1 0 1
2530 pm_nl_set_limits $ns2 0 1
2531 run_tests $ns1 $ns2 10.0.1.1
2536 if reset_with_checksum 0 1; then
2537 pm_nl_set_limits $ns1 0 1
2538 pm_nl_set_limits $ns2 0 1
2539 run_tests $ns1 $ns2 10.0.1.1
2544 if reset_with_checksum 1 0; then
2545 pm_nl_set_limits $ns1 0 1
2546 pm_nl_set_limits $ns2 0 1
2547 run_tests $ns1 $ns2 10.0.1.1
2552 deny_join_id0_tests()
2554 # subflow allow join id0 ns1
2555 if reset_with_allow_join_id0 "single subflow allow join id0 ns1" 1 0; then
2556 pm_nl_set_limits $ns1 1 1
2557 pm_nl_set_limits $ns2 1 1
2558 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2559 run_tests $ns1 $ns2 10.0.1.1
2563 # subflow allow join id0 ns2
2564 if reset_with_allow_join_id0 "single subflow allow join id0 ns2" 0 1; then
2565 pm_nl_set_limits $ns1 1 1
2566 pm_nl_set_limits $ns2 1 1
2567 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2568 run_tests $ns1 $ns2 10.0.1.1
2572 # signal address allow join id0 ns1
2573 # ADD_ADDRs are not affected by allow_join_id0 value.
2574 if reset_with_allow_join_id0 "signal address allow join id0 ns1" 1 0; then
2575 pm_nl_set_limits $ns1 1 1
2576 pm_nl_set_limits $ns2 1 1
2577 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2578 run_tests $ns1 $ns2 10.0.1.1
2583 # signal address allow join id0 ns2
2584 # ADD_ADDRs are not affected by allow_join_id0 value.
2585 if reset_with_allow_join_id0 "signal address allow join id0 ns2" 0 1; then
2586 pm_nl_set_limits $ns1 1 1
2587 pm_nl_set_limits $ns2 1 1
2588 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2589 run_tests $ns1 $ns2 10.0.1.1
2594 # subflow and address allow join id0 ns1
2595 if reset_with_allow_join_id0 "subflow and address allow join id0 1" 1 0; then
2596 pm_nl_set_limits $ns1 2 2
2597 pm_nl_set_limits $ns2 2 2
2598 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2599 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2600 run_tests $ns1 $ns2 10.0.1.1
2604 # subflow and address allow join id0 ns2
2605 if reset_with_allow_join_id0 "subflow and address allow join id0 2" 0 1; then
2606 pm_nl_set_limits $ns1 2 2
2607 pm_nl_set_limits $ns2 2 2
2608 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2609 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2610 run_tests $ns1 $ns2 10.0.1.1
2618 # 2 fullmesh addrs in ns2, added before the connection,
2619 # 1 non-fullmesh addr in ns1, added during the connection.
2620 if reset "fullmesh test 2x1"; then
2621 pm_nl_set_limits $ns1 0 4
2622 pm_nl_set_limits $ns2 1 4
2623 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,fullmesh
2624 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,fullmesh
2625 run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow
2631 # 1 non-fullmesh addr in ns1, added before the connection,
2632 # 1 fullmesh addr in ns2, added during the connection.
2633 if reset "fullmesh test 1x1"; then
2634 pm_nl_set_limits $ns1 1 3
2635 pm_nl_set_limits $ns2 1 3
2636 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2637 run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow
2643 # 1 non-fullmesh addr in ns1, added before the connection,
2644 # 2 fullmesh addrs in ns2, added during the connection.
2645 if reset "fullmesh test 1x2"; then
2646 pm_nl_set_limits $ns1 2 5
2647 pm_nl_set_limits $ns2 1 5
2648 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2649 run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow
2655 # 1 non-fullmesh addr in ns1, added before the connection,
2656 # 2 fullmesh addrs in ns2, added during the connection,
2657 # limit max_subflows to 4.
2658 if reset "fullmesh test 1x2, limited"; then
2659 pm_nl_set_limits $ns1 2 4
2660 pm_nl_set_limits $ns2 1 4
2661 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2662 run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow
2668 if reset "set fullmesh flag test"; then
2669 pm_nl_set_limits $ns1 4 4
2670 pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow
2671 pm_nl_set_limits $ns2 4 4
2672 run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow fullmesh
2677 # set nofullmesh flag
2678 if reset "set nofullmesh flag test"; then
2679 pm_nl_set_limits $ns1 4 4
2680 pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow,fullmesh
2681 pm_nl_set_limits $ns2 4 4
2682 run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow nofullmesh
2687 # set backup,fullmesh flags
2688 if reset "set backup,fullmesh flags test"; then
2689 pm_nl_set_limits $ns1 4 4
2690 pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow
2691 pm_nl_set_limits $ns2 4 4
2692 run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow backup,fullmesh
2698 # set nobackup,nofullmesh flags
2699 if reset "set nobackup,nofullmesh flags test"; then
2700 pm_nl_set_limits $ns1 4 4
2701 pm_nl_set_limits $ns2 4 4
2702 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,backup,fullmesh
2703 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup,nofullmesh
2712 if reset "fastclose test"; then
2713 run_tests $ns1 $ns2 10.0.1.1 1024 0 fastclose_2
2716 chk_rst_nr 1 1 invert
2722 tc -n $ns2 -j -s action show action pedit index 100 | \
2724 sed 's/.*"packets":\([0-9]\+\),.*/\1/'
2730 if reset_with_fail "Infinite map" 1; then
2731 run_tests $ns1 $ns2 10.0.1.1 128
2732 chk_join_nr 0 0 0 +1 +0 1 0 1 "$(pedit_action_pkts)"
2733 chk_fail_nr 1 -1 invert
2737 if reset_with_fail "MP_FAIL MP_RST" 2; then
2738 tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit delay 5
2739 pm_nl_set_limits $ns1 0 1
2740 pm_nl_set_limits $ns2 0 1
2741 pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow
2742 run_tests $ns1 $ns2 10.0.1.1 1024
2743 chk_join_nr 1 1 1 1 0 1 1 0 "$(pedit_action_pkts)"
2749 # userspace pm type prevents add_addr
2750 if reset "userspace pm type prevents add_addr"; then
2751 set_userspace_pm $ns1
2752 pm_nl_set_limits $ns1 0 2
2753 pm_nl_set_limits $ns2 0 2
2754 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2755 run_tests $ns1 $ns2 10.0.1.1
2760 # userspace pm type does not echo add_addr without daemon
2761 if reset "userspace pm no echo w/o daemon"; then
2762 set_userspace_pm $ns2
2763 pm_nl_set_limits $ns1 0 2
2764 pm_nl_set_limits $ns2 0 2
2765 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2766 run_tests $ns1 $ns2 10.0.1.1
2771 # userspace pm type rejects join
2772 if reset "userspace pm type rejects join"; then
2773 set_userspace_pm $ns1
2774 pm_nl_set_limits $ns1 1 1
2775 pm_nl_set_limits $ns2 1 1
2776 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2777 run_tests $ns1 $ns2 10.0.1.1
2781 # userspace pm type does not send join
2782 if reset "userspace pm type does not send join"; then
2783 set_userspace_pm $ns2
2784 pm_nl_set_limits $ns1 1 1
2785 pm_nl_set_limits $ns2 1 1
2786 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2787 run_tests $ns1 $ns2 10.0.1.1
2791 # userspace pm type prevents mp_prio
2792 if reset "userspace pm type prevents mp_prio"; then
2793 set_userspace_pm $ns1
2794 pm_nl_set_limits $ns1 1 1
2795 pm_nl_set_limits $ns2 1 1
2796 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2797 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup
2802 # userspace pm type prevents rm_addr
2803 if reset "userspace pm type prevents rm_addr"; then
2804 set_userspace_pm $ns1
2805 set_userspace_pm $ns2
2806 pm_nl_set_limits $ns1 0 1
2807 pm_nl_set_limits $ns2 0 1
2808 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2809 run_tests $ns1 $ns2 10.0.1.1 0 0 -1 slow
2817 # userspace pm type prevents add_addr
2818 if reset "implicit EP"; then
2819 pm_nl_set_limits $ns1 2 2
2820 pm_nl_set_limits $ns2 2 2
2821 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2822 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow &
2825 pm_nl_check_endpoint 1 "creation" \
2826 $ns2 10.0.2.2 id 1 flags implicit
2828 pm_nl_add_endpoint $ns2 10.0.2.2 id 33
2829 pm_nl_check_endpoint 0 "ID change is prevented" \
2830 $ns2 10.0.2.2 id 1 flags implicit
2832 pm_nl_add_endpoint $ns2 10.0.2.2 flags signal
2833 pm_nl_check_endpoint 0 "modif is allowed" \
2834 $ns2 10.0.2.2 id 1 flags signal
2838 if reset "delete and re-add"; then
2839 pm_nl_set_limits $ns1 1 1
2840 pm_nl_set_limits $ns2 1 1
2841 pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow
2842 run_tests $ns1 $ns2 10.0.1.1 4 0 0 slow &
2845 pm_nl_del_endpoint $ns2 2 10.0.2.2
2847 chk_subflow_nr needtitle "after delete" 1
2849 pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow
2851 chk_subflow_nr "" "after re-add" 2
2856 # [$1: error message]
2859 if [ -n "${1}" ]; then
2864 echo "mptcp_join usage:"
2867 for key in "${!all_tests[@]}"; do
2868 echo " -${key} ${all_tests[${key}]}"
2871 echo " -c capture pcap files"
2872 echo " -C enable data checksum"
2873 echo " -i use ip mptcp"
2876 echo "[test ids|names]"
2882 # Use a "simple" array to force an specific order we cannot have with an associative one
2885 e@subflows_error_tests
2886 s@signal_address_tests
2887 l@link_failure_tests
2888 t@add_addr_timeout_tests
2894 p@add_addr_ports_tests
2897 d@deny_join_id0_tests
2907 for subtests in "${all_tests_sorted[@]}"; do
2908 key="${subtests%@*}"
2909 value="${subtests#*@}"
2911 all_tests_args+="${key}"
2912 all_tests_names+=("${value}")
2913 all_tests[${key}]="${value}"
2917 while getopts "${all_tests_args}cCih" opt; do
2919 ["${all_tests_args}"])
2920 tests+=("${all_tests[${opt}]}")
2935 usage "Unknown option: -${opt}"
2940 shift $((OPTIND - 1))
2942 for arg in "${@}"; do
2943 if [[ "${arg}" =~ ^[0-9]+$ ]]; then
2944 only_tests_ids+=("${arg}")
2946 only_tests_names+=("${arg}")
2950 if [ ${#tests[@]} -eq 0 ]; then
2951 tests=("${all_tests_names[@]}")
2954 for subtests in "${tests[@]}"; do
2958 if [ ${ret} -ne 0 ]; then
2960 echo "${#failed_tests[@]} failure(s) has(ve) been detected:"
2961 for i in $(get_failed_tests_ids); do
2962 echo -e "\t- ${i}: ${failed_tests[${i}]}"