2 # SPDX-License-Identifier: GPL-2.0
17 # generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) ||
18 # (ip6 && (ip6[74] & 0xf0) == 0x30)'"
19 CBPF_MPTCP_SUBOPTION_ADD_ADDR="14,
39 rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
44 for netns in "$ns1" "$ns2";do
45 ip netns add $netns || exit $ksft_skip
46 ip -net $netns link set lo up
47 ip netns exec $netns sysctl -q net.mptcp.enabled=1
48 ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0
49 ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0
58 for i in `seq 1 4`; do
59 ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2"
60 ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i
61 ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad
62 ip -net "$ns1" link set ns1eth$i up
64 ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i
65 ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad
66 ip -net "$ns2" link set ns2eth$i up
68 # let $ns2 reach any $ns1 address from any interface
69 ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i
77 for netns in "$ns1" "$ns2"; do
85 rm -f "$sin" "$sout" "$cinsent"
99 for netns in "$ns1" "$ns2";do
100 ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2
104 reset_with_add_addr_timeout()
110 if [ $ip -eq 6 ]; then
116 ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
117 ip netns exec $ns2 $tables -A OUTPUT -p tcp \
118 -m tcp --tcp-option 30 \
120 "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \
125 if [ "$arg" = "-c" ]; then
130 ip -Version > /dev/null 2>&1
132 echo "SKIP: Could not run test without ip tool"
136 iptables -V > /dev/null 2>&1
138 echo "SKIP: Could not run all tests without iptables tool"
142 ip6tables -V > /dev/null 2>&1
144 echo "SKIP: Could not run all tests without ip6tables tool"
151 echo "Trailing bytes are: "
161 cmp "$in" "$out" > /dev/null 2>&1
162 if [ $? -ne 0 ] ;then
163 echo "[ FAIL ] $what does not match (in, out):"
165 print_file_err "$out"
180 ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null
181 if [ $? -ne 0 ] ; then
182 echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2
195 ip -net "$ns" link set "$veth" down
217 port=$((10000+$TEST_COUNT))
218 TEST_COUNT=$((TEST_COUNT+1))
224 if [ $capture -eq 1 ]; then
225 if [ -z $SUDO_USER ] ; then
228 capuser="-Z $SUDO_USER"
231 capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}")
233 echo "Capturing traffic for test $TEST_COUNT into $capfile"
234 ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 &
240 if [ $speed = "fast" ]; then
241 mptcp_connect="./mptcp_connect -j"
243 mptcp_connect="./mptcp_connect -r"
247 if is_v6 "${connect_addr}"; then
253 ip netns exec ${listener_ns} $mptcp_connect -t $timeout -l -p $port \
254 -s ${srv_proto} ${local_addr} < "$sin" > "$sout" &
259 if [ "$test_link_fail" -eq 0 ];then
260 ip netns exec ${connector_ns} $mptcp_connect -t $timeout -p $port -s ${cl_proto} $connect_addr < "$cin" > "$cout" &
262 ( cat "$cin" ; sleep 2; link_failure $listener_ns ; cat "$cin" ) | tee "$cinsent" | \
263 ip netns exec ${connector_ns} $mptcp_connect -t $timeout -p $port -s ${cl_proto} $connect_addr > "$cout" &
267 if [ $addr_nr_ns1 -gt 0 ]; then
268 let add_nr_ns1=addr_nr_ns1
271 while [ $add_nr_ns1 -gt 0 ]; do
273 if is_v6 "${connect_addr}"; then
274 addr="dead:beef:$counter::1"
276 addr="10.0.$counter.1"
278 ip netns exec $ns1 ./pm_nl_ctl add $addr flags signal
283 elif [ $addr_nr_ns1 -lt 0 ]; then
284 let rm_nr_ns1=-addr_nr_ns1
285 if [ $rm_nr_ns1 -lt 8 ]; then
289 while [ $counter -le $rm_nr_ns1 ]
291 ip netns exec ${listener_ns} ./pm_nl_ctl del $counter
297 ip netns exec ${listener_ns} ./pm_nl_ctl flush
301 if [ $addr_nr_ns2 -gt 0 ]; then
302 let add_nr_ns2=addr_nr_ns2
305 while [ $add_nr_ns2 -gt 0 ]; do
307 if is_v6 "${connect_addr}"; then
308 addr="dead:beef:$counter::2"
310 addr="10.0.$counter.2"
312 ip netns exec $ns2 ./pm_nl_ctl add $addr flags subflow
317 elif [ $addr_nr_ns2 -lt 0 ]; then
318 let rm_nr_ns2=-addr_nr_ns2
319 if [ $rm_nr_ns2 -lt 8 ]; then
323 while [ $counter -le $rm_nr_ns2 ]
325 ip netns exec ${connector_ns} ./pm_nl_ctl del $counter
331 ip netns exec ${connector_ns} ./pm_nl_ctl flush
335 if [ ! -z $bkup ]; then
337 for netns in "$ns1" "$ns2"; do
338 dump=(`ip netns exec $netns ./pm_nl_ctl dump`)
339 if [ ${#dump[@]} -gt 0 ]; then
340 addr=${dump[${#dump[@]} - 1]}
341 backup="ip netns exec $netns ./pm_nl_ctl set $addr flags $bkup"
352 if [ $capture -eq 1 ]; then
357 if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
358 echo " client exit code $retc, server $rets" 1>&2
359 echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2
360 ip netns exec ${listener_ns} ss -nita 1>&2 -o "sport = :$port"
361 echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2
362 ip netns exec ${connector_ns} ss -nita 1>&2 -o "dport = :$port"
369 check_transfer $sin $cout "file received by client"
371 if [ "$test_link_fail" -eq 0 ];then
372 check_transfer $cin $sout "file received by server"
374 check_transfer $cinsent $sout "file received by server"
378 if [ $retc -eq 0 ] && [ $rets -eq 0 ];then
393 dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null
394 echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
396 echo "Created $name (size $size KB) containing data sent by $who"
404 test_linkfail="${4:-0}"
405 addr_nr_ns1="${5:-0}"
406 addr_nr_ns2="${6:-0}"
412 if [ "$test_linkfail" -eq 1 ];then
413 size=$((RANDOM%1024))
419 make_file "$cin" "client" $size
422 do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \
423 ${test_linkfail} ${addr_nr_ns1} ${addr_nr_ns2} ${speed} ${bkup}
426 if [ "$test_linkfail" -eq 1 ];then
431 if [ $lret -ne 0 ]; then
446 printf "%02u %-36s %s" "$TEST_COUNT" "$msg" "syn"
447 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'`
448 [ -z "$count" ] && count=0
449 if [ "$count" != "$syn_nr" ]; then
450 echo "[fail] got $count JOIN[s] syn expected $syn_nr"
458 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'`
459 [ -z "$count" ] && count=0
460 if [ "$count" != "$syn_ack_nr" ]; then
461 echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr"
469 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'`
470 [ -z "$count" ] && count=0
471 if [ "$count" != "$ack_nr" ]; then
472 echo "[fail] got $count JOIN[s] ack expected $ack_nr"
478 if [ "${dump_stats}" = 1 ]; then
480 ip netns exec $ns1 nstat -as | grep MPTcp
482 ip netns exec $ns2 nstat -as | grep MPTcp
490 local port_nr=${3:-0}
491 local syn_nr=${4:-$port_nr}
492 local syn_ack_nr=${5:-$port_nr}
493 local ack_nr=${6:-$port_nr}
494 local mis_syn_nr=${7:-0}
495 local mis_ack_nr=${8:-0}
499 printf "%-39s %s" " " "add"
500 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtAddAddr | awk '{print $2}'`
501 [ -z "$count" ] && count=0
502 if [ "$count" != "$add_nr" ]; then
503 echo "[fail] got $count ADD_ADDR[s] expected $add_nr"
511 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtEchoAdd | awk '{print $2}'`
512 [ -z "$count" ] && count=0
513 if [ "$count" != "$echo_nr" ]; then
514 echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr"
521 if [ $port_nr -gt 0 ]; then
523 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtPortAdd | awk '{print $2}'`
524 [ -z "$count" ] && count=0
525 if [ "$count" != "$port_nr" ]; then
526 echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr"
533 printf "%-39s %s" " " "syn"
534 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortSynRx |
536 [ -z "$count" ] && count=0
537 if [ "$count" != "$syn_nr" ]; then
538 echo "[fail] got $count JOIN[s] syn with a different \
539 port-number expected $syn_nr"
547 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinPortSynAckRx |
549 [ -z "$count" ] && count=0
550 if [ "$count" != "$syn_ack_nr" ]; then
551 echo "[fail] got $count JOIN[s] synack with a different \
552 port-number expected $syn_ack_nr"
560 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortAckRx |
562 [ -z "$count" ] && count=0
563 if [ "$count" != "$ack_nr" ]; then
564 echo "[fail] got $count JOIN[s] ack with a different \
565 port-number expected $ack_nr"
572 printf "%-39s %s" " " "syn"
573 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortSynRx |
575 [ -z "$count" ] && count=0
576 if [ "$count" != "$mis_syn_nr" ]; then
577 echo "[fail] got $count JOIN[s] syn with a mismatched \
578 port-number expected $mis_syn_nr"
586 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortAckRx |
588 [ -z "$count" ] && count=0
589 if [ "$count" != "$mis_ack_nr" ]; then
590 echo "[fail] got $count JOIN[s] ack with a mismatched \
591 port-number expected $mis_ack_nr"
601 if [ "${dump_stats}" = 1 ]; then
603 ip netns exec $ns1 nstat -as | grep MPTcp
605 ip netns exec $ns2 nstat -as | grep MPTcp
612 local rm_subflow_nr=$2
616 printf "%-39s %s" " " "rm "
617 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'`
618 [ -z "$count" ] && count=0
619 if [ "$count" != "$rm_addr_nr" ]; then
620 echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr"
628 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'`
629 [ -z "$count" ] && count=0
630 if [ "$count" != "$rm_subflow_nr" ]; then
631 echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr"
638 if [ "${dump_stats}" = 1 ]; then
640 ip netns exec $ns1 nstat -as | grep MPTcp
642 ip netns exec $ns2 nstat -as | grep MPTcp
648 local mp_prio_nr_tx=$1
649 local mp_prio_nr_rx=$2
653 printf "%-39s %s" " " "ptx"
654 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}'`
655 [ -z "$count" ] && count=0
656 if [ "$count" != "$mp_prio_nr_tx" ]; then
657 echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx"
665 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}'`
666 [ -z "$count" ] && count=0
667 if [ "$count" != "$mp_prio_nr_rx" ]; then
668 echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx"
675 if [ "${dump_stats}" = 1 ]; then
677 ip netns exec $ns1 nstat -as | grep MPTcp
679 ip netns exec $ns2 nstat -as | grep MPTcp
686 run_tests $ns1 $ns2 10.0.1.1
687 chk_join_nr "no JOIN" "0" "0" "0"
689 # subflow limited by client
691 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
692 run_tests $ns1 $ns2 10.0.1.1
693 chk_join_nr "single subflow, limited by client" 0 0 0
695 # subflow limited by server
697 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
698 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
699 run_tests $ns1 $ns2 10.0.1.1
700 chk_join_nr "single subflow, limited by server" 1 1 0
704 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
705 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
706 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
707 run_tests $ns1 $ns2 10.0.1.1
708 chk_join_nr "single subflow" 1 1 1
712 ip netns exec $ns1 ./pm_nl_ctl limits 0 2
713 ip netns exec $ns2 ./pm_nl_ctl limits 0 2
714 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
715 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow
716 run_tests $ns1 $ns2 10.0.1.1
717 chk_join_nr "multiple subflows" 2 2 2
719 # multiple subflows limited by serverf
721 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
722 ip netns exec $ns2 ./pm_nl_ctl limits 0 2
723 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
724 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow
725 run_tests $ns1 $ns2 10.0.1.1
726 chk_join_nr "multiple subflows, limited by server" 2 2 1
729 signal_address_tests()
731 # add_address, unused
733 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
734 run_tests $ns1 $ns2 10.0.1.1
735 chk_join_nr "unused signal address" 0 0 0
738 # accept and use add_addr
740 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
741 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
742 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
743 run_tests $ns1 $ns2 10.0.1.1
744 chk_join_nr "signal address" 1 1 1
747 # accept and use add_addr with an additional subflow
748 # note: signal address in server ns and local addresses in client ns must
749 # belong to different subnets or one of the listed local address could be
750 # used for 'add_addr' subflow
752 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
753 ip netns exec $ns1 ./pm_nl_ctl limits 0 2
754 ip netns exec $ns2 ./pm_nl_ctl limits 1 2
755 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
756 run_tests $ns1 $ns2 10.0.1.1
757 chk_join_nr "subflow and signal" 2 2 2
760 # accept and use add_addr with additional subflows
762 ip netns exec $ns1 ./pm_nl_ctl limits 0 3
763 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
764 ip netns exec $ns2 ./pm_nl_ctl limits 1 3
765 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
766 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
767 run_tests $ns1 $ns2 10.0.1.1
768 chk_join_nr "multiple subflows and signal" 3 3 3
774 # accept and use add_addr with additional subflows and link loss
776 ip netns exec $ns1 ./pm_nl_ctl limits 0 3
777 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
778 ip netns exec $ns2 ./pm_nl_ctl limits 1 3
779 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
780 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
781 run_tests $ns1 $ns2 10.0.1.1 1
782 chk_join_nr "multiple flows, signal, link failure" 3 3 3
786 add_addr_timeout_tests()
789 reset_with_add_addr_timeout
790 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
791 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
792 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
793 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
794 chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1
797 # add_addr timeout IPv6
798 reset_with_add_addr_timeout 6
799 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
800 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
801 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal
802 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
803 chk_join_nr "signal address, ADD_ADDR6 timeout" 1 1 1
809 # single subflow, remove
811 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
812 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
813 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
814 run_tests $ns1 $ns2 10.0.1.1 0 0 -1 slow
815 chk_join_nr "remove single subflow" 1 1 1
818 # multiple subflows, remove
820 ip netns exec $ns1 ./pm_nl_ctl limits 0 2
821 ip netns exec $ns2 ./pm_nl_ctl limits 0 2
822 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow
823 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
824 run_tests $ns1 $ns2 10.0.1.1 0 0 -2 slow
825 chk_join_nr "remove multiple subflows" 2 2 2
828 # single address, remove
830 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
831 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
832 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
833 run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow
834 chk_join_nr "remove single address" 1 1 1
838 # subflow and signal, remove
840 ip netns exec $ns1 ./pm_nl_ctl limits 0 2
841 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
842 ip netns exec $ns2 ./pm_nl_ctl limits 1 2
843 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
844 run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow
845 chk_join_nr "remove subflow and signal" 2 2 2
849 # subflows and signal, remove
851 ip netns exec $ns1 ./pm_nl_ctl limits 0 3
852 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
853 ip netns exec $ns2 ./pm_nl_ctl limits 1 3
854 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
855 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
856 run_tests $ns1 $ns2 10.0.1.1 0 -1 -2 slow
857 chk_join_nr "remove subflows and signal" 3 3 3
861 # subflows and signal, flush
863 ip netns exec $ns1 ./pm_nl_ctl limits 0 3
864 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
865 ip netns exec $ns2 ./pm_nl_ctl limits 1 3
866 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
867 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
868 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow
869 chk_join_nr "flush subflows and signal" 3 3 3
878 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
879 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
880 run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow
881 chk_join_nr "add single subflow" 1 1 1
885 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
886 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
887 run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow
888 chk_join_nr "add signal address" 1 1 1
891 # add multiple subflows
893 ip netns exec $ns1 ./pm_nl_ctl limits 0 2
894 ip netns exec $ns2 ./pm_nl_ctl limits 0 2
895 run_tests $ns1 $ns2 10.0.1.1 0 0 2 slow
896 chk_join_nr "add multiple subflows" 2 2 2
898 # add multiple subflows IPv6
900 ip netns exec $ns1 ./pm_nl_ctl limits 0 2
901 ip netns exec $ns2 ./pm_nl_ctl limits 0 2
902 run_tests $ns1 $ns2 dead:beef:1::1 0 0 2 slow
903 chk_join_nr "add multiple subflows IPv6" 2 2 2
905 # add multiple addresses IPv6
907 ip netns exec $ns1 ./pm_nl_ctl limits 0 2
908 ip netns exec $ns2 ./pm_nl_ctl limits 2 2
909 run_tests $ns1 $ns2 dead:beef:1::1 0 2 0 slow
910 chk_join_nr "add multiple addresses IPv6" 2 2 2
918 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
919 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
920 ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 flags subflow
921 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
922 chk_join_nr "single subflow IPv6" 1 1 1
924 # add_address, unused IPv6
926 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal
927 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
928 chk_join_nr "unused signal address IPv6" 0 0 0
931 # signal address IPv6
933 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
934 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal
935 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
936 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
937 chk_join_nr "single address IPv6" 1 1 1
940 # single address IPv6, remove
942 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
943 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal
944 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
945 run_tests $ns1 $ns2 dead:beef:1::1 0 -1 0 slow
946 chk_join_nr "remove single address IPv6" 1 1 1
950 # subflow and signal IPv6, remove
952 ip netns exec $ns1 ./pm_nl_ctl limits 0 2
953 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal
954 ip netns exec $ns2 ./pm_nl_ctl limits 1 2
955 ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 flags subflow
956 run_tests $ns1 $ns2 dead:beef:1::1 0 -1 -1 slow
957 chk_join_nr "remove subflow and signal IPv6" 2 2 2
964 # subflow IPv4-mapped to IPv4-mapped
966 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
967 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
968 ip netns exec $ns2 ./pm_nl_ctl add "::ffff:10.0.3.2" flags subflow
969 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
970 chk_join_nr "single subflow IPv4-mapped" 1 1 1
972 # signal address IPv4-mapped with IPv4-mapped sk
974 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
975 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
976 ip netns exec $ns1 ./pm_nl_ctl add "::ffff:10.0.2.1" flags signal
977 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
978 chk_join_nr "signal address IPv4-mapped" 1 1 1
983 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
984 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
985 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
986 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
987 chk_join_nr "single subflow v4-map-v6" 1 1 1
989 # signal address v4-map-v6
991 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
992 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
993 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
994 run_tests $ns1 $ns2 "::ffff:10.0.1.1"
995 chk_join_nr "signal address v4-map-v6" 1 1 1
1000 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
1001 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
1002 ip netns exec $ns2 ./pm_nl_ctl add "::ffff:10.0.3.2" flags subflow
1003 run_tests $ns1 $ns2 10.0.1.1
1004 chk_join_nr "single subflow v6-map-v4" 1 1 1
1006 # signal address v6-map-v4
1008 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
1009 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
1010 ip netns exec $ns1 ./pm_nl_ctl add "::ffff:10.0.2.1" flags signal
1011 run_tests $ns1 $ns2 10.0.1.1
1012 chk_join_nr "signal address v6-map-v4" 1 1 1
1015 # no subflow IPv6 to v4 address
1017 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
1018 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
1019 ip netns exec $ns2 ./pm_nl_ctl add dead:beef:2::2 flags subflow
1020 run_tests $ns1 $ns2 10.0.1.1
1021 chk_join_nr "no JOIN with diff families v4-v6" 0 0 0
1023 # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end
1025 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
1026 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
1027 ip netns exec $ns2 ./pm_nl_ctl add dead:beef:2::10.0.3.2 flags subflow
1028 run_tests $ns1 $ns2 10.0.1.1
1029 chk_join_nr "no JOIN with diff families v4-v6-2" 0 0 0
1031 # no subflow IPv4 to v6 address, no need to slow down too then
1033 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
1034 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
1035 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
1036 run_tests $ns1 $ns2 dead:beef:1::1
1037 chk_join_nr "no JOIN with diff families v6-v4" 0 0 0
1042 # single subflow, backup
1044 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
1045 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
1046 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow,backup
1047 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup
1048 chk_join_nr "single subflow, backup" 1 1 1
1051 # single address, backup
1053 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
1054 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
1055 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
1056 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup
1057 chk_join_nr "single address, backup" 1 1 1
1062 add_addr_ports_tests()
1064 # signal address with port
1066 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
1067 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
1068 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100
1069 run_tests $ns1 $ns2 10.0.1.1
1070 chk_join_nr "signal address with port" 1 1 1
1073 # subflow and signal with port
1075 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100
1076 ip netns exec $ns1 ./pm_nl_ctl limits 0 2
1077 ip netns exec $ns2 ./pm_nl_ctl limits 1 2
1078 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
1079 run_tests $ns1 $ns2 10.0.1.1
1080 chk_join_nr "subflow and signal with port" 2 2 2
1083 # single address with port, remove
1085 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
1086 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100
1087 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
1088 run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow
1089 chk_join_nr "remove single address with port" 1 1 1
1093 # subflow and signal with port, remove
1095 ip netns exec $ns1 ./pm_nl_ctl limits 0 2
1096 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100
1097 ip netns exec $ns2 ./pm_nl_ctl limits 1 2
1098 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
1099 run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow
1100 chk_join_nr "remove subflow and signal with port" 2 2 2
1104 # subflows and signal with port, flush
1106 ip netns exec $ns1 ./pm_nl_ctl limits 0 3
1107 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100
1108 ip netns exec $ns2 ./pm_nl_ctl limits 1 3
1109 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
1110 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
1111 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow
1112 chk_join_nr "flush subflows and signal with port" 3 3 3
1116 # multiple addresses with port
1118 ip netns exec $ns1 ./pm_nl_ctl limits 2 2
1119 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100
1120 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal port 10100
1121 ip netns exec $ns2 ./pm_nl_ctl limits 2 2
1122 run_tests $ns1 $ns2 10.0.1.1
1123 chk_join_nr "multiple addresses with port" 2 2 2
1126 # multiple addresses with ports
1128 ip netns exec $ns1 ./pm_nl_ctl limits 2 2
1129 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100
1130 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal port 10101
1131 ip netns exec $ns2 ./pm_nl_ctl limits 2 2
1132 run_tests $ns1 $ns2 10.0.1.1
1133 chk_join_nr "multiple addresses with ports" 2 2 2
1139 # single subflow, syncookies
1141 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
1142 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
1143 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
1144 run_tests $ns1 $ns2 10.0.1.1
1145 chk_join_nr "single subflow with syn cookies" 1 1 1
1147 # multiple subflows with syn cookies
1149 ip netns exec $ns1 ./pm_nl_ctl limits 0 2
1150 ip netns exec $ns2 ./pm_nl_ctl limits 0 2
1151 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
1152 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow
1153 run_tests $ns1 $ns2 10.0.1.1
1154 chk_join_nr "multiple subflows with syn cookies" 2 2 2
1156 # multiple subflows limited by server
1158 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
1159 ip netns exec $ns2 ./pm_nl_ctl limits 0 2
1160 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
1161 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow
1162 run_tests $ns1 $ns2 10.0.1.1
1163 chk_join_nr "subflows limited by server w cookies" 2 2 1
1165 # test signal address with cookies
1167 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
1168 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
1169 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
1170 run_tests $ns1 $ns2 10.0.1.1
1171 chk_join_nr "signal address with syn cookies" 1 1 1
1174 # test cookie with subflow and signal
1176 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
1177 ip netns exec $ns1 ./pm_nl_ctl limits 0 2
1178 ip netns exec $ns2 ./pm_nl_ctl limits 1 2
1179 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
1180 run_tests $ns1 $ns2 10.0.1.1
1181 chk_join_nr "subflow and signal w cookies" 2 2 2
1184 # accept and use add_addr with additional subflows
1186 ip netns exec $ns1 ./pm_nl_ctl limits 0 3
1187 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
1188 ip netns exec $ns2 ./pm_nl_ctl limits 1 3
1189 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
1190 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
1191 run_tests $ns1 $ns2 10.0.1.1
1192 chk_join_nr "subflows and signal w. cookies" 3 3 3
1199 signal_address_tests
1201 add_addr_timeout_tests
1207 add_addr_ports_tests
1213 echo "mptcp_join usage:"
1214 echo " -f subflows_tests"
1215 echo " -s signal_address_tests"
1216 echo " -l link_failure_tests"
1217 echo " -t add_addr_timeout_tests"
1218 echo " -r remove_tests"
1219 echo " -a add_tests"
1220 echo " -6 ipv6_tests"
1221 echo " -4 v4mapped_tests"
1222 echo " -b backup_tests"
1223 echo " -p add_addr_ports_tests"
1224 echo " -c syncookies_tests"
1234 make_file "$cin" "client" 1
1235 make_file "$sin" "server" 1
1243 while getopts 'fsltra64bpch' opt; do
1249 signal_address_tests
1255 add_addr_timeout_tests
1273 add_addr_ports_tests