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 45b08fbf24SPaolo Abeni rndh=$(printf %x $sec)-$(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 372*bccefb76SGeliang Tang local id=$2 373*bccefb76SGeliang 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 378*bccefb76SGeliang 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) 581*bccefb76SGeliang Tang local nr=0 582f0140386SGeliang Tang local id 58333397b83SGeliang Tang 58433397b83SGeliang Tang for i in ${arr[@]}; do 585*bccefb76SGeliang Tang if [ $i = "id" ]; then 586*bccefb76SGeliang Tang id=${arr[$nr+1]} 587718eb44eSGeliang Tang fi 588*bccefb76SGeliang Tang let nr+=1 58933397b83SGeliang Tang done 590*bccefb76SGeliang 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:-""}" 668b08fbf24SPaolo Abeni lret=0 6698b819a84SFlorian Westphal oldin="" 6708b819a84SFlorian Westphal 6717d1e6f16SPaolo Abeni # create the input file for the failure test when 6727d1e6f16SPaolo Abeni # the first failure test run 6737d1e6f16SPaolo Abeni if [ "$test_linkfail" -ne 0 -a -z "$cinfail" ]; then 6747d1e6f16SPaolo Abeni # the client file must be considerably larger 6757d1e6f16SPaolo Abeni # of the maximum expected cwin value, or the 6767d1e6f16SPaolo Abeni # link utilization will be not predicable 6777d1e6f16SPaolo Abeni size=$((RANDOM%2)) 6788b819a84SFlorian Westphal size=$((size+1)) 6797d1e6f16SPaolo Abeni size=$((size*8192)) 6807d1e6f16SPaolo Abeni size=$((size + ( $RANDOM % 8192) )) 6818b819a84SFlorian Westphal 6827d1e6f16SPaolo Abeni cinfail=$(mktemp) 6837d1e6f16SPaolo Abeni make_file "$cinfail" "client" $size 6847d1e6f16SPaolo Abeni fi 6857d1e6f16SPaolo Abeni 6867d1e6f16SPaolo Abeni if [ "$test_linkfail" -eq 2 -a -z "$sinfail" ]; then 6877d1e6f16SPaolo Abeni size=$((RANDOM%16)) 6887d1e6f16SPaolo Abeni size=$((size+1)) 6897d1e6f16SPaolo Abeni size=$((size*2048)) 6907d1e6f16SPaolo Abeni 6917d1e6f16SPaolo Abeni sinfail=$(mktemp) 6927d1e6f16SPaolo Abeni make_file "$sinfail" "server" $size 6938b819a84SFlorian Westphal fi 694b08fbf24SPaolo Abeni 6958d014eaaSGeliang Tang do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \ 6966a0653b9SGeliang Tang ${test_linkfail} ${addr_nr_ns1} ${addr_nr_ns2} ${speed} ${sflags} 697b08fbf24SPaolo Abeni lret=$? 698b08fbf24SPaolo Abeni} 699b08fbf24SPaolo Abeni 700327b9a94SPaolo Abenidump_stats() 701327b9a94SPaolo Abeni{ 702327b9a94SPaolo Abeni echo Server ns stats 703327b9a94SPaolo Abeni ip netns exec $ns1 nstat -as | grep Tcp 704327b9a94SPaolo Abeni echo Client ns stats 705327b9a94SPaolo Abeni ip netns exec $ns2 nstat -as | grep Tcp 706327b9a94SPaolo Abeni} 707327b9a94SPaolo Abeni 708af66d3e1SGeliang Tangchk_csum_nr() 709af66d3e1SGeliang Tang{ 710af66d3e1SGeliang Tang local msg=${1:-""} 711af66d3e1SGeliang Tang local count 712af66d3e1SGeliang Tang local dump_stats 713af66d3e1SGeliang Tang 714af66d3e1SGeliang Tang if [ ! -z "$msg" ]; then 715af66d3e1SGeliang Tang printf "%02u" "$TEST_COUNT" 716af66d3e1SGeliang Tang else 717af66d3e1SGeliang Tang echo -n " " 718af66d3e1SGeliang Tang fi 719af66d3e1SGeliang Tang printf " %-36s %s" "$msg" "sum" 720af66d3e1SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'` 721af66d3e1SGeliang Tang [ -z "$count" ] && count=0 722af66d3e1SGeliang Tang if [ "$count" != 0 ]; then 723af66d3e1SGeliang Tang echo "[fail] got $count data checksum error[s] expected 0" 724af66d3e1SGeliang Tang ret=1 725af66d3e1SGeliang Tang dump_stats=1 726af66d3e1SGeliang Tang else 727af66d3e1SGeliang Tang echo -n "[ ok ]" 728af66d3e1SGeliang Tang fi 729af66d3e1SGeliang Tang echo -n " - csum " 730af66d3e1SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'` 731af66d3e1SGeliang Tang [ -z "$count" ] && count=0 732af66d3e1SGeliang Tang if [ "$count" != 0 ]; then 733af66d3e1SGeliang Tang echo "[fail] got $count data checksum error[s] expected 0" 734af66d3e1SGeliang Tang ret=1 735af66d3e1SGeliang Tang dump_stats=1 736af66d3e1SGeliang Tang else 737af66d3e1SGeliang Tang echo "[ ok ]" 738af66d3e1SGeliang Tang fi 739327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 740af66d3e1SGeliang Tang} 741af66d3e1SGeliang Tang 7426bb3ab49SGeliang Tangchk_fail_nr() 7436bb3ab49SGeliang Tang{ 7446bb3ab49SGeliang Tang local mp_fail_nr_tx=$1 7456bb3ab49SGeliang Tang local mp_fail_nr_rx=$2 7466bb3ab49SGeliang Tang local count 7476bb3ab49SGeliang Tang local dump_stats 7486bb3ab49SGeliang Tang 7496bb3ab49SGeliang Tang printf "%-39s %s" " " "ftx" 7506bb3ab49SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPFailTx | awk '{print $2}'` 7516bb3ab49SGeliang Tang [ -z "$count" ] && count=0 7526bb3ab49SGeliang Tang if [ "$count" != "$mp_fail_nr_tx" ]; then 7536bb3ab49SGeliang Tang echo "[fail] got $count MP_FAIL[s] TX expected $mp_fail_nr_tx" 7546bb3ab49SGeliang Tang ret=1 7556bb3ab49SGeliang Tang dump_stats=1 7566bb3ab49SGeliang Tang else 7576bb3ab49SGeliang Tang echo -n "[ ok ]" 7586bb3ab49SGeliang Tang fi 7596bb3ab49SGeliang Tang 7606bb3ab49SGeliang Tang echo -n " - frx " 7616bb3ab49SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPFailRx | awk '{print $2}'` 7626bb3ab49SGeliang Tang [ -z "$count" ] && count=0 7636bb3ab49SGeliang Tang if [ "$count" != "$mp_fail_nr_rx" ]; then 7646bb3ab49SGeliang Tang echo "[fail] got $count MP_FAIL[s] RX expected $mp_fail_nr_rx" 7656bb3ab49SGeliang Tang ret=1 7666bb3ab49SGeliang Tang dump_stats=1 7676bb3ab49SGeliang Tang else 7686bb3ab49SGeliang Tang echo "[ ok ]" 7696bb3ab49SGeliang Tang fi 7706bb3ab49SGeliang Tang 771327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 7726bb3ab49SGeliang Tang} 7736bb3ab49SGeliang Tang 774b08fbf24SPaolo Abenichk_join_nr() 775b08fbf24SPaolo Abeni{ 776b08fbf24SPaolo Abeni local msg="$1" 777b08fbf24SPaolo Abeni local syn_nr=$2 778b08fbf24SPaolo Abeni local syn_ack_nr=$3 779b08fbf24SPaolo Abeni local ack_nr=$4 780b08fbf24SPaolo Abeni local count 781b08fbf24SPaolo Abeni local dump_stats 782b08fbf24SPaolo Abeni 78300587187SFlorian Westphal printf "%02u %-36s %s" "$TEST_COUNT" "$msg" "syn" 784b08fbf24SPaolo Abeni count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'` 785b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 786b08fbf24SPaolo Abeni if [ "$count" != "$syn_nr" ]; then 787b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] syn expected $syn_nr" 788b08fbf24SPaolo Abeni ret=1 789b08fbf24SPaolo Abeni dump_stats=1 790b08fbf24SPaolo Abeni else 791b08fbf24SPaolo Abeni echo -n "[ ok ]" 792b08fbf24SPaolo Abeni fi 793b08fbf24SPaolo Abeni 794b08fbf24SPaolo Abeni echo -n " - synack" 795b08fbf24SPaolo Abeni count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'` 796b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 797b08fbf24SPaolo Abeni if [ "$count" != "$syn_ack_nr" ]; then 798b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr" 799b08fbf24SPaolo Abeni ret=1 800b08fbf24SPaolo Abeni dump_stats=1 801b08fbf24SPaolo Abeni else 802b08fbf24SPaolo Abeni echo -n "[ ok ]" 803b08fbf24SPaolo Abeni fi 804b08fbf24SPaolo Abeni 805b08fbf24SPaolo Abeni echo -n " - ack" 806b08fbf24SPaolo Abeni count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'` 807b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 808b08fbf24SPaolo Abeni if [ "$count" != "$ack_nr" ]; then 809b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] ack expected $ack_nr" 810b08fbf24SPaolo Abeni ret=1 811b08fbf24SPaolo Abeni dump_stats=1 812b08fbf24SPaolo Abeni else 813b08fbf24SPaolo Abeni echo "[ ok ]" 814b08fbf24SPaolo Abeni fi 815327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 816af66d3e1SGeliang Tang if [ $checksum -eq 1 ]; then 817af66d3e1SGeliang Tang chk_csum_nr 8186bb3ab49SGeliang Tang chk_fail_nr 0 0 819af66d3e1SGeliang Tang fi 820b08fbf24SPaolo Abeni} 821b08fbf24SPaolo Abeni 8227d1e6f16SPaolo Abeni# a negative value for 'stale_max' means no upper bound: 8237d1e6f16SPaolo Abeni# for bidirectional transfer, if one peer sleep for a while 8247d1e6f16SPaolo Abeni# - as these tests do - we can have a quite high number of 8257d1e6f16SPaolo Abeni# stale/recover conversions, proportional to 8267d1e6f16SPaolo Abeni# sleep duration/ MPTCP-level RTX interval. 8277d1e6f16SPaolo Abenichk_stale_nr() 8287d1e6f16SPaolo Abeni{ 8297d1e6f16SPaolo Abeni local ns=$1 8307d1e6f16SPaolo Abeni local stale_min=$2 8317d1e6f16SPaolo Abeni local stale_max=$3 8327d1e6f16SPaolo Abeni local stale_delta=$4 8337d1e6f16SPaolo Abeni local dump_stats 8347d1e6f16SPaolo Abeni local stale_nr 8357d1e6f16SPaolo Abeni local recover_nr 8367d1e6f16SPaolo Abeni 8377d1e6f16SPaolo Abeni printf "%-39s %-18s" " " "stale" 8387d1e6f16SPaolo Abeni stale_nr=`ip netns exec $ns nstat -as | grep MPTcpExtSubflowStale | awk '{print $2}'` 8397d1e6f16SPaolo Abeni [ -z "$stale_nr" ] && stale_nr=0 8407d1e6f16SPaolo Abeni recover_nr=`ip netns exec $ns nstat -as | grep MPTcpExtSubflowRecover | awk '{print $2}'` 8417d1e6f16SPaolo Abeni [ -z "$recover_nr" ] && recover_nr=0 8427d1e6f16SPaolo Abeni 8437d1e6f16SPaolo Abeni if [ $stale_nr -lt $stale_min ] || 8447d1e6f16SPaolo Abeni [ $stale_max -gt 0 -a $stale_nr -gt $stale_max ] || 8457d1e6f16SPaolo Abeni [ $((stale_nr - $recover_nr)) -ne $stale_delta ]; then 8467d1e6f16SPaolo Abeni echo "[fail] got $stale_nr stale[s] $recover_nr recover[s], " \ 8477d1e6f16SPaolo Abeni " expected stale in range [$stale_min..$stale_max]," \ 8487d1e6f16SPaolo Abeni " stale-recover delta $stale_delta " 8497d1e6f16SPaolo Abeni ret=1 8507d1e6f16SPaolo Abeni dump_stats=1 8517d1e6f16SPaolo Abeni else 8527d1e6f16SPaolo Abeni echo "[ ok ]" 8537d1e6f16SPaolo Abeni fi 8547d1e6f16SPaolo Abeni 8557d1e6f16SPaolo Abeni if [ "${dump_stats}" = 1 ]; then 8567d1e6f16SPaolo Abeni echo $ns stats 8577d1e6f16SPaolo Abeni ip netns exec $ns ip -s link show 8587d1e6f16SPaolo Abeni ip netns exec $ns nstat -as | grep MPTcp 8597d1e6f16SPaolo Abeni fi 8607d1e6f16SPaolo Abeni} 8617d1e6f16SPaolo Abeni 862be613160SGeliang Tangchk_add_nr() 863be613160SGeliang Tang{ 864be613160SGeliang Tang local add_nr=$1 865be613160SGeliang Tang local echo_nr=$2 8668a127bf6SGeliang Tang local port_nr=${3:-0} 8678a127bf6SGeliang Tang local syn_nr=${4:-$port_nr} 8688a127bf6SGeliang Tang local syn_ack_nr=${5:-$port_nr} 8698a127bf6SGeliang Tang local ack_nr=${6:-$port_nr} 8708a127bf6SGeliang Tang local mis_syn_nr=${7:-0} 8718a127bf6SGeliang Tang local mis_ack_nr=${8:-0} 872be613160SGeliang Tang local count 873be613160SGeliang Tang local dump_stats 874be613160SGeliang Tang 875be613160SGeliang Tang printf "%-39s %s" " " "add" 876be613160SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtAddAddr | awk '{print $2}'` 877be613160SGeliang Tang [ -z "$count" ] && count=0 878be613160SGeliang Tang if [ "$count" != "$add_nr" ]; then 879be613160SGeliang Tang echo "[fail] got $count ADD_ADDR[s] expected $add_nr" 880be613160SGeliang Tang ret=1 881be613160SGeliang Tang dump_stats=1 882be613160SGeliang Tang else 883be613160SGeliang Tang echo -n "[ ok ]" 884be613160SGeliang Tang fi 885be613160SGeliang Tang 886be613160SGeliang Tang echo -n " - echo " 887be613160SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtEchoAdd | awk '{print $2}'` 888be613160SGeliang Tang [ -z "$count" ] && count=0 889be613160SGeliang Tang if [ "$count" != "$echo_nr" ]; then 890be613160SGeliang Tang echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr" 891be613160SGeliang Tang ret=1 892be613160SGeliang Tang dump_stats=1 893be613160SGeliang Tang else 8948a127bf6SGeliang Tang echo -n "[ ok ]" 8958a127bf6SGeliang Tang fi 8968a127bf6SGeliang Tang 8978a127bf6SGeliang Tang if [ $port_nr -gt 0 ]; then 8988a127bf6SGeliang Tang echo -n " - pt " 8998a127bf6SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtPortAdd | awk '{print $2}'` 9008a127bf6SGeliang Tang [ -z "$count" ] && count=0 9018a127bf6SGeliang Tang if [ "$count" != "$port_nr" ]; then 9028a127bf6SGeliang Tang echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr" 9038a127bf6SGeliang Tang ret=1 9048a127bf6SGeliang Tang dump_stats=1 9058a127bf6SGeliang Tang else 906be613160SGeliang Tang echo "[ ok ]" 907be613160SGeliang Tang fi 908be613160SGeliang Tang 9098a127bf6SGeliang Tang printf "%-39s %s" " " "syn" 9108a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortSynRx | 9118a127bf6SGeliang Tang awk '{print $2}'` 9128a127bf6SGeliang Tang [ -z "$count" ] && count=0 9138a127bf6SGeliang Tang if [ "$count" != "$syn_nr" ]; then 9148a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] syn with a different \ 9158a127bf6SGeliang Tang port-number expected $syn_nr" 9168a127bf6SGeliang Tang ret=1 9178a127bf6SGeliang Tang dump_stats=1 9188a127bf6SGeliang Tang else 9198a127bf6SGeliang Tang echo -n "[ ok ]" 9208a127bf6SGeliang Tang fi 9218a127bf6SGeliang Tang 9228a127bf6SGeliang Tang echo -n " - synack" 9238a127bf6SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinPortSynAckRx | 9248a127bf6SGeliang Tang awk '{print $2}'` 9258a127bf6SGeliang Tang [ -z "$count" ] && count=0 9268a127bf6SGeliang Tang if [ "$count" != "$syn_ack_nr" ]; then 9278a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] synack with a different \ 9288a127bf6SGeliang Tang port-number expected $syn_ack_nr" 9298a127bf6SGeliang Tang ret=1 9308a127bf6SGeliang Tang dump_stats=1 9318a127bf6SGeliang Tang else 9328a127bf6SGeliang Tang echo -n "[ ok ]" 9338a127bf6SGeliang Tang fi 9348a127bf6SGeliang Tang 9358a127bf6SGeliang Tang echo -n " - ack" 9368a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortAckRx | 9378a127bf6SGeliang Tang awk '{print $2}'` 9388a127bf6SGeliang Tang [ -z "$count" ] && count=0 9398a127bf6SGeliang Tang if [ "$count" != "$ack_nr" ]; then 9408a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] ack with a different \ 9418a127bf6SGeliang Tang port-number expected $ack_nr" 9428a127bf6SGeliang Tang ret=1 9438a127bf6SGeliang Tang dump_stats=1 9448a127bf6SGeliang Tang else 9458a127bf6SGeliang Tang echo "[ ok ]" 9468a127bf6SGeliang Tang fi 9478a127bf6SGeliang Tang 9488a127bf6SGeliang Tang printf "%-39s %s" " " "syn" 9498a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortSynRx | 9508a127bf6SGeliang Tang awk '{print $2}'` 9518a127bf6SGeliang Tang [ -z "$count" ] && count=0 9528a127bf6SGeliang Tang if [ "$count" != "$mis_syn_nr" ]; then 9538a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] syn with a mismatched \ 9548a127bf6SGeliang Tang port-number expected $mis_syn_nr" 9558a127bf6SGeliang Tang ret=1 9568a127bf6SGeliang Tang dump_stats=1 9578a127bf6SGeliang Tang else 9588a127bf6SGeliang Tang echo -n "[ ok ]" 9598a127bf6SGeliang Tang fi 9608a127bf6SGeliang Tang 9618a127bf6SGeliang Tang echo -n " - ack " 9628a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortAckRx | 9638a127bf6SGeliang Tang awk '{print $2}'` 9648a127bf6SGeliang Tang [ -z "$count" ] && count=0 9658a127bf6SGeliang Tang if [ "$count" != "$mis_ack_nr" ]; then 9668a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] ack with a mismatched \ 9678a127bf6SGeliang Tang port-number expected $mis_ack_nr" 9688a127bf6SGeliang Tang ret=1 9698a127bf6SGeliang Tang dump_stats=1 9708a127bf6SGeliang Tang else 9718a127bf6SGeliang Tang echo "[ ok ]" 9728a127bf6SGeliang Tang fi 9738a127bf6SGeliang Tang else 9748a127bf6SGeliang Tang echo "" 9758a127bf6SGeliang Tang fi 9768a127bf6SGeliang Tang 977327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 978be613160SGeliang Tang} 979be613160SGeliang Tang 980dd72b0feSGeliang Tangchk_rm_nr() 981dd72b0feSGeliang Tang{ 982dd72b0feSGeliang Tang local rm_addr_nr=$1 983dd72b0feSGeliang Tang local rm_subflow_nr=$2 9847028ba8aSGeliang Tang local invert=${3:-""} 985dd72b0feSGeliang Tang local count 986dd72b0feSGeliang Tang local dump_stats 9877028ba8aSGeliang Tang local addr_ns 9887028ba8aSGeliang Tang local subflow_ns 9897028ba8aSGeliang Tang 9907028ba8aSGeliang Tang if [ -z $invert ]; then 9917028ba8aSGeliang Tang addr_ns=$ns1 9927028ba8aSGeliang Tang subflow_ns=$ns2 9937028ba8aSGeliang Tang elif [ $invert = "invert" ]; then 9947028ba8aSGeliang Tang addr_ns=$ns2 9957028ba8aSGeliang Tang subflow_ns=$ns1 9967028ba8aSGeliang Tang fi 997dd72b0feSGeliang Tang 998dd72b0feSGeliang Tang printf "%-39s %s" " " "rm " 9997028ba8aSGeliang Tang count=`ip netns exec $addr_ns nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'` 1000dd72b0feSGeliang Tang [ -z "$count" ] && count=0 1001dd72b0feSGeliang Tang if [ "$count" != "$rm_addr_nr" ]; then 1002dd72b0feSGeliang Tang echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" 1003dd72b0feSGeliang Tang ret=1 1004dd72b0feSGeliang Tang dump_stats=1 1005dd72b0feSGeliang Tang else 1006dd72b0feSGeliang Tang echo -n "[ ok ]" 1007dd72b0feSGeliang Tang fi 1008dd72b0feSGeliang Tang 1009dd72b0feSGeliang Tang echo -n " - sf " 10107028ba8aSGeliang Tang count=`ip netns exec $subflow_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'` 1011dd72b0feSGeliang Tang [ -z "$count" ] && count=0 1012dd72b0feSGeliang Tang if [ "$count" != "$rm_subflow_nr" ]; then 1013dd72b0feSGeliang Tang echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr" 1014dd72b0feSGeliang Tang ret=1 1015dd72b0feSGeliang Tang dump_stats=1 1016dd72b0feSGeliang Tang else 1017dd72b0feSGeliang Tang echo "[ ok ]" 1018dd72b0feSGeliang Tang fi 1019dd72b0feSGeliang Tang 1020327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 1021dd72b0feSGeliang Tang} 1022dd72b0feSGeliang Tang 1023718eb44eSGeliang Tangchk_prio_nr() 1024718eb44eSGeliang Tang{ 1025718eb44eSGeliang Tang local mp_prio_nr_tx=$1 1026718eb44eSGeliang Tang local mp_prio_nr_rx=$2 1027718eb44eSGeliang Tang local count 1028718eb44eSGeliang Tang local dump_stats 1029718eb44eSGeliang Tang 1030718eb44eSGeliang Tang printf "%-39s %s" " " "ptx" 1031718eb44eSGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}'` 1032718eb44eSGeliang Tang [ -z "$count" ] && count=0 1033718eb44eSGeliang Tang if [ "$count" != "$mp_prio_nr_tx" ]; then 1034718eb44eSGeliang Tang echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" 1035718eb44eSGeliang Tang ret=1 1036718eb44eSGeliang Tang dump_stats=1 1037718eb44eSGeliang Tang else 1038718eb44eSGeliang Tang echo -n "[ ok ]" 1039718eb44eSGeliang Tang fi 1040718eb44eSGeliang Tang 1041718eb44eSGeliang Tang echo -n " - prx " 1042718eb44eSGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}'` 1043718eb44eSGeliang Tang [ -z "$count" ] && count=0 1044718eb44eSGeliang Tang if [ "$count" != "$mp_prio_nr_rx" ]; then 1045718eb44eSGeliang Tang echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" 1046718eb44eSGeliang Tang ret=1 1047718eb44eSGeliang Tang dump_stats=1 1048718eb44eSGeliang Tang else 1049718eb44eSGeliang Tang echo "[ ok ]" 1050718eb44eSGeliang Tang fi 1051718eb44eSGeliang Tang 1052327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 1053718eb44eSGeliang Tang} 1054718eb44eSGeliang Tang 10557d1e6f16SPaolo Abenichk_link_usage() 10567d1e6f16SPaolo Abeni{ 10577d1e6f16SPaolo Abeni local ns=$1 10587d1e6f16SPaolo Abeni local link=$2 10597d1e6f16SPaolo Abeni local out=$3 10607d1e6f16SPaolo Abeni local expected_rate=$4 10617d1e6f16SPaolo Abeni local tx_link=`ip netns exec $ns cat /sys/class/net/$link/statistics/tx_bytes` 10627d1e6f16SPaolo Abeni local tx_total=`ls -l $out | awk '{print $5}'` 10637d1e6f16SPaolo Abeni local tx_rate=$((tx_link * 100 / $tx_total)) 10647d1e6f16SPaolo Abeni local tolerance=5 10657d1e6f16SPaolo Abeni 10667d1e6f16SPaolo Abeni printf "%-39s %-18s" " " "link usage" 10677d1e6f16SPaolo Abeni if [ $tx_rate -lt $((expected_rate - $tolerance)) -o \ 10687d1e6f16SPaolo Abeni $tx_rate -gt $((expected_rate + $tolerance)) ]; then 10697d1e6f16SPaolo Abeni echo "[fail] got $tx_rate% usage, expected $expected_rate%" 10707d1e6f16SPaolo Abeni ret=1 10717d1e6f16SPaolo Abeni else 10727d1e6f16SPaolo Abeni echo "[ ok ]" 10737d1e6f16SPaolo Abeni fi 10747d1e6f16SPaolo Abeni} 10757d1e6f16SPaolo Abeni 107646e967d1SPaolo Abeniwait_for_tw() 107746e967d1SPaolo Abeni{ 107846e967d1SPaolo Abeni local timeout_ms=$((timeout_poll * 1000)) 107946e967d1SPaolo Abeni local time=0 108046e967d1SPaolo Abeni local ns=$1 108146e967d1SPaolo Abeni 108246e967d1SPaolo Abeni while [ $time -lt $timeout_ms ]; do 108346e967d1SPaolo Abeni local cnt=$(ip netns exec $ns ss -t state time-wait |wc -l) 108446e967d1SPaolo Abeni 108546e967d1SPaolo Abeni [ "$cnt" = 1 ] && return 1 108646e967d1SPaolo Abeni time=$((time + 100)) 108746e967d1SPaolo Abeni sleep 0.1 108846e967d1SPaolo Abeni done 108946e967d1SPaolo Abeni return 1 109046e967d1SPaolo Abeni} 109146e967d1SPaolo Abeni 10921002b89fSGeliang Tangsubflows_tests() 10931002b89fSGeliang Tang{ 10941002b89fSGeliang Tang reset 1095b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1096b08fbf24SPaolo Abeni chk_join_nr "no JOIN" "0" "0" "0" 1097b08fbf24SPaolo Abeni 10981002b89fSGeliang Tang # subflow limited by client 1099b08fbf24SPaolo Abeni reset 110034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 0 110134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 0 110234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1103b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1104b08fbf24SPaolo Abeni chk_join_nr "single subflow, limited by client" 0 0 0 1105b08fbf24SPaolo Abeni 11061002b89fSGeliang Tang # subflow limited by server 1107b08fbf24SPaolo Abeni reset 110834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 0 110934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 111034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1111b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1112b08fbf24SPaolo Abeni chk_join_nr "single subflow, limited by server" 1 1 0 1113b08fbf24SPaolo Abeni 1114b08fbf24SPaolo Abeni # subflow 1115b08fbf24SPaolo Abeni reset 111634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 111734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 111834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1119b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1120b08fbf24SPaolo Abeni chk_join_nr "single subflow" 1 1 1 1121b08fbf24SPaolo Abeni 1122b08fbf24SPaolo Abeni # multiple subflows 1123b08fbf24SPaolo Abeni reset 112434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 112534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 112634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 112734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 1128b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1129b08fbf24SPaolo Abeni chk_join_nr "multiple subflows" 2 2 2 1130b08fbf24SPaolo Abeni 113172bcbc46SPaolo Abeni # multiple subflows limited by server 1132b08fbf24SPaolo Abeni reset 113334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 113434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 113534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 113634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 1137b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1138b08fbf24SPaolo Abeni chk_join_nr "multiple subflows, limited by server" 2 2 1 1139c3eaa5f6SGeliang Tang 1140c3eaa5f6SGeliang Tang # single subflow, dev 1141c3eaa5f6SGeliang Tang reset 114234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 114334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 114434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow dev ns2eth3 1145c3eaa5f6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1146c3eaa5f6SGeliang Tang chk_join_nr "single subflow, dev" 1 1 1 11471002b89fSGeliang Tang} 1148b08fbf24SPaolo Abeni 114946e967d1SPaolo Abenisubflows_error_tests() 115046e967d1SPaolo Abeni{ 115146e967d1SPaolo Abeni # If a single subflow is configured, and matches the MPC src 115246e967d1SPaolo Abeni # address, no additional subflow should be created 115346e967d1SPaolo Abeni reset 115434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 115534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 115634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow 115746e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 115846e967d1SPaolo Abeni chk_join_nr "no MPC reuse with single endpoint" 0 0 0 115946e967d1SPaolo Abeni 116046e967d1SPaolo Abeni # multiple subflows, with subflow creation error 116146e967d1SPaolo Abeni reset 116234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 116334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 116434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 116534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 116646e967d1SPaolo Abeni ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT 116746e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 116846e967d1SPaolo Abeni chk_join_nr "multi subflows, with failing subflow" 1 1 1 116946e967d1SPaolo Abeni 117046e967d1SPaolo Abeni # multiple subflows, with subflow timeout on MPJ 117146e967d1SPaolo Abeni reset 117234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 117334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 117434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 117534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 117646e967d1SPaolo Abeni ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j DROP 117746e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 117846e967d1SPaolo Abeni chk_join_nr "multi subflows, with subflow timeout" 1 1 1 117946e967d1SPaolo Abeni 118046e967d1SPaolo Abeni # multiple subflows, check that the endpoint corresponding to 118146e967d1SPaolo Abeni # closed subflow (due to reset) is not reused if additional 118246e967d1SPaolo Abeni # subflows are added later 118346e967d1SPaolo Abeni reset 118434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 118534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 118634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 118746e967d1SPaolo Abeni ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT 118846e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow & 118946e967d1SPaolo Abeni 119046e967d1SPaolo Abeni # updates in the child shell do not have any effect here, we 119146e967d1SPaolo Abeni # need to bump the test counter for the above case 119246e967d1SPaolo Abeni TEST_COUNT=$((TEST_COUNT+1)) 119346e967d1SPaolo Abeni 119446e967d1SPaolo Abeni # mpj subflow will be in TW after the reset 119546e967d1SPaolo Abeni wait_for_tw $ns2 119634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 119746e967d1SPaolo Abeni wait 119846e967d1SPaolo Abeni 119946e967d1SPaolo Abeni # additional subflow could be created only if the PM select 120046e967d1SPaolo Abeni # the later endpoint, skipping the already used one 120146e967d1SPaolo Abeni chk_join_nr "multi subflows, fair usage on close" 1 1 1 120246e967d1SPaolo Abeni} 120346e967d1SPaolo Abeni 12041002b89fSGeliang Tangsignal_address_tests() 12051002b89fSGeliang Tang{ 1206b08fbf24SPaolo Abeni # add_address, unused 1207b08fbf24SPaolo Abeni reset 120834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 1209b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1210b08fbf24SPaolo Abeni chk_join_nr "unused signal address" 0 0 0 1211be613160SGeliang Tang chk_add_nr 1 1 1212b08fbf24SPaolo Abeni 1213b08fbf24SPaolo Abeni # accept and use add_addr 1214b08fbf24SPaolo Abeni reset 121534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 121634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 121734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 1218b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1219b08fbf24SPaolo Abeni chk_join_nr "signal address" 1 1 1 1220be613160SGeliang Tang chk_add_nr 1 1 1221b08fbf24SPaolo Abeni 1222b08fbf24SPaolo Abeni # accept and use add_addr with an additional subflow 1223b08fbf24SPaolo Abeni # note: signal address in server ns and local addresses in client ns must 1224b08fbf24SPaolo Abeni # belong to different subnets or one of the listed local address could be 1225b08fbf24SPaolo Abeni # used for 'add_addr' subflow 1226b08fbf24SPaolo Abeni reset 122734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 122834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 122934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 123034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1231b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1232b08fbf24SPaolo Abeni chk_join_nr "subflow and signal" 2 2 2 1233be613160SGeliang Tang chk_add_nr 1 1 1234b08fbf24SPaolo Abeni 1235b08fbf24SPaolo Abeni # accept and use add_addr with additional subflows 1236b08fbf24SPaolo Abeni reset 123734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 123834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 123934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 124034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 124134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 1242b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1243b08fbf24SPaolo Abeni chk_join_nr "multiple subflows and signal" 3 3 3 1244be613160SGeliang Tang chk_add_nr 1 1 1245ef360019SGeliang Tang 1246ef360019SGeliang Tang # signal addresses 1247ef360019SGeliang Tang reset 124834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 124934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 125034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 125134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 125234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1253ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1254ef360019SGeliang Tang chk_join_nr "signal addresses" 3 3 3 1255ef360019SGeliang Tang chk_add_nr 3 3 1256ef360019SGeliang Tang 1257ef360019SGeliang Tang # signal invalid addresses 1258ef360019SGeliang Tang reset 125934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 126034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 126134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 126234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 126334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1264ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1265ef360019SGeliang Tang chk_join_nr "signal invalid addresses" 1 1 1 1266ef360019SGeliang Tang chk_add_nr 3 3 126733c563adSYonglong Li 126833c563adSYonglong Li # signal addresses race test 126933c563adSYonglong Li reset 127034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 127134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 127234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.1.1 flags signal 127334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 127434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 127534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 127634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.1.2 flags signal 127734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags signal 127834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags signal 127934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags signal 128033c563adSYonglong Li run_tests $ns1 $ns2 10.0.1.1 1281857898ebSMatthieu Baerts chk_join_nr "signal addresses race test" 3 3 3 128286e39e04SPaolo Abeni 128386e39e04SPaolo Abeni # the server will not signal the address terminating 128486e39e04SPaolo Abeni # the MPC subflow 128586e39e04SPaolo Abeni chk_add_nr 3 3 12861002b89fSGeliang Tang} 1287b08fbf24SPaolo Abeni 12881002b89fSGeliang Tanglink_failure_tests() 12891002b89fSGeliang Tang{ 12908b819a84SFlorian Westphal # accept and use add_addr with additional subflows and link loss 12918b819a84SFlorian Westphal reset 12927d1e6f16SPaolo Abeni 12937d1e6f16SPaolo Abeni # without any b/w limit each veth could spool the packets and get 12947d1e6f16SPaolo Abeni # them acked at xmit time, so that the corresponding subflow will 12957d1e6f16SPaolo Abeni # have almost always no outstanding pkts, the scheduler will pick 12967d1e6f16SPaolo Abeni # always the first subflow and we will have hard time testing 12977d1e6f16SPaolo Abeni # active backup and link switch-over. 12987d1e6f16SPaolo Abeni # Let's set some arbitrary (low) virtual link limits. 12997d1e6f16SPaolo Abeni init_shapers 130034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 130134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 130234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 130334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow 130434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow 13058b819a84SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 1 13068b819a84SFlorian Westphal chk_join_nr "multiple flows, signal, link failure" 3 3 3 13078b819a84SFlorian Westphal chk_add_nr 1 1 13087d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 5 1 13097d1e6f16SPaolo Abeni 13107d1e6f16SPaolo Abeni # accept and use add_addr with additional subflows and link loss 13117d1e6f16SPaolo Abeni # for bidirectional transfer 13127d1e6f16SPaolo Abeni reset 13137d1e6f16SPaolo Abeni init_shapers 131434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 131534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 131634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 131734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow 131834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow 13197d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2 13207d1e6f16SPaolo Abeni chk_join_nr "multi flows, signal, bidi, link fail" 3 3 3 13217d1e6f16SPaolo Abeni chk_add_nr 1 1 13227d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 -1 1 13237d1e6f16SPaolo Abeni 13247d1e6f16SPaolo Abeni # 2 subflows plus 1 backup subflow with a lossy link, backup 13257d1e6f16SPaolo Abeni # will never be used 13267d1e6f16SPaolo Abeni reset 13277d1e6f16SPaolo Abeni init_shapers 132834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 132934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 133034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 13317d1e6f16SPaolo Abeni export FAILING_LINKS="1" 133234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 13337d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1 13347d1e6f16SPaolo Abeni chk_join_nr "backup subflow unused, link failure" 2 2 2 13357d1e6f16SPaolo Abeni chk_add_nr 1 1 13367d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 0 13377d1e6f16SPaolo Abeni 13387d1e6f16SPaolo Abeni # 2 lossy links after half transfer, backup will get half of 13397d1e6f16SPaolo Abeni # the traffic 13407d1e6f16SPaolo Abeni reset 13417d1e6f16SPaolo Abeni init_shapers 134234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 134334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 134434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 134534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 13467d1e6f16SPaolo Abeni export FAILING_LINKS="1 2" 13477d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1 13487d1e6f16SPaolo Abeni chk_join_nr "backup flow used, multi links fail" 2 2 2 13497d1e6f16SPaolo Abeni chk_add_nr 1 1 13507d1e6f16SPaolo Abeni chk_stale_nr $ns2 2 4 2 13517d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 50 13527d1e6f16SPaolo Abeni 13537d1e6f16SPaolo Abeni # use a backup subflow with the first subflow on a lossy link 13547d1e6f16SPaolo Abeni # for bidirectional transfer 13557d1e6f16SPaolo Abeni reset 13567d1e6f16SPaolo Abeni init_shapers 135734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 135834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 135934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 136034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 13617d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2 13627d1e6f16SPaolo Abeni chk_join_nr "backup flow used, bidi, link failure" 2 2 2 13637d1e6f16SPaolo Abeni chk_add_nr 1 1 13647d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 -1 2 13657d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 50 13661002b89fSGeliang Tang} 13678b819a84SFlorian Westphal 13681002b89fSGeliang Tangadd_addr_timeout_tests() 13691002b89fSGeliang Tang{ 13708d014eaaSGeliang Tang # add_addr timeout 13718d014eaaSGeliang Tang reset_with_add_addr_timeout 137234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 137334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 137434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 13758b819a84SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 13768d014eaaSGeliang Tang chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1 13778d014eaaSGeliang Tang chk_add_nr 4 0 13788d014eaaSGeliang Tang 13791002b89fSGeliang Tang # add_addr timeout IPv6 13801002b89fSGeliang Tang reset_with_add_addr_timeout 6 138134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 138234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 138334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 13841002b89fSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 13851002b89fSGeliang Tang chk_join_nr "signal address, ADD_ADDR6 timeout" 1 1 1 13861002b89fSGeliang Tang chk_add_nr 4 0 13878da6229bSGeliang Tang 13888da6229bSGeliang Tang # signal addresses timeout 13898da6229bSGeliang Tang reset_with_add_addr_timeout 139034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 139134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 139234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 139334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 13948da6229bSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 13958da6229bSGeliang Tang chk_join_nr "signal addresses, ADD_ADDR timeout" 2 2 2 13968da6229bSGeliang Tang chk_add_nr 8 0 13978da6229bSGeliang Tang 13988da6229bSGeliang Tang # signal invalid addresses timeout 13998da6229bSGeliang Tang reset_with_add_addr_timeout 140034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 140134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 140234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 140334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 14048da6229bSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 14058da6229bSGeliang Tang chk_join_nr "invalid address, ADD_ADDR timeout" 1 1 1 14068da6229bSGeliang Tang chk_add_nr 8 0 14071002b89fSGeliang Tang} 14081002b89fSGeliang Tang 14091002b89fSGeliang Tangremove_tests() 14101002b89fSGeliang Tang{ 1411dd72b0feSGeliang Tang # single subflow, remove 1412dd72b0feSGeliang Tang reset 141334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 141434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 141534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 14162e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -1 slow 1417dd72b0feSGeliang Tang chk_join_nr "remove single subflow" 1 1 1 1418dd72b0feSGeliang Tang chk_rm_nr 1 1 1419dd72b0feSGeliang Tang 1420dd72b0feSGeliang Tang # multiple subflows, remove 1421dd72b0feSGeliang Tang reset 142234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 142334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 142434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 142534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 14262e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -2 slow 1427dd72b0feSGeliang Tang chk_join_nr "remove multiple subflows" 2 2 2 1428dd72b0feSGeliang Tang chk_rm_nr 2 2 1429dd72b0feSGeliang Tang 1430dd72b0feSGeliang Tang # single address, remove 1431dd72b0feSGeliang Tang reset 143234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 143334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 143434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 14352e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 1436dd72b0feSGeliang Tang chk_join_nr "remove single address" 1 1 1 1437dd72b0feSGeliang Tang chk_add_nr 1 1 14387028ba8aSGeliang Tang chk_rm_nr 1 1 invert 1439dd72b0feSGeliang Tang 1440dd72b0feSGeliang Tang # subflow and signal, remove 1441dd72b0feSGeliang Tang reset 144234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 144334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 144434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 144534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 14462e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 1447dd72b0feSGeliang Tang chk_join_nr "remove subflow and signal" 2 2 2 1448dd72b0feSGeliang Tang chk_add_nr 1 1 1449dd72b0feSGeliang Tang chk_rm_nr 1 1 1450dd72b0feSGeliang Tang 1451dd72b0feSGeliang Tang # subflows and signal, remove 1452dd72b0feSGeliang Tang reset 145334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 145434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 145534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 145634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 145734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 14582e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -2 slow 1459dd72b0feSGeliang Tang chk_join_nr "remove subflows and signal" 3 3 3 1460dd72b0feSGeliang Tang chk_add_nr 1 1 1461dd72b0feSGeliang Tang chk_rm_nr 2 2 1462dd72b0feSGeliang Tang 1463ef360019SGeliang Tang # addresses remove 1464ef360019SGeliang Tang reset 146534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 146634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 146734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 146834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 146934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1470ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 1471ef360019SGeliang Tang chk_join_nr "remove addresses" 3 3 3 1472ef360019SGeliang Tang chk_add_nr 3 3 1473ef360019SGeliang Tang chk_rm_nr 3 3 invert 1474ef360019SGeliang Tang 1475ef360019SGeliang Tang # invalid addresses remove 1476ef360019SGeliang Tang reset 147734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 147834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 147934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 148034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 148134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1482ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 1483ef360019SGeliang Tang chk_join_nr "remove invalid addresses" 1 1 1 1484ef360019SGeliang Tang chk_add_nr 3 3 1485ef360019SGeliang Tang chk_rm_nr 3 1 invert 1486ef360019SGeliang Tang 14876fe4ccdcSGeliang Tang # subflows and signal, flush 14886fe4ccdcSGeliang Tang reset 148934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 149034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 149134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 149234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 149334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 14942e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 14956fe4ccdcSGeliang Tang chk_join_nr "flush subflows and signal" 3 3 3 14966fe4ccdcSGeliang Tang chk_add_nr 1 1 14976fe4ccdcSGeliang Tang chk_rm_nr 2 2 1498d2c4333aSGeliang Tang 1499d2c4333aSGeliang Tang # subflows flush 1500d2c4333aSGeliang Tang reset 150134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 150234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 150334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow id 150 150434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 150534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 1506d2c4333aSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1507d2c4333aSGeliang Tang chk_join_nr "flush subflows" 3 3 3 1508d2c4333aSGeliang Tang chk_rm_nr 3 3 1509d2c4333aSGeliang Tang 1510d2c4333aSGeliang Tang # addresses flush 1511d2c4333aSGeliang Tang reset 151234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 151334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 151434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 151534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 151634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1517d2c4333aSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1518d2c4333aSGeliang Tang chk_join_nr "flush addresses" 3 3 3 1519d2c4333aSGeliang Tang chk_add_nr 3 3 1520d2c4333aSGeliang Tang chk_rm_nr 3 3 invert 1521ef360019SGeliang Tang 1522ef360019SGeliang Tang # invalid addresses flush 1523ef360019SGeliang Tang reset 152434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 152534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 152634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 152734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 152834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1529ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 0 slow 1530ef360019SGeliang Tang chk_join_nr "flush invalid addresses" 1 1 1 1531ef360019SGeliang Tang chk_add_nr 3 3 1532ef360019SGeliang Tang chk_rm_nr 3 1 invert 15335e287fe7SGeliang Tang 15345e287fe7SGeliang Tang # remove id 0 subflow 15355e287fe7SGeliang Tang reset 153634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 153734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 153834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 15395e287fe7SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -9 slow 15405e287fe7SGeliang Tang chk_join_nr "remove id 0 subflow" 1 1 1 15415e287fe7SGeliang Tang chk_rm_nr 1 1 15425e287fe7SGeliang Tang 15435e287fe7SGeliang Tang # remove id 0 address 15445e287fe7SGeliang Tang reset 154534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 154634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 154734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 15485e287fe7SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -9 0 slow 15495e287fe7SGeliang Tang chk_join_nr "remove id 0 address" 1 1 1 15505e287fe7SGeliang Tang chk_add_nr 1 1 15515e287fe7SGeliang Tang chk_rm_nr 1 1 invert 15521002b89fSGeliang Tang} 15536fe4ccdcSGeliang Tang 15541002b89fSGeliang Tangadd_tests() 15551002b89fSGeliang Tang{ 15566208fd82SGeliang Tang # add single subflow 15576208fd82SGeliang Tang reset 155834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 155934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 15606208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow 15616208fd82SGeliang Tang chk_join_nr "add single subflow" 1 1 1 15626208fd82SGeliang Tang 15636208fd82SGeliang Tang # add signal address 15646208fd82SGeliang Tang reset 156534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 156634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 15676208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 15686208fd82SGeliang Tang chk_join_nr "add signal address" 1 1 1 15696208fd82SGeliang Tang chk_add_nr 1 1 15706208fd82SGeliang Tang 15716208fd82SGeliang Tang # add multiple subflows 15726208fd82SGeliang Tang reset 157334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 157434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 15756208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 2 slow 15766208fd82SGeliang Tang chk_join_nr "add multiple subflows" 2 2 2 15776208fd82SGeliang Tang 15786208fd82SGeliang Tang # add multiple subflows IPv6 15796208fd82SGeliang Tang reset 158034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 158134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 15826208fd82SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 2 slow 15836208fd82SGeliang Tang chk_join_nr "add multiple subflows IPv6" 2 2 2 15846208fd82SGeliang Tang 15856208fd82SGeliang Tang # add multiple addresses IPv6 15866208fd82SGeliang Tang reset 158734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 158834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 15896208fd82SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 2 0 slow 15906208fd82SGeliang Tang chk_join_nr "add multiple addresses IPv6" 2 2 2 15916208fd82SGeliang Tang chk_add_nr 2 2 15921002b89fSGeliang Tang} 15936208fd82SGeliang Tang 15941002b89fSGeliang Tangipv6_tests() 15951002b89fSGeliang Tang{ 1596523514edSGeliang Tang # subflow IPv6 1597523514edSGeliang Tang reset 159834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 159934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 160034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow 1601523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1602523514edSGeliang Tang chk_join_nr "single subflow IPv6" 1 1 1 1603523514edSGeliang Tang 1604523514edSGeliang Tang # add_address, unused IPv6 1605523514edSGeliang Tang reset 160634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 1607523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1608523514edSGeliang Tang chk_join_nr "unused signal address IPv6" 0 0 0 1609523514edSGeliang Tang chk_add_nr 1 1 1610523514edSGeliang Tang 1611523514edSGeliang Tang # signal address IPv6 1612523514edSGeliang Tang reset 161334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 161434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 161534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 1616523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1617523514edSGeliang Tang chk_join_nr "single address IPv6" 1 1 1 1618523514edSGeliang Tang chk_add_nr 1 1 1619523514edSGeliang Tang 1620523514edSGeliang Tang # single address IPv6, remove 1621523514edSGeliang Tang reset 162234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 162334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 162434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 16252e8cbf45SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 -1 0 slow 1626523514edSGeliang Tang chk_join_nr "remove single address IPv6" 1 1 1 1627523514edSGeliang Tang chk_add_nr 1 1 16287028ba8aSGeliang Tang chk_rm_nr 1 1 invert 1629523514edSGeliang Tang 1630523514edSGeliang Tang # subflow and signal IPv6, remove 1631523514edSGeliang Tang reset 163234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 163334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 163434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 163534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow 16362e8cbf45SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 -1 -1 slow 1637523514edSGeliang Tang chk_join_nr "remove subflow and signal IPv6" 2 2 2 1638523514edSGeliang Tang chk_add_nr 1 1 1639523514edSGeliang Tang chk_rm_nr 1 1 16401002b89fSGeliang Tang} 1641523514edSGeliang Tang 16421002b89fSGeliang Tangv4mapped_tests() 16431002b89fSGeliang Tang{ 1644a6094788SGeliang Tang # subflow IPv4-mapped to IPv4-mapped 1645a6094788SGeliang Tang reset 164634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 164734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 164834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow 1649a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1650a6094788SGeliang Tang chk_join_nr "single subflow IPv4-mapped" 1 1 1 1651a6094788SGeliang Tang 1652a6094788SGeliang Tang # signal address IPv4-mapped with IPv4-mapped sk 1653a6094788SGeliang Tang reset 165434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 165534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 165634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal 1657a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1658a6094788SGeliang Tang chk_join_nr "signal address IPv4-mapped" 1 1 1 1659a6094788SGeliang Tang chk_add_nr 1 1 1660a6094788SGeliang Tang 1661a6094788SGeliang Tang # subflow v4-map-v6 1662a6094788SGeliang Tang reset 166334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 166434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 166534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1666a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1667a6094788SGeliang Tang chk_join_nr "single subflow v4-map-v6" 1 1 1 1668a6094788SGeliang Tang 1669a6094788SGeliang Tang # signal address v4-map-v6 1670a6094788SGeliang Tang reset 167134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 167234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 167334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 1674a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1675a6094788SGeliang Tang chk_join_nr "signal address v4-map-v6" 1 1 1 1676a6094788SGeliang Tang chk_add_nr 1 1 1677a6094788SGeliang Tang 1678a6094788SGeliang Tang # subflow v6-map-v4 1679a6094788SGeliang Tang reset 168034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 168134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 168234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow 1683a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1684a6094788SGeliang Tang chk_join_nr "single subflow v6-map-v4" 1 1 1 1685a6094788SGeliang Tang 1686a6094788SGeliang Tang # signal address v6-map-v4 1687a6094788SGeliang Tang reset 168834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 168934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 169034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal 1691a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1692a6094788SGeliang Tang chk_join_nr "signal address v6-map-v4" 1 1 1 1693a6094788SGeliang Tang chk_add_nr 1 1 1694a6094788SGeliang Tang 1695a6094788SGeliang Tang # no subflow IPv6 to v4 address 1696a6094788SGeliang Tang reset 169734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 169834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 169934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow 1700a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1701a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v4-v6" 0 0 0 1702a6094788SGeliang Tang 1703a6094788SGeliang Tang # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end 1704a6094788SGeliang Tang reset 170534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 170634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 170734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:2::10.0.3.2 flags subflow 1708a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1709a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v4-v6-2" 0 0 0 1710a6094788SGeliang Tang 1711a6094788SGeliang Tang # no subflow IPv4 to v6 address, no need to slow down too then 1712a6094788SGeliang Tang reset 171334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 171434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 171534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1716a6094788SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 1717a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v6-v4" 0 0 0 17181002b89fSGeliang Tang} 1719a6094788SGeliang Tang 17201002b89fSGeliang Tangbackup_tests() 17211002b89fSGeliang Tang{ 1722718eb44eSGeliang Tang # single subflow, backup 1723718eb44eSGeliang Tang reset 172434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 172534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 172634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup 1727718eb44eSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup 1728718eb44eSGeliang Tang chk_join_nr "single subflow, backup" 1 1 1 1729718eb44eSGeliang Tang chk_prio_nr 0 1 1730718eb44eSGeliang Tang 1731718eb44eSGeliang Tang # single address, backup 1732718eb44eSGeliang Tang reset 173334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 173434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 173534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 1736718eb44eSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup 1737718eb44eSGeliang Tang chk_join_nr "single address, backup" 1 1 1 1738718eb44eSGeliang Tang chk_add_nr 1 1 1739718eb44eSGeliang Tang chk_prio_nr 1 0 174033397b83SGeliang Tang 174133397b83SGeliang Tang # single address with port, backup 174233397b83SGeliang Tang reset 174334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 174434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 174534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 174633397b83SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup 174733397b83SGeliang Tang chk_join_nr "single address with port, backup" 1 1 1 174833397b83SGeliang Tang chk_add_nr 1 1 174933397b83SGeliang Tang chk_prio_nr 1 0 17501002b89fSGeliang Tang} 1751718eb44eSGeliang Tang 17521002b89fSGeliang Tangadd_addr_ports_tests() 17531002b89fSGeliang Tang{ 17548a127bf6SGeliang Tang # signal address with port 17558a127bf6SGeliang Tang reset 175634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 175734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 175834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 17598a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 17608a127bf6SGeliang Tang chk_join_nr "signal address with port" 1 1 1 17618a127bf6SGeliang Tang chk_add_nr 1 1 1 17628a127bf6SGeliang Tang 17638a127bf6SGeliang Tang # subflow and signal with port 17648a127bf6SGeliang Tang reset 176534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 176634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 176734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 176834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 17698a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 17708a127bf6SGeliang Tang chk_join_nr "subflow and signal with port" 2 2 2 17718a127bf6SGeliang Tang chk_add_nr 1 1 1 17728a127bf6SGeliang Tang 17738a127bf6SGeliang Tang # single address with port, remove 17748a127bf6SGeliang Tang reset 177534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 177634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 177734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 17788a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 17798a127bf6SGeliang Tang chk_join_nr "remove single address with port" 1 1 1 17808a127bf6SGeliang Tang chk_add_nr 1 1 1 17817028ba8aSGeliang Tang chk_rm_nr 1 1 invert 17828a127bf6SGeliang Tang 17838a127bf6SGeliang Tang # subflow and signal with port, remove 17848a127bf6SGeliang Tang reset 178534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 178634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 178734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 178834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 17898a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 17908a127bf6SGeliang Tang chk_join_nr "remove subflow and signal with port" 2 2 2 17918a127bf6SGeliang Tang chk_add_nr 1 1 1 17928a127bf6SGeliang Tang chk_rm_nr 1 1 17938a127bf6SGeliang Tang 17948a127bf6SGeliang Tang # subflows and signal with port, flush 17958a127bf6SGeliang Tang reset 179634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 179734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 179834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 179934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 180034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 1801327b9a94SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 -8 -2 slow 18028a127bf6SGeliang Tang chk_join_nr "flush subflows and signal with port" 3 3 3 18038a127bf6SGeliang Tang chk_add_nr 1 1 18048a127bf6SGeliang Tang chk_rm_nr 2 2 18058a127bf6SGeliang Tang 18068a127bf6SGeliang Tang # multiple addresses with port 18078a127bf6SGeliang Tang reset 180834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 180934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 181034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10100 181134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 18128a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 18138a127bf6SGeliang Tang chk_join_nr "multiple addresses with port" 2 2 2 18148a127bf6SGeliang Tang chk_add_nr 2 2 2 18158a127bf6SGeliang Tang 18168a127bf6SGeliang Tang # multiple addresses with ports 18178a127bf6SGeliang Tang reset 181834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 181934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 182034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10101 182134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 18228a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 18238a127bf6SGeliang Tang chk_join_nr "multiple addresses with ports" 2 2 2 18248a127bf6SGeliang Tang chk_add_nr 2 2 2 18251002b89fSGeliang Tang} 18268a127bf6SGeliang Tang 18271002b89fSGeliang Tangsyncookies_tests() 18281002b89fSGeliang Tang{ 182900587187SFlorian Westphal # single subflow, syncookies 183000587187SFlorian Westphal reset_with_cookies 183134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 183234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 183334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 183400587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 183500587187SFlorian Westphal chk_join_nr "single subflow with syn cookies" 1 1 1 183600587187SFlorian Westphal 183700587187SFlorian Westphal # multiple subflows with syn cookies 183800587187SFlorian Westphal reset_with_cookies 183934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 184034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 184134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 184234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 184300587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 184400587187SFlorian Westphal chk_join_nr "multiple subflows with syn cookies" 2 2 2 184500587187SFlorian Westphal 184600587187SFlorian Westphal # multiple subflows limited by server 184700587187SFlorian Westphal reset_with_cookies 184834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 184934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 185034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 185134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 185200587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 1853a7da4416SJianguo Wu chk_join_nr "subflows limited by server w cookies" 2 1 1 185400587187SFlorian Westphal 185500587187SFlorian Westphal # test signal address with cookies 185600587187SFlorian Westphal reset_with_cookies 185734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 185834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 185934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 186000587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 186100587187SFlorian Westphal chk_join_nr "signal address with syn cookies" 1 1 1 1862be613160SGeliang Tang chk_add_nr 1 1 186300587187SFlorian Westphal 186400587187SFlorian Westphal # test cookie with subflow and signal 186500587187SFlorian Westphal reset_with_cookies 186634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 186734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 186834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 186934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 187000587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 187100587187SFlorian Westphal chk_join_nr "subflow and signal w cookies" 2 2 2 1872be613160SGeliang Tang chk_add_nr 1 1 187300587187SFlorian Westphal 187400587187SFlorian Westphal # accept and use add_addr with additional subflows 187500587187SFlorian Westphal reset_with_cookies 187634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 187734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 187834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 187934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 188034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 188100587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 188200587187SFlorian Westphal chk_join_nr "subflows and signal w. cookies" 3 3 3 1883be613160SGeliang Tang chk_add_nr 1 1 18841002b89fSGeliang Tang} 18851002b89fSGeliang Tang 1886af66d3e1SGeliang Tangchecksum_tests() 1887af66d3e1SGeliang Tang{ 1888af66d3e1SGeliang Tang # checksum test 0 0 1889af66d3e1SGeliang Tang reset_with_checksum 0 0 189034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 189134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1892af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1893af66d3e1SGeliang Tang chk_csum_nr "checksum test 0 0" 1894af66d3e1SGeliang Tang 1895af66d3e1SGeliang Tang # checksum test 1 1 1896af66d3e1SGeliang Tang reset_with_checksum 1 1 189734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 189834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1899af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1900af66d3e1SGeliang Tang chk_csum_nr "checksum test 1 1" 1901af66d3e1SGeliang Tang 1902af66d3e1SGeliang Tang # checksum test 0 1 1903af66d3e1SGeliang Tang reset_with_checksum 0 1 190434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 190534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1906af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1907af66d3e1SGeliang Tang chk_csum_nr "checksum test 0 1" 1908af66d3e1SGeliang Tang 1909af66d3e1SGeliang Tang # checksum test 1 0 1910af66d3e1SGeliang Tang reset_with_checksum 1 0 191134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 191234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1913af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1914af66d3e1SGeliang Tang chk_csum_nr "checksum test 1 0" 1915af66d3e1SGeliang Tang} 1916af66d3e1SGeliang Tang 19170cddb4a6SGeliang Tangdeny_join_id0_tests() 19180cddb4a6SGeliang Tang{ 19190cddb4a6SGeliang Tang # subflow allow join id0 ns1 19200cddb4a6SGeliang Tang reset_with_allow_join_id0 1 0 192134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 192234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 192334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19240cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19250cddb4a6SGeliang Tang chk_join_nr "single subflow allow join id0 ns1" 1 1 1 19260cddb4a6SGeliang Tang 19270cddb4a6SGeliang Tang # subflow allow join id0 ns2 19280cddb4a6SGeliang Tang reset_with_allow_join_id0 0 1 192934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 193034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 193134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19320cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19330cddb4a6SGeliang Tang chk_join_nr "single subflow allow join id0 ns2" 0 0 0 19340cddb4a6SGeliang Tang 19350cddb4a6SGeliang Tang # signal address allow join id0 ns1 19360cddb4a6SGeliang Tang # ADD_ADDRs are not affected by allow_join_id0 value. 19370cddb4a6SGeliang Tang reset_with_allow_join_id0 1 0 193834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 193934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 194034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 19410cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19420cddb4a6SGeliang Tang chk_join_nr "signal address allow join id0 ns1" 1 1 1 19430cddb4a6SGeliang Tang chk_add_nr 1 1 19440cddb4a6SGeliang Tang 19450cddb4a6SGeliang Tang # signal address allow join id0 ns2 19460cddb4a6SGeliang Tang # ADD_ADDRs are not affected by allow_join_id0 value. 19470cddb4a6SGeliang Tang reset_with_allow_join_id0 0 1 194834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 194934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 195034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 19510cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19520cddb4a6SGeliang Tang chk_join_nr "signal address allow join id0 ns2" 1 1 1 19530cddb4a6SGeliang Tang chk_add_nr 1 1 19540cddb4a6SGeliang Tang 19550cddb4a6SGeliang Tang # subflow and address allow join id0 ns1 19560cddb4a6SGeliang Tang reset_with_allow_join_id0 1 0 195734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 195834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 195934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 196034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19610cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19620cddb4a6SGeliang Tang chk_join_nr "subflow and address allow join id0 1" 2 2 2 19630cddb4a6SGeliang Tang 19640cddb4a6SGeliang Tang # subflow and address allow join id0 ns2 19650cddb4a6SGeliang Tang reset_with_allow_join_id0 0 1 196634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 196734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 196834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 196934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19700cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19710cddb4a6SGeliang Tang chk_join_nr "subflow and address allow join id0 2" 1 1 1 19720cddb4a6SGeliang Tang} 19730cddb4a6SGeliang Tang 19744f49d633SGeliang Tangfullmesh_tests() 19754f49d633SGeliang Tang{ 19764f49d633SGeliang Tang # fullmesh 1 19774f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added before the connection, 19784f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added during the connection. 19794f49d633SGeliang Tang reset 198034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 4 198134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 4 198234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,fullmesh 198334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,fullmesh 19844f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 19854f49d633SGeliang Tang chk_join_nr "fullmesh test 2x1" 4 4 4 19864f49d633SGeliang Tang chk_add_nr 1 1 19874f49d633SGeliang Tang 19884f49d633SGeliang Tang # fullmesh 2 19894f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 19904f49d633SGeliang Tang # 1 fullmesh addr in ns2, added during the connection. 19914f49d633SGeliang Tang reset 199234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 3 199334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 199434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 19954f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow 19964f49d633SGeliang Tang chk_join_nr "fullmesh test 1x1" 3 3 3 19974f49d633SGeliang Tang chk_add_nr 1 1 19984f49d633SGeliang Tang 19994f49d633SGeliang Tang # fullmesh 3 20004f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 20014f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added during the connection. 20024f49d633SGeliang Tang reset 200334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 5 200434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 5 200534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 20064f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow 20074f49d633SGeliang Tang chk_join_nr "fullmesh test 1x2" 5 5 5 20084f49d633SGeliang Tang chk_add_nr 1 1 20094f49d633SGeliang Tang 20104f49d633SGeliang Tang # fullmesh 4 20114f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 20124f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added during the connection, 20134f49d633SGeliang Tang # limit max_subflows to 4. 20144f49d633SGeliang Tang reset 201534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 4 201634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 4 201734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 20184f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow 20194f49d633SGeliang Tang chk_join_nr "fullmesh test 1x2, limited" 4 4 4 20204f49d633SGeliang Tang chk_add_nr 1 1 20216a0653b9SGeliang Tang 20226a0653b9SGeliang Tang # set fullmesh flag 20236a0653b9SGeliang Tang reset 202434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 202534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow 202634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 20276a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow fullmesh 20286a0653b9SGeliang Tang chk_join_nr "set fullmesh flag test" 2 2 2 20296a0653b9SGeliang Tang chk_rm_nr 0 1 20306a0653b9SGeliang Tang 20316a0653b9SGeliang Tang # set nofullmesh flag 20326a0653b9SGeliang Tang reset 203334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 203434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow,fullmesh 203534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 20366a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow nofullmesh 20376a0653b9SGeliang Tang chk_join_nr "set nofullmesh flag test" 2 2 2 20386a0653b9SGeliang Tang chk_rm_nr 0 1 20396a0653b9SGeliang Tang 20406a0653b9SGeliang Tang # set backup,fullmesh flags 20416a0653b9SGeliang Tang reset 204234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 204334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow 204434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 20456a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow backup,fullmesh 20466a0653b9SGeliang Tang chk_join_nr "set backup,fullmesh flags test" 2 2 2 20476a0653b9SGeliang Tang chk_prio_nr 0 1 20486a0653b9SGeliang Tang chk_rm_nr 0 1 20496a0653b9SGeliang Tang 20506a0653b9SGeliang Tang # set nobackup,nofullmesh flags 20516a0653b9SGeliang Tang reset 205234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 205334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 205434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,backup,fullmesh 20556a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup,nofullmesh 20566a0653b9SGeliang Tang chk_join_nr "set nobackup,nofullmesh flags test" 2 2 2 20576a0653b9SGeliang Tang chk_prio_nr 0 1 20586a0653b9SGeliang Tang chk_rm_nr 0 1 20594f49d633SGeliang Tang} 20604f49d633SGeliang Tang 20611002b89fSGeliang Tangall_tests() 20621002b89fSGeliang Tang{ 20631002b89fSGeliang Tang subflows_tests 206446e967d1SPaolo Abeni subflows_error_tests 20651002b89fSGeliang Tang signal_address_tests 20661002b89fSGeliang Tang link_failure_tests 20671002b89fSGeliang Tang add_addr_timeout_tests 20681002b89fSGeliang Tang remove_tests 20691002b89fSGeliang Tang add_tests 20701002b89fSGeliang Tang ipv6_tests 20711002b89fSGeliang Tang v4mapped_tests 20721002b89fSGeliang Tang backup_tests 20731002b89fSGeliang Tang add_addr_ports_tests 20741002b89fSGeliang Tang syncookies_tests 2075af66d3e1SGeliang Tang checksum_tests 20760cddb4a6SGeliang Tang deny_join_id0_tests 20774f49d633SGeliang Tang fullmesh_tests 20781002b89fSGeliang Tang} 20791002b89fSGeliang Tang 20801002b89fSGeliang Tangusage() 20811002b89fSGeliang Tang{ 20821002b89fSGeliang Tang echo "mptcp_join usage:" 20831002b89fSGeliang Tang echo " -f subflows_tests" 208446e967d1SPaolo Abeni echo " -e subflows_error_tests" 20851002b89fSGeliang Tang echo " -s signal_address_tests" 20861002b89fSGeliang Tang echo " -l link_failure_tests" 20871002b89fSGeliang Tang echo " -t add_addr_timeout_tests" 20881002b89fSGeliang Tang echo " -r remove_tests" 20891002b89fSGeliang Tang echo " -a add_tests" 20901002b89fSGeliang Tang echo " -6 ipv6_tests" 20911002b89fSGeliang Tang echo " -4 v4mapped_tests" 20921002b89fSGeliang Tang echo " -b backup_tests" 20931002b89fSGeliang Tang echo " -p add_addr_ports_tests" 2094a673321aSMat Martineau echo " -k syncookies_tests" 2095af66d3e1SGeliang Tang echo " -S checksum_tests" 20960cddb4a6SGeliang Tang echo " -d deny_join_id0_tests" 20974f49d633SGeliang Tang echo " -m fullmesh_tests" 2098a673321aSMat Martineau echo " -c capture pcap files" 2099af66d3e1SGeliang Tang echo " -C enable data checksum" 2100621bd393SGeliang Tang echo " -i use ip mptcp" 21011002b89fSGeliang Tang echo " -h help" 21021002b89fSGeliang Tang} 21031002b89fSGeliang Tang 21041002b89fSGeliang Tangsin=$(mktemp) 21051002b89fSGeliang Tangsout=$(mktemp) 21061002b89fSGeliang Tangcin=$(mktemp) 21071002b89fSGeliang Tangcinsent=$(mktemp) 21081002b89fSGeliang Tangcout=$(mktemp) 21091002b89fSGeliang Tanginit 21101002b89fSGeliang Tangmake_file "$cin" "client" 1 21111002b89fSGeliang Tangmake_file "$sin" "server" 1 21121002b89fSGeliang Tangtrap cleanup EXIT 21131002b89fSGeliang Tang 2114a673321aSMat Martineaufor arg in "$@"; do 2115af66d3e1SGeliang Tang # check for "capture/checksum" args before launching tests 2116a673321aSMat Martineau if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"c"[0-9a-zA-Z]*$ ]]; then 2117a673321aSMat Martineau capture=1 2118a673321aSMat Martineau fi 2119af66d3e1SGeliang Tang if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"C"[0-9a-zA-Z]*$ ]]; then 2120af66d3e1SGeliang Tang checksum=1 2121af66d3e1SGeliang Tang fi 2122621bd393SGeliang Tang if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"i"[0-9a-zA-Z]*$ ]]; then 2123621bd393SGeliang Tang ip_mptcp=1 2124621bd393SGeliang Tang fi 2125a673321aSMat Martineau 2126621bd393SGeliang Tang # exception for the capture/checksum/ip_mptcp options, the rest means: a part of the tests 2127621bd393SGeliang Tang if [ "${arg}" != "-c" ] && [ "${arg}" != "-C" ] && [ "${arg}" != "-i" ]; then 2128a673321aSMat Martineau do_all_tests=0 2129a673321aSMat Martineau fi 2130a673321aSMat Martineaudone 2131a673321aSMat Martineau 2132a673321aSMat Martineauif [ $do_all_tests -eq 1 ]; then 21331002b89fSGeliang Tang all_tests 21341002b89fSGeliang Tang exit $ret 21351002b89fSGeliang Tangfi 21361002b89fSGeliang Tang 2137621bd393SGeliang Tangwhile getopts 'fesltra64bpkdmchCSi' opt; do 21381002b89fSGeliang Tang case $opt in 21391002b89fSGeliang Tang f) 21401002b89fSGeliang Tang subflows_tests 21411002b89fSGeliang Tang ;; 214246e967d1SPaolo Abeni e) 214346e967d1SPaolo Abeni subflows_error_tests 214446e967d1SPaolo Abeni ;; 21451002b89fSGeliang Tang s) 21461002b89fSGeliang Tang signal_address_tests 21471002b89fSGeliang Tang ;; 21481002b89fSGeliang Tang l) 21491002b89fSGeliang Tang link_failure_tests 21501002b89fSGeliang Tang ;; 21511002b89fSGeliang Tang t) 21521002b89fSGeliang Tang add_addr_timeout_tests 21531002b89fSGeliang Tang ;; 21541002b89fSGeliang Tang r) 21551002b89fSGeliang Tang remove_tests 21561002b89fSGeliang Tang ;; 21571002b89fSGeliang Tang a) 21581002b89fSGeliang Tang add_tests 21591002b89fSGeliang Tang ;; 21601002b89fSGeliang Tang 6) 21611002b89fSGeliang Tang ipv6_tests 21621002b89fSGeliang Tang ;; 21631002b89fSGeliang Tang 4) 21641002b89fSGeliang Tang v4mapped_tests 21651002b89fSGeliang Tang ;; 21661002b89fSGeliang Tang b) 21671002b89fSGeliang Tang backup_tests 21681002b89fSGeliang Tang ;; 21691002b89fSGeliang Tang p) 21701002b89fSGeliang Tang add_addr_ports_tests 21711002b89fSGeliang Tang ;; 2172a673321aSMat Martineau k) 21731002b89fSGeliang Tang syncookies_tests 21741002b89fSGeliang Tang ;; 2175af66d3e1SGeliang Tang S) 2176af66d3e1SGeliang Tang checksum_tests 2177af66d3e1SGeliang Tang ;; 21780cddb4a6SGeliang Tang d) 21790cddb4a6SGeliang Tang deny_join_id0_tests 21800cddb4a6SGeliang Tang ;; 21814f49d633SGeliang Tang m) 21824f49d633SGeliang Tang fullmesh_tests 21834f49d633SGeliang Tang ;; 2184a673321aSMat Martineau c) 2185a673321aSMat Martineau ;; 2186af66d3e1SGeliang Tang C) 2187af66d3e1SGeliang Tang ;; 2188621bd393SGeliang Tang i) 2189621bd393SGeliang Tang ;; 21901002b89fSGeliang Tang h | *) 21911002b89fSGeliang Tang usage 21921002b89fSGeliang Tang ;; 21931002b89fSGeliang Tang esac 21941002b89fSGeliang Tangdone 219500587187SFlorian Westphal 2196b08fbf24SPaolo Abeniexit $ret 2197