1b08fbf24SPaolo Abeni#!/bin/bash 2b08fbf24SPaolo Abeni# SPDX-License-Identifier: GPL-2.0 3b08fbf24SPaolo Abeni 4b08fbf24SPaolo Abeniret=0 5b08fbf24SPaolo Abenisin="" 67d1e6f16SPaolo Abenisinfail="" 7b08fbf24SPaolo Abenisout="" 8b08fbf24SPaolo Abenicin="" 97d1e6f16SPaolo Abenicinfail="" 108b819a84SFlorian Westphalcinsent="" 11b08fbf24SPaolo Abenicout="" 12b08fbf24SPaolo Abeniksft_skip=4 135888a61cSMatthieu Baertstimeout_poll=30 145888a61cSMatthieu Baertstimeout_test=$((timeout_poll * 2 + 1)) 15dd72b0feSGeliang Tangmptcp_connect="" 16b08fbf24SPaolo Abenicapture=0 17af66d3e1SGeliang Tangchecksum=0 1834aa6e3bSGeliang Tangip_mptcp=0 19a673321aSMat Martineaudo_all_tests=1 20b08fbf24SPaolo Abeni 21b08fbf24SPaolo AbeniTEST_COUNT=0 22b08fbf24SPaolo Abeni 238d014eaaSGeliang Tang# generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) || 248d014eaaSGeliang Tang# (ip6 && (ip6[74] & 0xf0) == 0x30)'" 258d014eaaSGeliang TangCBPF_MPTCP_SUBOPTION_ADD_ADDR="14, 268d014eaaSGeliang Tang 48 0 0 0, 278d014eaaSGeliang Tang 84 0 0 240, 288d014eaaSGeliang Tang 21 0 3 64, 298d014eaaSGeliang Tang 48 0 0 54, 308d014eaaSGeliang Tang 84 0 0 240, 318d014eaaSGeliang Tang 21 6 7 48, 328d014eaaSGeliang Tang 48 0 0 0, 338d014eaaSGeliang Tang 84 0 0 240, 348d014eaaSGeliang Tang 21 0 4 96, 358d014eaaSGeliang Tang 48 0 0 74, 368d014eaaSGeliang Tang 84 0 0 240, 378d014eaaSGeliang Tang 21 0 1 48, 388d014eaaSGeliang Tang 6 0 0 65535, 398d014eaaSGeliang Tang 6 0 0 0" 408d014eaaSGeliang Tang 41b08fbf24SPaolo Abeniinit() 42b08fbf24SPaolo Abeni{ 43b08fbf24SPaolo Abeni capout=$(mktemp) 44b08fbf24SPaolo Abeni 45*0a40e273SMatthieu Baerts rndh=$(mktemp -u XXXXXX) 46b08fbf24SPaolo Abeni 47b08fbf24SPaolo Abeni ns1="ns1-$rndh" 48b08fbf24SPaolo Abeni ns2="ns2-$rndh" 49b08fbf24SPaolo Abeni 50b08fbf24SPaolo Abeni for netns in "$ns1" "$ns2";do 51b08fbf24SPaolo Abeni ip netns add $netns || exit $ksft_skip 52b08fbf24SPaolo Abeni ip -net $netns link set lo up 53b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.mptcp.enabled=1 54b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 55b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 56af66d3e1SGeliang Tang if [ $checksum -eq 1 ]; then 57af66d3e1SGeliang Tang ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1 58af66d3e1SGeliang Tang fi 59b08fbf24SPaolo Abeni done 60b08fbf24SPaolo Abeni 61b08fbf24SPaolo Abeni # ns1 ns2 62b08fbf24SPaolo Abeni # ns1eth1 ns2eth1 63b08fbf24SPaolo Abeni # ns1eth2 ns2eth2 64b08fbf24SPaolo Abeni # ns1eth3 ns2eth3 65b08fbf24SPaolo Abeni # ns1eth4 ns2eth4 66b08fbf24SPaolo Abeni 67b08fbf24SPaolo Abeni for i in `seq 1 4`; do 68b08fbf24SPaolo Abeni ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2" 69b08fbf24SPaolo Abeni ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i 70b08fbf24SPaolo Abeni ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad 71b08fbf24SPaolo Abeni ip -net "$ns1" link set ns1eth$i up 72b08fbf24SPaolo Abeni 73b08fbf24SPaolo Abeni ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i 74b08fbf24SPaolo Abeni ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad 75b08fbf24SPaolo Abeni ip -net "$ns2" link set ns2eth$i up 76b08fbf24SPaolo Abeni 77b08fbf24SPaolo Abeni # let $ns2 reach any $ns1 address from any interface 78b08fbf24SPaolo Abeni ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i 799846921dSPaolo Abeni ip -net "$ns2" route add default via dead:beef:$i::1 dev ns2eth$i metric 10$i 80b08fbf24SPaolo Abeni done 81b08fbf24SPaolo Abeni} 82b08fbf24SPaolo Abeni 837d1e6f16SPaolo Abeniinit_shapers() 847d1e6f16SPaolo Abeni{ 857d1e6f16SPaolo Abeni for i in `seq 1 4`; do 867d1e6f16SPaolo Abeni tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1 877d1e6f16SPaolo Abeni tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1 887d1e6f16SPaolo Abeni done 897d1e6f16SPaolo Abeni} 907d1e6f16SPaolo Abeni 91b08fbf24SPaolo Abenicleanup_partial() 92b08fbf24SPaolo Abeni{ 93b08fbf24SPaolo Abeni rm -f "$capout" 94b08fbf24SPaolo Abeni 95b08fbf24SPaolo Abeni for netns in "$ns1" "$ns2"; do 96b08fbf24SPaolo Abeni ip netns del $netns 97c2a55e8fSMatthieu Baerts rm -f /tmp/$netns.{nstat,out} 98b08fbf24SPaolo Abeni done 99b08fbf24SPaolo Abeni} 100b08fbf24SPaolo Abeni 101b08fbf24SPaolo Abenicleanup() 102b08fbf24SPaolo Abeni{ 1037d1e6f16SPaolo Abeni rm -f "$cin" "$cout" "$sinfail" 1047d1e6f16SPaolo Abeni rm -f "$sin" "$sout" "$cinsent" "$cinfail" 105b08fbf24SPaolo Abeni cleanup_partial 106b08fbf24SPaolo Abeni} 107b08fbf24SPaolo Abeni 108b08fbf24SPaolo Abenireset() 109b08fbf24SPaolo Abeni{ 110b08fbf24SPaolo Abeni cleanup_partial 111b08fbf24SPaolo Abeni init 112b08fbf24SPaolo Abeni} 113b08fbf24SPaolo Abeni 11400587187SFlorian Westphalreset_with_cookies() 11500587187SFlorian Westphal{ 11600587187SFlorian Westphal reset 11700587187SFlorian Westphal 11800587187SFlorian Westphal for netns in "$ns1" "$ns2";do 11900587187SFlorian Westphal ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2 12000587187SFlorian Westphal done 12100587187SFlorian Westphal} 12200587187SFlorian Westphal 1238d014eaaSGeliang Tangreset_with_add_addr_timeout() 1248d014eaaSGeliang Tang{ 1258d014eaaSGeliang Tang local ip="${1:-4}" 1268d014eaaSGeliang Tang local tables 1278d014eaaSGeliang Tang 1288d014eaaSGeliang Tang tables="iptables" 1298d014eaaSGeliang Tang if [ $ip -eq 6 ]; then 1308d014eaaSGeliang Tang tables="ip6tables" 1318d014eaaSGeliang Tang fi 1328d014eaaSGeliang Tang 1338d014eaaSGeliang Tang reset 1348d014eaaSGeliang Tang 1358d014eaaSGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 1368d014eaaSGeliang Tang ip netns exec $ns2 $tables -A OUTPUT -p tcp \ 1378d014eaaSGeliang Tang -m tcp --tcp-option 30 \ 1388d014eaaSGeliang Tang -m bpf --bytecode \ 1398d014eaaSGeliang Tang "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \ 1408d014eaaSGeliang Tang -j DROP 1418d014eaaSGeliang Tang} 1428d014eaaSGeliang Tang 143af66d3e1SGeliang Tangreset_with_checksum() 144af66d3e1SGeliang Tang{ 145af66d3e1SGeliang Tang local ns1_enable=$1 146af66d3e1SGeliang Tang local ns2_enable=$2 147af66d3e1SGeliang Tang 148af66d3e1SGeliang Tang reset 149af66d3e1SGeliang Tang 150af66d3e1SGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=$ns1_enable 151af66d3e1SGeliang Tang ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=$ns2_enable 152af66d3e1SGeliang Tang} 153af66d3e1SGeliang Tang 1540cddb4a6SGeliang Tangreset_with_allow_join_id0() 1550cddb4a6SGeliang Tang{ 1560cddb4a6SGeliang Tang local ns1_enable=$1 1570cddb4a6SGeliang Tang local ns2_enable=$2 1580cddb4a6SGeliang Tang 1590cddb4a6SGeliang Tang reset 1600cddb4a6SGeliang Tang 1610cddb4a6SGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns1_enable 1620cddb4a6SGeliang Tang ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable 1630cddb4a6SGeliang Tang} 1640cddb4a6SGeliang Tang 165b08fbf24SPaolo Abeniip -Version > /dev/null 2>&1 166b08fbf24SPaolo Abeniif [ $? -ne 0 ];then 167b08fbf24SPaolo Abeni echo "SKIP: Could not run test without ip tool" 168b08fbf24SPaolo Abeni exit $ksft_skip 169b08fbf24SPaolo Abenifi 170b08fbf24SPaolo Abeni 1718d014eaaSGeliang Tangiptables -V > /dev/null 2>&1 1728d014eaaSGeliang Tangif [ $? -ne 0 ];then 1738d014eaaSGeliang Tang echo "SKIP: Could not run all tests without iptables tool" 1748d014eaaSGeliang Tang exit $ksft_skip 1758d014eaaSGeliang Tangfi 1768d014eaaSGeliang Tang 1778d014eaaSGeliang Tangip6tables -V > /dev/null 2>&1 1788d014eaaSGeliang Tangif [ $? -ne 0 ];then 1798d014eaaSGeliang Tang echo "SKIP: Could not run all tests without ip6tables tool" 1808d014eaaSGeliang Tang exit $ksft_skip 1818d014eaaSGeliang Tangfi 182b08fbf24SPaolo Abeni 1838b819a84SFlorian Westphalprint_file_err() 1848b819a84SFlorian Westphal{ 1858b819a84SFlorian Westphal ls -l "$1" 1>&2 1868b819a84SFlorian Westphal echo "Trailing bytes are: " 1878b819a84SFlorian Westphal tail -c 27 "$1" 1888b819a84SFlorian Westphal} 1898b819a84SFlorian Westphal 190b08fbf24SPaolo Abenicheck_transfer() 191b08fbf24SPaolo Abeni{ 192b08fbf24SPaolo Abeni in=$1 193b08fbf24SPaolo Abeni out=$2 194b08fbf24SPaolo Abeni what=$3 195b08fbf24SPaolo Abeni 196b08fbf24SPaolo Abeni cmp "$in" "$out" > /dev/null 2>&1 197b08fbf24SPaolo Abeni if [ $? -ne 0 ] ;then 198b08fbf24SPaolo Abeni echo "[ FAIL ] $what does not match (in, out):" 199b08fbf24SPaolo Abeni print_file_err "$in" 200b08fbf24SPaolo Abeni print_file_err "$out" 2018b819a84SFlorian Westphal ret=1 202b08fbf24SPaolo Abeni 203b08fbf24SPaolo Abeni return 1 204b08fbf24SPaolo Abeni fi 205b08fbf24SPaolo Abeni 206b08fbf24SPaolo Abeni return 0 207b08fbf24SPaolo Abeni} 208b08fbf24SPaolo Abeni 209b08fbf24SPaolo Abenido_ping() 210b08fbf24SPaolo Abeni{ 211b08fbf24SPaolo Abeni listener_ns="$1" 212b08fbf24SPaolo Abeni connector_ns="$2" 213b08fbf24SPaolo Abeni connect_addr="$3" 214b08fbf24SPaolo Abeni 215b08fbf24SPaolo Abeni ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null 216b08fbf24SPaolo Abeni if [ $? -ne 0 ] ; then 217b08fbf24SPaolo Abeni echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2 218b08fbf24SPaolo Abeni ret=1 219b08fbf24SPaolo Abeni fi 220b08fbf24SPaolo Abeni} 221b08fbf24SPaolo Abeni 2228b819a84SFlorian Westphallink_failure() 2238b819a84SFlorian Westphal{ 2248b819a84SFlorian Westphal ns="$1" 2258b819a84SFlorian Westphal 2267d1e6f16SPaolo Abeni if [ -z "$FAILING_LINKS" ]; then 2278b819a84SFlorian Westphal l=$((RANDOM%4)) 2287d1e6f16SPaolo Abeni FAILING_LINKS=$((l+1)) 2297d1e6f16SPaolo Abeni fi 2308b819a84SFlorian Westphal 2317d1e6f16SPaolo Abeni for l in $FAILING_LINKS; do 2328b819a84SFlorian Westphal veth="ns1eth$l" 2338b819a84SFlorian Westphal ip -net "$ns" link set "$veth" down 2347d1e6f16SPaolo Abeni done 2358b819a84SFlorian Westphal} 2368b819a84SFlorian Westphal 237523514edSGeliang Tang# $1: IP address 238523514edSGeliang Tangis_v6() 239523514edSGeliang Tang{ 240523514edSGeliang Tang [ -z "${1##*:*}" ] 241523514edSGeliang Tang} 242523514edSGeliang Tang 243327b9a94SPaolo Abeni# $1: ns, $2: port 244327b9a94SPaolo Abeniwait_local_port_listen() 245327b9a94SPaolo Abeni{ 246327b9a94SPaolo Abeni local listener_ns="${1}" 247327b9a94SPaolo Abeni local port="${2}" 248327b9a94SPaolo Abeni 249327b9a94SPaolo Abeni local port_hex i 250327b9a94SPaolo Abeni 251327b9a94SPaolo Abeni port_hex="$(printf "%04X" "${port}")" 252327b9a94SPaolo Abeni for i in $(seq 10); do 253327b9a94SPaolo Abeni ip netns exec "${listener_ns}" cat /proc/net/tcp* | \ 254327b9a94SPaolo Abeni awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" && 255327b9a94SPaolo Abeni break 256327b9a94SPaolo Abeni sleep 0.1 257327b9a94SPaolo Abeni done 258327b9a94SPaolo Abeni} 259327b9a94SPaolo Abeni 260327b9a94SPaolo Abenirm_addr_count() 261327b9a94SPaolo Abeni{ 262327b9a94SPaolo Abeni ns=${1} 263327b9a94SPaolo Abeni 264327b9a94SPaolo Abeni ip netns exec ${ns} nstat -as | grep MPTcpExtRmAddr | awk '{print $2}' 265327b9a94SPaolo Abeni} 266327b9a94SPaolo Abeni 267327b9a94SPaolo Abeni# $1: ns, $2: old rm_addr counter in $ns 268327b9a94SPaolo Abeniwait_rm_addr() 269327b9a94SPaolo Abeni{ 270327b9a94SPaolo Abeni local ns="${1}" 271327b9a94SPaolo Abeni local old_cnt="${2}" 272327b9a94SPaolo Abeni local cnt 273327b9a94SPaolo Abeni local i 274327b9a94SPaolo Abeni 275327b9a94SPaolo Abeni for i in $(seq 10); do 276327b9a94SPaolo Abeni cnt=$(rm_addr_count ${ns}) 277327b9a94SPaolo Abeni [ "$cnt" = "${old_cnt}" ] || break 278327b9a94SPaolo Abeni sleep 0.1 279327b9a94SPaolo Abeni done 280327b9a94SPaolo Abeni} 281327b9a94SPaolo Abeni 28234aa6e3bSGeliang Tangpm_nl_set_limits() 28334aa6e3bSGeliang Tang{ 28434aa6e3bSGeliang Tang local ns=$1 28534aa6e3bSGeliang Tang local addrs=$2 28634aa6e3bSGeliang Tang local subflows=$3 28734aa6e3bSGeliang Tang 28834aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 28934aa6e3bSGeliang Tang ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows 29034aa6e3bSGeliang Tang else 29134aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows 29234aa6e3bSGeliang Tang fi 29334aa6e3bSGeliang Tang} 29434aa6e3bSGeliang Tang 29534aa6e3bSGeliang Tangpm_nl_add_endpoint() 29634aa6e3bSGeliang Tang{ 29734aa6e3bSGeliang Tang local ns=$1 29834aa6e3bSGeliang Tang local addr=$2 29934aa6e3bSGeliang Tang local flags 30034aa6e3bSGeliang Tang local port 30134aa6e3bSGeliang Tang local dev 30234aa6e3bSGeliang Tang local id 30334aa6e3bSGeliang Tang local nr=2 30434aa6e3bSGeliang Tang 30534aa6e3bSGeliang Tang for p in $@ 30634aa6e3bSGeliang Tang do 30734aa6e3bSGeliang Tang if [ $p = "flags" ]; then 30834aa6e3bSGeliang Tang eval _flags=\$"$nr" 30934aa6e3bSGeliang Tang [ ! -z $_flags ]; flags="flags $_flags" 31034aa6e3bSGeliang Tang fi 31134aa6e3bSGeliang Tang if [ $p = "dev" ]; then 31234aa6e3bSGeliang Tang eval _dev=\$"$nr" 31334aa6e3bSGeliang Tang [ ! -z $_dev ]; dev="dev $_dev" 31434aa6e3bSGeliang Tang fi 31534aa6e3bSGeliang Tang if [ $p = "id" ]; then 31634aa6e3bSGeliang Tang eval _id=\$"$nr" 31734aa6e3bSGeliang Tang [ ! -z $_id ]; id="id $_id" 31834aa6e3bSGeliang Tang fi 31934aa6e3bSGeliang Tang if [ $p = "port" ]; then 32034aa6e3bSGeliang Tang eval _port=\$"$nr" 32134aa6e3bSGeliang Tang [ ! -z $_port ]; port="port $_port" 32234aa6e3bSGeliang Tang fi 32334aa6e3bSGeliang Tang 32434aa6e3bSGeliang Tang let nr+=1 32534aa6e3bSGeliang Tang done 32634aa6e3bSGeliang Tang 32734aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 32834aa6e3bSGeliang Tang ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port 32934aa6e3bSGeliang Tang else 33034aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port 33134aa6e3bSGeliang Tang fi 33234aa6e3bSGeliang Tang} 33334aa6e3bSGeliang Tang 33434aa6e3bSGeliang Tangpm_nl_del_endpoint() 33534aa6e3bSGeliang Tang{ 33634aa6e3bSGeliang Tang local ns=$1 33734aa6e3bSGeliang Tang local id=$2 33834aa6e3bSGeliang Tang local addr=$3 33934aa6e3bSGeliang Tang 34034aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 34134aa6e3bSGeliang Tang ip -n $ns mptcp endpoint delete id $id $addr 34234aa6e3bSGeliang Tang else 34334aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl del $id $addr 34434aa6e3bSGeliang Tang fi 34534aa6e3bSGeliang Tang} 34634aa6e3bSGeliang Tang 34734aa6e3bSGeliang Tangpm_nl_flush_endpoint() 34834aa6e3bSGeliang Tang{ 34934aa6e3bSGeliang Tang local ns=$1 35034aa6e3bSGeliang Tang 35134aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 35234aa6e3bSGeliang Tang ip -n $ns mptcp endpoint flush 35334aa6e3bSGeliang Tang else 35434aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl flush 35534aa6e3bSGeliang Tang fi 35634aa6e3bSGeliang Tang} 35734aa6e3bSGeliang Tang 358dda61b3dSGeliang Tangpm_nl_show_endpoints() 359dda61b3dSGeliang Tang{ 360dda61b3dSGeliang Tang local ns=$1 361dda61b3dSGeliang Tang 362dda61b3dSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 363dda61b3dSGeliang Tang ip -n $ns mptcp endpoint show 364dda61b3dSGeliang Tang else 365dda61b3dSGeliang Tang ip netns exec $ns ./pm_nl_ctl dump 366dda61b3dSGeliang Tang fi 367dda61b3dSGeliang Tang} 368dda61b3dSGeliang Tang 369f0140386SGeliang Tangpm_nl_change_endpoint() 370f0140386SGeliang Tang{ 371f0140386SGeliang Tang local ns=$1 372bccefb76SGeliang Tang local id=$2 373bccefb76SGeliang Tang local flags=$3 374f0140386SGeliang Tang 375f0140386SGeliang Tang if [ $ip_mptcp -eq 1 ]; then 376f0140386SGeliang Tang ip -n $ns mptcp endpoint change id $id ${flags//","/" "} 377f0140386SGeliang Tang else 378bccefb76SGeliang Tang ip netns exec $ns ./pm_nl_ctl set id $id flags $flags 379f0140386SGeliang Tang fi 380f0140386SGeliang Tang} 381f0140386SGeliang Tang 382b08fbf24SPaolo Abenido_transfer() 383b08fbf24SPaolo Abeni{ 384b08fbf24SPaolo Abeni listener_ns="$1" 385b08fbf24SPaolo Abeni connector_ns="$2" 386b08fbf24SPaolo Abeni cl_proto="$3" 387b08fbf24SPaolo Abeni srv_proto="$4" 388b08fbf24SPaolo Abeni connect_addr="$5" 3898b819a84SFlorian Westphal test_link_fail="$6" 3902e8cbf45SGeliang Tang addr_nr_ns1="$7" 3912e8cbf45SGeliang Tang addr_nr_ns2="$8" 3928b819a84SFlorian Westphal speed="$9" 3936a0653b9SGeliang Tang sflags="${10}" 394b08fbf24SPaolo Abeni 395b08fbf24SPaolo Abeni port=$((10000+$TEST_COUNT)) 396b08fbf24SPaolo Abeni TEST_COUNT=$((TEST_COUNT+1)) 397b08fbf24SPaolo Abeni 398b08fbf24SPaolo Abeni :> "$cout" 399b08fbf24SPaolo Abeni :> "$sout" 400b08fbf24SPaolo Abeni :> "$capout" 401b08fbf24SPaolo Abeni 402b08fbf24SPaolo Abeni if [ $capture -eq 1 ]; then 403b08fbf24SPaolo Abeni if [ -z $SUDO_USER ] ; then 404b08fbf24SPaolo Abeni capuser="" 405b08fbf24SPaolo Abeni else 406b08fbf24SPaolo Abeni capuser="-Z $SUDO_USER" 407b08fbf24SPaolo Abeni fi 408b08fbf24SPaolo Abeni 40900587187SFlorian Westphal capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}") 410b08fbf24SPaolo Abeni 411b08fbf24SPaolo Abeni echo "Capturing traffic for test $TEST_COUNT into $capfile" 412b08fbf24SPaolo Abeni ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & 413b08fbf24SPaolo Abeni cappid=$! 414b08fbf24SPaolo Abeni 415b08fbf24SPaolo Abeni sleep 1 416b08fbf24SPaolo Abeni fi 417b08fbf24SPaolo Abeni 418c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 419c2a55e8fSMatthieu Baerts nstat -n 420c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 421c2a55e8fSMatthieu Baerts nstat -n 422c2a55e8fSMatthieu Baerts 4238d014eaaSGeliang Tang if [ $speed = "fast" ]; then 424dd72b0feSGeliang Tang mptcp_connect="./mptcp_connect -j" 4258da6229bSGeliang Tang elif [ $speed = "slow" ]; then 4268da6229bSGeliang Tang mptcp_connect="./mptcp_connect -r 50" 4278da6229bSGeliang Tang elif [ $speed = "least" ]; then 4288da6229bSGeliang Tang mptcp_connect="./mptcp_connect -r 10" 429dd72b0feSGeliang Tang fi 430dd72b0feSGeliang Tang 431523514edSGeliang Tang local local_addr 432523514edSGeliang Tang if is_v6 "${connect_addr}"; then 433523514edSGeliang Tang local_addr="::" 434523514edSGeliang Tang else 435523514edSGeliang Tang local_addr="0.0.0.0" 436523514edSGeliang Tang fi 437523514edSGeliang Tang 4387d1e6f16SPaolo Abeni if [ "$test_link_fail" -eq 2 ];then 4397d1e6f16SPaolo Abeni timeout ${timeout_test} \ 4407d1e6f16SPaolo Abeni ip netns exec ${listener_ns} \ 4417c909a98SGeliang Tang $mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 4427d1e6f16SPaolo Abeni ${local_addr} < "$sinfail" > "$sout" & 4437d1e6f16SPaolo Abeni else 4445888a61cSMatthieu Baerts timeout ${timeout_test} \ 4455888a61cSMatthieu Baerts ip netns exec ${listener_ns} \ 4465888a61cSMatthieu Baerts $mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 4475888a61cSMatthieu Baerts ${local_addr} < "$sin" > "$sout" & 4487d1e6f16SPaolo Abeni fi 449b08fbf24SPaolo Abeni spid=$! 450b08fbf24SPaolo Abeni 451327b9a94SPaolo Abeni wait_local_port_listen "${listener_ns}" "${port}" 452b08fbf24SPaolo Abeni 4538b819a84SFlorian Westphal if [ "$test_link_fail" -eq 0 ];then 4545888a61cSMatthieu Baerts timeout ${timeout_test} \ 4555888a61cSMatthieu Baerts ip netns exec ${connector_ns} \ 4565888a61cSMatthieu Baerts $mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 4575888a61cSMatthieu Baerts $connect_addr < "$cin" > "$cout" & 4588b819a84SFlorian Westphal else 4597d1e6f16SPaolo Abeni ( cat "$cinfail" ; sleep 2; link_failure $listener_ns ; cat "$cinfail" ) | \ 4605888a61cSMatthieu Baerts tee "$cinsent" | \ 4615888a61cSMatthieu Baerts timeout ${timeout_test} \ 4625888a61cSMatthieu Baerts ip netns exec ${connector_ns} \ 4635888a61cSMatthieu Baerts $mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 4645888a61cSMatthieu Baerts $connect_addr > "$cout" & 4658b819a84SFlorian Westphal fi 466b08fbf24SPaolo Abeni cpid=$! 467b08fbf24SPaolo Abeni 468327b9a94SPaolo Abeni # let the mptcp subflow be established in background before 469327b9a94SPaolo Abeni # do endpoint manipulation 470327b9a94SPaolo Abeni [ $addr_nr_ns1 = "0" -a $addr_nr_ns2 = "0" ] || sleep 1 471327b9a94SPaolo Abeni 4726208fd82SGeliang Tang if [ $addr_nr_ns1 -gt 0 ]; then 4736208fd82SGeliang Tang let add_nr_ns1=addr_nr_ns1 4746208fd82SGeliang Tang counter=2 4756208fd82SGeliang Tang while [ $add_nr_ns1 -gt 0 ]; do 4766208fd82SGeliang Tang local addr 4776208fd82SGeliang Tang if is_v6 "${connect_addr}"; then 4786208fd82SGeliang Tang addr="dead:beef:$counter::1" 4796208fd82SGeliang Tang else 4806208fd82SGeliang Tang addr="10.0.$counter.1" 4816208fd82SGeliang Tang fi 48234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 $addr flags signal 4836208fd82SGeliang Tang let counter+=1 4846208fd82SGeliang Tang let add_nr_ns1-=1 4856208fd82SGeliang Tang done 4866208fd82SGeliang Tang elif [ $addr_nr_ns1 -lt 0 ]; then 4872e8cbf45SGeliang Tang let rm_nr_ns1=-addr_nr_ns1 4886fe4ccdcSGeliang Tang if [ $rm_nr_ns1 -lt 8 ]; then 489dda61b3dSGeliang Tang counter=0 490dda61b3dSGeliang Tang pm_nl_show_endpoints ${listener_ns} | while read line; do 491dda61b3dSGeliang Tang local arr=($line) 492dda61b3dSGeliang Tang local nr=0 493dda61b3dSGeliang Tang 494dda61b3dSGeliang Tang for i in ${arr[@]}; do 495dda61b3dSGeliang Tang if [ $i = "id" ]; then 496dda61b3dSGeliang Tang if [ $counter -eq $rm_nr_ns1 ]; then 497dda61b3dSGeliang Tang break 498dda61b3dSGeliang Tang fi 499dda61b3dSGeliang Tang id=${arr[$nr+1]} 500327b9a94SPaolo Abeni rm_addr=$(rm_addr_count ${connector_ns}) 50134aa6e3bSGeliang Tang pm_nl_del_endpoint ${listener_ns} $id 502327b9a94SPaolo Abeni wait_rm_addr ${connector_ns} ${rm_addr} 503dd72b0feSGeliang Tang let counter+=1 504f87744adSGeliang Tang fi 505dda61b3dSGeliang Tang let nr+=1 506dda61b3dSGeliang Tang done 507dda61b3dSGeliang Tang done 5085e287fe7SGeliang Tang elif [ $rm_nr_ns1 -eq 8 ]; then 50934aa6e3bSGeliang Tang pm_nl_flush_endpoint ${listener_ns} 5105e287fe7SGeliang Tang elif [ $rm_nr_ns1 -eq 9 ]; then 51134aa6e3bSGeliang Tang pm_nl_del_endpoint ${listener_ns} 0 ${connect_addr} 5126fe4ccdcSGeliang Tang fi 513dd72b0feSGeliang Tang fi 514dd72b0feSGeliang Tang 5154f49d633SGeliang Tang flags="subflow" 5164f49d633SGeliang Tang if [[ "${addr_nr_ns2}" = "fullmesh_"* ]]; then 5174f49d633SGeliang Tang flags="${flags},fullmesh" 5184f49d633SGeliang Tang addr_nr_ns2=${addr_nr_ns2:9} 5194f49d633SGeliang Tang fi 5204f49d633SGeliang Tang 521327b9a94SPaolo Abeni # if newly added endpoints must be deleted, give the background msk 522327b9a94SPaolo Abeni # some time to created them 523327b9a94SPaolo Abeni [ $addr_nr_ns1 -gt 0 -a $addr_nr_ns2 -lt 0 ] && sleep 1 524327b9a94SPaolo Abeni 5256208fd82SGeliang Tang if [ $addr_nr_ns2 -gt 0 ]; then 5266208fd82SGeliang Tang let add_nr_ns2=addr_nr_ns2 5276208fd82SGeliang Tang counter=3 5286208fd82SGeliang Tang while [ $add_nr_ns2 -gt 0 ]; do 5296208fd82SGeliang Tang local addr 5306208fd82SGeliang Tang if is_v6 "${connect_addr}"; then 5316208fd82SGeliang Tang addr="dead:beef:$counter::2" 5326208fd82SGeliang Tang else 5336208fd82SGeliang Tang addr="10.0.$counter.2" 5346208fd82SGeliang Tang fi 53534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 $addr flags $flags 5366208fd82SGeliang Tang let counter+=1 5376208fd82SGeliang Tang let add_nr_ns2-=1 5386208fd82SGeliang Tang done 5396208fd82SGeliang Tang elif [ $addr_nr_ns2 -lt 0 ]; then 5402e8cbf45SGeliang Tang let rm_nr_ns2=-addr_nr_ns2 5416fe4ccdcSGeliang Tang if [ $rm_nr_ns2 -lt 8 ]; then 542dda61b3dSGeliang Tang counter=0 543dda61b3dSGeliang Tang pm_nl_show_endpoints ${connector_ns} | while read line; do 544dda61b3dSGeliang Tang local arr=($line) 545dda61b3dSGeliang Tang local nr=0 546dda61b3dSGeliang Tang 547dda61b3dSGeliang Tang for i in ${arr[@]}; do 548dda61b3dSGeliang Tang if [ $i = "id" ]; then 549dda61b3dSGeliang Tang if [ $counter -eq $rm_nr_ns2 ]; then 550dda61b3dSGeliang Tang break 551dda61b3dSGeliang Tang fi 552dda61b3dSGeliang Tang # rm_addr are serialized, allow the previous one to 553dda61b3dSGeliang Tang # complete 554dda61b3dSGeliang Tang id=${arr[$nr+1]} 555327b9a94SPaolo Abeni rm_addr=$(rm_addr_count ${listener_ns}) 55634aa6e3bSGeliang Tang pm_nl_del_endpoint ${connector_ns} $id 557327b9a94SPaolo Abeni wait_rm_addr ${listener_ns} ${rm_addr} 558dd72b0feSGeliang Tang let counter+=1 559f87744adSGeliang Tang fi 560dda61b3dSGeliang Tang let nr+=1 561dda61b3dSGeliang Tang done 562dda61b3dSGeliang Tang done 5635e287fe7SGeliang Tang elif [ $rm_nr_ns2 -eq 8 ]; then 56434aa6e3bSGeliang Tang pm_nl_flush_endpoint ${connector_ns} 5655e287fe7SGeliang Tang elif [ $rm_nr_ns2 -eq 9 ]; then 5665e287fe7SGeliang Tang local addr 5675e287fe7SGeliang Tang if is_v6 "${connect_addr}"; then 5685e287fe7SGeliang Tang addr="dead:beef:1::2" 5695e287fe7SGeliang Tang else 5705e287fe7SGeliang Tang addr="10.0.1.2" 5715e287fe7SGeliang Tang fi 57234aa6e3bSGeliang Tang pm_nl_del_endpoint ${connector_ns} 0 $addr 5736fe4ccdcSGeliang Tang fi 574dd72b0feSGeliang Tang fi 575dd72b0feSGeliang Tang 5766a0653b9SGeliang Tang if [ ! -z $sflags ]; then 577718eb44eSGeliang Tang sleep 1 578718eb44eSGeliang Tang for netns in "$ns1" "$ns2"; do 579dda61b3dSGeliang Tang pm_nl_show_endpoints $netns | while read line; do 58033397b83SGeliang Tang local arr=($line) 581bccefb76SGeliang Tang local nr=0 582f0140386SGeliang Tang local id 58333397b83SGeliang Tang 58433397b83SGeliang Tang for i in ${arr[@]}; do 585bccefb76SGeliang Tang if [ $i = "id" ]; then 586bccefb76SGeliang Tang id=${arr[$nr+1]} 587718eb44eSGeliang Tang fi 588bccefb76SGeliang Tang let nr+=1 58933397b83SGeliang Tang done 590bccefb76SGeliang Tang pm_nl_change_endpoint $netns $id $sflags 59133397b83SGeliang Tang done 592718eb44eSGeliang Tang done 593718eb44eSGeliang Tang fi 594718eb44eSGeliang Tang 595b08fbf24SPaolo Abeni wait $cpid 596b08fbf24SPaolo Abeni retc=$? 597b08fbf24SPaolo Abeni wait $spid 598b08fbf24SPaolo Abeni rets=$? 599b08fbf24SPaolo Abeni 600b08fbf24SPaolo Abeni if [ $capture -eq 1 ]; then 601b08fbf24SPaolo Abeni sleep 1 602b08fbf24SPaolo Abeni kill $cappid 603b08fbf24SPaolo Abeni fi 604b08fbf24SPaolo Abeni 605c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 606c2a55e8fSMatthieu Baerts nstat | grep Tcp > /tmp/${listener_ns}.out 607c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 608c2a55e8fSMatthieu Baerts nstat | grep Tcp > /tmp/${connector_ns}.out 609c2a55e8fSMatthieu Baerts 610b08fbf24SPaolo Abeni if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then 611b08fbf24SPaolo Abeni echo " client exit code $retc, server $rets" 1>&2 6128b974778SMatthieu Baerts echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 613c2a55e8fSMatthieu Baerts ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port" 614c2a55e8fSMatthieu Baerts cat /tmp/${listener_ns}.out 6158b974778SMatthieu Baerts echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2 616c2a55e8fSMatthieu Baerts ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port" 617c2a55e8fSMatthieu Baerts cat /tmp/${connector_ns}.out 618b08fbf24SPaolo Abeni 619b08fbf24SPaolo Abeni cat "$capout" 6208b819a84SFlorian Westphal ret=1 621b08fbf24SPaolo Abeni return 1 622b08fbf24SPaolo Abeni fi 623b08fbf24SPaolo Abeni 6247d1e6f16SPaolo Abeni if [ "$test_link_fail" -eq 2 ];then 6257d1e6f16SPaolo Abeni check_transfer $sinfail $cout "file received by client" 6267d1e6f16SPaolo Abeni else 627b08fbf24SPaolo Abeni check_transfer $sin $cout "file received by client" 6287d1e6f16SPaolo Abeni fi 629b08fbf24SPaolo Abeni retc=$? 6308b819a84SFlorian Westphal if [ "$test_link_fail" -eq 0 ];then 631b08fbf24SPaolo Abeni check_transfer $cin $sout "file received by server" 6328b819a84SFlorian Westphal else 6338b819a84SFlorian Westphal check_transfer $cinsent $sout "file received by server" 6348b819a84SFlorian Westphal fi 635b08fbf24SPaolo Abeni rets=$? 636b08fbf24SPaolo Abeni 637b08fbf24SPaolo Abeni if [ $retc -eq 0 ] && [ $rets -eq 0 ];then 638b08fbf24SPaolo Abeni cat "$capout" 639b08fbf24SPaolo Abeni return 0 640b08fbf24SPaolo Abeni fi 641b08fbf24SPaolo Abeni 642b08fbf24SPaolo Abeni cat "$capout" 643b08fbf24SPaolo Abeni return 1 644b08fbf24SPaolo Abeni} 645b08fbf24SPaolo Abeni 646b08fbf24SPaolo Abenimake_file() 647b08fbf24SPaolo Abeni{ 648b08fbf24SPaolo Abeni name=$1 649b08fbf24SPaolo Abeni who=$2 6508b819a84SFlorian Westphal size=$3 651b08fbf24SPaolo Abeni 6528b819a84SFlorian Westphal dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null 653b08fbf24SPaolo Abeni echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" 654b08fbf24SPaolo Abeni 6558b819a84SFlorian Westphal echo "Created $name (size $size KB) containing data sent by $who" 656b08fbf24SPaolo Abeni} 657b08fbf24SPaolo Abeni 658b08fbf24SPaolo Abenirun_tests() 659b08fbf24SPaolo Abeni{ 660b08fbf24SPaolo Abeni listener_ns="$1" 661b08fbf24SPaolo Abeni connector_ns="$2" 662b08fbf24SPaolo Abeni connect_addr="$3" 6638b819a84SFlorian Westphal test_linkfail="${4:-0}" 6642e8cbf45SGeliang Tang addr_nr_ns1="${5:-0}" 6652e8cbf45SGeliang Tang addr_nr_ns2="${6:-0}" 6668b819a84SFlorian Westphal speed="${7:-fast}" 6676a0653b9SGeliang Tang sflags="${8:-""}" 6688b819a84SFlorian Westphal 6697d1e6f16SPaolo Abeni # create the input file for the failure test when 6707d1e6f16SPaolo Abeni # the first failure test run 6717d1e6f16SPaolo Abeni if [ "$test_linkfail" -ne 0 -a -z "$cinfail" ]; then 6727d1e6f16SPaolo Abeni # the client file must be considerably larger 6737d1e6f16SPaolo Abeni # of the maximum expected cwin value, or the 6747d1e6f16SPaolo Abeni # link utilization will be not predicable 6757d1e6f16SPaolo Abeni size=$((RANDOM%2)) 6768b819a84SFlorian Westphal size=$((size+1)) 6777d1e6f16SPaolo Abeni size=$((size*8192)) 6787d1e6f16SPaolo Abeni size=$((size + ( $RANDOM % 8192) )) 6798b819a84SFlorian Westphal 6807d1e6f16SPaolo Abeni cinfail=$(mktemp) 6817d1e6f16SPaolo Abeni make_file "$cinfail" "client" $size 6827d1e6f16SPaolo Abeni fi 6837d1e6f16SPaolo Abeni 6847d1e6f16SPaolo Abeni if [ "$test_linkfail" -eq 2 -a -z "$sinfail" ]; then 6857d1e6f16SPaolo Abeni size=$((RANDOM%16)) 6867d1e6f16SPaolo Abeni size=$((size+1)) 6877d1e6f16SPaolo Abeni size=$((size*2048)) 6887d1e6f16SPaolo Abeni 6897d1e6f16SPaolo Abeni sinfail=$(mktemp) 6907d1e6f16SPaolo Abeni make_file "$sinfail" "server" $size 6918b819a84SFlorian Westphal fi 692b08fbf24SPaolo Abeni 6938d014eaaSGeliang Tang do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \ 6946a0653b9SGeliang Tang ${test_linkfail} ${addr_nr_ns1} ${addr_nr_ns2} ${speed} ${sflags} 695b08fbf24SPaolo Abeni} 696b08fbf24SPaolo Abeni 697327b9a94SPaolo Abenidump_stats() 698327b9a94SPaolo Abeni{ 699327b9a94SPaolo Abeni echo Server ns stats 700327b9a94SPaolo Abeni ip netns exec $ns1 nstat -as | grep Tcp 701327b9a94SPaolo Abeni echo Client ns stats 702327b9a94SPaolo Abeni ip netns exec $ns2 nstat -as | grep Tcp 703327b9a94SPaolo Abeni} 704327b9a94SPaolo Abeni 705af66d3e1SGeliang Tangchk_csum_nr() 706af66d3e1SGeliang Tang{ 707af66d3e1SGeliang Tang local msg=${1:-""} 708af66d3e1SGeliang Tang local count 709af66d3e1SGeliang Tang local dump_stats 710af66d3e1SGeliang Tang 711af66d3e1SGeliang Tang if [ ! -z "$msg" ]; then 712af66d3e1SGeliang Tang printf "%02u" "$TEST_COUNT" 713af66d3e1SGeliang Tang else 714af66d3e1SGeliang Tang echo -n " " 715af66d3e1SGeliang Tang fi 716af66d3e1SGeliang Tang printf " %-36s %s" "$msg" "sum" 717af66d3e1SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'` 718af66d3e1SGeliang Tang [ -z "$count" ] && count=0 719af66d3e1SGeliang Tang if [ "$count" != 0 ]; then 720af66d3e1SGeliang Tang echo "[fail] got $count data checksum error[s] expected 0" 721af66d3e1SGeliang Tang ret=1 722af66d3e1SGeliang Tang dump_stats=1 723af66d3e1SGeliang Tang else 724af66d3e1SGeliang Tang echo -n "[ ok ]" 725af66d3e1SGeliang Tang fi 726af66d3e1SGeliang Tang echo -n " - csum " 727af66d3e1SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'` 728af66d3e1SGeliang Tang [ -z "$count" ] && count=0 729af66d3e1SGeliang Tang if [ "$count" != 0 ]; then 730af66d3e1SGeliang Tang echo "[fail] got $count data checksum error[s] expected 0" 731af66d3e1SGeliang Tang ret=1 732af66d3e1SGeliang Tang dump_stats=1 733af66d3e1SGeliang Tang else 734af66d3e1SGeliang Tang echo "[ ok ]" 735af66d3e1SGeliang Tang fi 736327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 737af66d3e1SGeliang Tang} 738af66d3e1SGeliang Tang 7396bb3ab49SGeliang Tangchk_fail_nr() 7406bb3ab49SGeliang Tang{ 7416bb3ab49SGeliang Tang local mp_fail_nr_tx=$1 7426bb3ab49SGeliang Tang local mp_fail_nr_rx=$2 7436bb3ab49SGeliang Tang local count 7446bb3ab49SGeliang Tang local dump_stats 7456bb3ab49SGeliang Tang 7466bb3ab49SGeliang Tang printf "%-39s %s" " " "ftx" 7476bb3ab49SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPFailTx | awk '{print $2}'` 7486bb3ab49SGeliang Tang [ -z "$count" ] && count=0 7496bb3ab49SGeliang Tang if [ "$count" != "$mp_fail_nr_tx" ]; then 7506bb3ab49SGeliang Tang echo "[fail] got $count MP_FAIL[s] TX expected $mp_fail_nr_tx" 7516bb3ab49SGeliang Tang ret=1 7526bb3ab49SGeliang Tang dump_stats=1 7536bb3ab49SGeliang Tang else 7546bb3ab49SGeliang Tang echo -n "[ ok ]" 7556bb3ab49SGeliang Tang fi 7566bb3ab49SGeliang Tang 7576bb3ab49SGeliang Tang echo -n " - frx " 7586bb3ab49SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPFailRx | awk '{print $2}'` 7596bb3ab49SGeliang Tang [ -z "$count" ] && count=0 7606bb3ab49SGeliang Tang if [ "$count" != "$mp_fail_nr_rx" ]; then 7616bb3ab49SGeliang Tang echo "[fail] got $count MP_FAIL[s] RX expected $mp_fail_nr_rx" 7626bb3ab49SGeliang Tang ret=1 7636bb3ab49SGeliang Tang dump_stats=1 7646bb3ab49SGeliang Tang else 7656bb3ab49SGeliang Tang echo "[ ok ]" 7666bb3ab49SGeliang Tang fi 7676bb3ab49SGeliang Tang 768327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 7696bb3ab49SGeliang Tang} 7706bb3ab49SGeliang Tang 771b08fbf24SPaolo Abenichk_join_nr() 772b08fbf24SPaolo Abeni{ 773b08fbf24SPaolo Abeni local msg="$1" 774b08fbf24SPaolo Abeni local syn_nr=$2 775b08fbf24SPaolo Abeni local syn_ack_nr=$3 776b08fbf24SPaolo Abeni local ack_nr=$4 777b08fbf24SPaolo Abeni local count 778b08fbf24SPaolo Abeni local dump_stats 779b08fbf24SPaolo Abeni 78000587187SFlorian Westphal printf "%02u %-36s %s" "$TEST_COUNT" "$msg" "syn" 781b08fbf24SPaolo Abeni count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'` 782b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 783b08fbf24SPaolo Abeni if [ "$count" != "$syn_nr" ]; then 784b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] syn expected $syn_nr" 785b08fbf24SPaolo Abeni ret=1 786b08fbf24SPaolo Abeni dump_stats=1 787b08fbf24SPaolo Abeni else 788b08fbf24SPaolo Abeni echo -n "[ ok ]" 789b08fbf24SPaolo Abeni fi 790b08fbf24SPaolo Abeni 791b08fbf24SPaolo Abeni echo -n " - synack" 792b08fbf24SPaolo Abeni count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'` 793b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 794b08fbf24SPaolo Abeni if [ "$count" != "$syn_ack_nr" ]; then 795b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr" 796b08fbf24SPaolo Abeni ret=1 797b08fbf24SPaolo Abeni dump_stats=1 798b08fbf24SPaolo Abeni else 799b08fbf24SPaolo Abeni echo -n "[ ok ]" 800b08fbf24SPaolo Abeni fi 801b08fbf24SPaolo Abeni 802b08fbf24SPaolo Abeni echo -n " - ack" 803b08fbf24SPaolo Abeni count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'` 804b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 805b08fbf24SPaolo Abeni if [ "$count" != "$ack_nr" ]; then 806b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] ack expected $ack_nr" 807b08fbf24SPaolo Abeni ret=1 808b08fbf24SPaolo Abeni dump_stats=1 809b08fbf24SPaolo Abeni else 810b08fbf24SPaolo Abeni echo "[ ok ]" 811b08fbf24SPaolo Abeni fi 812327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 813af66d3e1SGeliang Tang if [ $checksum -eq 1 ]; then 814af66d3e1SGeliang Tang chk_csum_nr 8156bb3ab49SGeliang Tang chk_fail_nr 0 0 816af66d3e1SGeliang Tang fi 817b08fbf24SPaolo Abeni} 818b08fbf24SPaolo Abeni 8197d1e6f16SPaolo Abeni# a negative value for 'stale_max' means no upper bound: 8207d1e6f16SPaolo Abeni# for bidirectional transfer, if one peer sleep for a while 8217d1e6f16SPaolo Abeni# - as these tests do - we can have a quite high number of 8227d1e6f16SPaolo Abeni# stale/recover conversions, proportional to 8237d1e6f16SPaolo Abeni# sleep duration/ MPTCP-level RTX interval. 8247d1e6f16SPaolo Abenichk_stale_nr() 8257d1e6f16SPaolo Abeni{ 8267d1e6f16SPaolo Abeni local ns=$1 8277d1e6f16SPaolo Abeni local stale_min=$2 8287d1e6f16SPaolo Abeni local stale_max=$3 8297d1e6f16SPaolo Abeni local stale_delta=$4 8307d1e6f16SPaolo Abeni local dump_stats 8317d1e6f16SPaolo Abeni local stale_nr 8327d1e6f16SPaolo Abeni local recover_nr 8337d1e6f16SPaolo Abeni 8347d1e6f16SPaolo Abeni printf "%-39s %-18s" " " "stale" 8357d1e6f16SPaolo Abeni stale_nr=`ip netns exec $ns nstat -as | grep MPTcpExtSubflowStale | awk '{print $2}'` 8367d1e6f16SPaolo Abeni [ -z "$stale_nr" ] && stale_nr=0 8377d1e6f16SPaolo Abeni recover_nr=`ip netns exec $ns nstat -as | grep MPTcpExtSubflowRecover | awk '{print $2}'` 8387d1e6f16SPaolo Abeni [ -z "$recover_nr" ] && recover_nr=0 8397d1e6f16SPaolo Abeni 8407d1e6f16SPaolo Abeni if [ $stale_nr -lt $stale_min ] || 8417d1e6f16SPaolo Abeni [ $stale_max -gt 0 -a $stale_nr -gt $stale_max ] || 8427d1e6f16SPaolo Abeni [ $((stale_nr - $recover_nr)) -ne $stale_delta ]; then 8437d1e6f16SPaolo Abeni echo "[fail] got $stale_nr stale[s] $recover_nr recover[s], " \ 8447d1e6f16SPaolo Abeni " expected stale in range [$stale_min..$stale_max]," \ 8457d1e6f16SPaolo Abeni " stale-recover delta $stale_delta " 8467d1e6f16SPaolo Abeni ret=1 8477d1e6f16SPaolo Abeni dump_stats=1 8487d1e6f16SPaolo Abeni else 8497d1e6f16SPaolo Abeni echo "[ ok ]" 8507d1e6f16SPaolo Abeni fi 8517d1e6f16SPaolo Abeni 8527d1e6f16SPaolo Abeni if [ "${dump_stats}" = 1 ]; then 8537d1e6f16SPaolo Abeni echo $ns stats 8547d1e6f16SPaolo Abeni ip netns exec $ns ip -s link show 8557d1e6f16SPaolo Abeni ip netns exec $ns nstat -as | grep MPTcp 8567d1e6f16SPaolo Abeni fi 8577d1e6f16SPaolo Abeni} 8587d1e6f16SPaolo Abeni 859be613160SGeliang Tangchk_add_nr() 860be613160SGeliang Tang{ 861be613160SGeliang Tang local add_nr=$1 862be613160SGeliang Tang local echo_nr=$2 8638a127bf6SGeliang Tang local port_nr=${3:-0} 8648a127bf6SGeliang Tang local syn_nr=${4:-$port_nr} 8658a127bf6SGeliang Tang local syn_ack_nr=${5:-$port_nr} 8668a127bf6SGeliang Tang local ack_nr=${6:-$port_nr} 8678a127bf6SGeliang Tang local mis_syn_nr=${7:-0} 8688a127bf6SGeliang Tang local mis_ack_nr=${8:-0} 869be613160SGeliang Tang local count 870be613160SGeliang Tang local dump_stats 871be613160SGeliang Tang 872be613160SGeliang Tang printf "%-39s %s" " " "add" 873be613160SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtAddAddr | awk '{print $2}'` 874be613160SGeliang Tang [ -z "$count" ] && count=0 875be613160SGeliang Tang if [ "$count" != "$add_nr" ]; then 876be613160SGeliang Tang echo "[fail] got $count ADD_ADDR[s] expected $add_nr" 877be613160SGeliang Tang ret=1 878be613160SGeliang Tang dump_stats=1 879be613160SGeliang Tang else 880be613160SGeliang Tang echo -n "[ ok ]" 881be613160SGeliang Tang fi 882be613160SGeliang Tang 883be613160SGeliang Tang echo -n " - echo " 884be613160SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtEchoAdd | awk '{print $2}'` 885be613160SGeliang Tang [ -z "$count" ] && count=0 886be613160SGeliang Tang if [ "$count" != "$echo_nr" ]; then 887be613160SGeliang Tang echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr" 888be613160SGeliang Tang ret=1 889be613160SGeliang Tang dump_stats=1 890be613160SGeliang Tang else 8918a127bf6SGeliang Tang echo -n "[ ok ]" 8928a127bf6SGeliang Tang fi 8938a127bf6SGeliang Tang 8948a127bf6SGeliang Tang if [ $port_nr -gt 0 ]; then 8958a127bf6SGeliang Tang echo -n " - pt " 8968a127bf6SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtPortAdd | awk '{print $2}'` 8978a127bf6SGeliang Tang [ -z "$count" ] && count=0 8988a127bf6SGeliang Tang if [ "$count" != "$port_nr" ]; then 8998a127bf6SGeliang Tang echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr" 9008a127bf6SGeliang Tang ret=1 9018a127bf6SGeliang Tang dump_stats=1 9028a127bf6SGeliang Tang else 903be613160SGeliang Tang echo "[ ok ]" 904be613160SGeliang Tang fi 905be613160SGeliang Tang 9068a127bf6SGeliang Tang printf "%-39s %s" " " "syn" 9078a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortSynRx | 9088a127bf6SGeliang Tang awk '{print $2}'` 9098a127bf6SGeliang Tang [ -z "$count" ] && count=0 9108a127bf6SGeliang Tang if [ "$count" != "$syn_nr" ]; then 9118a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] syn with a different \ 9128a127bf6SGeliang Tang port-number expected $syn_nr" 9138a127bf6SGeliang Tang ret=1 9148a127bf6SGeliang Tang dump_stats=1 9158a127bf6SGeliang Tang else 9168a127bf6SGeliang Tang echo -n "[ ok ]" 9178a127bf6SGeliang Tang fi 9188a127bf6SGeliang Tang 9198a127bf6SGeliang Tang echo -n " - synack" 9208a127bf6SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinPortSynAckRx | 9218a127bf6SGeliang Tang awk '{print $2}'` 9228a127bf6SGeliang Tang [ -z "$count" ] && count=0 9238a127bf6SGeliang Tang if [ "$count" != "$syn_ack_nr" ]; then 9248a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] synack with a different \ 9258a127bf6SGeliang Tang port-number expected $syn_ack_nr" 9268a127bf6SGeliang Tang ret=1 9278a127bf6SGeliang Tang dump_stats=1 9288a127bf6SGeliang Tang else 9298a127bf6SGeliang Tang echo -n "[ ok ]" 9308a127bf6SGeliang Tang fi 9318a127bf6SGeliang Tang 9328a127bf6SGeliang Tang echo -n " - ack" 9338a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortAckRx | 9348a127bf6SGeliang Tang awk '{print $2}'` 9358a127bf6SGeliang Tang [ -z "$count" ] && count=0 9368a127bf6SGeliang Tang if [ "$count" != "$ack_nr" ]; then 9378a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] ack with a different \ 9388a127bf6SGeliang Tang port-number expected $ack_nr" 9398a127bf6SGeliang Tang ret=1 9408a127bf6SGeliang Tang dump_stats=1 9418a127bf6SGeliang Tang else 9428a127bf6SGeliang Tang echo "[ ok ]" 9438a127bf6SGeliang Tang fi 9448a127bf6SGeliang Tang 9458a127bf6SGeliang Tang printf "%-39s %s" " " "syn" 9468a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortSynRx | 9478a127bf6SGeliang Tang awk '{print $2}'` 9488a127bf6SGeliang Tang [ -z "$count" ] && count=0 9498a127bf6SGeliang Tang if [ "$count" != "$mis_syn_nr" ]; then 9508a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] syn with a mismatched \ 9518a127bf6SGeliang Tang port-number expected $mis_syn_nr" 9528a127bf6SGeliang Tang ret=1 9538a127bf6SGeliang Tang dump_stats=1 9548a127bf6SGeliang Tang else 9558a127bf6SGeliang Tang echo -n "[ ok ]" 9568a127bf6SGeliang Tang fi 9578a127bf6SGeliang Tang 9588a127bf6SGeliang Tang echo -n " - ack " 9598a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortAckRx | 9608a127bf6SGeliang Tang awk '{print $2}'` 9618a127bf6SGeliang Tang [ -z "$count" ] && count=0 9628a127bf6SGeliang Tang if [ "$count" != "$mis_ack_nr" ]; then 9638a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] ack with a mismatched \ 9648a127bf6SGeliang Tang port-number expected $mis_ack_nr" 9658a127bf6SGeliang Tang ret=1 9668a127bf6SGeliang Tang dump_stats=1 9678a127bf6SGeliang Tang else 9688a127bf6SGeliang Tang echo "[ ok ]" 9698a127bf6SGeliang Tang fi 9708a127bf6SGeliang Tang else 9718a127bf6SGeliang Tang echo "" 9728a127bf6SGeliang Tang fi 9738a127bf6SGeliang Tang 974327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 975be613160SGeliang Tang} 976be613160SGeliang Tang 977dd72b0feSGeliang Tangchk_rm_nr() 978dd72b0feSGeliang Tang{ 979dd72b0feSGeliang Tang local rm_addr_nr=$1 980dd72b0feSGeliang Tang local rm_subflow_nr=$2 9817028ba8aSGeliang Tang local invert=${3:-""} 982dd72b0feSGeliang Tang local count 983dd72b0feSGeliang Tang local dump_stats 9847028ba8aSGeliang Tang local addr_ns 9857028ba8aSGeliang Tang local subflow_ns 9867028ba8aSGeliang Tang 9877028ba8aSGeliang Tang if [ -z $invert ]; then 9887028ba8aSGeliang Tang addr_ns=$ns1 9897028ba8aSGeliang Tang subflow_ns=$ns2 9907028ba8aSGeliang Tang elif [ $invert = "invert" ]; then 9917028ba8aSGeliang Tang addr_ns=$ns2 9927028ba8aSGeliang Tang subflow_ns=$ns1 9937028ba8aSGeliang Tang fi 994dd72b0feSGeliang Tang 995dd72b0feSGeliang Tang printf "%-39s %s" " " "rm " 9967028ba8aSGeliang Tang count=`ip netns exec $addr_ns nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'` 997dd72b0feSGeliang Tang [ -z "$count" ] && count=0 998dd72b0feSGeliang Tang if [ "$count" != "$rm_addr_nr" ]; then 999dd72b0feSGeliang Tang echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" 1000dd72b0feSGeliang Tang ret=1 1001dd72b0feSGeliang Tang dump_stats=1 1002dd72b0feSGeliang Tang else 1003dd72b0feSGeliang Tang echo -n "[ ok ]" 1004dd72b0feSGeliang Tang fi 1005dd72b0feSGeliang Tang 1006dd72b0feSGeliang Tang echo -n " - sf " 10077028ba8aSGeliang Tang count=`ip netns exec $subflow_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'` 1008dd72b0feSGeliang Tang [ -z "$count" ] && count=0 1009dd72b0feSGeliang Tang if [ "$count" != "$rm_subflow_nr" ]; then 1010dd72b0feSGeliang Tang echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr" 1011dd72b0feSGeliang Tang ret=1 1012dd72b0feSGeliang Tang dump_stats=1 1013dd72b0feSGeliang Tang else 1014dd72b0feSGeliang Tang echo "[ ok ]" 1015dd72b0feSGeliang Tang fi 1016dd72b0feSGeliang Tang 1017327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 1018dd72b0feSGeliang Tang} 1019dd72b0feSGeliang Tang 1020718eb44eSGeliang Tangchk_prio_nr() 1021718eb44eSGeliang Tang{ 1022718eb44eSGeliang Tang local mp_prio_nr_tx=$1 1023718eb44eSGeliang Tang local mp_prio_nr_rx=$2 1024718eb44eSGeliang Tang local count 1025718eb44eSGeliang Tang local dump_stats 1026718eb44eSGeliang Tang 1027718eb44eSGeliang Tang printf "%-39s %s" " " "ptx" 1028718eb44eSGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}'` 1029718eb44eSGeliang Tang [ -z "$count" ] && count=0 1030718eb44eSGeliang Tang if [ "$count" != "$mp_prio_nr_tx" ]; then 1031718eb44eSGeliang Tang echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" 1032718eb44eSGeliang Tang ret=1 1033718eb44eSGeliang Tang dump_stats=1 1034718eb44eSGeliang Tang else 1035718eb44eSGeliang Tang echo -n "[ ok ]" 1036718eb44eSGeliang Tang fi 1037718eb44eSGeliang Tang 1038718eb44eSGeliang Tang echo -n " - prx " 1039718eb44eSGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}'` 1040718eb44eSGeliang Tang [ -z "$count" ] && count=0 1041718eb44eSGeliang Tang if [ "$count" != "$mp_prio_nr_rx" ]; then 1042718eb44eSGeliang Tang echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" 1043718eb44eSGeliang Tang ret=1 1044718eb44eSGeliang Tang dump_stats=1 1045718eb44eSGeliang Tang else 1046718eb44eSGeliang Tang echo "[ ok ]" 1047718eb44eSGeliang Tang fi 1048718eb44eSGeliang Tang 1049327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 1050718eb44eSGeliang Tang} 1051718eb44eSGeliang Tang 10527d1e6f16SPaolo Abenichk_link_usage() 10537d1e6f16SPaolo Abeni{ 10547d1e6f16SPaolo Abeni local ns=$1 10557d1e6f16SPaolo Abeni local link=$2 10567d1e6f16SPaolo Abeni local out=$3 10577d1e6f16SPaolo Abeni local expected_rate=$4 10587d1e6f16SPaolo Abeni local tx_link=`ip netns exec $ns cat /sys/class/net/$link/statistics/tx_bytes` 10597d1e6f16SPaolo Abeni local tx_total=`ls -l $out | awk '{print $5}'` 10607d1e6f16SPaolo Abeni local tx_rate=$((tx_link * 100 / $tx_total)) 10617d1e6f16SPaolo Abeni local tolerance=5 10627d1e6f16SPaolo Abeni 10637d1e6f16SPaolo Abeni printf "%-39s %-18s" " " "link usage" 10647d1e6f16SPaolo Abeni if [ $tx_rate -lt $((expected_rate - $tolerance)) -o \ 10657d1e6f16SPaolo Abeni $tx_rate -gt $((expected_rate + $tolerance)) ]; then 10667d1e6f16SPaolo Abeni echo "[fail] got $tx_rate% usage, expected $expected_rate%" 10677d1e6f16SPaolo Abeni ret=1 10687d1e6f16SPaolo Abeni else 10697d1e6f16SPaolo Abeni echo "[ ok ]" 10707d1e6f16SPaolo Abeni fi 10717d1e6f16SPaolo Abeni} 10727d1e6f16SPaolo Abeni 107346e967d1SPaolo Abeniwait_for_tw() 107446e967d1SPaolo Abeni{ 107546e967d1SPaolo Abeni local timeout_ms=$((timeout_poll * 1000)) 107646e967d1SPaolo Abeni local time=0 107746e967d1SPaolo Abeni local ns=$1 107846e967d1SPaolo Abeni 107946e967d1SPaolo Abeni while [ $time -lt $timeout_ms ]; do 108046e967d1SPaolo Abeni local cnt=$(ip netns exec $ns ss -t state time-wait |wc -l) 108146e967d1SPaolo Abeni 108246e967d1SPaolo Abeni [ "$cnt" = 1 ] && return 1 108346e967d1SPaolo Abeni time=$((time + 100)) 108446e967d1SPaolo Abeni sleep 0.1 108546e967d1SPaolo Abeni done 108646e967d1SPaolo Abeni return 1 108746e967d1SPaolo Abeni} 108846e967d1SPaolo Abeni 10891002b89fSGeliang Tangsubflows_tests() 10901002b89fSGeliang Tang{ 10911002b89fSGeliang Tang reset 1092b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1093b08fbf24SPaolo Abeni chk_join_nr "no JOIN" "0" "0" "0" 1094b08fbf24SPaolo Abeni 10951002b89fSGeliang Tang # subflow limited by client 1096b08fbf24SPaolo Abeni reset 109734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 0 109834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 0 109934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1100b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1101b08fbf24SPaolo Abeni chk_join_nr "single subflow, limited by client" 0 0 0 1102b08fbf24SPaolo Abeni 11031002b89fSGeliang Tang # subflow limited by server 1104b08fbf24SPaolo Abeni reset 110534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 0 110634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 110734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1108b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1109b08fbf24SPaolo Abeni chk_join_nr "single subflow, limited by server" 1 1 0 1110b08fbf24SPaolo Abeni 1111b08fbf24SPaolo Abeni # subflow 1112b08fbf24SPaolo Abeni reset 111334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 111434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 111534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1116b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1117b08fbf24SPaolo Abeni chk_join_nr "single subflow" 1 1 1 1118b08fbf24SPaolo Abeni 1119b08fbf24SPaolo Abeni # multiple subflows 1120b08fbf24SPaolo Abeni reset 112134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 112234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 112334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 112434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 1125b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1126b08fbf24SPaolo Abeni chk_join_nr "multiple subflows" 2 2 2 1127b08fbf24SPaolo Abeni 112872bcbc46SPaolo Abeni # multiple subflows limited by server 1129b08fbf24SPaolo Abeni reset 113034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 113134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 113234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 113334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 1134b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1135b08fbf24SPaolo Abeni chk_join_nr "multiple subflows, limited by server" 2 2 1 1136c3eaa5f6SGeliang Tang 1137c3eaa5f6SGeliang Tang # single subflow, dev 1138c3eaa5f6SGeliang Tang reset 113934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 114034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 114134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow dev ns2eth3 1142c3eaa5f6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1143c3eaa5f6SGeliang Tang chk_join_nr "single subflow, dev" 1 1 1 11441002b89fSGeliang Tang} 1145b08fbf24SPaolo Abeni 114646e967d1SPaolo Abenisubflows_error_tests() 114746e967d1SPaolo Abeni{ 114846e967d1SPaolo Abeni # If a single subflow is configured, and matches the MPC src 114946e967d1SPaolo Abeni # address, no additional subflow should be created 115046e967d1SPaolo Abeni reset 115134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 115234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 115334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow 115446e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 115546e967d1SPaolo Abeni chk_join_nr "no MPC reuse with single endpoint" 0 0 0 115646e967d1SPaolo Abeni 115746e967d1SPaolo Abeni # multiple subflows, with subflow creation error 115846e967d1SPaolo Abeni reset 115934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 116034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 116134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 116234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 116346e967d1SPaolo Abeni ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT 116446e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 116546e967d1SPaolo Abeni chk_join_nr "multi subflows, with failing subflow" 1 1 1 116646e967d1SPaolo Abeni 116746e967d1SPaolo Abeni # multiple subflows, with subflow timeout on MPJ 116846e967d1SPaolo Abeni reset 116934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 117034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 117134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 117234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 117346e967d1SPaolo Abeni ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j DROP 117446e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 117546e967d1SPaolo Abeni chk_join_nr "multi subflows, with subflow timeout" 1 1 1 117646e967d1SPaolo Abeni 117746e967d1SPaolo Abeni # multiple subflows, check that the endpoint corresponding to 117846e967d1SPaolo Abeni # closed subflow (due to reset) is not reused if additional 117946e967d1SPaolo Abeni # subflows are added later 118046e967d1SPaolo Abeni reset 118134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 118234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 118334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 118446e967d1SPaolo Abeni ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT 118546e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow & 118646e967d1SPaolo Abeni 118746e967d1SPaolo Abeni # updates in the child shell do not have any effect here, we 118846e967d1SPaolo Abeni # need to bump the test counter for the above case 118946e967d1SPaolo Abeni TEST_COUNT=$((TEST_COUNT+1)) 119046e967d1SPaolo Abeni 119146e967d1SPaolo Abeni # mpj subflow will be in TW after the reset 119246e967d1SPaolo Abeni wait_for_tw $ns2 119334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 119446e967d1SPaolo Abeni wait 119546e967d1SPaolo Abeni 119646e967d1SPaolo Abeni # additional subflow could be created only if the PM select 119746e967d1SPaolo Abeni # the later endpoint, skipping the already used one 119846e967d1SPaolo Abeni chk_join_nr "multi subflows, fair usage on close" 1 1 1 119946e967d1SPaolo Abeni} 120046e967d1SPaolo Abeni 12011002b89fSGeliang Tangsignal_address_tests() 12021002b89fSGeliang Tang{ 1203b08fbf24SPaolo Abeni # add_address, unused 1204b08fbf24SPaolo Abeni reset 120534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 1206b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1207b08fbf24SPaolo Abeni chk_join_nr "unused signal address" 0 0 0 1208be613160SGeliang Tang chk_add_nr 1 1 1209b08fbf24SPaolo Abeni 1210b08fbf24SPaolo Abeni # accept and use add_addr 1211b08fbf24SPaolo Abeni reset 121234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 121334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 121434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 1215b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1216b08fbf24SPaolo Abeni chk_join_nr "signal address" 1 1 1 1217be613160SGeliang Tang chk_add_nr 1 1 1218b08fbf24SPaolo Abeni 1219b08fbf24SPaolo Abeni # accept and use add_addr with an additional subflow 1220b08fbf24SPaolo Abeni # note: signal address in server ns and local addresses in client ns must 1221b08fbf24SPaolo Abeni # belong to different subnets or one of the listed local address could be 1222b08fbf24SPaolo Abeni # used for 'add_addr' subflow 1223b08fbf24SPaolo Abeni reset 122434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 122534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 122634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 122734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1228b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1229b08fbf24SPaolo Abeni chk_join_nr "subflow and signal" 2 2 2 1230be613160SGeliang Tang chk_add_nr 1 1 1231b08fbf24SPaolo Abeni 1232b08fbf24SPaolo Abeni # accept and use add_addr with additional subflows 1233b08fbf24SPaolo Abeni reset 123434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 123534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 123634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 123734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 123834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 1239b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1240b08fbf24SPaolo Abeni chk_join_nr "multiple subflows and signal" 3 3 3 1241be613160SGeliang Tang chk_add_nr 1 1 1242ef360019SGeliang Tang 1243ef360019SGeliang Tang # signal addresses 1244ef360019SGeliang Tang reset 124534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 124634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 124734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 124834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 124934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1250ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1251ef360019SGeliang Tang chk_join_nr "signal addresses" 3 3 3 1252ef360019SGeliang Tang chk_add_nr 3 3 1253ef360019SGeliang Tang 1254ef360019SGeliang Tang # signal invalid addresses 1255ef360019SGeliang Tang reset 125634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 125734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 125834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 125934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 126034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1261ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1262ef360019SGeliang Tang chk_join_nr "signal invalid addresses" 1 1 1 1263ef360019SGeliang Tang chk_add_nr 3 3 126433c563adSYonglong Li 126533c563adSYonglong Li # signal addresses race test 126633c563adSYonglong Li reset 126734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 126834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 126934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.1.1 flags signal 127034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 127134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 127234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 127334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.1.2 flags signal 127434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags signal 127534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags signal 127634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags signal 127733c563adSYonglong Li run_tests $ns1 $ns2 10.0.1.1 1278857898ebSMatthieu Baerts chk_join_nr "signal addresses race test" 3 3 3 127986e39e04SPaolo Abeni 128086e39e04SPaolo Abeni # the server will not signal the address terminating 128186e39e04SPaolo Abeni # the MPC subflow 128286e39e04SPaolo Abeni chk_add_nr 3 3 12831002b89fSGeliang Tang} 1284b08fbf24SPaolo Abeni 12851002b89fSGeliang Tanglink_failure_tests() 12861002b89fSGeliang Tang{ 12878b819a84SFlorian Westphal # accept and use add_addr with additional subflows and link loss 12888b819a84SFlorian Westphal reset 12897d1e6f16SPaolo Abeni 12907d1e6f16SPaolo Abeni # without any b/w limit each veth could spool the packets and get 12917d1e6f16SPaolo Abeni # them acked at xmit time, so that the corresponding subflow will 12927d1e6f16SPaolo Abeni # have almost always no outstanding pkts, the scheduler will pick 12937d1e6f16SPaolo Abeni # always the first subflow and we will have hard time testing 12947d1e6f16SPaolo Abeni # active backup and link switch-over. 12957d1e6f16SPaolo Abeni # Let's set some arbitrary (low) virtual link limits. 12967d1e6f16SPaolo Abeni init_shapers 129734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 129834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 129934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 130034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow 130134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow 13028b819a84SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 1 13038b819a84SFlorian Westphal chk_join_nr "multiple flows, signal, link failure" 3 3 3 13048b819a84SFlorian Westphal chk_add_nr 1 1 13057d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 5 1 13067d1e6f16SPaolo Abeni 13077d1e6f16SPaolo Abeni # accept and use add_addr with additional subflows and link loss 13087d1e6f16SPaolo Abeni # for bidirectional transfer 13097d1e6f16SPaolo Abeni reset 13107d1e6f16SPaolo Abeni init_shapers 131134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 131234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 131334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 131434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow 131534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow 13167d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2 13177d1e6f16SPaolo Abeni chk_join_nr "multi flows, signal, bidi, link fail" 3 3 3 13187d1e6f16SPaolo Abeni chk_add_nr 1 1 13197d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 -1 1 13207d1e6f16SPaolo Abeni 13217d1e6f16SPaolo Abeni # 2 subflows plus 1 backup subflow with a lossy link, backup 13227d1e6f16SPaolo Abeni # will never be used 13237d1e6f16SPaolo Abeni reset 13247d1e6f16SPaolo Abeni init_shapers 132534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 132634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 132734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 13287d1e6f16SPaolo Abeni export FAILING_LINKS="1" 132934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 13307d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1 13317d1e6f16SPaolo Abeni chk_join_nr "backup subflow unused, link failure" 2 2 2 13327d1e6f16SPaolo Abeni chk_add_nr 1 1 13337d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 0 13347d1e6f16SPaolo Abeni 13357d1e6f16SPaolo Abeni # 2 lossy links after half transfer, backup will get half of 13367d1e6f16SPaolo Abeni # the traffic 13377d1e6f16SPaolo Abeni reset 13387d1e6f16SPaolo Abeni init_shapers 133934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 134034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 134134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 134234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 13437d1e6f16SPaolo Abeni export FAILING_LINKS="1 2" 13447d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1 13457d1e6f16SPaolo Abeni chk_join_nr "backup flow used, multi links fail" 2 2 2 13467d1e6f16SPaolo Abeni chk_add_nr 1 1 13477d1e6f16SPaolo Abeni chk_stale_nr $ns2 2 4 2 13487d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 50 13497d1e6f16SPaolo Abeni 13507d1e6f16SPaolo Abeni # use a backup subflow with the first subflow on a lossy link 13517d1e6f16SPaolo Abeni # for bidirectional transfer 13527d1e6f16SPaolo Abeni reset 13537d1e6f16SPaolo Abeni init_shapers 135434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 135534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 135634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 135734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 13587d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2 13597d1e6f16SPaolo Abeni chk_join_nr "backup flow used, bidi, link failure" 2 2 2 13607d1e6f16SPaolo Abeni chk_add_nr 1 1 13617d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 -1 2 13627d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 50 13631002b89fSGeliang Tang} 13648b819a84SFlorian Westphal 13651002b89fSGeliang Tangadd_addr_timeout_tests() 13661002b89fSGeliang Tang{ 13678d014eaaSGeliang Tang # add_addr timeout 13688d014eaaSGeliang Tang reset_with_add_addr_timeout 136934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 137034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 137134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 13728b819a84SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 13738d014eaaSGeliang Tang chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1 13748d014eaaSGeliang Tang chk_add_nr 4 0 13758d014eaaSGeliang Tang 13761002b89fSGeliang Tang # add_addr timeout IPv6 13771002b89fSGeliang Tang reset_with_add_addr_timeout 6 137834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 137934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 138034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 13811002b89fSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 13821002b89fSGeliang Tang chk_join_nr "signal address, ADD_ADDR6 timeout" 1 1 1 13831002b89fSGeliang Tang chk_add_nr 4 0 13848da6229bSGeliang Tang 13858da6229bSGeliang Tang # signal addresses timeout 13868da6229bSGeliang Tang reset_with_add_addr_timeout 138734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 138834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 138934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 139034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 13918da6229bSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 13928da6229bSGeliang Tang chk_join_nr "signal addresses, ADD_ADDR timeout" 2 2 2 13938da6229bSGeliang Tang chk_add_nr 8 0 13948da6229bSGeliang Tang 13958da6229bSGeliang Tang # signal invalid addresses timeout 13968da6229bSGeliang Tang reset_with_add_addr_timeout 139734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 139834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 139934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 140034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 14018da6229bSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 14028da6229bSGeliang Tang chk_join_nr "invalid address, ADD_ADDR timeout" 1 1 1 14038da6229bSGeliang Tang chk_add_nr 8 0 14041002b89fSGeliang Tang} 14051002b89fSGeliang Tang 14061002b89fSGeliang Tangremove_tests() 14071002b89fSGeliang Tang{ 1408dd72b0feSGeliang Tang # single subflow, remove 1409dd72b0feSGeliang Tang reset 141034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 141134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 141234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 14132e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -1 slow 1414dd72b0feSGeliang Tang chk_join_nr "remove single subflow" 1 1 1 1415dd72b0feSGeliang Tang chk_rm_nr 1 1 1416dd72b0feSGeliang Tang 1417dd72b0feSGeliang Tang # multiple subflows, remove 1418dd72b0feSGeliang Tang reset 141934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 142034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 142134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 142234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 14232e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -2 slow 1424dd72b0feSGeliang Tang chk_join_nr "remove multiple subflows" 2 2 2 1425dd72b0feSGeliang Tang chk_rm_nr 2 2 1426dd72b0feSGeliang Tang 1427dd72b0feSGeliang Tang # single address, remove 1428dd72b0feSGeliang Tang reset 142934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 143034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 143134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 14322e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 1433dd72b0feSGeliang Tang chk_join_nr "remove single address" 1 1 1 1434dd72b0feSGeliang Tang chk_add_nr 1 1 14357028ba8aSGeliang Tang chk_rm_nr 1 1 invert 1436dd72b0feSGeliang Tang 1437dd72b0feSGeliang Tang # subflow and signal, remove 1438dd72b0feSGeliang Tang reset 143934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 144034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 144134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 144234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 14432e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 1444dd72b0feSGeliang Tang chk_join_nr "remove subflow and signal" 2 2 2 1445dd72b0feSGeliang Tang chk_add_nr 1 1 1446dd72b0feSGeliang Tang chk_rm_nr 1 1 1447dd72b0feSGeliang Tang 1448dd72b0feSGeliang Tang # subflows and signal, remove 1449dd72b0feSGeliang Tang reset 145034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 145134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 145234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 145334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 145434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 14552e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -2 slow 1456dd72b0feSGeliang Tang chk_join_nr "remove subflows and signal" 3 3 3 1457dd72b0feSGeliang Tang chk_add_nr 1 1 1458dd72b0feSGeliang Tang chk_rm_nr 2 2 1459dd72b0feSGeliang Tang 1460ef360019SGeliang Tang # addresses remove 1461ef360019SGeliang Tang reset 146234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 146334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 146434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 146534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 146634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1467ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 1468ef360019SGeliang Tang chk_join_nr "remove addresses" 3 3 3 1469ef360019SGeliang Tang chk_add_nr 3 3 1470ef360019SGeliang Tang chk_rm_nr 3 3 invert 1471ef360019SGeliang Tang 1472ef360019SGeliang Tang # invalid addresses remove 1473ef360019SGeliang Tang reset 147434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 147534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 147634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 147734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 147834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1479ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 1480ef360019SGeliang Tang chk_join_nr "remove invalid addresses" 1 1 1 1481ef360019SGeliang Tang chk_add_nr 3 3 1482ef360019SGeliang Tang chk_rm_nr 3 1 invert 1483ef360019SGeliang Tang 14846fe4ccdcSGeliang Tang # subflows and signal, flush 14856fe4ccdcSGeliang Tang reset 148634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 148734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 148834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 148934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 149034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 14912e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 14926fe4ccdcSGeliang Tang chk_join_nr "flush subflows and signal" 3 3 3 14936fe4ccdcSGeliang Tang chk_add_nr 1 1 14946fe4ccdcSGeliang Tang chk_rm_nr 2 2 1495d2c4333aSGeliang Tang 1496d2c4333aSGeliang Tang # subflows flush 1497d2c4333aSGeliang Tang reset 149834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 149934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 150034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow id 150 150134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 150234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 1503d2c4333aSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1504d2c4333aSGeliang Tang chk_join_nr "flush subflows" 3 3 3 1505d2c4333aSGeliang Tang chk_rm_nr 3 3 1506d2c4333aSGeliang Tang 1507d2c4333aSGeliang Tang # addresses flush 1508d2c4333aSGeliang Tang reset 150934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 151034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 151134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 151234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 151334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1514d2c4333aSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1515d2c4333aSGeliang Tang chk_join_nr "flush addresses" 3 3 3 1516d2c4333aSGeliang Tang chk_add_nr 3 3 1517d2c4333aSGeliang Tang chk_rm_nr 3 3 invert 1518ef360019SGeliang Tang 1519ef360019SGeliang Tang # invalid addresses flush 1520ef360019SGeliang Tang reset 152134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 152234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 152334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 152434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 152534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1526ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 0 slow 1527ef360019SGeliang Tang chk_join_nr "flush invalid addresses" 1 1 1 1528ef360019SGeliang Tang chk_add_nr 3 3 1529ef360019SGeliang Tang chk_rm_nr 3 1 invert 15305e287fe7SGeliang Tang 15315e287fe7SGeliang Tang # remove id 0 subflow 15325e287fe7SGeliang Tang reset 153334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 153434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 153534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 15365e287fe7SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -9 slow 15375e287fe7SGeliang Tang chk_join_nr "remove id 0 subflow" 1 1 1 15385e287fe7SGeliang Tang chk_rm_nr 1 1 15395e287fe7SGeliang Tang 15405e287fe7SGeliang Tang # remove id 0 address 15415e287fe7SGeliang Tang reset 154234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 154334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 154434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 15455e287fe7SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -9 0 slow 15465e287fe7SGeliang Tang chk_join_nr "remove id 0 address" 1 1 1 15475e287fe7SGeliang Tang chk_add_nr 1 1 15485e287fe7SGeliang Tang chk_rm_nr 1 1 invert 15491002b89fSGeliang Tang} 15506fe4ccdcSGeliang Tang 15511002b89fSGeliang Tangadd_tests() 15521002b89fSGeliang Tang{ 15536208fd82SGeliang Tang # add single subflow 15546208fd82SGeliang Tang reset 155534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 155634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 15576208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow 15586208fd82SGeliang Tang chk_join_nr "add single subflow" 1 1 1 15596208fd82SGeliang Tang 15606208fd82SGeliang Tang # add signal address 15616208fd82SGeliang Tang reset 156234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 156334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 15646208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 15656208fd82SGeliang Tang chk_join_nr "add signal address" 1 1 1 15666208fd82SGeliang Tang chk_add_nr 1 1 15676208fd82SGeliang Tang 15686208fd82SGeliang Tang # add multiple subflows 15696208fd82SGeliang Tang reset 157034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 157134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 15726208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 2 slow 15736208fd82SGeliang Tang chk_join_nr "add multiple subflows" 2 2 2 15746208fd82SGeliang Tang 15756208fd82SGeliang Tang # add multiple subflows IPv6 15766208fd82SGeliang Tang reset 157734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 157834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 15796208fd82SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 2 slow 15806208fd82SGeliang Tang chk_join_nr "add multiple subflows IPv6" 2 2 2 15816208fd82SGeliang Tang 15826208fd82SGeliang Tang # add multiple addresses IPv6 15836208fd82SGeliang Tang reset 158434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 158534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 15866208fd82SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 2 0 slow 15876208fd82SGeliang Tang chk_join_nr "add multiple addresses IPv6" 2 2 2 15886208fd82SGeliang Tang chk_add_nr 2 2 15891002b89fSGeliang Tang} 15906208fd82SGeliang Tang 15911002b89fSGeliang Tangipv6_tests() 15921002b89fSGeliang Tang{ 1593523514edSGeliang Tang # subflow IPv6 1594523514edSGeliang Tang reset 159534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 159634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 159734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow 1598523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1599523514edSGeliang Tang chk_join_nr "single subflow IPv6" 1 1 1 1600523514edSGeliang Tang 1601523514edSGeliang Tang # add_address, unused IPv6 1602523514edSGeliang Tang reset 160334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 1604523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1605523514edSGeliang Tang chk_join_nr "unused signal address IPv6" 0 0 0 1606523514edSGeliang Tang chk_add_nr 1 1 1607523514edSGeliang Tang 1608523514edSGeliang Tang # signal address IPv6 1609523514edSGeliang Tang reset 161034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 161134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 161234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 1613523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1614523514edSGeliang Tang chk_join_nr "single address IPv6" 1 1 1 1615523514edSGeliang Tang chk_add_nr 1 1 1616523514edSGeliang Tang 1617523514edSGeliang Tang # single address IPv6, remove 1618523514edSGeliang Tang reset 161934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 162034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 162134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 16222e8cbf45SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 -1 0 slow 1623523514edSGeliang Tang chk_join_nr "remove single address IPv6" 1 1 1 1624523514edSGeliang Tang chk_add_nr 1 1 16257028ba8aSGeliang Tang chk_rm_nr 1 1 invert 1626523514edSGeliang Tang 1627523514edSGeliang Tang # subflow and signal IPv6, remove 1628523514edSGeliang Tang reset 162934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 163034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 163134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 163234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow 16332e8cbf45SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 -1 -1 slow 1634523514edSGeliang Tang chk_join_nr "remove subflow and signal IPv6" 2 2 2 1635523514edSGeliang Tang chk_add_nr 1 1 1636523514edSGeliang Tang chk_rm_nr 1 1 16371002b89fSGeliang Tang} 1638523514edSGeliang Tang 16391002b89fSGeliang Tangv4mapped_tests() 16401002b89fSGeliang Tang{ 1641a6094788SGeliang Tang # subflow IPv4-mapped to IPv4-mapped 1642a6094788SGeliang Tang reset 164334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 164434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 164534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow 1646a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1647a6094788SGeliang Tang chk_join_nr "single subflow IPv4-mapped" 1 1 1 1648a6094788SGeliang Tang 1649a6094788SGeliang Tang # signal address IPv4-mapped with IPv4-mapped sk 1650a6094788SGeliang Tang reset 165134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 165234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 165334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal 1654a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1655a6094788SGeliang Tang chk_join_nr "signal address IPv4-mapped" 1 1 1 1656a6094788SGeliang Tang chk_add_nr 1 1 1657a6094788SGeliang Tang 1658a6094788SGeliang Tang # subflow v4-map-v6 1659a6094788SGeliang Tang reset 166034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 166134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 166234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1663a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1664a6094788SGeliang Tang chk_join_nr "single subflow v4-map-v6" 1 1 1 1665a6094788SGeliang Tang 1666a6094788SGeliang Tang # signal address v4-map-v6 1667a6094788SGeliang Tang reset 166834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 166934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 167034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 1671a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1672a6094788SGeliang Tang chk_join_nr "signal address v4-map-v6" 1 1 1 1673a6094788SGeliang Tang chk_add_nr 1 1 1674a6094788SGeliang Tang 1675a6094788SGeliang Tang # subflow v6-map-v4 1676a6094788SGeliang Tang reset 167734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 167834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 167934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow 1680a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1681a6094788SGeliang Tang chk_join_nr "single subflow v6-map-v4" 1 1 1 1682a6094788SGeliang Tang 1683a6094788SGeliang Tang # signal address v6-map-v4 1684a6094788SGeliang Tang reset 168534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 168634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 168734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal 1688a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1689a6094788SGeliang Tang chk_join_nr "signal address v6-map-v4" 1 1 1 1690a6094788SGeliang Tang chk_add_nr 1 1 1691a6094788SGeliang Tang 1692a6094788SGeliang Tang # no subflow IPv6 to v4 address 1693a6094788SGeliang Tang reset 169434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 169534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 169634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow 1697a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1698a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v4-v6" 0 0 0 1699a6094788SGeliang Tang 1700a6094788SGeliang Tang # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end 1701a6094788SGeliang Tang reset 170234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 170334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 170434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:2::10.0.3.2 flags subflow 1705a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1706a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v4-v6-2" 0 0 0 1707a6094788SGeliang Tang 1708a6094788SGeliang Tang # no subflow IPv4 to v6 address, no need to slow down too then 1709a6094788SGeliang Tang reset 171034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 171134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 171234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1713a6094788SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 1714a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v6-v4" 0 0 0 17151002b89fSGeliang Tang} 1716a6094788SGeliang Tang 17171002b89fSGeliang Tangbackup_tests() 17181002b89fSGeliang Tang{ 1719718eb44eSGeliang Tang # single subflow, backup 1720718eb44eSGeliang Tang reset 172134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 172234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 172334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup 1724718eb44eSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup 1725718eb44eSGeliang Tang chk_join_nr "single subflow, backup" 1 1 1 1726718eb44eSGeliang Tang chk_prio_nr 0 1 1727718eb44eSGeliang Tang 1728718eb44eSGeliang Tang # single address, backup 1729718eb44eSGeliang Tang reset 173034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 173134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 173234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 1733718eb44eSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup 1734718eb44eSGeliang Tang chk_join_nr "single address, backup" 1 1 1 1735718eb44eSGeliang Tang chk_add_nr 1 1 1736718eb44eSGeliang Tang chk_prio_nr 1 0 173733397b83SGeliang Tang 173833397b83SGeliang Tang # single address with port, backup 173933397b83SGeliang Tang reset 174034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 174134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 174234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 174333397b83SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup 174433397b83SGeliang Tang chk_join_nr "single address with port, backup" 1 1 1 174533397b83SGeliang Tang chk_add_nr 1 1 174633397b83SGeliang Tang chk_prio_nr 1 0 17471002b89fSGeliang Tang} 1748718eb44eSGeliang Tang 17491002b89fSGeliang Tangadd_addr_ports_tests() 17501002b89fSGeliang Tang{ 17518a127bf6SGeliang Tang # signal address with port 17528a127bf6SGeliang Tang reset 175334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 175434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 175534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 17568a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 17578a127bf6SGeliang Tang chk_join_nr "signal address with port" 1 1 1 17588a127bf6SGeliang Tang chk_add_nr 1 1 1 17598a127bf6SGeliang Tang 17608a127bf6SGeliang Tang # subflow and signal with port 17618a127bf6SGeliang Tang reset 176234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 176334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 176434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 176534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 17668a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 17678a127bf6SGeliang Tang chk_join_nr "subflow and signal with port" 2 2 2 17688a127bf6SGeliang Tang chk_add_nr 1 1 1 17698a127bf6SGeliang Tang 17708a127bf6SGeliang Tang # single address with port, remove 17718a127bf6SGeliang Tang reset 177234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 177334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 177434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 17758a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 17768a127bf6SGeliang Tang chk_join_nr "remove single address with port" 1 1 1 17778a127bf6SGeliang Tang chk_add_nr 1 1 1 17787028ba8aSGeliang Tang chk_rm_nr 1 1 invert 17798a127bf6SGeliang Tang 17808a127bf6SGeliang Tang # subflow and signal with port, remove 17818a127bf6SGeliang Tang reset 178234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 178334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 178434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 178534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 17868a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 17878a127bf6SGeliang Tang chk_join_nr "remove subflow and signal with port" 2 2 2 17888a127bf6SGeliang Tang chk_add_nr 1 1 1 17898a127bf6SGeliang Tang chk_rm_nr 1 1 17908a127bf6SGeliang Tang 17918a127bf6SGeliang Tang # subflows and signal with port, flush 17928a127bf6SGeliang Tang reset 179334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 179434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 179534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 179634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 179734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 1798327b9a94SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 -8 -2 slow 17998a127bf6SGeliang Tang chk_join_nr "flush subflows and signal with port" 3 3 3 18008a127bf6SGeliang Tang chk_add_nr 1 1 18018a127bf6SGeliang Tang chk_rm_nr 2 2 18028a127bf6SGeliang Tang 18038a127bf6SGeliang Tang # multiple addresses with port 18048a127bf6SGeliang Tang reset 180534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 180634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 180734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10100 180834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 18098a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 18108a127bf6SGeliang Tang chk_join_nr "multiple addresses with port" 2 2 2 18118a127bf6SGeliang Tang chk_add_nr 2 2 2 18128a127bf6SGeliang Tang 18138a127bf6SGeliang Tang # multiple addresses with ports 18148a127bf6SGeliang Tang reset 181534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 181634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 181734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10101 181834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 18198a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 18208a127bf6SGeliang Tang chk_join_nr "multiple addresses with ports" 2 2 2 18218a127bf6SGeliang Tang chk_add_nr 2 2 2 18221002b89fSGeliang Tang} 18238a127bf6SGeliang Tang 18241002b89fSGeliang Tangsyncookies_tests() 18251002b89fSGeliang Tang{ 182600587187SFlorian Westphal # single subflow, syncookies 182700587187SFlorian Westphal reset_with_cookies 182834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 182934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 183034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 183100587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 183200587187SFlorian Westphal chk_join_nr "single subflow with syn cookies" 1 1 1 183300587187SFlorian Westphal 183400587187SFlorian Westphal # multiple subflows with syn cookies 183500587187SFlorian Westphal reset_with_cookies 183634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 183734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 183834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 183934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 184000587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 184100587187SFlorian Westphal chk_join_nr "multiple subflows with syn cookies" 2 2 2 184200587187SFlorian Westphal 184300587187SFlorian Westphal # multiple subflows limited by server 184400587187SFlorian Westphal reset_with_cookies 184534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 184634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 184734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 184834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 184900587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 1850a7da4416SJianguo Wu chk_join_nr "subflows limited by server w cookies" 2 1 1 185100587187SFlorian Westphal 185200587187SFlorian Westphal # test signal address with cookies 185300587187SFlorian Westphal reset_with_cookies 185434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 185534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 185634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 185700587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 185800587187SFlorian Westphal chk_join_nr "signal address with syn cookies" 1 1 1 1859be613160SGeliang Tang chk_add_nr 1 1 186000587187SFlorian Westphal 186100587187SFlorian Westphal # test cookie with subflow and signal 186200587187SFlorian Westphal reset_with_cookies 186334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 186434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 186534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 186634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 186700587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 186800587187SFlorian Westphal chk_join_nr "subflow and signal w cookies" 2 2 2 1869be613160SGeliang Tang chk_add_nr 1 1 187000587187SFlorian Westphal 187100587187SFlorian Westphal # accept and use add_addr with additional subflows 187200587187SFlorian Westphal reset_with_cookies 187334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 187434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 187534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 187634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 187734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 187800587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 187900587187SFlorian Westphal chk_join_nr "subflows and signal w. cookies" 3 3 3 1880be613160SGeliang Tang chk_add_nr 1 1 18811002b89fSGeliang Tang} 18821002b89fSGeliang Tang 1883af66d3e1SGeliang Tangchecksum_tests() 1884af66d3e1SGeliang Tang{ 1885af66d3e1SGeliang Tang # checksum test 0 0 1886af66d3e1SGeliang Tang reset_with_checksum 0 0 188734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 188834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1889af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1890af66d3e1SGeliang Tang chk_csum_nr "checksum test 0 0" 1891af66d3e1SGeliang Tang 1892af66d3e1SGeliang Tang # checksum test 1 1 1893af66d3e1SGeliang Tang reset_with_checksum 1 1 189434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 189534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1896af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1897af66d3e1SGeliang Tang chk_csum_nr "checksum test 1 1" 1898af66d3e1SGeliang Tang 1899af66d3e1SGeliang Tang # checksum test 0 1 1900af66d3e1SGeliang Tang reset_with_checksum 0 1 190134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 190234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1903af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1904af66d3e1SGeliang Tang chk_csum_nr "checksum test 0 1" 1905af66d3e1SGeliang Tang 1906af66d3e1SGeliang Tang # checksum test 1 0 1907af66d3e1SGeliang Tang reset_with_checksum 1 0 190834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 190934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1910af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1911af66d3e1SGeliang Tang chk_csum_nr "checksum test 1 0" 1912af66d3e1SGeliang Tang} 1913af66d3e1SGeliang Tang 19140cddb4a6SGeliang Tangdeny_join_id0_tests() 19150cddb4a6SGeliang Tang{ 19160cddb4a6SGeliang Tang # subflow allow join id0 ns1 19170cddb4a6SGeliang Tang reset_with_allow_join_id0 1 0 191834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 191934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 192034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19210cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19220cddb4a6SGeliang Tang chk_join_nr "single subflow allow join id0 ns1" 1 1 1 19230cddb4a6SGeliang Tang 19240cddb4a6SGeliang Tang # subflow allow join id0 ns2 19250cddb4a6SGeliang Tang reset_with_allow_join_id0 0 1 192634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 192734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 192834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19290cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19300cddb4a6SGeliang Tang chk_join_nr "single subflow allow join id0 ns2" 0 0 0 19310cddb4a6SGeliang Tang 19320cddb4a6SGeliang Tang # signal address allow join id0 ns1 19330cddb4a6SGeliang Tang # ADD_ADDRs are not affected by allow_join_id0 value. 19340cddb4a6SGeliang Tang reset_with_allow_join_id0 1 0 193534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 193634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 193734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 19380cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19390cddb4a6SGeliang Tang chk_join_nr "signal address allow join id0 ns1" 1 1 1 19400cddb4a6SGeliang Tang chk_add_nr 1 1 19410cddb4a6SGeliang Tang 19420cddb4a6SGeliang Tang # signal address allow join id0 ns2 19430cddb4a6SGeliang Tang # ADD_ADDRs are not affected by allow_join_id0 value. 19440cddb4a6SGeliang Tang reset_with_allow_join_id0 0 1 194534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 194634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 194734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 19480cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19490cddb4a6SGeliang Tang chk_join_nr "signal address allow join id0 ns2" 1 1 1 19500cddb4a6SGeliang Tang chk_add_nr 1 1 19510cddb4a6SGeliang Tang 19520cddb4a6SGeliang Tang # subflow and address allow join id0 ns1 19530cddb4a6SGeliang Tang reset_with_allow_join_id0 1 0 195434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 195534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 195634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 195734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19580cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19590cddb4a6SGeliang Tang chk_join_nr "subflow and address allow join id0 1" 2 2 2 19600cddb4a6SGeliang Tang 19610cddb4a6SGeliang Tang # subflow and address allow join id0 ns2 19620cddb4a6SGeliang Tang reset_with_allow_join_id0 0 1 196334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 196434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 196534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 196634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19670cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19680cddb4a6SGeliang Tang chk_join_nr "subflow and address allow join id0 2" 1 1 1 19690cddb4a6SGeliang Tang} 19700cddb4a6SGeliang Tang 19714f49d633SGeliang Tangfullmesh_tests() 19724f49d633SGeliang Tang{ 19734f49d633SGeliang Tang # fullmesh 1 19744f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added before the connection, 19754f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added during the connection. 19764f49d633SGeliang Tang reset 197734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 4 197834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 4 197934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,fullmesh 198034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,fullmesh 19814f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 19824f49d633SGeliang Tang chk_join_nr "fullmesh test 2x1" 4 4 4 19834f49d633SGeliang Tang chk_add_nr 1 1 19844f49d633SGeliang Tang 19854f49d633SGeliang Tang # fullmesh 2 19864f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 19874f49d633SGeliang Tang # 1 fullmesh addr in ns2, added during the connection. 19884f49d633SGeliang Tang reset 198934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 3 199034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 199134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 19924f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow 19934f49d633SGeliang Tang chk_join_nr "fullmesh test 1x1" 3 3 3 19944f49d633SGeliang Tang chk_add_nr 1 1 19954f49d633SGeliang Tang 19964f49d633SGeliang Tang # fullmesh 3 19974f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 19984f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added during the connection. 19994f49d633SGeliang Tang reset 200034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 5 200134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 5 200234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 20034f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow 20044f49d633SGeliang Tang chk_join_nr "fullmesh test 1x2" 5 5 5 20054f49d633SGeliang Tang chk_add_nr 1 1 20064f49d633SGeliang Tang 20074f49d633SGeliang Tang # fullmesh 4 20084f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 20094f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added during the connection, 20104f49d633SGeliang Tang # limit max_subflows to 4. 20114f49d633SGeliang Tang reset 201234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 4 201334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 4 201434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 20154f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow 20164f49d633SGeliang Tang chk_join_nr "fullmesh test 1x2, limited" 4 4 4 20174f49d633SGeliang Tang chk_add_nr 1 1 20186a0653b9SGeliang Tang 20196a0653b9SGeliang Tang # set fullmesh flag 20206a0653b9SGeliang Tang reset 202134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 202234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow 202334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 20246a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow fullmesh 20256a0653b9SGeliang Tang chk_join_nr "set fullmesh flag test" 2 2 2 20266a0653b9SGeliang Tang chk_rm_nr 0 1 20276a0653b9SGeliang Tang 20286a0653b9SGeliang Tang # set nofullmesh flag 20296a0653b9SGeliang Tang reset 203034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 203134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow,fullmesh 203234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 20336a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow nofullmesh 20346a0653b9SGeliang Tang chk_join_nr "set nofullmesh flag test" 2 2 2 20356a0653b9SGeliang Tang chk_rm_nr 0 1 20366a0653b9SGeliang Tang 20376a0653b9SGeliang Tang # set backup,fullmesh flags 20386a0653b9SGeliang Tang reset 203934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 204034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow 204134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 20426a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow backup,fullmesh 20436a0653b9SGeliang Tang chk_join_nr "set backup,fullmesh flags test" 2 2 2 20446a0653b9SGeliang Tang chk_prio_nr 0 1 20456a0653b9SGeliang Tang chk_rm_nr 0 1 20466a0653b9SGeliang Tang 20476a0653b9SGeliang Tang # set nobackup,nofullmesh flags 20486a0653b9SGeliang Tang reset 204934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 205034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 205134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,backup,fullmesh 20526a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup,nofullmesh 20536a0653b9SGeliang Tang chk_join_nr "set nobackup,nofullmesh flags test" 2 2 2 20546a0653b9SGeliang Tang chk_prio_nr 0 1 20556a0653b9SGeliang Tang chk_rm_nr 0 1 20564f49d633SGeliang Tang} 20574f49d633SGeliang Tang 20581002b89fSGeliang Tangall_tests() 20591002b89fSGeliang Tang{ 20601002b89fSGeliang Tang subflows_tests 206146e967d1SPaolo Abeni subflows_error_tests 20621002b89fSGeliang Tang signal_address_tests 20631002b89fSGeliang Tang link_failure_tests 20641002b89fSGeliang Tang add_addr_timeout_tests 20651002b89fSGeliang Tang remove_tests 20661002b89fSGeliang Tang add_tests 20671002b89fSGeliang Tang ipv6_tests 20681002b89fSGeliang Tang v4mapped_tests 20691002b89fSGeliang Tang backup_tests 20701002b89fSGeliang Tang add_addr_ports_tests 20711002b89fSGeliang Tang syncookies_tests 2072af66d3e1SGeliang Tang checksum_tests 20730cddb4a6SGeliang Tang deny_join_id0_tests 20744f49d633SGeliang Tang fullmesh_tests 20751002b89fSGeliang Tang} 20761002b89fSGeliang Tang 207722514d52SMatthieu Baerts# [$1: error message] 20781002b89fSGeliang Tangusage() 20791002b89fSGeliang Tang{ 208022514d52SMatthieu Baerts if [ -n "${1}" ]; then 208122514d52SMatthieu Baerts echo "${1}" 208222514d52SMatthieu Baerts ret=1 208322514d52SMatthieu Baerts fi 208422514d52SMatthieu Baerts 20851002b89fSGeliang Tang echo "mptcp_join usage:" 20861002b89fSGeliang Tang echo " -f subflows_tests" 208746e967d1SPaolo Abeni echo " -e subflows_error_tests" 20881002b89fSGeliang Tang echo " -s signal_address_tests" 20891002b89fSGeliang Tang echo " -l link_failure_tests" 20901002b89fSGeliang Tang echo " -t add_addr_timeout_tests" 20911002b89fSGeliang Tang echo " -r remove_tests" 20921002b89fSGeliang Tang echo " -a add_tests" 20931002b89fSGeliang Tang echo " -6 ipv6_tests" 20941002b89fSGeliang Tang echo " -4 v4mapped_tests" 20951002b89fSGeliang Tang echo " -b backup_tests" 20961002b89fSGeliang Tang echo " -p add_addr_ports_tests" 2097a673321aSMat Martineau echo " -k syncookies_tests" 2098af66d3e1SGeliang Tang echo " -S checksum_tests" 20990cddb4a6SGeliang Tang echo " -d deny_join_id0_tests" 21004f49d633SGeliang Tang echo " -m fullmesh_tests" 2101a673321aSMat Martineau echo " -c capture pcap files" 2102af66d3e1SGeliang Tang echo " -C enable data checksum" 2103621bd393SGeliang Tang echo " -i use ip mptcp" 21041002b89fSGeliang Tang echo " -h help" 210522514d52SMatthieu Baerts 210622514d52SMatthieu Baerts exit ${ret} 21071002b89fSGeliang Tang} 21081002b89fSGeliang Tang 21091002b89fSGeliang Tangsin=$(mktemp) 21101002b89fSGeliang Tangsout=$(mktemp) 21111002b89fSGeliang Tangcin=$(mktemp) 21121002b89fSGeliang Tangcinsent=$(mktemp) 21131002b89fSGeliang Tangcout=$(mktemp) 21141002b89fSGeliang Tanginit 21151002b89fSGeliang Tangmake_file "$cin" "client" 1 21161002b89fSGeliang Tangmake_file "$sin" "server" 1 21171002b89fSGeliang Tangtrap cleanup EXIT 21181002b89fSGeliang Tang 2119a673321aSMat Martineaufor arg in "$@"; do 2120af66d3e1SGeliang Tang # check for "capture/checksum" args before launching tests 2121a673321aSMat Martineau if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"c"[0-9a-zA-Z]*$ ]]; then 2122a673321aSMat Martineau capture=1 2123a673321aSMat Martineau fi 2124af66d3e1SGeliang Tang if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"C"[0-9a-zA-Z]*$ ]]; then 2125af66d3e1SGeliang Tang checksum=1 2126af66d3e1SGeliang Tang fi 2127621bd393SGeliang Tang if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"i"[0-9a-zA-Z]*$ ]]; then 2128621bd393SGeliang Tang ip_mptcp=1 2129621bd393SGeliang Tang fi 2130a673321aSMat Martineau 2131621bd393SGeliang Tang # exception for the capture/checksum/ip_mptcp options, the rest means: a part of the tests 2132621bd393SGeliang Tang if [ "${arg}" != "-c" ] && [ "${arg}" != "-C" ] && [ "${arg}" != "-i" ]; then 2133a673321aSMat Martineau do_all_tests=0 2134a673321aSMat Martineau fi 2135a673321aSMat Martineaudone 2136a673321aSMat Martineau 2137a673321aSMat Martineauif [ $do_all_tests -eq 1 ]; then 21381002b89fSGeliang Tang all_tests 21391002b89fSGeliang Tang exit $ret 21401002b89fSGeliang Tangfi 21411002b89fSGeliang Tang 2142621bd393SGeliang Tangwhile getopts 'fesltra64bpkdmchCSi' opt; do 21431002b89fSGeliang Tang case $opt in 21441002b89fSGeliang Tang f) 21451002b89fSGeliang Tang subflows_tests 21461002b89fSGeliang Tang ;; 214746e967d1SPaolo Abeni e) 214846e967d1SPaolo Abeni subflows_error_tests 214946e967d1SPaolo Abeni ;; 21501002b89fSGeliang Tang s) 21511002b89fSGeliang Tang signal_address_tests 21521002b89fSGeliang Tang ;; 21531002b89fSGeliang Tang l) 21541002b89fSGeliang Tang link_failure_tests 21551002b89fSGeliang Tang ;; 21561002b89fSGeliang Tang t) 21571002b89fSGeliang Tang add_addr_timeout_tests 21581002b89fSGeliang Tang ;; 21591002b89fSGeliang Tang r) 21601002b89fSGeliang Tang remove_tests 21611002b89fSGeliang Tang ;; 21621002b89fSGeliang Tang a) 21631002b89fSGeliang Tang add_tests 21641002b89fSGeliang Tang ;; 21651002b89fSGeliang Tang 6) 21661002b89fSGeliang Tang ipv6_tests 21671002b89fSGeliang Tang ;; 21681002b89fSGeliang Tang 4) 21691002b89fSGeliang Tang v4mapped_tests 21701002b89fSGeliang Tang ;; 21711002b89fSGeliang Tang b) 21721002b89fSGeliang Tang backup_tests 21731002b89fSGeliang Tang ;; 21741002b89fSGeliang Tang p) 21751002b89fSGeliang Tang add_addr_ports_tests 21761002b89fSGeliang Tang ;; 2177a673321aSMat Martineau k) 21781002b89fSGeliang Tang syncookies_tests 21791002b89fSGeliang Tang ;; 2180af66d3e1SGeliang Tang S) 2181af66d3e1SGeliang Tang checksum_tests 2182af66d3e1SGeliang Tang ;; 21830cddb4a6SGeliang Tang d) 21840cddb4a6SGeliang Tang deny_join_id0_tests 21850cddb4a6SGeliang Tang ;; 21864f49d633SGeliang Tang m) 21874f49d633SGeliang Tang fullmesh_tests 21884f49d633SGeliang Tang ;; 2189a673321aSMat Martineau c) 2190a673321aSMat Martineau ;; 2191af66d3e1SGeliang Tang C) 2192af66d3e1SGeliang Tang ;; 2193621bd393SGeliang Tang i) 2194621bd393SGeliang Tang ;; 219522514d52SMatthieu Baerts h) 21961002b89fSGeliang Tang usage 21971002b89fSGeliang Tang ;; 219822514d52SMatthieu Baerts *) 219922514d52SMatthieu Baerts usage "Unknown option: -${opt}" 220022514d52SMatthieu Baerts ;; 22011002b89fSGeliang Tang esac 22021002b89fSGeliang Tangdone 220300587187SFlorian Westphal 2204b08fbf24SPaolo Abeniexit $ret 2205