2 # SPDX-License-Identifier: GPL-2.0
14 timeout_test=$((timeout_poll * 2 + 1))
24 # generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) ||
25 # (ip6 && (ip6[74] & 0xf0) == 0x30)'"
26 CBPF_MPTCP_SUBOPTION_ADD_ADDR="14,
46 rndh=$(mktemp -u XXXXXX)
51 for netns in "$ns1" "$ns2";do
52 ip netns add $netns || exit $ksft_skip
53 ip -net $netns link set lo up
54 ip netns exec $netns sysctl -q net.mptcp.enabled=1
55 ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0
56 ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0
57 if [ $checksum -eq 1 ]; then
58 ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1
68 for i in `seq 1 4`; do
69 ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2"
70 ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i
71 ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad
72 ip -net "$ns1" link set ns1eth$i up
74 ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i
75 ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad
76 ip -net "$ns2" link set ns2eth$i up
78 # let $ns2 reach any $ns1 address from any interface
79 ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i
80 ip -net "$ns2" route add default via dead:beef:$i::1 dev ns2eth$i metric 10$i
86 for i in `seq 1 4`; do
87 tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1
88 tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1
96 for netns in "$ns1" "$ns2"; do
98 rm -f /tmp/$netns.{nstat,out}
104 if ! ip -Version &> /dev/null; then
105 echo "SKIP: Could not run test without ip tool"
109 if ! iptables -V &> /dev/null; then
110 echo "SKIP: Could not run all tests without iptables tool"
114 if ! ip6tables -V &> /dev/null; then
115 echo "SKIP: Could not run all tests without ip6tables tool"
133 make_file "$cin" "client" 1
134 make_file "$sin" "server" 1
139 rm -f "$cin" "$cout" "$sinfail"
140 rm -f "$sin" "$sout" "$cinsent" "$cinfail"
146 if [ "${init}" != "1" ]; then
159 for netns in "$ns1" "$ns2";do
160 ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2
164 reset_with_add_addr_timeout()
170 if [ $ip -eq 6 ]; then
176 ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
177 ip netns exec $ns2 $tables -A OUTPUT -p tcp \
178 -m tcp --tcp-option 30 \
180 "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \
184 reset_with_checksum()
191 ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=$ns1_enable
192 ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=$ns2_enable
195 reset_with_allow_join_id0()
202 ip netns exec $ns1 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns1_enable
203 ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable
209 echo "Trailing bytes are: "
219 cmp "$in" "$out" > /dev/null 2>&1
220 if [ $? -ne 0 ] ;then
221 echo "[ FAIL ] $what does not match (in, out):"
223 print_file_err "$out"
238 ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null
239 if [ $? -ne 0 ] ; then
240 echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2
249 if [ -z "$FAILING_LINKS" ]; then
251 FAILING_LINKS=$((l+1))
254 for l in $FAILING_LINKS; do
256 ip -net "$ns" link set "$veth" down
267 wait_local_port_listen()
269 local listener_ns="${1}"
274 port_hex="$(printf "%04X" "${port}")"
275 for i in $(seq 10); do
276 ip netns exec "${listener_ns}" cat /proc/net/tcp* | \
277 awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" &&
287 ip netns exec ${ns} nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'
290 # $1: ns, $2: old rm_addr counter in $ns
298 for i in $(seq 10); do
299 cnt=$(rm_addr_count ${ns})
300 [ "$cnt" = "${old_cnt}" ] || break
311 if [ $ip_mptcp -eq 1 ]; then
312 ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows
314 ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows
330 if [ $p = "flags" ]; then
332 [ ! -z $_flags ]; flags="flags $_flags"
334 if [ $p = "dev" ]; then
336 [ ! -z $_dev ]; dev="dev $_dev"
338 if [ $p = "id" ]; then
340 [ ! -z $_id ]; id="id $_id"
342 if [ $p = "port" ]; then
344 [ ! -z $_port ]; port="port $_port"
350 if [ $ip_mptcp -eq 1 ]; then
351 ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port
353 ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port
363 if [ $ip_mptcp -eq 1 ]; then
364 ip -n $ns mptcp endpoint delete id $id $addr
366 ip netns exec $ns ./pm_nl_ctl del $id $addr
370 pm_nl_flush_endpoint()
374 if [ $ip_mptcp -eq 1 ]; then
375 ip -n $ns mptcp endpoint flush
377 ip netns exec $ns ./pm_nl_ctl flush
381 pm_nl_show_endpoints()
385 if [ $ip_mptcp -eq 1 ]; then
386 ip -n $ns mptcp endpoint show
388 ip netns exec $ns ./pm_nl_ctl dump
392 pm_nl_change_endpoint()
398 if [ $ip_mptcp -eq 1 ]; then
399 ip -n $ns mptcp endpoint change id $id ${flags//","/" "}
401 ip netns exec $ns ./pm_nl_ctl set id $id flags $flags
418 port=$((10000+$TEST_COUNT))
419 TEST_COUNT=$((TEST_COUNT+1))
425 if [ $capture -eq 1 ]; then
426 if [ -z $SUDO_USER ] ; then
429 capuser="-Z $SUDO_USER"
432 capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}")
434 echo "Capturing traffic for test $TEST_COUNT into $capfile"
435 ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 &
441 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \
443 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \
447 if [ $speed = "fast" ]; then
449 elif [ $speed = "slow" ]; then
451 elif [[ $speed = "speed_"* ]]; then
452 extra_args="-r ${speed:6}"
456 if is_v6 "${connect_addr}"; then
462 if [ "$test_link_fail" -gt 1 ];then
463 timeout ${timeout_test} \
464 ip netns exec ${listener_ns} \
465 ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \
466 $extra_args ${local_addr} < "$sinfail" > "$sout" &
468 timeout ${timeout_test} \
469 ip netns exec ${listener_ns} \
470 ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \
471 $extra_args ${local_addr} < "$sin" > "$sout" &
475 wait_local_port_listen "${listener_ns}" "${port}"
477 if [ "$test_link_fail" -eq 0 ];then
478 timeout ${timeout_test} \
479 ip netns exec ${connector_ns} \
480 ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
481 $extra_args $connect_addr < "$cin" > "$cout" &
482 elif [ "$test_link_fail" -eq 1 ] || [ "$test_link_fail" -eq 2 ];then
483 ( cat "$cinfail" ; sleep 2; link_failure $listener_ns ; cat "$cinfail" ) | \
485 timeout ${timeout_test} \
486 ip netns exec ${connector_ns} \
487 ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
488 $extra_args $connect_addr > "$cout" &
490 cat "$cinfail" | tee "$cinsent" | \
491 timeout ${timeout_test} \
492 ip netns exec ${connector_ns} \
493 ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
494 $extra_args $connect_addr > "$cout" &
498 # let the mptcp subflow be established in background before
499 # do endpoint manipulation
500 [ $addr_nr_ns1 = "0" -a $addr_nr_ns2 = "0" ] || sleep 1
502 if [ $addr_nr_ns1 -gt 0 ]; then
503 let add_nr_ns1=addr_nr_ns1
505 while [ $add_nr_ns1 -gt 0 ]; do
507 if is_v6 "${connect_addr}"; then
508 addr="dead:beef:$counter::1"
510 addr="10.0.$counter.1"
512 pm_nl_add_endpoint $ns1 $addr flags signal
516 elif [ $addr_nr_ns1 -lt 0 ]; then
517 let rm_nr_ns1=-addr_nr_ns1
518 if [ $rm_nr_ns1 -lt 8 ]; then
520 pm_nl_show_endpoints ${listener_ns} | while read line; do
524 for i in ${arr[@]}; do
525 if [ $i = "id" ]; then
526 if [ $counter -eq $rm_nr_ns1 ]; then
530 rm_addr=$(rm_addr_count ${connector_ns})
531 pm_nl_del_endpoint ${listener_ns} $id
532 wait_rm_addr ${connector_ns} ${rm_addr}
538 elif [ $rm_nr_ns1 -eq 8 ]; then
539 pm_nl_flush_endpoint ${listener_ns}
540 elif [ $rm_nr_ns1 -eq 9 ]; then
541 pm_nl_del_endpoint ${listener_ns} 0 ${connect_addr}
546 if [[ "${addr_nr_ns2}" = "fullmesh_"* ]]; then
547 flags="${flags},fullmesh"
548 addr_nr_ns2=${addr_nr_ns2:9}
551 # if newly added endpoints must be deleted, give the background msk
552 # some time to created them
553 [ $addr_nr_ns1 -gt 0 -a $addr_nr_ns2 -lt 0 ] && sleep 1
555 if [ $addr_nr_ns2 -gt 0 ]; then
556 let add_nr_ns2=addr_nr_ns2
558 while [ $add_nr_ns2 -gt 0 ]; do
560 if is_v6 "${connect_addr}"; then
561 addr="dead:beef:$counter::2"
563 addr="10.0.$counter.2"
565 pm_nl_add_endpoint $ns2 $addr flags $flags
569 elif [ $addr_nr_ns2 -lt 0 ]; then
570 let rm_nr_ns2=-addr_nr_ns2
571 if [ $rm_nr_ns2 -lt 8 ]; then
573 pm_nl_show_endpoints ${connector_ns} | while read line; do
577 for i in ${arr[@]}; do
578 if [ $i = "id" ]; then
579 if [ $counter -eq $rm_nr_ns2 ]; then
582 # rm_addr are serialized, allow the previous one to
585 rm_addr=$(rm_addr_count ${listener_ns})
586 pm_nl_del_endpoint ${connector_ns} $id
587 wait_rm_addr ${listener_ns} ${rm_addr}
593 elif [ $rm_nr_ns2 -eq 8 ]; then
594 pm_nl_flush_endpoint ${connector_ns}
595 elif [ $rm_nr_ns2 -eq 9 ]; then
597 if is_v6 "${connect_addr}"; then
598 addr="dead:beef:1::2"
602 pm_nl_del_endpoint ${connector_ns} 0 $addr
606 if [ ! -z $sflags ]; then
608 for netns in "$ns1" "$ns2"; do
609 pm_nl_show_endpoints $netns | while read line; do
614 for i in ${arr[@]}; do
615 if [ $i = "id" ]; then
620 pm_nl_change_endpoint $netns $id $sflags
630 if [ $capture -eq 1 ]; then
635 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \
636 nstat | grep Tcp > /tmp/${listener_ns}.out
637 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \
638 nstat | grep Tcp > /tmp/${connector_ns}.out
640 if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
641 echo " client exit code $retc, server $rets" 1>&2
642 echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2
643 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port"
644 cat /tmp/${listener_ns}.out
645 echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2
646 ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port"
647 cat /tmp/${connector_ns}.out
654 if [ "$test_link_fail" -gt 1 ];then
655 check_transfer $sinfail $cout "file received by client"
657 check_transfer $sin $cout "file received by client"
660 if [ "$test_link_fail" -eq 0 ];then
661 check_transfer $cin $sout "file received by server"
663 check_transfer $cinsent $sout "file received by server"
667 if [ $retc -eq 0 ] && [ $rets -eq 0 ];then
682 dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null
683 echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
685 echo "Created $name (size $size KB) containing data sent by $who"
693 test_linkfail="${4:-0}"
694 addr_nr_ns1="${5:-0}"
695 addr_nr_ns2="${6:-0}"
699 # The values above 2 are reused to make test files
700 # with the given sizes (KB)
701 if [ "$test_linkfail" -gt 2 ]; then
704 if [ -z "$cinfail" ]; then
707 make_file "$cinfail" "client" $size
708 # create the input file for the failure test when
709 # the first failure test run
710 elif [ "$test_linkfail" -ne 0 -a -z "$cinfail" ]; then
711 # the client file must be considerably larger
712 # of the maximum expected cwin value, or the
713 # link utilization will be not predicable
717 size=$((size + ( $RANDOM % 8192) ))
720 make_file "$cinfail" "client" $size
723 if [ "$test_linkfail" -gt 2 ]; then
726 if [ -z "$sinfail" ]; then
729 make_file "$sinfail" "server" $size
730 elif [ "$test_linkfail" -eq 2 -a -z "$sinfail" ]; then
736 make_file "$sinfail" "server" $size
739 do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \
740 ${test_linkfail} ${addr_nr_ns1} ${addr_nr_ns2} ${speed} ${sflags}
746 ip netns exec $ns1 nstat -as | grep Tcp
748 ip netns exec $ns2 nstat -as | grep Tcp
757 if [ ! -z "$msg" ]; then
758 printf "%03u" "$TEST_COUNT"
762 printf " %-36s %s" "$msg" "sum"
763 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'`
764 [ -z "$count" ] && count=0
765 if [ "$count" != 0 ]; then
766 echo "[fail] got $count data checksum error[s] expected 0"
773 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'`
774 [ -z "$count" ] && count=0
775 if [ "$count" != 0 ]; then
776 echo "[fail] got $count data checksum error[s] expected 0"
782 [ "${dump_stats}" = 1 ] && dump_stats
787 local mp_fail_nr_tx=$1
788 local mp_fail_nr_rx=$2
792 printf "%-${nr_blank}s %s" " " "ftx"
793 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPFailTx | awk '{print $2}'`
794 [ -z "$count" ] && count=0
795 if [ "$count" != "$mp_fail_nr_tx" ]; then
796 echo "[fail] got $count MP_FAIL[s] TX expected $mp_fail_nr_tx"
804 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPFailRx | awk '{print $2}'`
805 [ -z "$count" ] && count=0
806 if [ "$count" != "$mp_fail_nr_rx" ]; then
807 echo "[fail] got $count MP_FAIL[s] RX expected $mp_fail_nr_rx"
814 [ "${dump_stats}" = 1 ] && dump_stats
824 printf "%-${nr_blank}s %s" " " "ctx"
825 count=$(ip netns exec $ns2 nstat -as | grep MPTcpExtMPFastcloseTx | awk '{print $2}')
826 [ -z "$count" ] && count=0
827 if [ "$count" != "$fclose_tx" ]; then
828 echo "[fail] got $count MP_FASTCLOSE[s] TX expected $fclose_tx"
836 count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPFastcloseRx | awk '{print $2}')
837 [ -z "$count" ] && count=0
838 if [ "$count" != "$fclose_rx" ]; then
839 echo "[fail] got $count MP_FASTCLOSE[s] RX expected $fclose_rx"
846 [ "${dump_stats}" = 1 ] && dump_stats
853 local ns_invert=${3:-""}
860 if [[ $ns_invert = "invert" ]]; then
866 printf "%-${nr_blank}s %s" " " "rtx"
867 count=$(ip netns exec $ns_tx nstat -as | grep MPTcpExtMPRstTx | awk '{print $2}')
868 [ -z "$count" ] && count=0
869 if [ "$count" != "$rst_tx" ]; then
870 echo "[fail] got $count MP_RST[s] TX expected $rst_tx"
878 count=$(ip netns exec $ns_rx nstat -as | grep MPTcpExtMPRstRx | awk '{print $2}')
879 [ -z "$count" ] && count=0
880 if [ "$count" != "$rst_rx" ]; then
881 echo "[fail] got $count MP_RST[s] RX expected $rst_rx"
888 [ "${dump_stats}" = 1 ] && dump_stats
903 printf "%03u %-36s %s" "$TEST_COUNT" "$msg" "syn"
904 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'`
905 [ -z "$count" ] && count=0
906 if [ "$count" != "$syn_nr" ]; then
907 echo "[fail] got $count JOIN[s] syn expected $syn_nr"
915 with_cookie=`ip netns exec $ns2 sysctl -n net.ipv4.tcp_syncookies`
916 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'`
917 [ -z "$count" ] && count=0
918 if [ "$count" != "$syn_ack_nr" ]; then
919 # simult connections exceeding the limit with cookie enabled could go up to
920 # synack validation as the conn limit can be enforced reliably only after
921 # the subflow creation
922 if [ "$with_cookie" = 2 ] && [ "$count" -gt "$syn_ack_nr" ] && [ "$count" -le "$syn_nr" ]; then
925 echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr"
934 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'`
935 [ -z "$count" ] && count=0
936 if [ "$count" != "$ack_nr" ]; then
937 echo "[fail] got $count JOIN[s] ack expected $ack_nr"
943 [ "${dump_stats}" = 1 ] && dump_stats
944 if [ $checksum -eq 1 ]; then
951 # a negative value for 'stale_max' means no upper bound:
952 # for bidirectional transfer, if one peer sleep for a while
953 # - as these tests do - we can have a quite high number of
954 # stale/recover conversions, proportional to
955 # sleep duration/ MPTCP-level RTX interval.
966 printf "%-${nr_blank}s %-18s" " " "stale"
967 stale_nr=`ip netns exec $ns nstat -as | grep MPTcpExtSubflowStale | awk '{print $2}'`
968 [ -z "$stale_nr" ] && stale_nr=0
969 recover_nr=`ip netns exec $ns nstat -as | grep MPTcpExtSubflowRecover | awk '{print $2}'`
970 [ -z "$recover_nr" ] && recover_nr=0
972 if [ $stale_nr -lt $stale_min ] ||
973 [ $stale_max -gt 0 -a $stale_nr -gt $stale_max ] ||
974 [ $((stale_nr - $recover_nr)) -ne $stale_delta ]; then
975 echo "[fail] got $stale_nr stale[s] $recover_nr recover[s], " \
976 " expected stale in range [$stale_min..$stale_max]," \
977 " stale-recover delta $stale_delta "
984 if [ "${dump_stats}" = 1 ]; then
986 ip netns exec $ns ip -s link show
987 ip netns exec $ns nstat -as | grep MPTcp
995 local port_nr=${3:-0}
996 local syn_nr=${4:-$port_nr}
997 local syn_ack_nr=${5:-$port_nr}
998 local ack_nr=${6:-$port_nr}
999 local mis_syn_nr=${7:-0}
1000 local mis_ack_nr=${8:-0}
1005 timeout=`ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout`
1007 printf "%-${nr_blank}s %s" " " "add"
1008 count=`ip netns exec $ns2 nstat -as MPTcpExtAddAddr | grep MPTcpExtAddAddr | awk '{print $2}'`
1009 [ -z "$count" ] && count=0
1011 # if the test configured a short timeout tolerate greater then expected
1012 # add addrs options, due to retransmissions
1013 if [ "$count" != "$add_nr" ] && [ "$timeout" -gt 1 -o "$count" -lt "$add_nr" ]; then
1014 echo "[fail] got $count ADD_ADDR[s] expected $add_nr"
1022 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtEchoAdd | awk '{print $2}'`
1023 [ -z "$count" ] && count=0
1024 if [ "$count" != "$echo_nr" ]; then
1025 echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr"
1032 if [ $port_nr -gt 0 ]; then
1034 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtPortAdd | awk '{print $2}'`
1035 [ -z "$count" ] && count=0
1036 if [ "$count" != "$port_nr" ]; then
1037 echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr"
1044 printf "%-${nr_blank}s %s" " " "syn"
1045 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortSynRx |
1047 [ -z "$count" ] && count=0
1048 if [ "$count" != "$syn_nr" ]; then
1049 echo "[fail] got $count JOIN[s] syn with a different \
1050 port-number expected $syn_nr"
1058 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinPortSynAckRx |
1060 [ -z "$count" ] && count=0
1061 if [ "$count" != "$syn_ack_nr" ]; then
1062 echo "[fail] got $count JOIN[s] synack with a different \
1063 port-number expected $syn_ack_nr"
1071 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortAckRx |
1073 [ -z "$count" ] && count=0
1074 if [ "$count" != "$ack_nr" ]; then
1075 echo "[fail] got $count JOIN[s] ack with a different \
1076 port-number expected $ack_nr"
1083 printf "%-${nr_blank}s %s" " " "syn"
1084 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortSynRx |
1086 [ -z "$count" ] && count=0
1087 if [ "$count" != "$mis_syn_nr" ]; then
1088 echo "[fail] got $count JOIN[s] syn with a mismatched \
1089 port-number expected $mis_syn_nr"
1097 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortAckRx |
1099 [ -z "$count" ] && count=0
1100 if [ "$count" != "$mis_ack_nr" ]; then
1101 echo "[fail] got $count JOIN[s] ack with a mismatched \
1102 port-number expected $mis_ack_nr"
1112 [ "${dump_stats}" = 1 ] && dump_stats
1118 local rm_subflow_nr=$2
1119 local invert=${3:-""}
1125 if [ -z $invert ]; then
1128 elif [ $invert = "invert" ]; then
1133 printf "%-${nr_blank}s %s" " " "rm "
1134 count=`ip netns exec $addr_ns nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'`
1135 [ -z "$count" ] && count=0
1136 if [ "$count" != "$rm_addr_nr" ]; then
1137 echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr"
1145 count=`ip netns exec $subflow_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'`
1146 [ -z "$count" ] && count=0
1147 if [ "$count" != "$rm_subflow_nr" ]; then
1148 echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr"
1155 [ "${dump_stats}" = 1 ] && dump_stats
1160 local mp_prio_nr_tx=$1
1161 local mp_prio_nr_rx=$2
1165 printf "%-${nr_blank}s %s" " " "ptx"
1166 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}'`
1167 [ -z "$count" ] && count=0
1168 if [ "$count" != "$mp_prio_nr_tx" ]; then
1169 echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx"
1177 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}'`
1178 [ -z "$count" ] && count=0
1179 if [ "$count" != "$mp_prio_nr_rx" ]; then
1180 echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx"
1187 [ "${dump_stats}" = 1 ] && dump_stats
1195 local expected_rate=$4
1196 local tx_link=`ip netns exec $ns cat /sys/class/net/$link/statistics/tx_bytes`
1197 local tx_total=`ls -l $out | awk '{print $5}'`
1198 local tx_rate=$((tx_link * 100 / $tx_total))
1201 printf "%-${nr_blank}s %-18s" " " "link usage"
1202 if [ $tx_rate -lt $((expected_rate - $tolerance)) -o \
1203 $tx_rate -gt $((expected_rate + $tolerance)) ]; then
1204 echo "[fail] got $tx_rate% usage, expected $expected_rate%"
1213 local timeout_ms=$((timeout_poll * 1000))
1217 while [ $time -lt $timeout_ms ]; do
1218 local cnt=$(ip netns exec $ns nstat -as TcpAttemptFails | grep TcpAttemptFails | awk '{print $2}')
1220 [ "$cnt" = 1 ] && return 1
1221 time=$((time + 100))
1230 run_tests $ns1 $ns2 10.0.1.1
1231 chk_join_nr "no JOIN" "0" "0" "0"
1233 # subflow limited by client
1235 pm_nl_set_limits $ns1 0 0
1236 pm_nl_set_limits $ns2 0 0
1237 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1238 run_tests $ns1 $ns2 10.0.1.1
1239 chk_join_nr "single subflow, limited by client" 0 0 0
1241 # subflow limited by server
1243 pm_nl_set_limits $ns1 0 0
1244 pm_nl_set_limits $ns2 0 1
1245 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1246 run_tests $ns1 $ns2 10.0.1.1
1247 chk_join_nr "single subflow, limited by server" 1 1 0
1251 pm_nl_set_limits $ns1 0 1
1252 pm_nl_set_limits $ns2 0 1
1253 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1254 run_tests $ns1 $ns2 10.0.1.1
1255 chk_join_nr "single subflow" 1 1 1
1259 pm_nl_set_limits $ns1 0 2
1260 pm_nl_set_limits $ns2 0 2
1261 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1262 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1263 run_tests $ns1 $ns2 10.0.1.1
1264 chk_join_nr "multiple subflows" 2 2 2
1266 # multiple subflows limited by server
1268 pm_nl_set_limits $ns1 0 1
1269 pm_nl_set_limits $ns2 0 2
1270 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1271 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1272 run_tests $ns1 $ns2 10.0.1.1
1273 chk_join_nr "multiple subflows, limited by server" 2 2 1
1275 # single subflow, dev
1277 pm_nl_set_limits $ns1 0 1
1278 pm_nl_set_limits $ns2 0 1
1279 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow dev ns2eth3
1280 run_tests $ns1 $ns2 10.0.1.1
1281 chk_join_nr "single subflow, dev" 1 1 1
1284 subflows_error_tests()
1286 # If a single subflow is configured, and matches the MPC src
1287 # address, no additional subflow should be created
1289 pm_nl_set_limits $ns1 0 1
1290 pm_nl_set_limits $ns2 0 1
1291 pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow
1292 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
1293 chk_join_nr "no MPC reuse with single endpoint" 0 0 0
1295 # multiple subflows, with subflow creation error
1297 pm_nl_set_limits $ns1 0 2
1298 pm_nl_set_limits $ns2 0 2
1299 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1300 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1301 ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT
1302 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
1303 chk_join_nr "multi subflows, with failing subflow" 1 1 1
1305 # multiple subflows, with subflow timeout on MPJ
1307 pm_nl_set_limits $ns1 0 2
1308 pm_nl_set_limits $ns2 0 2
1309 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1310 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1311 ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j DROP
1312 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
1313 chk_join_nr "multi subflows, with subflow timeout" 1 1 1
1315 # multiple subflows, check that the endpoint corresponding to
1316 # closed subflow (due to reset) is not reused if additional
1317 # subflows are added later
1319 pm_nl_set_limits $ns1 0 1
1320 pm_nl_set_limits $ns2 0 1
1321 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1322 ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT
1323 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow &
1325 # updates in the child shell do not have any effect here, we
1326 # need to bump the test counter for the above case
1327 TEST_COUNT=$((TEST_COUNT+1))
1329 # mpj subflow will be in TW after the reset
1331 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1334 # additional subflow could be created only if the PM select
1335 # the later endpoint, skipping the already used one
1336 chk_join_nr "multi subflows, fair usage on close" 1 1 1
1339 signal_address_tests()
1341 # add_address, unused
1343 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1344 run_tests $ns1 $ns2 10.0.1.1
1345 chk_join_nr "unused signal address" 0 0 0
1348 # accept and use add_addr
1350 pm_nl_set_limits $ns1 0 1
1351 pm_nl_set_limits $ns2 1 1
1352 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1353 run_tests $ns1 $ns2 10.0.1.1
1354 chk_join_nr "signal address" 1 1 1
1357 # accept and use add_addr with an additional subflow
1358 # note: signal address in server ns and local addresses in client ns must
1359 # belong to different subnets or one of the listed local address could be
1360 # used for 'add_addr' subflow
1362 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1363 pm_nl_set_limits $ns1 0 2
1364 pm_nl_set_limits $ns2 1 2
1365 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1366 run_tests $ns1 $ns2 10.0.1.1
1367 chk_join_nr "subflow and signal" 2 2 2
1370 # accept and use add_addr with additional subflows
1372 pm_nl_set_limits $ns1 0 3
1373 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1374 pm_nl_set_limits $ns2 1 3
1375 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1376 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
1377 run_tests $ns1 $ns2 10.0.1.1
1378 chk_join_nr "multiple subflows and signal" 3 3 3
1383 pm_nl_set_limits $ns1 3 3
1384 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1385 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1386 pm_nl_add_endpoint $ns1 10.0.4.1 flags signal
1387 pm_nl_set_limits $ns2 3 3
1388 run_tests $ns1 $ns2 10.0.1.1
1389 chk_join_nr "signal addresses" 3 3 3
1392 # signal invalid addresses
1394 pm_nl_set_limits $ns1 3 3
1395 pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
1396 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1397 pm_nl_add_endpoint $ns1 10.0.14.1 flags signal
1398 pm_nl_set_limits $ns2 3 3
1399 run_tests $ns1 $ns2 10.0.1.1
1400 chk_join_nr "signal invalid addresses" 1 1 1
1403 # signal addresses race test
1405 pm_nl_set_limits $ns1 4 4
1406 pm_nl_set_limits $ns2 4 4
1407 pm_nl_add_endpoint $ns1 10.0.1.1 flags signal
1408 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1409 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1410 pm_nl_add_endpoint $ns1 10.0.4.1 flags signal
1411 pm_nl_add_endpoint $ns2 10.0.1.2 flags signal
1412 pm_nl_add_endpoint $ns2 10.0.2.2 flags signal
1413 pm_nl_add_endpoint $ns2 10.0.3.2 flags signal
1414 pm_nl_add_endpoint $ns2 10.0.4.2 flags signal
1416 # the peer could possibly miss some addr notification, allow retransmission
1417 ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
1418 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
1419 chk_join_nr "signal addresses race test" 3 3 3
1421 # the server will not signal the address terminating
1426 link_failure_tests()
1428 # accept and use add_addr with additional subflows and link loss
1431 # without any b/w limit each veth could spool the packets and get
1432 # them acked at xmit time, so that the corresponding subflow will
1433 # have almost always no outstanding pkts, the scheduler will pick
1434 # always the first subflow and we will have hard time testing
1435 # active backup and link switch-over.
1436 # Let's set some arbitrary (low) virtual link limits.
1438 pm_nl_set_limits $ns1 0 3
1439 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
1440 pm_nl_set_limits $ns2 1 3
1441 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow
1442 pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow
1443 run_tests $ns1 $ns2 10.0.1.1 1
1444 chk_join_nr "multiple flows, signal, link failure" 3 3 3
1446 chk_stale_nr $ns2 1 5 1
1448 # accept and use add_addr with additional subflows and link loss
1449 # for bidirectional transfer
1452 pm_nl_set_limits $ns1 0 3
1453 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
1454 pm_nl_set_limits $ns2 1 3
1455 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow
1456 pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow
1457 run_tests $ns1 $ns2 10.0.1.1 2
1458 chk_join_nr "multi flows, signal, bidi, link fail" 3 3 3
1460 chk_stale_nr $ns2 1 -1 1
1462 # 2 subflows plus 1 backup subflow with a lossy link, backup
1463 # will never be used
1466 pm_nl_set_limits $ns1 0 2
1467 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
1468 pm_nl_set_limits $ns2 1 2
1469 export FAILING_LINKS="1"
1470 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup
1471 run_tests $ns1 $ns2 10.0.1.1 1
1472 chk_join_nr "backup subflow unused, link failure" 2 2 2
1474 chk_link_usage $ns2 ns2eth3 $cinsent 0
1476 # 2 lossy links after half transfer, backup will get half of
1480 pm_nl_set_limits $ns1 0 2
1481 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
1482 pm_nl_set_limits $ns2 1 2
1483 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup
1484 export FAILING_LINKS="1 2"
1485 run_tests $ns1 $ns2 10.0.1.1 1
1486 chk_join_nr "backup flow used, multi links fail" 2 2 2
1488 chk_stale_nr $ns2 2 4 2
1489 chk_link_usage $ns2 ns2eth3 $cinsent 50
1491 # use a backup subflow with the first subflow on a lossy link
1492 # for bidirectional transfer
1495 pm_nl_set_limits $ns1 0 2
1496 pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal
1497 pm_nl_set_limits $ns2 1 3
1498 pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup
1499 run_tests $ns1 $ns2 10.0.1.1 2
1500 chk_join_nr "backup flow used, bidi, link failure" 2 2 2
1502 chk_stale_nr $ns2 1 -1 2
1503 chk_link_usage $ns2 ns2eth3 $cinsent 50
1506 add_addr_timeout_tests()
1509 reset_with_add_addr_timeout
1510 pm_nl_set_limits $ns1 0 1
1511 pm_nl_set_limits $ns2 1 1
1512 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1513 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
1514 chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1
1517 # add_addr timeout IPv6
1518 reset_with_add_addr_timeout 6
1519 pm_nl_set_limits $ns1 0 1
1520 pm_nl_set_limits $ns2 1 1
1521 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
1522 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
1523 chk_join_nr "signal address, ADD_ADDR6 timeout" 1 1 1
1526 # signal addresses timeout
1527 reset_with_add_addr_timeout
1528 pm_nl_set_limits $ns1 2 2
1529 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1530 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1531 pm_nl_set_limits $ns2 2 2
1532 run_tests $ns1 $ns2 10.0.1.1 0 0 0 speed_10
1533 chk_join_nr "signal addresses, ADD_ADDR timeout" 2 2 2
1536 # signal invalid addresses timeout
1537 reset_with_add_addr_timeout
1538 pm_nl_set_limits $ns1 2 2
1539 pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
1540 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1541 pm_nl_set_limits $ns2 2 2
1542 run_tests $ns1 $ns2 10.0.1.1 0 0 0 speed_10
1543 chk_join_nr "invalid address, ADD_ADDR timeout" 1 1 1
1549 # single subflow, remove
1551 pm_nl_set_limits $ns1 0 1
1552 pm_nl_set_limits $ns2 0 1
1553 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1554 run_tests $ns1 $ns2 10.0.1.1 0 0 -1 slow
1555 chk_join_nr "remove single subflow" 1 1 1
1558 # multiple subflows, remove
1560 pm_nl_set_limits $ns1 0 2
1561 pm_nl_set_limits $ns2 0 2
1562 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1563 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1564 run_tests $ns1 $ns2 10.0.1.1 0 0 -2 slow
1565 chk_join_nr "remove multiple subflows" 2 2 2
1568 # single address, remove
1570 pm_nl_set_limits $ns1 0 1
1571 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1572 pm_nl_set_limits $ns2 1 1
1573 run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow
1574 chk_join_nr "remove single address" 1 1 1
1576 chk_rm_nr 1 1 invert
1578 # subflow and signal, remove
1580 pm_nl_set_limits $ns1 0 2
1581 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1582 pm_nl_set_limits $ns2 1 2
1583 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1584 run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow
1585 chk_join_nr "remove subflow and signal" 2 2 2
1589 # subflows and signal, remove
1591 pm_nl_set_limits $ns1 0 3
1592 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1593 pm_nl_set_limits $ns2 1 3
1594 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1595 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
1596 run_tests $ns1 $ns2 10.0.1.1 0 -1 -2 slow
1597 chk_join_nr "remove subflows and signal" 3 3 3
1603 pm_nl_set_limits $ns1 3 3
1604 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250
1605 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1606 pm_nl_add_endpoint $ns1 10.0.4.1 flags signal
1607 pm_nl_set_limits $ns2 3 3
1608 run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow
1609 chk_join_nr "remove addresses" 3 3 3
1611 chk_rm_nr 3 3 invert
1613 # invalid addresses remove
1615 pm_nl_set_limits $ns1 3 3
1616 pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
1617 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1618 pm_nl_add_endpoint $ns1 10.0.14.1 flags signal
1619 pm_nl_set_limits $ns2 3 3
1620 run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow
1621 chk_join_nr "remove invalid addresses" 1 1 1
1623 chk_rm_nr 3 1 invert
1625 # subflows and signal, flush
1627 pm_nl_set_limits $ns1 0 3
1628 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1629 pm_nl_set_limits $ns2 1 3
1630 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1631 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
1632 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow
1633 chk_join_nr "flush subflows and signal" 3 3 3
1639 pm_nl_set_limits $ns1 3 3
1640 pm_nl_set_limits $ns2 3 3
1641 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow id 150
1642 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1643 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
1644 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow
1645 chk_join_nr "flush subflows" 3 3 3
1650 pm_nl_set_limits $ns1 3 3
1651 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250
1652 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1653 pm_nl_add_endpoint $ns1 10.0.4.1 flags signal
1654 pm_nl_set_limits $ns2 3 3
1655 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow
1656 chk_join_nr "flush addresses" 3 3 3
1658 chk_rm_nr 3 3 invert
1660 # invalid addresses flush
1662 pm_nl_set_limits $ns1 3 3
1663 pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
1664 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
1665 pm_nl_add_endpoint $ns1 10.0.14.1 flags signal
1666 pm_nl_set_limits $ns2 3 3
1667 run_tests $ns1 $ns2 10.0.1.1 0 -8 0 slow
1668 chk_join_nr "flush invalid addresses" 1 1 1
1670 chk_rm_nr 3 1 invert
1672 # remove id 0 subflow
1674 pm_nl_set_limits $ns1 0 1
1675 pm_nl_set_limits $ns2 0 1
1676 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1677 run_tests $ns1 $ns2 10.0.1.1 0 0 -9 slow
1678 chk_join_nr "remove id 0 subflow" 1 1 1
1681 # remove id 0 address
1683 pm_nl_set_limits $ns1 0 1
1684 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1685 pm_nl_set_limits $ns2 1 1
1686 run_tests $ns1 $ns2 10.0.1.1 0 -9 0 slow
1687 chk_join_nr "remove id 0 address" 1 1 1
1689 chk_rm_nr 1 1 invert
1694 # add single subflow
1696 pm_nl_set_limits $ns1 0 1
1697 pm_nl_set_limits $ns2 0 1
1698 run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow
1699 chk_join_nr "add single subflow" 1 1 1
1701 # add signal address
1703 pm_nl_set_limits $ns1 0 1
1704 pm_nl_set_limits $ns2 1 1
1705 run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow
1706 chk_join_nr "add signal address" 1 1 1
1709 # add multiple subflows
1711 pm_nl_set_limits $ns1 0 2
1712 pm_nl_set_limits $ns2 0 2
1713 run_tests $ns1 $ns2 10.0.1.1 0 0 2 slow
1714 chk_join_nr "add multiple subflows" 2 2 2
1716 # add multiple subflows IPv6
1718 pm_nl_set_limits $ns1 0 2
1719 pm_nl_set_limits $ns2 0 2
1720 run_tests $ns1 $ns2 dead:beef:1::1 0 0 2 slow
1721 chk_join_nr "add multiple subflows IPv6" 2 2 2
1723 # add multiple addresses IPv6
1725 pm_nl_set_limits $ns1 0 2
1726 pm_nl_set_limits $ns2 2 2
1727 run_tests $ns1 $ns2 dead:beef:1::1 0 2 0 slow
1728 chk_join_nr "add multiple addresses IPv6" 2 2 2
1736 pm_nl_set_limits $ns1 0 1
1737 pm_nl_set_limits $ns2 0 1
1738 pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow
1739 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
1740 chk_join_nr "single subflow IPv6" 1 1 1
1742 # add_address, unused IPv6
1744 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
1745 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
1746 chk_join_nr "unused signal address IPv6" 0 0 0
1749 # signal address IPv6
1751 pm_nl_set_limits $ns1 0 1
1752 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
1753 pm_nl_set_limits $ns2 1 1
1754 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
1755 chk_join_nr "single address IPv6" 1 1 1
1758 # single address IPv6, remove
1760 pm_nl_set_limits $ns1 0 1
1761 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
1762 pm_nl_set_limits $ns2 1 1
1763 run_tests $ns1 $ns2 dead:beef:1::1 0 -1 0 slow
1764 chk_join_nr "remove single address IPv6" 1 1 1
1766 chk_rm_nr 1 1 invert
1768 # subflow and signal IPv6, remove
1770 pm_nl_set_limits $ns1 0 2
1771 pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal
1772 pm_nl_set_limits $ns2 1 2
1773 pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow
1774 run_tests $ns1 $ns2 dead:beef:1::1 0 -1 -1 slow
1775 chk_join_nr "remove subflow and signal IPv6" 2 2 2
1782 # subflow IPv4-mapped to IPv4-mapped
1784 pm_nl_set_limits $ns1 0 1
1785 pm_nl_set_limits $ns2 0 1
1786 pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow
1787 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
1788 chk_join_nr "single subflow IPv4-mapped" 1 1 1
1790 # signal address IPv4-mapped with IPv4-mapped sk
1792 pm_nl_set_limits $ns1 0 1
1793 pm_nl_set_limits $ns2 1 1
1794 pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal
1795 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
1796 chk_join_nr "signal address IPv4-mapped" 1 1 1
1801 pm_nl_set_limits $ns1 0 1
1802 pm_nl_set_limits $ns2 0 1
1803 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1804 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
1805 chk_join_nr "single subflow v4-map-v6" 1 1 1
1807 # signal address v4-map-v6
1809 pm_nl_set_limits $ns1 0 1
1810 pm_nl_set_limits $ns2 1 1
1811 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1812 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
1813 chk_join_nr "signal address v4-map-v6" 1 1 1
1818 pm_nl_set_limits $ns1 0 1
1819 pm_nl_set_limits $ns2 0 1
1820 pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow
1821 run_tests $ns1 $ns2 10.0.1.1
1822 chk_join_nr "single subflow v6-map-v4" 1 1 1
1824 # signal address v6-map-v4
1826 pm_nl_set_limits $ns1 0 1
1827 pm_nl_set_limits $ns2 1 1
1828 pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal
1829 run_tests $ns1 $ns2 10.0.1.1
1830 chk_join_nr "signal address v6-map-v4" 1 1 1
1833 # no subflow IPv6 to v4 address
1835 pm_nl_set_limits $ns1 0 1
1836 pm_nl_set_limits $ns2 0 1
1837 pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow
1838 run_tests $ns1 $ns2 10.0.1.1
1839 chk_join_nr "no JOIN with diff families v4-v6" 0 0 0
1841 # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end
1843 pm_nl_set_limits $ns1 0 1
1844 pm_nl_set_limits $ns2 0 1
1845 pm_nl_add_endpoint $ns2 dead:beef:2::10.0.3.2 flags subflow
1846 run_tests $ns1 $ns2 10.0.1.1
1847 chk_join_nr "no JOIN with diff families v4-v6-2" 0 0 0
1849 # no subflow IPv4 to v6 address, no need to slow down too then
1851 pm_nl_set_limits $ns1 0 1
1852 pm_nl_set_limits $ns2 0 1
1853 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1854 run_tests $ns1 $ns2 dead:beef:1::1
1855 chk_join_nr "no JOIN with diff families v6-v4" 0 0 0
1860 # single subflow, backup
1862 pm_nl_set_limits $ns1 0 1
1863 pm_nl_set_limits $ns2 0 1
1864 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup
1865 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup
1866 chk_join_nr "single subflow, backup" 1 1 1
1869 # single address, backup
1871 pm_nl_set_limits $ns1 0 1
1872 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1873 pm_nl_set_limits $ns2 1 1
1874 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup
1875 chk_join_nr "single address, backup" 1 1 1
1879 # single address with port, backup
1881 pm_nl_set_limits $ns1 0 1
1882 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
1883 pm_nl_set_limits $ns2 1 1
1884 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup
1885 chk_join_nr "single address with port, backup" 1 1 1
1890 add_addr_ports_tests()
1892 # signal address with port
1894 pm_nl_set_limits $ns1 0 1
1895 pm_nl_set_limits $ns2 1 1
1896 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
1897 run_tests $ns1 $ns2 10.0.1.1
1898 chk_join_nr "signal address with port" 1 1 1
1901 # subflow and signal with port
1903 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
1904 pm_nl_set_limits $ns1 0 2
1905 pm_nl_set_limits $ns2 1 2
1906 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1907 run_tests $ns1 $ns2 10.0.1.1
1908 chk_join_nr "subflow and signal with port" 2 2 2
1911 # single address with port, remove
1913 pm_nl_set_limits $ns1 0 1
1914 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
1915 pm_nl_set_limits $ns2 1 1
1916 run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow
1917 chk_join_nr "remove single address with port" 1 1 1
1919 chk_rm_nr 1 1 invert
1921 # subflow and signal with port, remove
1923 pm_nl_set_limits $ns1 0 2
1924 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
1925 pm_nl_set_limits $ns2 1 2
1926 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1927 run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow
1928 chk_join_nr "remove subflow and signal with port" 2 2 2
1932 # subflows and signal with port, flush
1934 pm_nl_set_limits $ns1 0 3
1935 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
1936 pm_nl_set_limits $ns2 1 3
1937 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1938 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
1939 run_tests $ns1 $ns2 10.0.1.1 0 -8 -2 slow
1940 chk_join_nr "flush subflows and signal with port" 3 3 3
1944 # multiple addresses with port
1946 pm_nl_set_limits $ns1 2 2
1947 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
1948 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10100
1949 pm_nl_set_limits $ns2 2 2
1950 run_tests $ns1 $ns2 10.0.1.1
1951 chk_join_nr "multiple addresses with port" 2 2 2
1954 # multiple addresses with ports
1956 pm_nl_set_limits $ns1 2 2
1957 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100
1958 pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10101
1959 pm_nl_set_limits $ns2 2 2
1960 run_tests $ns1 $ns2 10.0.1.1
1961 chk_join_nr "multiple addresses with ports" 2 2 2
1967 # single subflow, syncookies
1969 pm_nl_set_limits $ns1 0 1
1970 pm_nl_set_limits $ns2 0 1
1971 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1972 run_tests $ns1 $ns2 10.0.1.1
1973 chk_join_nr "single subflow with syn cookies" 1 1 1
1975 # multiple subflows with syn cookies
1977 pm_nl_set_limits $ns1 0 2
1978 pm_nl_set_limits $ns2 0 2
1979 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1980 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1981 run_tests $ns1 $ns2 10.0.1.1
1982 chk_join_nr "multiple subflows with syn cookies" 2 2 2
1984 # multiple subflows limited by server
1986 pm_nl_set_limits $ns1 0 1
1987 pm_nl_set_limits $ns2 0 2
1988 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
1989 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
1990 run_tests $ns1 $ns2 10.0.1.1
1991 chk_join_nr "subflows limited by server w cookies" 2 1 1
1993 # test signal address with cookies
1995 pm_nl_set_limits $ns1 0 1
1996 pm_nl_set_limits $ns2 1 1
1997 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
1998 run_tests $ns1 $ns2 10.0.1.1
1999 chk_join_nr "signal address with syn cookies" 1 1 1
2002 # test cookie with subflow and signal
2004 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2005 pm_nl_set_limits $ns1 0 2
2006 pm_nl_set_limits $ns2 1 2
2007 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2008 run_tests $ns1 $ns2 10.0.1.1
2009 chk_join_nr "subflow and signal w cookies" 2 2 2
2012 # accept and use add_addr with additional subflows
2014 pm_nl_set_limits $ns1 0 3
2015 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2016 pm_nl_set_limits $ns2 1 3
2017 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2018 pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow
2019 run_tests $ns1 $ns2 10.0.1.1
2020 chk_join_nr "subflows and signal w. cookies" 3 3 3
2027 reset_with_checksum 0 0
2028 pm_nl_set_limits $ns1 0 1
2029 pm_nl_set_limits $ns2 0 1
2030 run_tests $ns1 $ns2 10.0.1.1
2031 chk_csum_nr "checksum test 0 0"
2034 reset_with_checksum 1 1
2035 pm_nl_set_limits $ns1 0 1
2036 pm_nl_set_limits $ns2 0 1
2037 run_tests $ns1 $ns2 10.0.1.1
2038 chk_csum_nr "checksum test 1 1"
2041 reset_with_checksum 0 1
2042 pm_nl_set_limits $ns1 0 1
2043 pm_nl_set_limits $ns2 0 1
2044 run_tests $ns1 $ns2 10.0.1.1
2045 chk_csum_nr "checksum test 0 1"
2048 reset_with_checksum 1 0
2049 pm_nl_set_limits $ns1 0 1
2050 pm_nl_set_limits $ns2 0 1
2051 run_tests $ns1 $ns2 10.0.1.1
2052 chk_csum_nr "checksum test 1 0"
2055 deny_join_id0_tests()
2057 # subflow allow join id0 ns1
2058 reset_with_allow_join_id0 1 0
2059 pm_nl_set_limits $ns1 1 1
2060 pm_nl_set_limits $ns2 1 1
2061 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2062 run_tests $ns1 $ns2 10.0.1.1
2063 chk_join_nr "single subflow allow join id0 ns1" 1 1 1
2065 # subflow allow join id0 ns2
2066 reset_with_allow_join_id0 0 1
2067 pm_nl_set_limits $ns1 1 1
2068 pm_nl_set_limits $ns2 1 1
2069 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2070 run_tests $ns1 $ns2 10.0.1.1
2071 chk_join_nr "single subflow allow join id0 ns2" 0 0 0
2073 # signal address allow join id0 ns1
2074 # ADD_ADDRs are not affected by allow_join_id0 value.
2075 reset_with_allow_join_id0 1 0
2076 pm_nl_set_limits $ns1 1 1
2077 pm_nl_set_limits $ns2 1 1
2078 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2079 run_tests $ns1 $ns2 10.0.1.1
2080 chk_join_nr "signal address allow join id0 ns1" 1 1 1
2083 # signal address allow join id0 ns2
2084 # ADD_ADDRs are not affected by allow_join_id0 value.
2085 reset_with_allow_join_id0 0 1
2086 pm_nl_set_limits $ns1 1 1
2087 pm_nl_set_limits $ns2 1 1
2088 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2089 run_tests $ns1 $ns2 10.0.1.1
2090 chk_join_nr "signal address allow join id0 ns2" 1 1 1
2093 # subflow and address allow join id0 ns1
2094 reset_with_allow_join_id0 1 0
2095 pm_nl_set_limits $ns1 2 2
2096 pm_nl_set_limits $ns2 2 2
2097 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2098 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2099 run_tests $ns1 $ns2 10.0.1.1
2100 chk_join_nr "subflow and address allow join id0 1" 2 2 2
2102 # subflow and address allow join id0 ns2
2103 reset_with_allow_join_id0 0 1
2104 pm_nl_set_limits $ns1 2 2
2105 pm_nl_set_limits $ns2 2 2
2106 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2107 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
2108 run_tests $ns1 $ns2 10.0.1.1
2109 chk_join_nr "subflow and address allow join id0 2" 1 1 1
2115 # 2 fullmesh addrs in ns2, added before the connection,
2116 # 1 non-fullmesh addr in ns1, added during the connection.
2118 pm_nl_set_limits $ns1 0 4
2119 pm_nl_set_limits $ns2 1 4
2120 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,fullmesh
2121 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,fullmesh
2122 run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow
2123 chk_join_nr "fullmesh test 2x1" 4 4 4
2127 # 1 non-fullmesh addr in ns1, added before the connection,
2128 # 1 fullmesh addr in ns2, added during the connection.
2130 pm_nl_set_limits $ns1 1 3
2131 pm_nl_set_limits $ns2 1 3
2132 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2133 run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow
2134 chk_join_nr "fullmesh test 1x1" 3 3 3
2138 # 1 non-fullmesh addr in ns1, added before the connection,
2139 # 2 fullmesh addrs in ns2, added during the connection.
2141 pm_nl_set_limits $ns1 2 5
2142 pm_nl_set_limits $ns2 1 5
2143 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2144 run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow
2145 chk_join_nr "fullmesh test 1x2" 5 5 5
2149 # 1 non-fullmesh addr in ns1, added before the connection,
2150 # 2 fullmesh addrs in ns2, added during the connection,
2151 # limit max_subflows to 4.
2153 pm_nl_set_limits $ns1 2 4
2154 pm_nl_set_limits $ns2 1 4
2155 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
2156 run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow
2157 chk_join_nr "fullmesh test 1x2, limited" 4 4 4
2162 pm_nl_set_limits $ns1 4 4
2163 pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow
2164 pm_nl_set_limits $ns2 4 4
2165 run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow fullmesh
2166 chk_join_nr "set fullmesh flag test" 2 2 2
2169 # set nofullmesh flag
2171 pm_nl_set_limits $ns1 4 4
2172 pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow,fullmesh
2173 pm_nl_set_limits $ns2 4 4
2174 run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow nofullmesh
2175 chk_join_nr "set nofullmesh flag test" 2 2 2
2178 # set backup,fullmesh flags
2180 pm_nl_set_limits $ns1 4 4
2181 pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow
2182 pm_nl_set_limits $ns2 4 4
2183 run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow backup,fullmesh
2184 chk_join_nr "set backup,fullmesh flags test" 2 2 2
2188 # set nobackup,nofullmesh flags
2190 pm_nl_set_limits $ns1 4 4
2191 pm_nl_set_limits $ns2 4 4
2192 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,backup,fullmesh
2193 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup,nofullmesh
2194 chk_join_nr "set nobackup,nofullmesh flags test" 2 2 2
2202 subflows_error_tests
2203 signal_address_tests
2205 add_addr_timeout_tests
2211 add_addr_ports_tests
2218 # [$1: error message]
2221 if [ -n "${1}" ]; then
2226 echo "mptcp_join usage:"
2227 echo " -f subflows_tests"
2228 echo " -e subflows_error_tests"
2229 echo " -s signal_address_tests"
2230 echo " -l link_failure_tests"
2231 echo " -t add_addr_timeout_tests"
2232 echo " -r remove_tests"
2233 echo " -a add_tests"
2234 echo " -6 ipv6_tests"
2235 echo " -4 v4mapped_tests"
2236 echo " -b backup_tests"
2237 echo " -p add_addr_ports_tests"
2238 echo " -k syncookies_tests"
2239 echo " -S checksum_tests"
2240 echo " -d deny_join_id0_tests"
2241 echo " -m fullmesh_tests"
2242 echo " -c capture pcap files"
2243 echo " -C enable data checksum"
2244 echo " -i use ip mptcp"
2251 # check for "capture/checksum" args before launching tests
2252 if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"c"[0-9a-zA-Z]*$ ]]; then
2255 if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"C"[0-9a-zA-Z]*$ ]]; then
2258 if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"i"[0-9a-zA-Z]*$ ]]; then
2262 # exception for the capture/checksum/ip_mptcp options, the rest means: a part of the tests
2263 if [ "${arg}" != "-c" ] && [ "${arg}" != "-C" ] && [ "${arg}" != "-i" ]; then
2268 if [ $do_all_tests -eq 1 ]; then
2273 while getopts 'fesltra64bpkdmchCSi' opt; do
2279 subflows_error_tests
2282 signal_address_tests
2288 add_addr_timeout_tests
2306 add_addr_ports_tests
2330 usage "Unknown option: -${opt}"