2 # SPDX-License-Identifier: GPL-2.0
4 . "$(dirname "${0}")/mptcp_lib.sh"
8 optstring="S:R:d:e:l:r:h4cm:f:tC"
19 timeout_test=$((timeout_poll * 2 + 1))
21 ethtool_random_on=true
22 tc_delay="$((RANDOM%50))"
23 tc_loss=$((RANDOM%101))
31 connect_per_transfer=1
33 if [ $tc_loss -eq 100 ];then
35 elif [ $tc_loss -ge 10 ]; then
37 elif [ $tc_loss -ge 1 ]; then
44 echo "Usage: $0 [ -a ]"
45 echo -e "\t-d: tc/netem delay in milliseconds, e.g. \"-d 10\" (default random)"
46 echo -e "\t-l: tc/netem loss percentage, e.g. \"-l 0.02\" (default random)"
47 echo -e "\t-r: tc/netem reorder mode, e.g. \"-r 25% 50% gap 5\", use "-r 0" to disable reordering (default random)"
48 echo -e "\t-e: ethtool features to disable, e.g.: \"-e tso -e gso\" (default: randomly disable any of tso/gso/gro)"
49 echo -e "\t-4: IPv4 only: disable IPv6 tests (default: test both IPv4 and IPv6)"
50 echo -e "\t-c: capture packets for each test using tcpdump (default: no capture)"
51 echo -e "\t-f: size of file to transfer in bytes (default random)"
52 echo -e "\t-S: set sndbuf value (default: use kernel default)"
53 echo -e "\t-R: set rcvbuf value (default: use kernel default)"
54 echo -e "\t-m: test mode (poll, sendfile; default: poll)"
55 echo -e "\t-t: also run tests with TCP (use twice to non-fallback tcp)"
56 echo -e "\t-C: enable the MPTCP data checksum"
59 while getopts "$optstring" option;do
66 if [ $OPTARG -ge 0 ];then
69 echo "-d requires numeric argument, got \"$OPTARG\"" 1>&2
74 ethtool_args="$ethtool_args $OPTARG off"
75 ethtool_random_on=false
90 if [ $OPTARG -ge 0 ];then
93 echo "-S requires numeric argument, got \"$OPTARG\"" 1>&2
98 if [ $OPTARG -ge 0 ];then
101 echo "-R requires numeric argument, got \"$OPTARG\"" 1>&2
125 rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
136 rm -f "$cin_disconnect" "$cout_disconnect"
142 for netns in "$ns1" "$ns2" "$ns3" "$ns4";do
144 rm -f /tmp/$netns.{nstat,out}
148 mptcp_lib_check_mptcp
149 mptcp_lib_check_kallsyms
151 ip -Version > /dev/null 2>&1
153 echo "SKIP: Could not run test without ip tool"
162 cin_disconnect="$cin".disconnect
163 cout_disconnect="$cout".disconnect
166 for i in "$ns1" "$ns2" "$ns3" "$ns4";do
167 ip netns add $i || exit $ksft_skip
168 ip -net $i link set lo up
172 # ns1eth2 ns2eth1 ns2eth3 ns3eth2 ns3eth4 ns4eth3
173 # - drop 1% -> reorder 25%
176 ip link add ns1eth2 netns "$ns1" type veth peer name ns2eth1 netns "$ns2"
177 ip link add ns2eth3 netns "$ns2" type veth peer name ns3eth2 netns "$ns3"
178 ip link add ns3eth4 netns "$ns3" type veth peer name ns4eth3 netns "$ns4"
180 ip -net "$ns1" addr add 10.0.1.1/24 dev ns1eth2
181 ip -net "$ns1" addr add dead:beef:1::1/64 dev ns1eth2 nodad
183 ip -net "$ns1" link set ns1eth2 up
184 ip -net "$ns1" route add default via 10.0.1.2
185 ip -net "$ns1" route add default via dead:beef:1::2
187 ip -net "$ns2" addr add 10.0.1.2/24 dev ns2eth1
188 ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 nodad
189 ip -net "$ns2" link set ns2eth1 up
191 ip -net "$ns2" addr add 10.0.2.1/24 dev ns2eth3
192 ip -net "$ns2" addr add dead:beef:2::1/64 dev ns2eth3 nodad
193 ip -net "$ns2" link set ns2eth3 up
194 ip -net "$ns2" route add default via 10.0.2.2
195 ip -net "$ns2" route add default via dead:beef:2::2
196 ip netns exec "$ns2" sysctl -q net.ipv4.ip_forward=1
197 ip netns exec "$ns2" sysctl -q net.ipv6.conf.all.forwarding=1
199 ip -net "$ns3" addr add 10.0.2.2/24 dev ns3eth2
200 ip -net "$ns3" addr add dead:beef:2::2/64 dev ns3eth2 nodad
201 ip -net "$ns3" link set ns3eth2 up
203 ip -net "$ns3" addr add 10.0.3.2/24 dev ns3eth4
204 ip -net "$ns3" addr add dead:beef:3::2/64 dev ns3eth4 nodad
205 ip -net "$ns3" link set ns3eth4 up
206 ip -net "$ns3" route add default via 10.0.2.1
207 ip -net "$ns3" route add default via dead:beef:2::1
208 ip netns exec "$ns3" sysctl -q net.ipv4.ip_forward=1
209 ip netns exec "$ns3" sysctl -q net.ipv6.conf.all.forwarding=1
211 ip -net "$ns4" addr add 10.0.3.1/24 dev ns4eth3
212 ip -net "$ns4" addr add dead:beef:3::1/64 dev ns4eth3 nodad
213 ip -net "$ns4" link set ns4eth3 up
214 ip -net "$ns4" route add default via 10.0.3.2
215 ip -net "$ns4" route add default via dead:beef:3::2
218 for i in "$ns1" "$ns2" "$ns3" "$ns4";do
219 ip netns exec $i sysctl -q net.mptcp.checksum_enabled=1
223 set_ethtool_flags() {
228 ip netns exec $ns ethtool -K $dev $flags 2>/dev/null
229 [ $? -eq 0 ] && echo "INFO: set $ns dev $dev: ethtool -K $flags"
232 set_random_ethtool_flags() {
236 local pick1=$((r & 1))
237 local pick2=$((r & 2))
238 local pick3=$((r & 4))
240 [ $pick1 -ne 0 ] && flags="tso off"
241 [ $pick2 -ne 0 ] && flags="$flags gso off"
242 [ $pick3 -ne 0 ] && flags="$flags gro off"
244 [ -z "$flags" ] && return
246 set_ethtool_flags "$1" "$2" "$flags"
249 if $ethtool_random_on;then
250 set_random_ethtool_flags "$ns3" ns3eth2
251 set_random_ethtool_flags "$ns4" ns4eth3
253 set_ethtool_flags "$ns3" ns3eth2 "$ethtool_args"
254 set_ethtool_flags "$ns4" ns4eth3 "$ethtool_args"
260 echo "Trailing bytes are: "
270 cmp "$in" "$out" > /dev/null 2>&1
271 if [ $? -ne 0 ] ;then
272 echo "[ FAIL ] $what does not match (in, out):"
274 print_file_err "$out"
282 check_mptcp_disabled()
284 local disabled_ns="ns_disabled-$rndh"
285 ip netns add ${disabled_ns} || exit $ksft_skip
287 # net.mptcp.enabled should be enabled by default
288 if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then
289 echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t[ FAIL ]"
290 mptcp_lib_result_fail "net.mptcp.enabled sysctl is not 1 by default"
294 ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=0
297 LC_ALL=C ip netns exec ${disabled_ns} ./mptcp_connect -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \
298 grep -q "^socket: Protocol not available$" && err=1
299 ip netns delete ${disabled_ns}
301 if [ ${err} -eq 0 ]; then
302 echo -e "New MPTCP socket cannot be blocked via sysctl\t\t[ FAIL ]"
303 mptcp_lib_result_fail "New MPTCP socket cannot be blocked via sysctl"
308 echo -e "New MPTCP socket can be blocked via sysctl\t\t[ OK ]"
309 mptcp_lib_result_pass "New MPTCP socket can be blocked via sysctl"
321 local listener_ns="$1"
322 local connector_ns="$2"
323 local connect_addr="$3"
324 local ping_args="-q -c 1"
327 if is_v6 "${connect_addr}"; then
329 ping_args="${ping_args} -6"
332 ip netns exec ${connector_ns} ping ${ping_args} $connect_addr >/dev/null || rc=1
334 if [ $rc -ne 0 ] ; then
335 echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2
344 # $1: ns, $2: MIB counter
347 local listener_ns="${1}"
351 ip netns exec "${listener_ns}" \
352 nstat -z -a "${mib}" | \
354 while read a count c rest; do
360 wait_local_port_listen()
362 local listener_ns="${1}"
367 port_hex="$(printf "%04X" "${port}")"
368 for i in $(seq 10); do
369 ip netns exec "${listener_ns}" cat /proc/net/tcp* | \
370 awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" &&
378 local listener_ns="$1"
379 local connector_ns="$2"
382 local connect_addr="$5"
383 local local_addr="$6"
384 local extra_args="$7"
387 port=$((10000+$TEST_COUNT))
388 TEST_COUNT=$((TEST_COUNT+1))
390 if [ "$rcvbuf" -gt 0 ]; then
391 extra_args="$extra_args -R $rcvbuf"
394 if [ "$sndbuf" -gt 0 ]; then
395 extra_args="$extra_args -S $sndbuf"
398 if [ -n "$testmode" ]; then
399 extra_args="$extra_args -m $testmode"
402 if [ -n "$extra_args" ] && $options_log; then
403 echo "INFO: extra options: $extra_args"
412 addr_port=$(printf "%s:%d" ${connect_addr} ${port})
414 result_msg="$(printf "%.3s %-5s -> %.3s (%-20s) %-5s" ${connector_ns} ${cl_proto} ${listener_ns} ${addr_port} ${srv_proto})"
415 printf "%s\t" "${result_msg}"
419 if [ -z $SUDO_USER ] ; then
422 capuser="-Z $SUDO_USER"
425 local capfile="${rndh}-${connector_ns:0:3}-${listener_ns:0:3}-${cl_proto}-${srv_proto}-${connect_addr}-${port}"
426 local capopt="-i any -s 65535 -B 32768 ${capuser}"
428 ip netns exec ${listener_ns} tcpdump ${capopt} -w "${capfile}-listener.pcap" >> "${capout}" 2>&1 &
429 local cappid_listener=$!
431 ip netns exec ${connector_ns} tcpdump ${capopt} -w "${capfile}-connector.pcap" >> "${capout}" 2>&1 &
432 local cappid_connector=$!
437 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \
439 if [ ${listener_ns} != ${connector_ns} ]; then
440 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \
444 local stat_synrx_last_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX")
445 local stat_ackrx_last_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
446 local stat_cookietx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent")
447 local stat_cookierx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv")
448 local stat_csum_err_s=$(get_mib_counter "${listener_ns}" "MPTcpExtDataCsumErr")
449 local stat_csum_err_c=$(get_mib_counter "${connector_ns}" "MPTcpExtDataCsumErr")
451 timeout ${timeout_test} \
452 ip netns exec ${listener_ns} \
453 ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \
454 $extra_args $local_addr < "$sin" > "$sout" &
457 wait_local_port_listen "${listener_ns}" "${port}"
461 timeout ${timeout_test} \
462 ip netns exec ${connector_ns} \
463 ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
464 $extra_args $connect_addr < "$cin" > "$cout" &
477 kill ${cappid_listener}
478 kill ${cappid_connector}
481 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \
482 nstat | grep Tcp > /tmp/${listener_ns}.out
483 if [ ${listener_ns} != ${connector_ns} ]; then
484 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \
485 nstat | grep Tcp > /tmp/${connector_ns}.out
489 duration=$((stop-start))
490 result_msg+=" # time=${duration}ms"
491 printf "(duration %05sms) " "${duration}"
492 if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
493 echo "[ FAIL ] client exit code $retc, server $rets" 1>&2
494 echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2
495 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port"
496 cat /tmp/${listener_ns}.out
497 echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2
498 ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port"
499 [ ${listener_ns} != ${connector_ns} ] && cat /tmp/${connector_ns}.out
503 mptcp_lib_result_fail "${TEST_GROUP}: ${result_msg}"
507 check_transfer $sin $cout "file received by client"
509 check_transfer $cin $sout "file received by server"
512 local stat_synrx_now_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX")
513 local stat_ackrx_now_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
514 local stat_cookietx_now=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent")
515 local stat_cookierx_now=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv")
516 local stat_ooo_now=$(get_mib_counter "${listener_ns}" "TcpExtTCPOFOQueue")
518 expect_synrx=$((stat_synrx_last_l))
519 expect_ackrx=$((stat_ackrx_last_l))
521 cookies=$(ip netns exec ${listener_ns} sysctl net.ipv4.tcp_syncookies)
522 cookies=${cookies##*=}
524 if [ ${cl_proto} = "MPTCP" ] && [ ${srv_proto} = "MPTCP" ]; then
525 expect_synrx=$((stat_synrx_last_l+$connect_per_transfer))
526 expect_ackrx=$((stat_ackrx_last_l+$connect_per_transfer))
529 if [ ${stat_synrx_now_l} -lt ${expect_synrx} ]; then
530 printf "[ FAIL ] lower MPC SYN rx (%d) than expected (%d)\n" \
531 "${stat_synrx_now_l}" "${expect_synrx}" 1>&2
534 if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} -a ${stat_ooo_now} -eq 0 ]; then
535 if [ ${stat_ooo_now} -eq 0 ]; then
536 printf "[ FAIL ] lower MPC ACK rx (%d) than expected (%d)\n" \
537 "${stat_ackrx_now_l}" "${expect_ackrx}" 1>&2
540 printf "[ Note ] fallback due to TCP OoO"
545 local csum_err_s=$(get_mib_counter "${listener_ns}" "MPTcpExtDataCsumErr")
546 local csum_err_c=$(get_mib_counter "${connector_ns}" "MPTcpExtDataCsumErr")
548 local csum_err_s_nr=$((csum_err_s - stat_csum_err_s))
549 if [ $csum_err_s_nr -gt 0 ]; then
550 printf "[ FAIL ]\nserver got $csum_err_s_nr data checksum error[s]"
554 local csum_err_c_nr=$((csum_err_c - stat_csum_err_c))
555 if [ $csum_err_c_nr -gt 0 ]; then
556 printf "[ FAIL ]\nclient got $csum_err_c_nr data checksum error[s]"
561 if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then
563 mptcp_lib_result_pass "${TEST_GROUP}: ${result_msg}"
565 mptcp_lib_result_fail "${TEST_GROUP}: ${result_msg}"
568 if [ $cookies -eq 2 ];then
569 if [ $stat_cookietx_last -ge $stat_cookietx_now ] ;then
570 printf " WARN: CookieSent: did not advance"
572 if [ $stat_cookierx_last -ge $stat_cookierx_now ] ;then
573 printf " WARN: CookieRecv: did not advance"
576 if [ $stat_cookietx_last -ne $stat_cookietx_now ] ;then
577 printf " WARN: CookieSent: changed"
579 if [ $stat_cookierx_last -ne $stat_cookierx_now ] ;then
580 printf " WARN: CookieRecv: changed"
584 if [ ${stat_synrx_now_l} -gt ${expect_synrx} ]; then
585 printf " WARN: SYNRX: expect %d, got %d (probably retransmissions)" \
586 "${expect_synrx}" "${stat_synrx_now_l}"
588 if [ ${stat_ackrx_now_l} -gt ${expect_ackrx} ]; then
589 printf " WARN: ACKRX: expect %d, got %d (probably retransmissions)" \
590 "${expect_ackrx}" "${stat_ackrx_now_l}"
595 [ $retc -eq 0 ] && [ $rets -eq 0 ]
606 if [ $SIZE -eq 0 ]; then
607 local MAXSIZE=$((1024 * 1024 * 8))
608 local MINSIZE=$((1024 * 256))
610 SIZE=$(((RANDOM * RANDOM + MINSIZE) % MAXSIZE))
613 ksize=$((SIZE / 1024))
614 rem=$((SIZE - (ksize * 1024)))
616 dd if=/dev/urandom of="$name" bs=1024 count=$ksize 2> /dev/null
617 dd if=/dev/urandom conv=notrunc of="$name" bs=1 count=$rem 2> /dev/null
618 echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
620 echo "Created $name (size $(du -b "$name")) containing data sent by $who"
625 local listener_ns="$1"
626 local connector_ns="$2"
627 local connect_addr="$3"
629 local extra_args="$5"
632 # skip if test programs are running inside same netns for subsequent runs.
633 if [ $loopback -eq 0 ] && [ ${listener_ns} = ${connector_ns} ]; then
637 # skip if we don't want v6
638 if ! $ipv6 && is_v6 "${connect_addr}"; then
643 if is_v6 "${connect_addr}"; then
649 do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP \
650 ${connect_addr} ${local_addr} "${extra_args}"
652 if [ $lret -ne 0 ]; then
657 if [ $do_tcp -eq 0 ]; then
658 # don't bother testing fallback tcp except for loopback case.
659 if [ ${listener_ns} != ${connector_ns} ]; then
664 do_transfer ${listener_ns} ${connector_ns} MPTCP TCP \
665 ${connect_addr} ${local_addr} "${extra_args}"
667 if [ $lret -ne 0 ]; then
672 do_transfer ${listener_ns} ${connector_ns} TCP MPTCP \
673 ${connect_addr} ${local_addr} "${extra_args}"
675 if [ $lret -ne 0 ]; then
680 if [ $do_tcp -gt 1 ] ;then
681 do_transfer ${listener_ns} ${connector_ns} TCP TCP \
682 ${connect_addr} ${local_addr} "${extra_args}"
684 if [ $lret -ne 0 ]; then
695 run_tests_lo $1 $2 $3 0
698 run_test_transparent()
700 local connect_addr="$1"
703 local connector_ns="$ns1"
704 local listener_ns="$ns2"
710 # skip if we don't want v6
711 if ! $ipv6 && is_v6 "${connect_addr}"; then
715 # IP(V6)_TRANSPARENT has been added after TOS support which came with
716 # the required infrastructure in MPTCP sockopt code. To support TOS, the
717 # following function has been exported (T). Not great but better than
718 # checking for a specific kernel version.
719 if ! mptcp_lib_kallsyms_has "T __ip_sock_set_tos$"; then
720 echo "INFO: ${msg} not supported by the kernel: SKIP"
721 mptcp_lib_result_skip "${TEST_GROUP}"
725 ip netns exec "$listener_ns" nft -f /dev/stdin <<"EOF"
729 type filter hook prerouting priority -150;
731 meta l4proto tcp socket transparent 1 meta mark set 1 accept
732 tcp dport 20000 tproxy to :20000 meta mark set 1 accept
736 if [ $? -ne 0 ]; then
737 echo "SKIP: $msg, could not load nft ruleset"
738 mptcp_lib_fail_if_expected_feature "nft rules"
739 mptcp_lib_result_skip "${TEST_GROUP}"
744 if is_v6 "${connect_addr}"; then
751 ip -net "$listener_ns" $r6flag rule add fwmark 1 lookup 100
752 if [ $? -ne 0 ]; then
753 ip netns exec "$listener_ns" nft flush ruleset
754 echo "SKIP: $msg, ip $r6flag rule failed"
755 mptcp_lib_fail_if_expected_feature "ip rule"
756 mptcp_lib_result_skip "${TEST_GROUP}"
760 ip -net "$listener_ns" route add local $local_addr/0 dev lo table 100
761 if [ $? -ne 0 ]; then
762 ip netns exec "$listener_ns" nft flush ruleset
763 ip -net "$listener_ns" $r6flag rule del fwmark 1 lookup 100
764 echo "SKIP: $msg, ip route add local $local_addr failed"
765 mptcp_lib_fail_if_expected_feature "ip route"
766 mptcp_lib_result_skip "${TEST_GROUP}"
770 echo "INFO: test $msg"
773 local extra_args="-o TRANSPARENT"
774 do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP \
775 ${connect_addr} ${local_addr} "${extra_args}"
778 ip netns exec "$listener_ns" nft flush ruleset
779 ip -net "$listener_ns" $r6flag rule del fwmark 1 lookup 100
780 ip -net "$listener_ns" route del local $local_addr/0 dev lo table 100
782 if [ $lret -ne 0 ]; then
783 echo "FAIL: $msg, mptcp connection error" 1>&2
796 TEST_GROUP="peek mode: ${peekmode}"
797 echo "INFO: with peek mode: ${peekmode}"
798 run_tests_lo "$ns1" "$ns1" 10.0.1.1 1 "-P ${peekmode}"
799 run_tests_lo "$ns1" "$ns1" dead:beef:1::1 1 "-P ${peekmode}"
806 if ! mptcp_lib_kallsyms_has "mptcp_fastopen_"; then
807 echo "INFO: TFO not supported by the kernel: SKIP"
808 mptcp_lib_result_skip "${TEST_GROUP}"
812 echo "INFO: with MPTFO start"
813 ip netns exec "$ns1" sysctl -q net.ipv4.tcp_fastopen=2
814 ip netns exec "$ns2" sysctl -q net.ipv4.tcp_fastopen=1
816 run_tests_lo "$ns1" "$ns2" 10.0.1.1 0 "-o MPTFO"
817 run_tests_lo "$ns1" "$ns2" 10.0.1.1 0 "-o MPTFO"
819 run_tests_lo "$ns1" "$ns2" dead:beef:1::1 0 "-o MPTFO"
820 run_tests_lo "$ns1" "$ns2" dead:beef:1::1 0 "-o MPTFO"
822 ip netns exec "$ns1" sysctl -q net.ipv4.tcp_fastopen=0
823 ip netns exec "$ns2" sysctl -q net.ipv4.tcp_fastopen=0
824 echo "INFO: with MPTFO end"
827 run_tests_disconnect()
832 TEST_GROUP="full disconnect"
834 if ! mptcp_lib_kallsyms_has "mptcp_pm_data_reset$"; then
835 echo "INFO: Full disconnect not supported: SKIP"
836 mptcp_lib_result_skip "${TEST_GROUP}"
840 cat $cin $cin $cin > "$cin".disconnect
842 # force do_transfer to cope with the multiple transmissions
843 sin="$cin.disconnect"
844 cin="$cin.disconnect"
845 cin_disconnect="$old_cin"
846 connect_per_transfer=3
848 echo "INFO: disconnect"
849 run_tests_lo "$ns1" "$ns1" 10.0.1.1 1 "-I 3 -i $old_cin"
850 run_tests_lo "$ns1" "$ns1" dead:beef:1::1 1 "-I 3 -i $old_cin"
852 # restore previous status
855 cin_disconnect="$cin".disconnect
856 connect_per_transfer=1
862 time_run=$((time_end-time_start))
864 echo "Time: ${time_run} seconds"
871 if [ ${ret} -ne 0 ]; then
872 echo "FAIL: ${msg}" 1>&2
883 if ! log_if_error "${@}"; then
885 mptcp_lib_result_print_all_tap
890 make_file "$cin" "client"
891 make_file "$sin" "server"
895 stop_if_error "The kernel configuration is not valid for MPTCP"
897 echo "INFO: validating network environment with pings"
898 for sender in "$ns1" "$ns2" "$ns3" "$ns4";do
899 do_ping "$ns1" $sender 10.0.1.1
900 do_ping "$ns1" $sender dead:beef:1::1
902 do_ping "$ns2" $sender 10.0.1.2
903 do_ping "$ns2" $sender dead:beef:1::2
904 do_ping "$ns2" $sender 10.0.2.1
905 do_ping "$ns2" $sender dead:beef:2::1
907 do_ping "$ns3" $sender 10.0.2.2
908 do_ping "$ns3" $sender dead:beef:2::2
909 do_ping "$ns3" $sender 10.0.3.2
910 do_ping "$ns3" $sender dead:beef:3::2
912 do_ping "$ns4" $sender 10.0.3.1
913 do_ping "$ns4" $sender dead:beef:3::1
916 mptcp_lib_result_code "${ret}" "ping tests"
918 stop_if_error "Could not even run ping tests"
920 [ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $tc_loss delay ${tc_delay}ms
921 echo -n "INFO: Using loss of $tc_loss "
922 test "$tc_delay" -gt 0 && echo -n "delay $tc_delay ms "
924 reorder_delay=$(($tc_delay / 4))
926 if [ -z "${tc_reorder}" ]; then
927 reorder1=$((RANDOM%10))
928 reorder1=$((100 - reorder1))
929 reorder2=$((RANDOM%100))
931 if [ $reorder_delay -gt 0 ] && [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then
932 tc_reorder="reorder ${reorder1}% ${reorder2}%"
933 echo -n "$tc_reorder with delay ${reorder_delay}ms "
935 elif [ "$tc_reorder" = "0" ];then
937 elif [ "$reorder_delay" -gt 0 ];then
938 # reordering requires some delay
939 tc_reorder="reorder $tc_reorder"
940 echo -n "$tc_reorder with delay ${reorder_delay}ms "
945 tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${reorder_delay}ms $tc_reorder
947 TEST_GROUP="loopback v4"
948 run_tests_lo "$ns1" "$ns1" 10.0.1.1 1
949 stop_if_error "Could not even run loopback test"
951 TEST_GROUP="loopback v6"
952 run_tests_lo "$ns1" "$ns1" dead:beef:1::1 1
953 stop_if_error "Could not even run loopback v6 test"
955 TEST_GROUP="multihosts"
956 for sender in $ns1 $ns2 $ns3 $ns4;do
957 # ns1<->ns2 is not subject to reordering/tc delays. Use it to test
958 # mptcp syncookie support.
959 if [ $sender = $ns1 ]; then
960 ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=2
962 ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=1
965 run_tests "$ns1" $sender 10.0.1.1
966 run_tests "$ns1" $sender dead:beef:1::1
968 run_tests "$ns2" $sender 10.0.1.2
969 run_tests "$ns2" $sender dead:beef:1::2
970 run_tests "$ns2" $sender 10.0.2.1
971 run_tests "$ns2" $sender dead:beef:2::1
973 run_tests "$ns3" $sender 10.0.2.2
974 run_tests "$ns3" $sender dead:beef:2::2
975 run_tests "$ns3" $sender 10.0.3.2
976 run_tests "$ns3" $sender dead:beef:3::2
978 run_tests "$ns4" $sender 10.0.3.1
979 run_tests "$ns4" $sender dead:beef:3::1
981 log_if_error "Tests with $sender as a sender have failed"
984 run_tests_peekmode "saveWithPeek"
985 run_tests_peekmode "saveAfterPeek"
986 log_if_error "Tests with peek mode have failed"
988 # MPTFO (MultiPath TCP Fatopen tests)
990 log_if_error "Tests with MPTFO have failed"
992 # connect to ns4 ip address, ns2 should intercept/proxy
993 run_test_transparent 10.0.3.1 "tproxy ipv4"
994 run_test_transparent dead:beef:3::1 "tproxy ipv6"
995 log_if_error "Tests with tproxy have failed"
998 log_if_error "Tests of the full disconnection have failed"
1001 mptcp_lib_result_print_all_tap