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 2093827ad5SMatthieu Baertsinit=0 21b08fbf24SPaolo Abeni 22b08fbf24SPaolo AbeniTEST_COUNT=0 23b08fbf24SPaolo Abeni 248d014eaaSGeliang Tang# generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) || 258d014eaaSGeliang Tang# (ip6 && (ip6[74] & 0xf0) == 0x30)'" 268d014eaaSGeliang TangCBPF_MPTCP_SUBOPTION_ADD_ADDR="14, 278d014eaaSGeliang Tang 48 0 0 0, 288d014eaaSGeliang Tang 84 0 0 240, 298d014eaaSGeliang Tang 21 0 3 64, 308d014eaaSGeliang Tang 48 0 0 54, 318d014eaaSGeliang Tang 84 0 0 240, 328d014eaaSGeliang Tang 21 6 7 48, 338d014eaaSGeliang Tang 48 0 0 0, 348d014eaaSGeliang Tang 84 0 0 240, 358d014eaaSGeliang Tang 21 0 4 96, 368d014eaaSGeliang Tang 48 0 0 74, 378d014eaaSGeliang Tang 84 0 0 240, 388d014eaaSGeliang Tang 21 0 1 48, 398d014eaaSGeliang Tang 6 0 0 65535, 408d014eaaSGeliang Tang 6 0 0 0" 418d014eaaSGeliang Tang 4293827ad5SMatthieu Baertsinit_partial() 43b08fbf24SPaolo Abeni{ 44b08fbf24SPaolo Abeni capout=$(mktemp) 45b08fbf24SPaolo Abeni 460a40e273SMatthieu Baerts rndh=$(mktemp -u XXXXXX) 47b08fbf24SPaolo Abeni 48b08fbf24SPaolo Abeni ns1="ns1-$rndh" 49b08fbf24SPaolo Abeni ns2="ns2-$rndh" 50b08fbf24SPaolo Abeni 51b08fbf24SPaolo Abeni for netns in "$ns1" "$ns2";do 52b08fbf24SPaolo Abeni ip netns add $netns || exit $ksft_skip 53b08fbf24SPaolo Abeni ip -net $netns link set lo up 54b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.mptcp.enabled=1 55b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 56b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 57af66d3e1SGeliang Tang if [ $checksum -eq 1 ]; then 58af66d3e1SGeliang Tang ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1 59af66d3e1SGeliang Tang fi 60b08fbf24SPaolo Abeni done 61b08fbf24SPaolo Abeni 62b08fbf24SPaolo Abeni # ns1 ns2 63b08fbf24SPaolo Abeni # ns1eth1 ns2eth1 64b08fbf24SPaolo Abeni # ns1eth2 ns2eth2 65b08fbf24SPaolo Abeni # ns1eth3 ns2eth3 66b08fbf24SPaolo Abeni # ns1eth4 ns2eth4 67b08fbf24SPaolo Abeni 68b08fbf24SPaolo Abeni for i in `seq 1 4`; do 69b08fbf24SPaolo Abeni ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2" 70b08fbf24SPaolo Abeni ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i 71b08fbf24SPaolo Abeni ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad 72b08fbf24SPaolo Abeni ip -net "$ns1" link set ns1eth$i up 73b08fbf24SPaolo Abeni 74b08fbf24SPaolo Abeni ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i 75b08fbf24SPaolo Abeni ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad 76b08fbf24SPaolo Abeni ip -net "$ns2" link set ns2eth$i up 77b08fbf24SPaolo Abeni 78b08fbf24SPaolo Abeni # let $ns2 reach any $ns1 address from any interface 79b08fbf24SPaolo Abeni ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i 809846921dSPaolo Abeni ip -net "$ns2" route add default via dead:beef:$i::1 dev ns2eth$i metric 10$i 81b08fbf24SPaolo Abeni done 82b08fbf24SPaolo Abeni} 83b08fbf24SPaolo Abeni 847d1e6f16SPaolo Abeniinit_shapers() 857d1e6f16SPaolo Abeni{ 867d1e6f16SPaolo Abeni for i in `seq 1 4`; do 877d1e6f16SPaolo Abeni tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1 887d1e6f16SPaolo Abeni tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1 897d1e6f16SPaolo Abeni done 907d1e6f16SPaolo Abeni} 917d1e6f16SPaolo Abeni 92b08fbf24SPaolo Abenicleanup_partial() 93b08fbf24SPaolo Abeni{ 94b08fbf24SPaolo Abeni rm -f "$capout" 95b08fbf24SPaolo Abeni 96b08fbf24SPaolo Abeni for netns in "$ns1" "$ns2"; do 97b08fbf24SPaolo Abeni ip netns del $netns 98c2a55e8fSMatthieu Baerts rm -f /tmp/$netns.{nstat,out} 99b08fbf24SPaolo Abeni done 100b08fbf24SPaolo Abeni} 101b08fbf24SPaolo Abeni 102*87154755SMatthieu Baertscheck_tools() 103*87154755SMatthieu Baerts{ 104*87154755SMatthieu Baerts if ! ip -Version &> /dev/null; then 105*87154755SMatthieu Baerts echo "SKIP: Could not run test without ip tool" 106*87154755SMatthieu Baerts exit $ksft_skip 107*87154755SMatthieu Baerts fi 108*87154755SMatthieu Baerts 109*87154755SMatthieu Baerts if ! iptables -V &> /dev/null; then 110*87154755SMatthieu Baerts echo "SKIP: Could not run all tests without iptables tool" 111*87154755SMatthieu Baerts exit $ksft_skip 112*87154755SMatthieu Baerts fi 113*87154755SMatthieu Baerts 114*87154755SMatthieu Baerts if ! ip6tables -V &> /dev/null; then 115*87154755SMatthieu Baerts echo "SKIP: Could not run all tests without ip6tables tool" 116*87154755SMatthieu Baerts exit $ksft_skip 117*87154755SMatthieu Baerts fi 118*87154755SMatthieu Baerts} 119*87154755SMatthieu Baerts 12093827ad5SMatthieu Baertsinit() { 12193827ad5SMatthieu Baerts init=1 12293827ad5SMatthieu Baerts 123*87154755SMatthieu Baerts check_tools 124*87154755SMatthieu Baerts 12593827ad5SMatthieu Baerts sin=$(mktemp) 12693827ad5SMatthieu Baerts sout=$(mktemp) 12793827ad5SMatthieu Baerts cin=$(mktemp) 12893827ad5SMatthieu Baerts cinsent=$(mktemp) 12993827ad5SMatthieu Baerts cout=$(mktemp) 13093827ad5SMatthieu Baerts 13193827ad5SMatthieu Baerts trap cleanup EXIT 13293827ad5SMatthieu Baerts 13393827ad5SMatthieu Baerts make_file "$cin" "client" 1 13493827ad5SMatthieu Baerts make_file "$sin" "server" 1 13593827ad5SMatthieu Baerts} 13693827ad5SMatthieu Baerts 137b08fbf24SPaolo Abenicleanup() 138b08fbf24SPaolo Abeni{ 1397d1e6f16SPaolo Abeni rm -f "$cin" "$cout" "$sinfail" 1407d1e6f16SPaolo Abeni rm -f "$sin" "$sout" "$cinsent" "$cinfail" 141b08fbf24SPaolo Abeni cleanup_partial 142b08fbf24SPaolo Abeni} 143b08fbf24SPaolo Abeni 144b08fbf24SPaolo Abenireset() 145b08fbf24SPaolo Abeni{ 14693827ad5SMatthieu Baerts if [ "${init}" != "1" ]; then 147b08fbf24SPaolo Abeni init 14893827ad5SMatthieu Baerts else 14993827ad5SMatthieu Baerts cleanup_partial 15093827ad5SMatthieu Baerts fi 15193827ad5SMatthieu Baerts 15293827ad5SMatthieu Baerts init_partial 153b08fbf24SPaolo Abeni} 154b08fbf24SPaolo Abeni 15500587187SFlorian Westphalreset_with_cookies() 15600587187SFlorian Westphal{ 15700587187SFlorian Westphal reset 15800587187SFlorian Westphal 15900587187SFlorian Westphal for netns in "$ns1" "$ns2";do 16000587187SFlorian Westphal ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2 16100587187SFlorian Westphal done 16200587187SFlorian Westphal} 16300587187SFlorian Westphal 1648d014eaaSGeliang Tangreset_with_add_addr_timeout() 1658d014eaaSGeliang Tang{ 1668d014eaaSGeliang Tang local ip="${1:-4}" 1678d014eaaSGeliang Tang local tables 1688d014eaaSGeliang Tang 1698d014eaaSGeliang Tang tables="iptables" 1708d014eaaSGeliang Tang if [ $ip -eq 6 ]; then 1718d014eaaSGeliang Tang tables="ip6tables" 1728d014eaaSGeliang Tang fi 1738d014eaaSGeliang Tang 1748d014eaaSGeliang Tang reset 1758d014eaaSGeliang Tang 1768d014eaaSGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 1778d014eaaSGeliang Tang ip netns exec $ns2 $tables -A OUTPUT -p tcp \ 1788d014eaaSGeliang Tang -m tcp --tcp-option 30 \ 1798d014eaaSGeliang Tang -m bpf --bytecode \ 1808d014eaaSGeliang Tang "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \ 1818d014eaaSGeliang Tang -j DROP 1828d014eaaSGeliang Tang} 1838d014eaaSGeliang Tang 184af66d3e1SGeliang Tangreset_with_checksum() 185af66d3e1SGeliang Tang{ 186af66d3e1SGeliang Tang local ns1_enable=$1 187af66d3e1SGeliang Tang local ns2_enable=$2 188af66d3e1SGeliang Tang 189af66d3e1SGeliang Tang reset 190af66d3e1SGeliang Tang 191af66d3e1SGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=$ns1_enable 192af66d3e1SGeliang Tang ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=$ns2_enable 193af66d3e1SGeliang Tang} 194af66d3e1SGeliang Tang 1950cddb4a6SGeliang Tangreset_with_allow_join_id0() 1960cddb4a6SGeliang Tang{ 1970cddb4a6SGeliang Tang local ns1_enable=$1 1980cddb4a6SGeliang Tang local ns2_enable=$2 1990cddb4a6SGeliang Tang 2000cddb4a6SGeliang Tang reset 2010cddb4a6SGeliang Tang 2020cddb4a6SGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns1_enable 2030cddb4a6SGeliang Tang ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable 2040cddb4a6SGeliang Tang} 2050cddb4a6SGeliang Tang 2068b819a84SFlorian Westphalprint_file_err() 2078b819a84SFlorian Westphal{ 2088b819a84SFlorian Westphal ls -l "$1" 1>&2 2098b819a84SFlorian Westphal echo "Trailing bytes are: " 2108b819a84SFlorian Westphal tail -c 27 "$1" 2118b819a84SFlorian Westphal} 2128b819a84SFlorian Westphal 213b08fbf24SPaolo Abenicheck_transfer() 214b08fbf24SPaolo Abeni{ 215b08fbf24SPaolo Abeni in=$1 216b08fbf24SPaolo Abeni out=$2 217b08fbf24SPaolo Abeni what=$3 218b08fbf24SPaolo Abeni 219b08fbf24SPaolo Abeni cmp "$in" "$out" > /dev/null 2>&1 220b08fbf24SPaolo Abeni if [ $? -ne 0 ] ;then 221b08fbf24SPaolo Abeni echo "[ FAIL ] $what does not match (in, out):" 222b08fbf24SPaolo Abeni print_file_err "$in" 223b08fbf24SPaolo Abeni print_file_err "$out" 2248b819a84SFlorian Westphal ret=1 225b08fbf24SPaolo Abeni 226b08fbf24SPaolo Abeni return 1 227b08fbf24SPaolo Abeni fi 228b08fbf24SPaolo Abeni 229b08fbf24SPaolo Abeni return 0 230b08fbf24SPaolo Abeni} 231b08fbf24SPaolo Abeni 232b08fbf24SPaolo Abenido_ping() 233b08fbf24SPaolo Abeni{ 234b08fbf24SPaolo Abeni listener_ns="$1" 235b08fbf24SPaolo Abeni connector_ns="$2" 236b08fbf24SPaolo Abeni connect_addr="$3" 237b08fbf24SPaolo Abeni 238b08fbf24SPaolo Abeni ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null 239b08fbf24SPaolo Abeni if [ $? -ne 0 ] ; then 240b08fbf24SPaolo Abeni echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2 241b08fbf24SPaolo Abeni ret=1 242b08fbf24SPaolo Abeni fi 243b08fbf24SPaolo Abeni} 244b08fbf24SPaolo Abeni 2458b819a84SFlorian Westphallink_failure() 2468b819a84SFlorian Westphal{ 2478b819a84SFlorian Westphal ns="$1" 2488b819a84SFlorian Westphal 2497d1e6f16SPaolo Abeni if [ -z "$FAILING_LINKS" ]; then 2508b819a84SFlorian Westphal l=$((RANDOM%4)) 2517d1e6f16SPaolo Abeni FAILING_LINKS=$((l+1)) 2527d1e6f16SPaolo Abeni fi 2538b819a84SFlorian Westphal 2547d1e6f16SPaolo Abeni for l in $FAILING_LINKS; do 2558b819a84SFlorian Westphal veth="ns1eth$l" 2568b819a84SFlorian Westphal ip -net "$ns" link set "$veth" down 2577d1e6f16SPaolo Abeni done 2588b819a84SFlorian Westphal} 2598b819a84SFlorian Westphal 260523514edSGeliang Tang# $1: IP address 261523514edSGeliang Tangis_v6() 262523514edSGeliang Tang{ 263523514edSGeliang Tang [ -z "${1##*:*}" ] 264523514edSGeliang Tang} 265523514edSGeliang Tang 266327b9a94SPaolo Abeni# $1: ns, $2: port 267327b9a94SPaolo Abeniwait_local_port_listen() 268327b9a94SPaolo Abeni{ 269327b9a94SPaolo Abeni local listener_ns="${1}" 270327b9a94SPaolo Abeni local port="${2}" 271327b9a94SPaolo Abeni 272327b9a94SPaolo Abeni local port_hex i 273327b9a94SPaolo Abeni 274327b9a94SPaolo Abeni port_hex="$(printf "%04X" "${port}")" 275327b9a94SPaolo Abeni for i in $(seq 10); do 276327b9a94SPaolo Abeni ip netns exec "${listener_ns}" cat /proc/net/tcp* | \ 277327b9a94SPaolo Abeni awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" && 278327b9a94SPaolo Abeni break 279327b9a94SPaolo Abeni sleep 0.1 280327b9a94SPaolo Abeni done 281327b9a94SPaolo Abeni} 282327b9a94SPaolo Abeni 283327b9a94SPaolo Abenirm_addr_count() 284327b9a94SPaolo Abeni{ 285327b9a94SPaolo Abeni ns=${1} 286327b9a94SPaolo Abeni 287327b9a94SPaolo Abeni ip netns exec ${ns} nstat -as | grep MPTcpExtRmAddr | awk '{print $2}' 288327b9a94SPaolo Abeni} 289327b9a94SPaolo Abeni 290327b9a94SPaolo Abeni# $1: ns, $2: old rm_addr counter in $ns 291327b9a94SPaolo Abeniwait_rm_addr() 292327b9a94SPaolo Abeni{ 293327b9a94SPaolo Abeni local ns="${1}" 294327b9a94SPaolo Abeni local old_cnt="${2}" 295327b9a94SPaolo Abeni local cnt 296327b9a94SPaolo Abeni local i 297327b9a94SPaolo Abeni 298327b9a94SPaolo Abeni for i in $(seq 10); do 299327b9a94SPaolo Abeni cnt=$(rm_addr_count ${ns}) 300327b9a94SPaolo Abeni [ "$cnt" = "${old_cnt}" ] || break 301327b9a94SPaolo Abeni sleep 0.1 302327b9a94SPaolo Abeni done 303327b9a94SPaolo Abeni} 304327b9a94SPaolo Abeni 30534aa6e3bSGeliang Tangpm_nl_set_limits() 30634aa6e3bSGeliang Tang{ 30734aa6e3bSGeliang Tang local ns=$1 30834aa6e3bSGeliang Tang local addrs=$2 30934aa6e3bSGeliang Tang local subflows=$3 31034aa6e3bSGeliang Tang 31134aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 31234aa6e3bSGeliang Tang ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows 31334aa6e3bSGeliang Tang else 31434aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows 31534aa6e3bSGeliang Tang fi 31634aa6e3bSGeliang Tang} 31734aa6e3bSGeliang Tang 31834aa6e3bSGeliang Tangpm_nl_add_endpoint() 31934aa6e3bSGeliang Tang{ 32034aa6e3bSGeliang Tang local ns=$1 32134aa6e3bSGeliang Tang local addr=$2 32234aa6e3bSGeliang Tang local flags 32334aa6e3bSGeliang Tang local port 32434aa6e3bSGeliang Tang local dev 32534aa6e3bSGeliang Tang local id 32634aa6e3bSGeliang Tang local nr=2 32734aa6e3bSGeliang Tang 32834aa6e3bSGeliang Tang for p in $@ 32934aa6e3bSGeliang Tang do 33034aa6e3bSGeliang Tang if [ $p = "flags" ]; then 33134aa6e3bSGeliang Tang eval _flags=\$"$nr" 33234aa6e3bSGeliang Tang [ ! -z $_flags ]; flags="flags $_flags" 33334aa6e3bSGeliang Tang fi 33434aa6e3bSGeliang Tang if [ $p = "dev" ]; then 33534aa6e3bSGeliang Tang eval _dev=\$"$nr" 33634aa6e3bSGeliang Tang [ ! -z $_dev ]; dev="dev $_dev" 33734aa6e3bSGeliang Tang fi 33834aa6e3bSGeliang Tang if [ $p = "id" ]; then 33934aa6e3bSGeliang Tang eval _id=\$"$nr" 34034aa6e3bSGeliang Tang [ ! -z $_id ]; id="id $_id" 34134aa6e3bSGeliang Tang fi 34234aa6e3bSGeliang Tang if [ $p = "port" ]; then 34334aa6e3bSGeliang Tang eval _port=\$"$nr" 34434aa6e3bSGeliang Tang [ ! -z $_port ]; port="port $_port" 34534aa6e3bSGeliang Tang fi 34634aa6e3bSGeliang Tang 34734aa6e3bSGeliang Tang let nr+=1 34834aa6e3bSGeliang Tang done 34934aa6e3bSGeliang Tang 35034aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 35134aa6e3bSGeliang Tang ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port 35234aa6e3bSGeliang Tang else 35334aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port 35434aa6e3bSGeliang Tang fi 35534aa6e3bSGeliang Tang} 35634aa6e3bSGeliang Tang 35734aa6e3bSGeliang Tangpm_nl_del_endpoint() 35834aa6e3bSGeliang Tang{ 35934aa6e3bSGeliang Tang local ns=$1 36034aa6e3bSGeliang Tang local id=$2 36134aa6e3bSGeliang Tang local addr=$3 36234aa6e3bSGeliang Tang 36334aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 36434aa6e3bSGeliang Tang ip -n $ns mptcp endpoint delete id $id $addr 36534aa6e3bSGeliang Tang else 36634aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl del $id $addr 36734aa6e3bSGeliang Tang fi 36834aa6e3bSGeliang Tang} 36934aa6e3bSGeliang Tang 37034aa6e3bSGeliang Tangpm_nl_flush_endpoint() 37134aa6e3bSGeliang Tang{ 37234aa6e3bSGeliang Tang local ns=$1 37334aa6e3bSGeliang Tang 37434aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 37534aa6e3bSGeliang Tang ip -n $ns mptcp endpoint flush 37634aa6e3bSGeliang Tang else 37734aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl flush 37834aa6e3bSGeliang Tang fi 37934aa6e3bSGeliang Tang} 38034aa6e3bSGeliang Tang 381dda61b3dSGeliang Tangpm_nl_show_endpoints() 382dda61b3dSGeliang Tang{ 383dda61b3dSGeliang Tang local ns=$1 384dda61b3dSGeliang Tang 385dda61b3dSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 386dda61b3dSGeliang Tang ip -n $ns mptcp endpoint show 387dda61b3dSGeliang Tang else 388dda61b3dSGeliang Tang ip netns exec $ns ./pm_nl_ctl dump 389dda61b3dSGeliang Tang fi 390dda61b3dSGeliang Tang} 391dda61b3dSGeliang Tang 392f0140386SGeliang Tangpm_nl_change_endpoint() 393f0140386SGeliang Tang{ 394f0140386SGeliang Tang local ns=$1 395bccefb76SGeliang Tang local id=$2 396bccefb76SGeliang Tang local flags=$3 397f0140386SGeliang Tang 398f0140386SGeliang Tang if [ $ip_mptcp -eq 1 ]; then 399f0140386SGeliang Tang ip -n $ns mptcp endpoint change id $id ${flags//","/" "} 400f0140386SGeliang Tang else 401bccefb76SGeliang Tang ip netns exec $ns ./pm_nl_ctl set id $id flags $flags 402f0140386SGeliang Tang fi 403f0140386SGeliang Tang} 404f0140386SGeliang Tang 405b08fbf24SPaolo Abenido_transfer() 406b08fbf24SPaolo Abeni{ 407b08fbf24SPaolo Abeni listener_ns="$1" 408b08fbf24SPaolo Abeni connector_ns="$2" 409b08fbf24SPaolo Abeni cl_proto="$3" 410b08fbf24SPaolo Abeni srv_proto="$4" 411b08fbf24SPaolo Abeni connect_addr="$5" 4128b819a84SFlorian Westphal test_link_fail="$6" 4132e8cbf45SGeliang Tang addr_nr_ns1="$7" 4142e8cbf45SGeliang Tang addr_nr_ns2="$8" 4158b819a84SFlorian Westphal speed="$9" 4166a0653b9SGeliang Tang sflags="${10}" 417b08fbf24SPaolo Abeni 418b08fbf24SPaolo Abeni port=$((10000+$TEST_COUNT)) 419b08fbf24SPaolo Abeni TEST_COUNT=$((TEST_COUNT+1)) 420b08fbf24SPaolo Abeni 421b08fbf24SPaolo Abeni :> "$cout" 422b08fbf24SPaolo Abeni :> "$sout" 423b08fbf24SPaolo Abeni :> "$capout" 424b08fbf24SPaolo Abeni 425b08fbf24SPaolo Abeni if [ $capture -eq 1 ]; then 426b08fbf24SPaolo Abeni if [ -z $SUDO_USER ] ; then 427b08fbf24SPaolo Abeni capuser="" 428b08fbf24SPaolo Abeni else 429b08fbf24SPaolo Abeni capuser="-Z $SUDO_USER" 430b08fbf24SPaolo Abeni fi 431b08fbf24SPaolo Abeni 43200587187SFlorian Westphal capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}") 433b08fbf24SPaolo Abeni 434b08fbf24SPaolo Abeni echo "Capturing traffic for test $TEST_COUNT into $capfile" 435b08fbf24SPaolo Abeni ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & 436b08fbf24SPaolo Abeni cappid=$! 437b08fbf24SPaolo Abeni 438b08fbf24SPaolo Abeni sleep 1 439b08fbf24SPaolo Abeni fi 440b08fbf24SPaolo Abeni 441c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 442c2a55e8fSMatthieu Baerts nstat -n 443c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 444c2a55e8fSMatthieu Baerts nstat -n 445c2a55e8fSMatthieu Baerts 4468d014eaaSGeliang Tang if [ $speed = "fast" ]; then 447dd72b0feSGeliang Tang mptcp_connect="./mptcp_connect -j" 4488da6229bSGeliang Tang elif [ $speed = "slow" ]; then 4498da6229bSGeliang Tang mptcp_connect="./mptcp_connect -r 50" 4508da6229bSGeliang Tang elif [ $speed = "least" ]; then 4518da6229bSGeliang Tang mptcp_connect="./mptcp_connect -r 10" 452dd72b0feSGeliang Tang fi 453dd72b0feSGeliang Tang 454523514edSGeliang Tang local local_addr 455523514edSGeliang Tang if is_v6 "${connect_addr}"; then 456523514edSGeliang Tang local_addr="::" 457523514edSGeliang Tang else 458523514edSGeliang Tang local_addr="0.0.0.0" 459523514edSGeliang Tang fi 460523514edSGeliang Tang 4617d1e6f16SPaolo Abeni if [ "$test_link_fail" -eq 2 ];then 4627d1e6f16SPaolo Abeni timeout ${timeout_test} \ 4637d1e6f16SPaolo Abeni ip netns exec ${listener_ns} \ 4647c909a98SGeliang Tang $mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 4657d1e6f16SPaolo Abeni ${local_addr} < "$sinfail" > "$sout" & 4667d1e6f16SPaolo Abeni else 4675888a61cSMatthieu Baerts timeout ${timeout_test} \ 4685888a61cSMatthieu Baerts ip netns exec ${listener_ns} \ 4695888a61cSMatthieu Baerts $mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 4705888a61cSMatthieu Baerts ${local_addr} < "$sin" > "$sout" & 4717d1e6f16SPaolo Abeni fi 472b08fbf24SPaolo Abeni spid=$! 473b08fbf24SPaolo Abeni 474327b9a94SPaolo Abeni wait_local_port_listen "${listener_ns}" "${port}" 475b08fbf24SPaolo Abeni 4768b819a84SFlorian Westphal if [ "$test_link_fail" -eq 0 ];then 4775888a61cSMatthieu Baerts timeout ${timeout_test} \ 4785888a61cSMatthieu Baerts ip netns exec ${connector_ns} \ 4795888a61cSMatthieu Baerts $mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 4805888a61cSMatthieu Baerts $connect_addr < "$cin" > "$cout" & 4818b819a84SFlorian Westphal else 4827d1e6f16SPaolo Abeni ( cat "$cinfail" ; sleep 2; link_failure $listener_ns ; cat "$cinfail" ) | \ 4835888a61cSMatthieu Baerts tee "$cinsent" | \ 4845888a61cSMatthieu Baerts timeout ${timeout_test} \ 4855888a61cSMatthieu Baerts ip netns exec ${connector_ns} \ 4865888a61cSMatthieu Baerts $mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 4875888a61cSMatthieu Baerts $connect_addr > "$cout" & 4888b819a84SFlorian Westphal fi 489b08fbf24SPaolo Abeni cpid=$! 490b08fbf24SPaolo Abeni 491327b9a94SPaolo Abeni # let the mptcp subflow be established in background before 492327b9a94SPaolo Abeni # do endpoint manipulation 493327b9a94SPaolo Abeni [ $addr_nr_ns1 = "0" -a $addr_nr_ns2 = "0" ] || sleep 1 494327b9a94SPaolo Abeni 4956208fd82SGeliang Tang if [ $addr_nr_ns1 -gt 0 ]; then 4966208fd82SGeliang Tang let add_nr_ns1=addr_nr_ns1 4976208fd82SGeliang Tang counter=2 4986208fd82SGeliang Tang while [ $add_nr_ns1 -gt 0 ]; do 4996208fd82SGeliang Tang local addr 5006208fd82SGeliang Tang if is_v6 "${connect_addr}"; then 5016208fd82SGeliang Tang addr="dead:beef:$counter::1" 5026208fd82SGeliang Tang else 5036208fd82SGeliang Tang addr="10.0.$counter.1" 5046208fd82SGeliang Tang fi 50534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 $addr flags signal 5066208fd82SGeliang Tang let counter+=1 5076208fd82SGeliang Tang let add_nr_ns1-=1 5086208fd82SGeliang Tang done 5096208fd82SGeliang Tang elif [ $addr_nr_ns1 -lt 0 ]; then 5102e8cbf45SGeliang Tang let rm_nr_ns1=-addr_nr_ns1 5116fe4ccdcSGeliang Tang if [ $rm_nr_ns1 -lt 8 ]; then 512dda61b3dSGeliang Tang counter=0 513dda61b3dSGeliang Tang pm_nl_show_endpoints ${listener_ns} | while read line; do 514dda61b3dSGeliang Tang local arr=($line) 515dda61b3dSGeliang Tang local nr=0 516dda61b3dSGeliang Tang 517dda61b3dSGeliang Tang for i in ${arr[@]}; do 518dda61b3dSGeliang Tang if [ $i = "id" ]; then 519dda61b3dSGeliang Tang if [ $counter -eq $rm_nr_ns1 ]; then 520dda61b3dSGeliang Tang break 521dda61b3dSGeliang Tang fi 522dda61b3dSGeliang Tang id=${arr[$nr+1]} 523327b9a94SPaolo Abeni rm_addr=$(rm_addr_count ${connector_ns}) 52434aa6e3bSGeliang Tang pm_nl_del_endpoint ${listener_ns} $id 525327b9a94SPaolo Abeni wait_rm_addr ${connector_ns} ${rm_addr} 526dd72b0feSGeliang Tang let counter+=1 527f87744adSGeliang Tang fi 528dda61b3dSGeliang Tang let nr+=1 529dda61b3dSGeliang Tang done 530dda61b3dSGeliang Tang done 5315e287fe7SGeliang Tang elif [ $rm_nr_ns1 -eq 8 ]; then 53234aa6e3bSGeliang Tang pm_nl_flush_endpoint ${listener_ns} 5335e287fe7SGeliang Tang elif [ $rm_nr_ns1 -eq 9 ]; then 53434aa6e3bSGeliang Tang pm_nl_del_endpoint ${listener_ns} 0 ${connect_addr} 5356fe4ccdcSGeliang Tang fi 536dd72b0feSGeliang Tang fi 537dd72b0feSGeliang Tang 5384f49d633SGeliang Tang flags="subflow" 5394f49d633SGeliang Tang if [[ "${addr_nr_ns2}" = "fullmesh_"* ]]; then 5404f49d633SGeliang Tang flags="${flags},fullmesh" 5414f49d633SGeliang Tang addr_nr_ns2=${addr_nr_ns2:9} 5424f49d633SGeliang Tang fi 5434f49d633SGeliang Tang 544327b9a94SPaolo Abeni # if newly added endpoints must be deleted, give the background msk 545327b9a94SPaolo Abeni # some time to created them 546327b9a94SPaolo Abeni [ $addr_nr_ns1 -gt 0 -a $addr_nr_ns2 -lt 0 ] && sleep 1 547327b9a94SPaolo Abeni 5486208fd82SGeliang Tang if [ $addr_nr_ns2 -gt 0 ]; then 5496208fd82SGeliang Tang let add_nr_ns2=addr_nr_ns2 5506208fd82SGeliang Tang counter=3 5516208fd82SGeliang Tang while [ $add_nr_ns2 -gt 0 ]; do 5526208fd82SGeliang Tang local addr 5536208fd82SGeliang Tang if is_v6 "${connect_addr}"; then 5546208fd82SGeliang Tang addr="dead:beef:$counter::2" 5556208fd82SGeliang Tang else 5566208fd82SGeliang Tang addr="10.0.$counter.2" 5576208fd82SGeliang Tang fi 55834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 $addr flags $flags 5596208fd82SGeliang Tang let counter+=1 5606208fd82SGeliang Tang let add_nr_ns2-=1 5616208fd82SGeliang Tang done 5626208fd82SGeliang Tang elif [ $addr_nr_ns2 -lt 0 ]; then 5632e8cbf45SGeliang Tang let rm_nr_ns2=-addr_nr_ns2 5646fe4ccdcSGeliang Tang if [ $rm_nr_ns2 -lt 8 ]; then 565dda61b3dSGeliang Tang counter=0 566dda61b3dSGeliang Tang pm_nl_show_endpoints ${connector_ns} | while read line; do 567dda61b3dSGeliang Tang local arr=($line) 568dda61b3dSGeliang Tang local nr=0 569dda61b3dSGeliang Tang 570dda61b3dSGeliang Tang for i in ${arr[@]}; do 571dda61b3dSGeliang Tang if [ $i = "id" ]; then 572dda61b3dSGeliang Tang if [ $counter -eq $rm_nr_ns2 ]; then 573dda61b3dSGeliang Tang break 574dda61b3dSGeliang Tang fi 575dda61b3dSGeliang Tang # rm_addr are serialized, allow the previous one to 576dda61b3dSGeliang Tang # complete 577dda61b3dSGeliang Tang id=${arr[$nr+1]} 578327b9a94SPaolo Abeni rm_addr=$(rm_addr_count ${listener_ns}) 57934aa6e3bSGeliang Tang pm_nl_del_endpoint ${connector_ns} $id 580327b9a94SPaolo Abeni wait_rm_addr ${listener_ns} ${rm_addr} 581dd72b0feSGeliang Tang let counter+=1 582f87744adSGeliang Tang fi 583dda61b3dSGeliang Tang let nr+=1 584dda61b3dSGeliang Tang done 585dda61b3dSGeliang Tang done 5865e287fe7SGeliang Tang elif [ $rm_nr_ns2 -eq 8 ]; then 58734aa6e3bSGeliang Tang pm_nl_flush_endpoint ${connector_ns} 5885e287fe7SGeliang Tang elif [ $rm_nr_ns2 -eq 9 ]; then 5895e287fe7SGeliang Tang local addr 5905e287fe7SGeliang Tang if is_v6 "${connect_addr}"; then 5915e287fe7SGeliang Tang addr="dead:beef:1::2" 5925e287fe7SGeliang Tang else 5935e287fe7SGeliang Tang addr="10.0.1.2" 5945e287fe7SGeliang Tang fi 59534aa6e3bSGeliang Tang pm_nl_del_endpoint ${connector_ns} 0 $addr 5966fe4ccdcSGeliang Tang fi 597dd72b0feSGeliang Tang fi 598dd72b0feSGeliang Tang 5996a0653b9SGeliang Tang if [ ! -z $sflags ]; then 600718eb44eSGeliang Tang sleep 1 601718eb44eSGeliang Tang for netns in "$ns1" "$ns2"; do 602dda61b3dSGeliang Tang pm_nl_show_endpoints $netns | while read line; do 60333397b83SGeliang Tang local arr=($line) 604bccefb76SGeliang Tang local nr=0 605f0140386SGeliang Tang local id 60633397b83SGeliang Tang 60733397b83SGeliang Tang for i in ${arr[@]}; do 608bccefb76SGeliang Tang if [ $i = "id" ]; then 609bccefb76SGeliang Tang id=${arr[$nr+1]} 610718eb44eSGeliang Tang fi 611bccefb76SGeliang Tang let nr+=1 61233397b83SGeliang Tang done 613bccefb76SGeliang Tang pm_nl_change_endpoint $netns $id $sflags 61433397b83SGeliang Tang done 615718eb44eSGeliang Tang done 616718eb44eSGeliang Tang fi 617718eb44eSGeliang Tang 618b08fbf24SPaolo Abeni wait $cpid 619b08fbf24SPaolo Abeni retc=$? 620b08fbf24SPaolo Abeni wait $spid 621b08fbf24SPaolo Abeni rets=$? 622b08fbf24SPaolo Abeni 623b08fbf24SPaolo Abeni if [ $capture -eq 1 ]; then 624b08fbf24SPaolo Abeni sleep 1 625b08fbf24SPaolo Abeni kill $cappid 626b08fbf24SPaolo Abeni fi 627b08fbf24SPaolo Abeni 628c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 629c2a55e8fSMatthieu Baerts nstat | grep Tcp > /tmp/${listener_ns}.out 630c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 631c2a55e8fSMatthieu Baerts nstat | grep Tcp > /tmp/${connector_ns}.out 632c2a55e8fSMatthieu Baerts 633b08fbf24SPaolo Abeni if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then 634b08fbf24SPaolo Abeni echo " client exit code $retc, server $rets" 1>&2 6358b974778SMatthieu Baerts echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 636c2a55e8fSMatthieu Baerts ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port" 637c2a55e8fSMatthieu Baerts cat /tmp/${listener_ns}.out 6388b974778SMatthieu Baerts echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2 639c2a55e8fSMatthieu Baerts ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port" 640c2a55e8fSMatthieu Baerts cat /tmp/${connector_ns}.out 641b08fbf24SPaolo Abeni 642b08fbf24SPaolo Abeni cat "$capout" 6438b819a84SFlorian Westphal ret=1 644b08fbf24SPaolo Abeni return 1 645b08fbf24SPaolo Abeni fi 646b08fbf24SPaolo Abeni 6477d1e6f16SPaolo Abeni if [ "$test_link_fail" -eq 2 ];then 6487d1e6f16SPaolo Abeni check_transfer $sinfail $cout "file received by client" 6497d1e6f16SPaolo Abeni else 650b08fbf24SPaolo Abeni check_transfer $sin $cout "file received by client" 6517d1e6f16SPaolo Abeni fi 652b08fbf24SPaolo Abeni retc=$? 6538b819a84SFlorian Westphal if [ "$test_link_fail" -eq 0 ];then 654b08fbf24SPaolo Abeni check_transfer $cin $sout "file received by server" 6558b819a84SFlorian Westphal else 6568b819a84SFlorian Westphal check_transfer $cinsent $sout "file received by server" 6578b819a84SFlorian Westphal fi 658b08fbf24SPaolo Abeni rets=$? 659b08fbf24SPaolo Abeni 660b08fbf24SPaolo Abeni if [ $retc -eq 0 ] && [ $rets -eq 0 ];then 661b08fbf24SPaolo Abeni cat "$capout" 662b08fbf24SPaolo Abeni return 0 663b08fbf24SPaolo Abeni fi 664b08fbf24SPaolo Abeni 665b08fbf24SPaolo Abeni cat "$capout" 666b08fbf24SPaolo Abeni return 1 667b08fbf24SPaolo Abeni} 668b08fbf24SPaolo Abeni 669b08fbf24SPaolo Abenimake_file() 670b08fbf24SPaolo Abeni{ 671b08fbf24SPaolo Abeni name=$1 672b08fbf24SPaolo Abeni who=$2 6738b819a84SFlorian Westphal size=$3 674b08fbf24SPaolo Abeni 6758b819a84SFlorian Westphal dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null 676b08fbf24SPaolo Abeni echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" 677b08fbf24SPaolo Abeni 6788b819a84SFlorian Westphal echo "Created $name (size $size KB) containing data sent by $who" 679b08fbf24SPaolo Abeni} 680b08fbf24SPaolo Abeni 681b08fbf24SPaolo Abenirun_tests() 682b08fbf24SPaolo Abeni{ 683b08fbf24SPaolo Abeni listener_ns="$1" 684b08fbf24SPaolo Abeni connector_ns="$2" 685b08fbf24SPaolo Abeni connect_addr="$3" 6868b819a84SFlorian Westphal test_linkfail="${4:-0}" 6872e8cbf45SGeliang Tang addr_nr_ns1="${5:-0}" 6882e8cbf45SGeliang Tang addr_nr_ns2="${6:-0}" 6898b819a84SFlorian Westphal speed="${7:-fast}" 6906a0653b9SGeliang Tang sflags="${8:-""}" 6918b819a84SFlorian Westphal 6927d1e6f16SPaolo Abeni # create the input file for the failure test when 6937d1e6f16SPaolo Abeni # the first failure test run 6947d1e6f16SPaolo Abeni if [ "$test_linkfail" -ne 0 -a -z "$cinfail" ]; then 6957d1e6f16SPaolo Abeni # the client file must be considerably larger 6967d1e6f16SPaolo Abeni # of the maximum expected cwin value, or the 6977d1e6f16SPaolo Abeni # link utilization will be not predicable 6987d1e6f16SPaolo Abeni size=$((RANDOM%2)) 6998b819a84SFlorian Westphal size=$((size+1)) 7007d1e6f16SPaolo Abeni size=$((size*8192)) 7017d1e6f16SPaolo Abeni size=$((size + ( $RANDOM % 8192) )) 7028b819a84SFlorian Westphal 7037d1e6f16SPaolo Abeni cinfail=$(mktemp) 7047d1e6f16SPaolo Abeni make_file "$cinfail" "client" $size 7057d1e6f16SPaolo Abeni fi 7067d1e6f16SPaolo Abeni 7077d1e6f16SPaolo Abeni if [ "$test_linkfail" -eq 2 -a -z "$sinfail" ]; then 7087d1e6f16SPaolo Abeni size=$((RANDOM%16)) 7097d1e6f16SPaolo Abeni size=$((size+1)) 7107d1e6f16SPaolo Abeni size=$((size*2048)) 7117d1e6f16SPaolo Abeni 7127d1e6f16SPaolo Abeni sinfail=$(mktemp) 7137d1e6f16SPaolo Abeni make_file "$sinfail" "server" $size 7148b819a84SFlorian Westphal fi 715b08fbf24SPaolo Abeni 7168d014eaaSGeliang Tang do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \ 7176a0653b9SGeliang Tang ${test_linkfail} ${addr_nr_ns1} ${addr_nr_ns2} ${speed} ${sflags} 718b08fbf24SPaolo Abeni} 719b08fbf24SPaolo Abeni 720327b9a94SPaolo Abenidump_stats() 721327b9a94SPaolo Abeni{ 722327b9a94SPaolo Abeni echo Server ns stats 723327b9a94SPaolo Abeni ip netns exec $ns1 nstat -as | grep Tcp 724327b9a94SPaolo Abeni echo Client ns stats 725327b9a94SPaolo Abeni ip netns exec $ns2 nstat -as | grep Tcp 726327b9a94SPaolo Abeni} 727327b9a94SPaolo Abeni 728af66d3e1SGeliang Tangchk_csum_nr() 729af66d3e1SGeliang Tang{ 730af66d3e1SGeliang Tang local msg=${1:-""} 731af66d3e1SGeliang Tang local count 732af66d3e1SGeliang Tang local dump_stats 733af66d3e1SGeliang Tang 734af66d3e1SGeliang Tang if [ ! -z "$msg" ]; then 735af66d3e1SGeliang Tang printf "%02u" "$TEST_COUNT" 736af66d3e1SGeliang Tang else 737af66d3e1SGeliang Tang echo -n " " 738af66d3e1SGeliang Tang fi 739af66d3e1SGeliang Tang printf " %-36s %s" "$msg" "sum" 740af66d3e1SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'` 741af66d3e1SGeliang Tang [ -z "$count" ] && count=0 742af66d3e1SGeliang Tang if [ "$count" != 0 ]; then 743af66d3e1SGeliang Tang echo "[fail] got $count data checksum error[s] expected 0" 744af66d3e1SGeliang Tang ret=1 745af66d3e1SGeliang Tang dump_stats=1 746af66d3e1SGeliang Tang else 747af66d3e1SGeliang Tang echo -n "[ ok ]" 748af66d3e1SGeliang Tang fi 749af66d3e1SGeliang Tang echo -n " - csum " 750af66d3e1SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'` 751af66d3e1SGeliang Tang [ -z "$count" ] && count=0 752af66d3e1SGeliang Tang if [ "$count" != 0 ]; then 753af66d3e1SGeliang Tang echo "[fail] got $count data checksum error[s] expected 0" 754af66d3e1SGeliang Tang ret=1 755af66d3e1SGeliang Tang dump_stats=1 756af66d3e1SGeliang Tang else 757af66d3e1SGeliang Tang echo "[ ok ]" 758af66d3e1SGeliang Tang fi 759327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 760af66d3e1SGeliang Tang} 761af66d3e1SGeliang Tang 7626bb3ab49SGeliang Tangchk_fail_nr() 7636bb3ab49SGeliang Tang{ 7646bb3ab49SGeliang Tang local mp_fail_nr_tx=$1 7656bb3ab49SGeliang Tang local mp_fail_nr_rx=$2 7666bb3ab49SGeliang Tang local count 7676bb3ab49SGeliang Tang local dump_stats 7686bb3ab49SGeliang Tang 7696bb3ab49SGeliang Tang printf "%-39s %s" " " "ftx" 7706bb3ab49SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPFailTx | awk '{print $2}'` 7716bb3ab49SGeliang Tang [ -z "$count" ] && count=0 7726bb3ab49SGeliang Tang if [ "$count" != "$mp_fail_nr_tx" ]; then 7736bb3ab49SGeliang Tang echo "[fail] got $count MP_FAIL[s] TX expected $mp_fail_nr_tx" 7746bb3ab49SGeliang Tang ret=1 7756bb3ab49SGeliang Tang dump_stats=1 7766bb3ab49SGeliang Tang else 7776bb3ab49SGeliang Tang echo -n "[ ok ]" 7786bb3ab49SGeliang Tang fi 7796bb3ab49SGeliang Tang 7806bb3ab49SGeliang Tang echo -n " - frx " 7816bb3ab49SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPFailRx | awk '{print $2}'` 7826bb3ab49SGeliang Tang [ -z "$count" ] && count=0 7836bb3ab49SGeliang Tang if [ "$count" != "$mp_fail_nr_rx" ]; then 7846bb3ab49SGeliang Tang echo "[fail] got $count MP_FAIL[s] RX expected $mp_fail_nr_rx" 7856bb3ab49SGeliang Tang ret=1 7866bb3ab49SGeliang Tang dump_stats=1 7876bb3ab49SGeliang Tang else 7886bb3ab49SGeliang Tang echo "[ ok ]" 7896bb3ab49SGeliang Tang fi 7906bb3ab49SGeliang Tang 791327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 7926bb3ab49SGeliang Tang} 7936bb3ab49SGeliang Tang 794b08fbf24SPaolo Abenichk_join_nr() 795b08fbf24SPaolo Abeni{ 796b08fbf24SPaolo Abeni local msg="$1" 797b08fbf24SPaolo Abeni local syn_nr=$2 798b08fbf24SPaolo Abeni local syn_ack_nr=$3 799b08fbf24SPaolo Abeni local ack_nr=$4 800b08fbf24SPaolo Abeni local count 801b08fbf24SPaolo Abeni local dump_stats 802b08fbf24SPaolo Abeni 80300587187SFlorian Westphal printf "%02u %-36s %s" "$TEST_COUNT" "$msg" "syn" 804b08fbf24SPaolo Abeni count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'` 805b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 806b08fbf24SPaolo Abeni if [ "$count" != "$syn_nr" ]; then 807b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] syn expected $syn_nr" 808b08fbf24SPaolo Abeni ret=1 809b08fbf24SPaolo Abeni dump_stats=1 810b08fbf24SPaolo Abeni else 811b08fbf24SPaolo Abeni echo -n "[ ok ]" 812b08fbf24SPaolo Abeni fi 813b08fbf24SPaolo Abeni 814b08fbf24SPaolo Abeni echo -n " - synack" 815b08fbf24SPaolo Abeni count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'` 816b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 817b08fbf24SPaolo Abeni if [ "$count" != "$syn_ack_nr" ]; then 818b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr" 819b08fbf24SPaolo Abeni ret=1 820b08fbf24SPaolo Abeni dump_stats=1 821b08fbf24SPaolo Abeni else 822b08fbf24SPaolo Abeni echo -n "[ ok ]" 823b08fbf24SPaolo Abeni fi 824b08fbf24SPaolo Abeni 825b08fbf24SPaolo Abeni echo -n " - ack" 826b08fbf24SPaolo Abeni count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'` 827b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 828b08fbf24SPaolo Abeni if [ "$count" != "$ack_nr" ]; then 829b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] ack expected $ack_nr" 830b08fbf24SPaolo Abeni ret=1 831b08fbf24SPaolo Abeni dump_stats=1 832b08fbf24SPaolo Abeni else 833b08fbf24SPaolo Abeni echo "[ ok ]" 834b08fbf24SPaolo Abeni fi 835327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 836af66d3e1SGeliang Tang if [ $checksum -eq 1 ]; then 837af66d3e1SGeliang Tang chk_csum_nr 8386bb3ab49SGeliang Tang chk_fail_nr 0 0 839af66d3e1SGeliang Tang fi 840b08fbf24SPaolo Abeni} 841b08fbf24SPaolo Abeni 8427d1e6f16SPaolo Abeni# a negative value for 'stale_max' means no upper bound: 8437d1e6f16SPaolo Abeni# for bidirectional transfer, if one peer sleep for a while 8447d1e6f16SPaolo Abeni# - as these tests do - we can have a quite high number of 8457d1e6f16SPaolo Abeni# stale/recover conversions, proportional to 8467d1e6f16SPaolo Abeni# sleep duration/ MPTCP-level RTX interval. 8477d1e6f16SPaolo Abenichk_stale_nr() 8487d1e6f16SPaolo Abeni{ 8497d1e6f16SPaolo Abeni local ns=$1 8507d1e6f16SPaolo Abeni local stale_min=$2 8517d1e6f16SPaolo Abeni local stale_max=$3 8527d1e6f16SPaolo Abeni local stale_delta=$4 8537d1e6f16SPaolo Abeni local dump_stats 8547d1e6f16SPaolo Abeni local stale_nr 8557d1e6f16SPaolo Abeni local recover_nr 8567d1e6f16SPaolo Abeni 8577d1e6f16SPaolo Abeni printf "%-39s %-18s" " " "stale" 8587d1e6f16SPaolo Abeni stale_nr=`ip netns exec $ns nstat -as | grep MPTcpExtSubflowStale | awk '{print $2}'` 8597d1e6f16SPaolo Abeni [ -z "$stale_nr" ] && stale_nr=0 8607d1e6f16SPaolo Abeni recover_nr=`ip netns exec $ns nstat -as | grep MPTcpExtSubflowRecover | awk '{print $2}'` 8617d1e6f16SPaolo Abeni [ -z "$recover_nr" ] && recover_nr=0 8627d1e6f16SPaolo Abeni 8637d1e6f16SPaolo Abeni if [ $stale_nr -lt $stale_min ] || 8647d1e6f16SPaolo Abeni [ $stale_max -gt 0 -a $stale_nr -gt $stale_max ] || 8657d1e6f16SPaolo Abeni [ $((stale_nr - $recover_nr)) -ne $stale_delta ]; then 8667d1e6f16SPaolo Abeni echo "[fail] got $stale_nr stale[s] $recover_nr recover[s], " \ 8677d1e6f16SPaolo Abeni " expected stale in range [$stale_min..$stale_max]," \ 8687d1e6f16SPaolo Abeni " stale-recover delta $stale_delta " 8697d1e6f16SPaolo Abeni ret=1 8707d1e6f16SPaolo Abeni dump_stats=1 8717d1e6f16SPaolo Abeni else 8727d1e6f16SPaolo Abeni echo "[ ok ]" 8737d1e6f16SPaolo Abeni fi 8747d1e6f16SPaolo Abeni 8757d1e6f16SPaolo Abeni if [ "${dump_stats}" = 1 ]; then 8767d1e6f16SPaolo Abeni echo $ns stats 8777d1e6f16SPaolo Abeni ip netns exec $ns ip -s link show 8787d1e6f16SPaolo Abeni ip netns exec $ns nstat -as | grep MPTcp 8797d1e6f16SPaolo Abeni fi 8807d1e6f16SPaolo Abeni} 8817d1e6f16SPaolo Abeni 882be613160SGeliang Tangchk_add_nr() 883be613160SGeliang Tang{ 884be613160SGeliang Tang local add_nr=$1 885be613160SGeliang Tang local echo_nr=$2 8868a127bf6SGeliang Tang local port_nr=${3:-0} 8878a127bf6SGeliang Tang local syn_nr=${4:-$port_nr} 8888a127bf6SGeliang Tang local syn_ack_nr=${5:-$port_nr} 8898a127bf6SGeliang Tang local ack_nr=${6:-$port_nr} 8908a127bf6SGeliang Tang local mis_syn_nr=${7:-0} 8918a127bf6SGeliang Tang local mis_ack_nr=${8:-0} 892be613160SGeliang Tang local count 893be613160SGeliang Tang local dump_stats 894be613160SGeliang Tang 895be613160SGeliang Tang printf "%-39s %s" " " "add" 896be613160SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtAddAddr | awk '{print $2}'` 897be613160SGeliang Tang [ -z "$count" ] && count=0 898be613160SGeliang Tang if [ "$count" != "$add_nr" ]; then 899be613160SGeliang Tang echo "[fail] got $count ADD_ADDR[s] expected $add_nr" 900be613160SGeliang Tang ret=1 901be613160SGeliang Tang dump_stats=1 902be613160SGeliang Tang else 903be613160SGeliang Tang echo -n "[ ok ]" 904be613160SGeliang Tang fi 905be613160SGeliang Tang 906be613160SGeliang Tang echo -n " - echo " 907be613160SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtEchoAdd | awk '{print $2}'` 908be613160SGeliang Tang [ -z "$count" ] && count=0 909be613160SGeliang Tang if [ "$count" != "$echo_nr" ]; then 910be613160SGeliang Tang echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr" 911be613160SGeliang Tang ret=1 912be613160SGeliang Tang dump_stats=1 913be613160SGeliang Tang else 9148a127bf6SGeliang Tang echo -n "[ ok ]" 9158a127bf6SGeliang Tang fi 9168a127bf6SGeliang Tang 9178a127bf6SGeliang Tang if [ $port_nr -gt 0 ]; then 9188a127bf6SGeliang Tang echo -n " - pt " 9198a127bf6SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtPortAdd | awk '{print $2}'` 9208a127bf6SGeliang Tang [ -z "$count" ] && count=0 9218a127bf6SGeliang Tang if [ "$count" != "$port_nr" ]; then 9228a127bf6SGeliang Tang echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr" 9238a127bf6SGeliang Tang ret=1 9248a127bf6SGeliang Tang dump_stats=1 9258a127bf6SGeliang Tang else 926be613160SGeliang Tang echo "[ ok ]" 927be613160SGeliang Tang fi 928be613160SGeliang Tang 9298a127bf6SGeliang Tang printf "%-39s %s" " " "syn" 9308a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortSynRx | 9318a127bf6SGeliang Tang awk '{print $2}'` 9328a127bf6SGeliang Tang [ -z "$count" ] && count=0 9338a127bf6SGeliang Tang if [ "$count" != "$syn_nr" ]; then 9348a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] syn with a different \ 9358a127bf6SGeliang Tang port-number expected $syn_nr" 9368a127bf6SGeliang Tang ret=1 9378a127bf6SGeliang Tang dump_stats=1 9388a127bf6SGeliang Tang else 9398a127bf6SGeliang Tang echo -n "[ ok ]" 9408a127bf6SGeliang Tang fi 9418a127bf6SGeliang Tang 9428a127bf6SGeliang Tang echo -n " - synack" 9438a127bf6SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinPortSynAckRx | 9448a127bf6SGeliang Tang awk '{print $2}'` 9458a127bf6SGeliang Tang [ -z "$count" ] && count=0 9468a127bf6SGeliang Tang if [ "$count" != "$syn_ack_nr" ]; then 9478a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] synack with a different \ 9488a127bf6SGeliang Tang port-number expected $syn_ack_nr" 9498a127bf6SGeliang Tang ret=1 9508a127bf6SGeliang Tang dump_stats=1 9518a127bf6SGeliang Tang else 9528a127bf6SGeliang Tang echo -n "[ ok ]" 9538a127bf6SGeliang Tang fi 9548a127bf6SGeliang Tang 9558a127bf6SGeliang Tang echo -n " - ack" 9568a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortAckRx | 9578a127bf6SGeliang Tang awk '{print $2}'` 9588a127bf6SGeliang Tang [ -z "$count" ] && count=0 9598a127bf6SGeliang Tang if [ "$count" != "$ack_nr" ]; then 9608a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] ack with a different \ 9618a127bf6SGeliang Tang port-number expected $ack_nr" 9628a127bf6SGeliang Tang ret=1 9638a127bf6SGeliang Tang dump_stats=1 9648a127bf6SGeliang Tang else 9658a127bf6SGeliang Tang echo "[ ok ]" 9668a127bf6SGeliang Tang fi 9678a127bf6SGeliang Tang 9688a127bf6SGeliang Tang printf "%-39s %s" " " "syn" 9698a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortSynRx | 9708a127bf6SGeliang Tang awk '{print $2}'` 9718a127bf6SGeliang Tang [ -z "$count" ] && count=0 9728a127bf6SGeliang Tang if [ "$count" != "$mis_syn_nr" ]; then 9738a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] syn with a mismatched \ 9748a127bf6SGeliang Tang port-number expected $mis_syn_nr" 9758a127bf6SGeliang Tang ret=1 9768a127bf6SGeliang Tang dump_stats=1 9778a127bf6SGeliang Tang else 9788a127bf6SGeliang Tang echo -n "[ ok ]" 9798a127bf6SGeliang Tang fi 9808a127bf6SGeliang Tang 9818a127bf6SGeliang Tang echo -n " - ack " 9828a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortAckRx | 9838a127bf6SGeliang Tang awk '{print $2}'` 9848a127bf6SGeliang Tang [ -z "$count" ] && count=0 9858a127bf6SGeliang Tang if [ "$count" != "$mis_ack_nr" ]; then 9868a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] ack with a mismatched \ 9878a127bf6SGeliang Tang port-number expected $mis_ack_nr" 9888a127bf6SGeliang Tang ret=1 9898a127bf6SGeliang Tang dump_stats=1 9908a127bf6SGeliang Tang else 9918a127bf6SGeliang Tang echo "[ ok ]" 9928a127bf6SGeliang Tang fi 9938a127bf6SGeliang Tang else 9948a127bf6SGeliang Tang echo "" 9958a127bf6SGeliang Tang fi 9968a127bf6SGeliang Tang 997327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 998be613160SGeliang Tang} 999be613160SGeliang Tang 1000dd72b0feSGeliang Tangchk_rm_nr() 1001dd72b0feSGeliang Tang{ 1002dd72b0feSGeliang Tang local rm_addr_nr=$1 1003dd72b0feSGeliang Tang local rm_subflow_nr=$2 10047028ba8aSGeliang Tang local invert=${3:-""} 1005dd72b0feSGeliang Tang local count 1006dd72b0feSGeliang Tang local dump_stats 10077028ba8aSGeliang Tang local addr_ns 10087028ba8aSGeliang Tang local subflow_ns 10097028ba8aSGeliang Tang 10107028ba8aSGeliang Tang if [ -z $invert ]; then 10117028ba8aSGeliang Tang addr_ns=$ns1 10127028ba8aSGeliang Tang subflow_ns=$ns2 10137028ba8aSGeliang Tang elif [ $invert = "invert" ]; then 10147028ba8aSGeliang Tang addr_ns=$ns2 10157028ba8aSGeliang Tang subflow_ns=$ns1 10167028ba8aSGeliang Tang fi 1017dd72b0feSGeliang Tang 1018dd72b0feSGeliang Tang printf "%-39s %s" " " "rm " 10197028ba8aSGeliang Tang count=`ip netns exec $addr_ns nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'` 1020dd72b0feSGeliang Tang [ -z "$count" ] && count=0 1021dd72b0feSGeliang Tang if [ "$count" != "$rm_addr_nr" ]; then 1022dd72b0feSGeliang Tang echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" 1023dd72b0feSGeliang Tang ret=1 1024dd72b0feSGeliang Tang dump_stats=1 1025dd72b0feSGeliang Tang else 1026dd72b0feSGeliang Tang echo -n "[ ok ]" 1027dd72b0feSGeliang Tang fi 1028dd72b0feSGeliang Tang 1029dd72b0feSGeliang Tang echo -n " - sf " 10307028ba8aSGeliang Tang count=`ip netns exec $subflow_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'` 1031dd72b0feSGeliang Tang [ -z "$count" ] && count=0 1032dd72b0feSGeliang Tang if [ "$count" != "$rm_subflow_nr" ]; then 1033dd72b0feSGeliang Tang echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr" 1034dd72b0feSGeliang Tang ret=1 1035dd72b0feSGeliang Tang dump_stats=1 1036dd72b0feSGeliang Tang else 1037dd72b0feSGeliang Tang echo "[ ok ]" 1038dd72b0feSGeliang Tang fi 1039dd72b0feSGeliang Tang 1040327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 1041dd72b0feSGeliang Tang} 1042dd72b0feSGeliang Tang 1043718eb44eSGeliang Tangchk_prio_nr() 1044718eb44eSGeliang Tang{ 1045718eb44eSGeliang Tang local mp_prio_nr_tx=$1 1046718eb44eSGeliang Tang local mp_prio_nr_rx=$2 1047718eb44eSGeliang Tang local count 1048718eb44eSGeliang Tang local dump_stats 1049718eb44eSGeliang Tang 1050718eb44eSGeliang Tang printf "%-39s %s" " " "ptx" 1051718eb44eSGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}'` 1052718eb44eSGeliang Tang [ -z "$count" ] && count=0 1053718eb44eSGeliang Tang if [ "$count" != "$mp_prio_nr_tx" ]; then 1054718eb44eSGeliang Tang echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" 1055718eb44eSGeliang Tang ret=1 1056718eb44eSGeliang Tang dump_stats=1 1057718eb44eSGeliang Tang else 1058718eb44eSGeliang Tang echo -n "[ ok ]" 1059718eb44eSGeliang Tang fi 1060718eb44eSGeliang Tang 1061718eb44eSGeliang Tang echo -n " - prx " 1062718eb44eSGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}'` 1063718eb44eSGeliang Tang [ -z "$count" ] && count=0 1064718eb44eSGeliang Tang if [ "$count" != "$mp_prio_nr_rx" ]; then 1065718eb44eSGeliang Tang echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" 1066718eb44eSGeliang Tang ret=1 1067718eb44eSGeliang Tang dump_stats=1 1068718eb44eSGeliang Tang else 1069718eb44eSGeliang Tang echo "[ ok ]" 1070718eb44eSGeliang Tang fi 1071718eb44eSGeliang Tang 1072327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 1073718eb44eSGeliang Tang} 1074718eb44eSGeliang Tang 10757d1e6f16SPaolo Abenichk_link_usage() 10767d1e6f16SPaolo Abeni{ 10777d1e6f16SPaolo Abeni local ns=$1 10787d1e6f16SPaolo Abeni local link=$2 10797d1e6f16SPaolo Abeni local out=$3 10807d1e6f16SPaolo Abeni local expected_rate=$4 10817d1e6f16SPaolo Abeni local tx_link=`ip netns exec $ns cat /sys/class/net/$link/statistics/tx_bytes` 10827d1e6f16SPaolo Abeni local tx_total=`ls -l $out | awk '{print $5}'` 10837d1e6f16SPaolo Abeni local tx_rate=$((tx_link * 100 / $tx_total)) 10847d1e6f16SPaolo Abeni local tolerance=5 10857d1e6f16SPaolo Abeni 10867d1e6f16SPaolo Abeni printf "%-39s %-18s" " " "link usage" 10877d1e6f16SPaolo Abeni if [ $tx_rate -lt $((expected_rate - $tolerance)) -o \ 10887d1e6f16SPaolo Abeni $tx_rate -gt $((expected_rate + $tolerance)) ]; then 10897d1e6f16SPaolo Abeni echo "[fail] got $tx_rate% usage, expected $expected_rate%" 10907d1e6f16SPaolo Abeni ret=1 10917d1e6f16SPaolo Abeni else 10927d1e6f16SPaolo Abeni echo "[ ok ]" 10937d1e6f16SPaolo Abeni fi 10947d1e6f16SPaolo Abeni} 10957d1e6f16SPaolo Abeni 109646e967d1SPaolo Abeniwait_for_tw() 109746e967d1SPaolo Abeni{ 109846e967d1SPaolo Abeni local timeout_ms=$((timeout_poll * 1000)) 109946e967d1SPaolo Abeni local time=0 110046e967d1SPaolo Abeni local ns=$1 110146e967d1SPaolo Abeni 110246e967d1SPaolo Abeni while [ $time -lt $timeout_ms ]; do 110346e967d1SPaolo Abeni local cnt=$(ip netns exec $ns ss -t state time-wait |wc -l) 110446e967d1SPaolo Abeni 110546e967d1SPaolo Abeni [ "$cnt" = 1 ] && return 1 110646e967d1SPaolo Abeni time=$((time + 100)) 110746e967d1SPaolo Abeni sleep 0.1 110846e967d1SPaolo Abeni done 110946e967d1SPaolo Abeni return 1 111046e967d1SPaolo Abeni} 111146e967d1SPaolo Abeni 11121002b89fSGeliang Tangsubflows_tests() 11131002b89fSGeliang Tang{ 11141002b89fSGeliang Tang reset 1115b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1116b08fbf24SPaolo Abeni chk_join_nr "no JOIN" "0" "0" "0" 1117b08fbf24SPaolo Abeni 11181002b89fSGeliang Tang # subflow limited by client 1119b08fbf24SPaolo Abeni reset 112034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 0 112134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 0 112234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1123b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1124b08fbf24SPaolo Abeni chk_join_nr "single subflow, limited by client" 0 0 0 1125b08fbf24SPaolo Abeni 11261002b89fSGeliang Tang # subflow limited by server 1127b08fbf24SPaolo Abeni reset 112834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 0 112934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 113034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1131b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1132b08fbf24SPaolo Abeni chk_join_nr "single subflow, limited by server" 1 1 0 1133b08fbf24SPaolo Abeni 1134b08fbf24SPaolo Abeni # subflow 1135b08fbf24SPaolo Abeni reset 113634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 113734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 113834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1139b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1140b08fbf24SPaolo Abeni chk_join_nr "single subflow" 1 1 1 1141b08fbf24SPaolo Abeni 1142b08fbf24SPaolo Abeni # multiple subflows 1143b08fbf24SPaolo Abeni reset 114434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 114534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 114634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 114734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 1148b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1149b08fbf24SPaolo Abeni chk_join_nr "multiple subflows" 2 2 2 1150b08fbf24SPaolo Abeni 115172bcbc46SPaolo Abeni # multiple subflows limited by server 1152b08fbf24SPaolo Abeni reset 115334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 115434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 115534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 115634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 1157b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1158b08fbf24SPaolo Abeni chk_join_nr "multiple subflows, limited by server" 2 2 1 1159c3eaa5f6SGeliang Tang 1160c3eaa5f6SGeliang Tang # single subflow, dev 1161c3eaa5f6SGeliang Tang reset 116234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 116334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 116434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow dev ns2eth3 1165c3eaa5f6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1166c3eaa5f6SGeliang Tang chk_join_nr "single subflow, dev" 1 1 1 11671002b89fSGeliang Tang} 1168b08fbf24SPaolo Abeni 116946e967d1SPaolo Abenisubflows_error_tests() 117046e967d1SPaolo Abeni{ 117146e967d1SPaolo Abeni # If a single subflow is configured, and matches the MPC src 117246e967d1SPaolo Abeni # address, no additional subflow should be created 117346e967d1SPaolo Abeni reset 117434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 117534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 117634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow 117746e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 117846e967d1SPaolo Abeni chk_join_nr "no MPC reuse with single endpoint" 0 0 0 117946e967d1SPaolo Abeni 118046e967d1SPaolo Abeni # multiple subflows, with subflow creation error 118146e967d1SPaolo Abeni reset 118234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 118334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 118434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 118534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 118646e967d1SPaolo Abeni ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT 118746e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 118846e967d1SPaolo Abeni chk_join_nr "multi subflows, with failing subflow" 1 1 1 118946e967d1SPaolo Abeni 119046e967d1SPaolo Abeni # multiple subflows, with subflow timeout on MPJ 119146e967d1SPaolo Abeni reset 119234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 119334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 119434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 119534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 119646e967d1SPaolo Abeni ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j DROP 119746e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 119846e967d1SPaolo Abeni chk_join_nr "multi subflows, with subflow timeout" 1 1 1 119946e967d1SPaolo Abeni 120046e967d1SPaolo Abeni # multiple subflows, check that the endpoint corresponding to 120146e967d1SPaolo Abeni # closed subflow (due to reset) is not reused if additional 120246e967d1SPaolo Abeni # subflows are added later 120346e967d1SPaolo Abeni reset 120434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 120534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 120634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 120746e967d1SPaolo Abeni ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT 120846e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow & 120946e967d1SPaolo Abeni 121046e967d1SPaolo Abeni # updates in the child shell do not have any effect here, we 121146e967d1SPaolo Abeni # need to bump the test counter for the above case 121246e967d1SPaolo Abeni TEST_COUNT=$((TEST_COUNT+1)) 121346e967d1SPaolo Abeni 121446e967d1SPaolo Abeni # mpj subflow will be in TW after the reset 121546e967d1SPaolo Abeni wait_for_tw $ns2 121634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 121746e967d1SPaolo Abeni wait 121846e967d1SPaolo Abeni 121946e967d1SPaolo Abeni # additional subflow could be created only if the PM select 122046e967d1SPaolo Abeni # the later endpoint, skipping the already used one 122146e967d1SPaolo Abeni chk_join_nr "multi subflows, fair usage on close" 1 1 1 122246e967d1SPaolo Abeni} 122346e967d1SPaolo Abeni 12241002b89fSGeliang Tangsignal_address_tests() 12251002b89fSGeliang Tang{ 1226b08fbf24SPaolo Abeni # add_address, unused 1227b08fbf24SPaolo Abeni reset 122834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 1229b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1230b08fbf24SPaolo Abeni chk_join_nr "unused signal address" 0 0 0 1231be613160SGeliang Tang chk_add_nr 1 1 1232b08fbf24SPaolo Abeni 1233b08fbf24SPaolo Abeni # accept and use add_addr 1234b08fbf24SPaolo Abeni reset 123534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 123634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 123734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 1238b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1239b08fbf24SPaolo Abeni chk_join_nr "signal address" 1 1 1 1240be613160SGeliang Tang chk_add_nr 1 1 1241b08fbf24SPaolo Abeni 1242b08fbf24SPaolo Abeni # accept and use add_addr with an additional subflow 1243b08fbf24SPaolo Abeni # note: signal address in server ns and local addresses in client ns must 1244b08fbf24SPaolo Abeni # belong to different subnets or one of the listed local address could be 1245b08fbf24SPaolo Abeni # used for 'add_addr' subflow 1246b08fbf24SPaolo Abeni reset 124734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 124834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 124934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 125034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1251b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1252b08fbf24SPaolo Abeni chk_join_nr "subflow and signal" 2 2 2 1253be613160SGeliang Tang chk_add_nr 1 1 1254b08fbf24SPaolo Abeni 1255b08fbf24SPaolo Abeni # accept and use add_addr with additional subflows 1256b08fbf24SPaolo Abeni reset 125734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 125834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 125934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 126034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 126134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 1262b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1263b08fbf24SPaolo Abeni chk_join_nr "multiple subflows and signal" 3 3 3 1264be613160SGeliang Tang chk_add_nr 1 1 1265ef360019SGeliang Tang 1266ef360019SGeliang Tang # signal addresses 1267ef360019SGeliang Tang reset 126834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 126934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 127034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 127134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 127234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1273ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1274ef360019SGeliang Tang chk_join_nr "signal addresses" 3 3 3 1275ef360019SGeliang Tang chk_add_nr 3 3 1276ef360019SGeliang Tang 1277ef360019SGeliang Tang # signal invalid addresses 1278ef360019SGeliang Tang reset 127934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 128034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 128134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 128234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 128334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1284ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1285ef360019SGeliang Tang chk_join_nr "signal invalid addresses" 1 1 1 1286ef360019SGeliang Tang chk_add_nr 3 3 128733c563adSYonglong Li 128833c563adSYonglong Li # signal addresses race test 128933c563adSYonglong Li reset 129034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 129134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 129234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.1.1 flags signal 129334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 129434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 129534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 129634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.1.2 flags signal 129734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags signal 129834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags signal 129934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags signal 130033c563adSYonglong Li run_tests $ns1 $ns2 10.0.1.1 1301857898ebSMatthieu Baerts chk_join_nr "signal addresses race test" 3 3 3 130286e39e04SPaolo Abeni 130386e39e04SPaolo Abeni # the server will not signal the address terminating 130486e39e04SPaolo Abeni # the MPC subflow 130586e39e04SPaolo Abeni chk_add_nr 3 3 13061002b89fSGeliang Tang} 1307b08fbf24SPaolo Abeni 13081002b89fSGeliang Tanglink_failure_tests() 13091002b89fSGeliang Tang{ 13108b819a84SFlorian Westphal # accept and use add_addr with additional subflows and link loss 13118b819a84SFlorian Westphal reset 13127d1e6f16SPaolo Abeni 13137d1e6f16SPaolo Abeni # without any b/w limit each veth could spool the packets and get 13147d1e6f16SPaolo Abeni # them acked at xmit time, so that the corresponding subflow will 13157d1e6f16SPaolo Abeni # have almost always no outstanding pkts, the scheduler will pick 13167d1e6f16SPaolo Abeni # always the first subflow and we will have hard time testing 13177d1e6f16SPaolo Abeni # active backup and link switch-over. 13187d1e6f16SPaolo Abeni # Let's set some arbitrary (low) virtual link limits. 13197d1e6f16SPaolo Abeni init_shapers 132034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 132134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 132234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 132334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow 132434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow 13258b819a84SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 1 13268b819a84SFlorian Westphal chk_join_nr "multiple flows, signal, link failure" 3 3 3 13278b819a84SFlorian Westphal chk_add_nr 1 1 13287d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 5 1 13297d1e6f16SPaolo Abeni 13307d1e6f16SPaolo Abeni # accept and use add_addr with additional subflows and link loss 13317d1e6f16SPaolo Abeni # for bidirectional transfer 13327d1e6f16SPaolo Abeni reset 13337d1e6f16SPaolo Abeni init_shapers 133434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 133534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 133634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 133734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow 133834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow 13397d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2 13407d1e6f16SPaolo Abeni chk_join_nr "multi flows, signal, bidi, link fail" 3 3 3 13417d1e6f16SPaolo Abeni chk_add_nr 1 1 13427d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 -1 1 13437d1e6f16SPaolo Abeni 13447d1e6f16SPaolo Abeni # 2 subflows plus 1 backup subflow with a lossy link, backup 13457d1e6f16SPaolo Abeni # will never be used 13467d1e6f16SPaolo Abeni reset 13477d1e6f16SPaolo Abeni init_shapers 134834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 134934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 135034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 13517d1e6f16SPaolo Abeni export FAILING_LINKS="1" 135234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 13537d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1 13547d1e6f16SPaolo Abeni chk_join_nr "backup subflow unused, link failure" 2 2 2 13557d1e6f16SPaolo Abeni chk_add_nr 1 1 13567d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 0 13577d1e6f16SPaolo Abeni 13587d1e6f16SPaolo Abeni # 2 lossy links after half transfer, backup will get half of 13597d1e6f16SPaolo Abeni # the traffic 13607d1e6f16SPaolo Abeni reset 13617d1e6f16SPaolo Abeni init_shapers 136234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 136334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 136434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 136534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 13667d1e6f16SPaolo Abeni export FAILING_LINKS="1 2" 13677d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1 13687d1e6f16SPaolo Abeni chk_join_nr "backup flow used, multi links fail" 2 2 2 13697d1e6f16SPaolo Abeni chk_add_nr 1 1 13707d1e6f16SPaolo Abeni chk_stale_nr $ns2 2 4 2 13717d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 50 13727d1e6f16SPaolo Abeni 13737d1e6f16SPaolo Abeni # use a backup subflow with the first subflow on a lossy link 13747d1e6f16SPaolo Abeni # for bidirectional transfer 13757d1e6f16SPaolo Abeni reset 13767d1e6f16SPaolo Abeni init_shapers 137734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 137834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 137934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 138034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 13817d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2 13827d1e6f16SPaolo Abeni chk_join_nr "backup flow used, bidi, link failure" 2 2 2 13837d1e6f16SPaolo Abeni chk_add_nr 1 1 13847d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 -1 2 13857d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 50 13861002b89fSGeliang Tang} 13878b819a84SFlorian Westphal 13881002b89fSGeliang Tangadd_addr_timeout_tests() 13891002b89fSGeliang Tang{ 13908d014eaaSGeliang Tang # add_addr timeout 13918d014eaaSGeliang Tang reset_with_add_addr_timeout 139234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 139334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 139434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 13958b819a84SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 13968d014eaaSGeliang Tang chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1 13978d014eaaSGeliang Tang chk_add_nr 4 0 13988d014eaaSGeliang Tang 13991002b89fSGeliang Tang # add_addr timeout IPv6 14001002b89fSGeliang Tang reset_with_add_addr_timeout 6 140134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 140234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 140334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 14041002b89fSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 14051002b89fSGeliang Tang chk_join_nr "signal address, ADD_ADDR6 timeout" 1 1 1 14061002b89fSGeliang Tang chk_add_nr 4 0 14078da6229bSGeliang Tang 14088da6229bSGeliang Tang # signal addresses timeout 14098da6229bSGeliang Tang reset_with_add_addr_timeout 141034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 141134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 141234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 141334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 14148da6229bSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 14158da6229bSGeliang Tang chk_join_nr "signal addresses, ADD_ADDR timeout" 2 2 2 14168da6229bSGeliang Tang chk_add_nr 8 0 14178da6229bSGeliang Tang 14188da6229bSGeliang Tang # signal invalid addresses timeout 14198da6229bSGeliang Tang reset_with_add_addr_timeout 142034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 142134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 142234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 142334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 14248da6229bSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 14258da6229bSGeliang Tang chk_join_nr "invalid address, ADD_ADDR timeout" 1 1 1 14268da6229bSGeliang Tang chk_add_nr 8 0 14271002b89fSGeliang Tang} 14281002b89fSGeliang Tang 14291002b89fSGeliang Tangremove_tests() 14301002b89fSGeliang Tang{ 1431dd72b0feSGeliang Tang # single subflow, remove 1432dd72b0feSGeliang Tang reset 143334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 143434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 143534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 14362e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -1 slow 1437dd72b0feSGeliang Tang chk_join_nr "remove single subflow" 1 1 1 1438dd72b0feSGeliang Tang chk_rm_nr 1 1 1439dd72b0feSGeliang Tang 1440dd72b0feSGeliang Tang # multiple subflows, remove 1441dd72b0feSGeliang Tang reset 144234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 144334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 144434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 144534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 14462e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -2 slow 1447dd72b0feSGeliang Tang chk_join_nr "remove multiple subflows" 2 2 2 1448dd72b0feSGeliang Tang chk_rm_nr 2 2 1449dd72b0feSGeliang Tang 1450dd72b0feSGeliang Tang # single address, remove 1451dd72b0feSGeliang Tang reset 145234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 145334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 145434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 14552e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 1456dd72b0feSGeliang Tang chk_join_nr "remove single address" 1 1 1 1457dd72b0feSGeliang Tang chk_add_nr 1 1 14587028ba8aSGeliang Tang chk_rm_nr 1 1 invert 1459dd72b0feSGeliang Tang 1460dd72b0feSGeliang Tang # subflow and signal, remove 1461dd72b0feSGeliang Tang reset 146234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 146334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 146434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 146534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 14662e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 1467dd72b0feSGeliang Tang chk_join_nr "remove subflow and signal" 2 2 2 1468dd72b0feSGeliang Tang chk_add_nr 1 1 1469dd72b0feSGeliang Tang chk_rm_nr 1 1 1470dd72b0feSGeliang Tang 1471dd72b0feSGeliang Tang # subflows and signal, remove 1472dd72b0feSGeliang Tang reset 147334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 147434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 147534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 147634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 147734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 14782e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -2 slow 1479dd72b0feSGeliang Tang chk_join_nr "remove subflows and signal" 3 3 3 1480dd72b0feSGeliang Tang chk_add_nr 1 1 1481dd72b0feSGeliang Tang chk_rm_nr 2 2 1482dd72b0feSGeliang Tang 1483ef360019SGeliang Tang # addresses remove 1484ef360019SGeliang Tang reset 148534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 148634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 148734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 148834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 148934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1490ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 1491ef360019SGeliang Tang chk_join_nr "remove addresses" 3 3 3 1492ef360019SGeliang Tang chk_add_nr 3 3 1493ef360019SGeliang Tang chk_rm_nr 3 3 invert 1494ef360019SGeliang Tang 1495ef360019SGeliang Tang # invalid addresses remove 1496ef360019SGeliang Tang reset 149734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 149834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 149934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 150034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 150134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1502ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 1503ef360019SGeliang Tang chk_join_nr "remove invalid addresses" 1 1 1 1504ef360019SGeliang Tang chk_add_nr 3 3 1505ef360019SGeliang Tang chk_rm_nr 3 1 invert 1506ef360019SGeliang Tang 15076fe4ccdcSGeliang Tang # subflows and signal, flush 15086fe4ccdcSGeliang Tang reset 150934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 151034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 151134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 151234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 151334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 15142e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 15156fe4ccdcSGeliang Tang chk_join_nr "flush subflows and signal" 3 3 3 15166fe4ccdcSGeliang Tang chk_add_nr 1 1 15176fe4ccdcSGeliang Tang chk_rm_nr 2 2 1518d2c4333aSGeliang Tang 1519d2c4333aSGeliang Tang # subflows flush 1520d2c4333aSGeliang Tang reset 152134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 152234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 152334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow id 150 152434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 152534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 1526d2c4333aSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1527d2c4333aSGeliang Tang chk_join_nr "flush subflows" 3 3 3 1528d2c4333aSGeliang Tang chk_rm_nr 3 3 1529d2c4333aSGeliang Tang 1530d2c4333aSGeliang Tang # addresses flush 1531d2c4333aSGeliang Tang reset 153234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 153334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 153434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 153534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 153634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1537d2c4333aSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1538d2c4333aSGeliang Tang chk_join_nr "flush addresses" 3 3 3 1539d2c4333aSGeliang Tang chk_add_nr 3 3 1540d2c4333aSGeliang Tang chk_rm_nr 3 3 invert 1541ef360019SGeliang Tang 1542ef360019SGeliang Tang # invalid addresses flush 1543ef360019SGeliang Tang reset 154434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 154534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 154634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 154734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 154834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1549ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 0 slow 1550ef360019SGeliang Tang chk_join_nr "flush invalid addresses" 1 1 1 1551ef360019SGeliang Tang chk_add_nr 3 3 1552ef360019SGeliang Tang chk_rm_nr 3 1 invert 15535e287fe7SGeliang Tang 15545e287fe7SGeliang Tang # remove id 0 subflow 15555e287fe7SGeliang Tang reset 155634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 155734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 155834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 15595e287fe7SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -9 slow 15605e287fe7SGeliang Tang chk_join_nr "remove id 0 subflow" 1 1 1 15615e287fe7SGeliang Tang chk_rm_nr 1 1 15625e287fe7SGeliang Tang 15635e287fe7SGeliang Tang # remove id 0 address 15645e287fe7SGeliang Tang reset 156534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 156634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 156734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 15685e287fe7SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -9 0 slow 15695e287fe7SGeliang Tang chk_join_nr "remove id 0 address" 1 1 1 15705e287fe7SGeliang Tang chk_add_nr 1 1 15715e287fe7SGeliang Tang chk_rm_nr 1 1 invert 15721002b89fSGeliang Tang} 15736fe4ccdcSGeliang Tang 15741002b89fSGeliang Tangadd_tests() 15751002b89fSGeliang Tang{ 15766208fd82SGeliang Tang # add single subflow 15776208fd82SGeliang Tang reset 157834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 157934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 15806208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow 15816208fd82SGeliang Tang chk_join_nr "add single subflow" 1 1 1 15826208fd82SGeliang Tang 15836208fd82SGeliang Tang # add signal address 15846208fd82SGeliang Tang reset 158534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 158634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 15876208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 15886208fd82SGeliang Tang chk_join_nr "add signal address" 1 1 1 15896208fd82SGeliang Tang chk_add_nr 1 1 15906208fd82SGeliang Tang 15916208fd82SGeliang Tang # add multiple subflows 15926208fd82SGeliang Tang reset 159334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 159434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 15956208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 2 slow 15966208fd82SGeliang Tang chk_join_nr "add multiple subflows" 2 2 2 15976208fd82SGeliang Tang 15986208fd82SGeliang Tang # add multiple subflows IPv6 15996208fd82SGeliang Tang reset 160034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 160134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 16026208fd82SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 2 slow 16036208fd82SGeliang Tang chk_join_nr "add multiple subflows IPv6" 2 2 2 16046208fd82SGeliang Tang 16056208fd82SGeliang Tang # add multiple addresses IPv6 16066208fd82SGeliang Tang reset 160734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 160834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 16096208fd82SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 2 0 slow 16106208fd82SGeliang Tang chk_join_nr "add multiple addresses IPv6" 2 2 2 16116208fd82SGeliang Tang chk_add_nr 2 2 16121002b89fSGeliang Tang} 16136208fd82SGeliang Tang 16141002b89fSGeliang Tangipv6_tests() 16151002b89fSGeliang Tang{ 1616523514edSGeliang Tang # subflow IPv6 1617523514edSGeliang Tang reset 161834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 161934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 162034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow 1621523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1622523514edSGeliang Tang chk_join_nr "single subflow IPv6" 1 1 1 1623523514edSGeliang Tang 1624523514edSGeliang Tang # add_address, unused IPv6 1625523514edSGeliang Tang reset 162634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 1627523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1628523514edSGeliang Tang chk_join_nr "unused signal address IPv6" 0 0 0 1629523514edSGeliang Tang chk_add_nr 1 1 1630523514edSGeliang Tang 1631523514edSGeliang Tang # signal address IPv6 1632523514edSGeliang Tang reset 163334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 163434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 163534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 1636523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1637523514edSGeliang Tang chk_join_nr "single address IPv6" 1 1 1 1638523514edSGeliang Tang chk_add_nr 1 1 1639523514edSGeliang Tang 1640523514edSGeliang Tang # single address IPv6, remove 1641523514edSGeliang Tang reset 164234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 164334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 164434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 16452e8cbf45SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 -1 0 slow 1646523514edSGeliang Tang chk_join_nr "remove single address IPv6" 1 1 1 1647523514edSGeliang Tang chk_add_nr 1 1 16487028ba8aSGeliang Tang chk_rm_nr 1 1 invert 1649523514edSGeliang Tang 1650523514edSGeliang Tang # subflow and signal IPv6, remove 1651523514edSGeliang Tang reset 165234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 165334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 165434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 165534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow 16562e8cbf45SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 -1 -1 slow 1657523514edSGeliang Tang chk_join_nr "remove subflow and signal IPv6" 2 2 2 1658523514edSGeliang Tang chk_add_nr 1 1 1659523514edSGeliang Tang chk_rm_nr 1 1 16601002b89fSGeliang Tang} 1661523514edSGeliang Tang 16621002b89fSGeliang Tangv4mapped_tests() 16631002b89fSGeliang Tang{ 1664a6094788SGeliang Tang # subflow IPv4-mapped to IPv4-mapped 1665a6094788SGeliang Tang reset 166634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 166734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 166834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow 1669a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1670a6094788SGeliang Tang chk_join_nr "single subflow IPv4-mapped" 1 1 1 1671a6094788SGeliang Tang 1672a6094788SGeliang Tang # signal address IPv4-mapped with IPv4-mapped sk 1673a6094788SGeliang Tang reset 167434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 167534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 167634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal 1677a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1678a6094788SGeliang Tang chk_join_nr "signal address IPv4-mapped" 1 1 1 1679a6094788SGeliang Tang chk_add_nr 1 1 1680a6094788SGeliang Tang 1681a6094788SGeliang Tang # subflow v4-map-v6 1682a6094788SGeliang Tang reset 168334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 168434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 168534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1686a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1687a6094788SGeliang Tang chk_join_nr "single subflow v4-map-v6" 1 1 1 1688a6094788SGeliang Tang 1689a6094788SGeliang Tang # signal address v4-map-v6 1690a6094788SGeliang Tang reset 169134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 169234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 169334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 1694a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1695a6094788SGeliang Tang chk_join_nr "signal address v4-map-v6" 1 1 1 1696a6094788SGeliang Tang chk_add_nr 1 1 1697a6094788SGeliang Tang 1698a6094788SGeliang Tang # subflow v6-map-v4 1699a6094788SGeliang Tang reset 170034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 170134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 170234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow 1703a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1704a6094788SGeliang Tang chk_join_nr "single subflow v6-map-v4" 1 1 1 1705a6094788SGeliang Tang 1706a6094788SGeliang Tang # signal address v6-map-v4 1707a6094788SGeliang Tang reset 170834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 170934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 171034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal 1711a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1712a6094788SGeliang Tang chk_join_nr "signal address v6-map-v4" 1 1 1 1713a6094788SGeliang Tang chk_add_nr 1 1 1714a6094788SGeliang Tang 1715a6094788SGeliang Tang # no subflow IPv6 to v4 address 1716a6094788SGeliang Tang reset 171734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 171834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 171934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow 1720a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1721a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v4-v6" 0 0 0 1722a6094788SGeliang Tang 1723a6094788SGeliang Tang # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end 1724a6094788SGeliang Tang reset 172534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 172634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 172734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:2::10.0.3.2 flags subflow 1728a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1729a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v4-v6-2" 0 0 0 1730a6094788SGeliang Tang 1731a6094788SGeliang Tang # no subflow IPv4 to v6 address, no need to slow down too then 1732a6094788SGeliang Tang reset 173334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 173434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 173534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1736a6094788SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 1737a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v6-v4" 0 0 0 17381002b89fSGeliang Tang} 1739a6094788SGeliang Tang 17401002b89fSGeliang Tangbackup_tests() 17411002b89fSGeliang Tang{ 1742718eb44eSGeliang Tang # single subflow, backup 1743718eb44eSGeliang Tang reset 174434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 174534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 174634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup 1747718eb44eSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup 1748718eb44eSGeliang Tang chk_join_nr "single subflow, backup" 1 1 1 1749718eb44eSGeliang Tang chk_prio_nr 0 1 1750718eb44eSGeliang Tang 1751718eb44eSGeliang Tang # single address, backup 1752718eb44eSGeliang Tang reset 175334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 175434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 175534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 1756718eb44eSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup 1757718eb44eSGeliang Tang chk_join_nr "single address, backup" 1 1 1 1758718eb44eSGeliang Tang chk_add_nr 1 1 1759718eb44eSGeliang Tang chk_prio_nr 1 0 176033397b83SGeliang Tang 176133397b83SGeliang Tang # single address with port, backup 176233397b83SGeliang Tang reset 176334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 176434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 176534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 176633397b83SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup 176733397b83SGeliang Tang chk_join_nr "single address with port, backup" 1 1 1 176833397b83SGeliang Tang chk_add_nr 1 1 176933397b83SGeliang Tang chk_prio_nr 1 0 17701002b89fSGeliang Tang} 1771718eb44eSGeliang Tang 17721002b89fSGeliang Tangadd_addr_ports_tests() 17731002b89fSGeliang Tang{ 17748a127bf6SGeliang Tang # signal address with port 17758a127bf6SGeliang Tang reset 177634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 177734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 177834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 17798a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 17808a127bf6SGeliang Tang chk_join_nr "signal address with port" 1 1 1 17818a127bf6SGeliang Tang chk_add_nr 1 1 1 17828a127bf6SGeliang Tang 17838a127bf6SGeliang Tang # subflow and signal with port 17848a127bf6SGeliang Tang reset 178534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 178634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 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 17908a127bf6SGeliang Tang chk_join_nr "subflow and signal with port" 2 2 2 17918a127bf6SGeliang Tang chk_add_nr 1 1 1 17928a127bf6SGeliang Tang 17938a127bf6SGeliang Tang # single address with port, remove 17948a127bf6SGeliang Tang reset 179534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 179634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 179734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 17988a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 17998a127bf6SGeliang Tang chk_join_nr "remove single address with port" 1 1 1 18008a127bf6SGeliang Tang chk_add_nr 1 1 1 18017028ba8aSGeliang Tang chk_rm_nr 1 1 invert 18028a127bf6SGeliang Tang 18038a127bf6SGeliang Tang # subflow and signal with port, remove 18048a127bf6SGeliang Tang reset 180534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 180634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 180734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 180834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 18098a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 18108a127bf6SGeliang Tang chk_join_nr "remove subflow and signal with port" 2 2 2 18118a127bf6SGeliang Tang chk_add_nr 1 1 1 18128a127bf6SGeliang Tang chk_rm_nr 1 1 18138a127bf6SGeliang Tang 18148a127bf6SGeliang Tang # subflows and signal with port, flush 18158a127bf6SGeliang Tang reset 181634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 181734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 181834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 181934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 182034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 1821327b9a94SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 -8 -2 slow 18228a127bf6SGeliang Tang chk_join_nr "flush subflows and signal with port" 3 3 3 18238a127bf6SGeliang Tang chk_add_nr 1 1 18248a127bf6SGeliang Tang chk_rm_nr 2 2 18258a127bf6SGeliang Tang 18268a127bf6SGeliang Tang # multiple addresses with port 18278a127bf6SGeliang Tang reset 182834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 182934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 183034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10100 183134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 18328a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 18338a127bf6SGeliang Tang chk_join_nr "multiple addresses with port" 2 2 2 18348a127bf6SGeliang Tang chk_add_nr 2 2 2 18358a127bf6SGeliang Tang 18368a127bf6SGeliang Tang # multiple addresses with ports 18378a127bf6SGeliang Tang reset 183834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 183934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 184034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10101 184134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 18428a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 18438a127bf6SGeliang Tang chk_join_nr "multiple addresses with ports" 2 2 2 18448a127bf6SGeliang Tang chk_add_nr 2 2 2 18451002b89fSGeliang Tang} 18468a127bf6SGeliang Tang 18471002b89fSGeliang Tangsyncookies_tests() 18481002b89fSGeliang Tang{ 184900587187SFlorian Westphal # single subflow, syncookies 185000587187SFlorian Westphal reset_with_cookies 185134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 185234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 185334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 185400587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 185500587187SFlorian Westphal chk_join_nr "single subflow with syn cookies" 1 1 1 185600587187SFlorian Westphal 185700587187SFlorian Westphal # multiple subflows with syn cookies 185800587187SFlorian Westphal reset_with_cookies 185934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 186034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 186134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 186234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 186300587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 186400587187SFlorian Westphal chk_join_nr "multiple subflows with syn cookies" 2 2 2 186500587187SFlorian Westphal 186600587187SFlorian Westphal # multiple subflows limited by server 186700587187SFlorian Westphal reset_with_cookies 186834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 186934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 187034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 187134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 187200587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 1873a7da4416SJianguo Wu chk_join_nr "subflows limited by server w cookies" 2 1 1 187400587187SFlorian Westphal 187500587187SFlorian Westphal # test signal address with cookies 187600587187SFlorian Westphal reset_with_cookies 187734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 187834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 187934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 188000587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 188100587187SFlorian Westphal chk_join_nr "signal address with syn cookies" 1 1 1 1882be613160SGeliang Tang chk_add_nr 1 1 188300587187SFlorian Westphal 188400587187SFlorian Westphal # test cookie with subflow and signal 188500587187SFlorian Westphal reset_with_cookies 188634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 188734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 188834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 188934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 189000587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 189100587187SFlorian Westphal chk_join_nr "subflow and signal w cookies" 2 2 2 1892be613160SGeliang Tang chk_add_nr 1 1 189300587187SFlorian Westphal 189400587187SFlorian Westphal # accept and use add_addr with additional subflows 189500587187SFlorian Westphal reset_with_cookies 189634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 189734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 189834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 189934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 190034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 190100587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 190200587187SFlorian Westphal chk_join_nr "subflows and signal w. cookies" 3 3 3 1903be613160SGeliang Tang chk_add_nr 1 1 19041002b89fSGeliang Tang} 19051002b89fSGeliang Tang 1906af66d3e1SGeliang Tangchecksum_tests() 1907af66d3e1SGeliang Tang{ 1908af66d3e1SGeliang Tang # checksum test 0 0 1909af66d3e1SGeliang Tang reset_with_checksum 0 0 191034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 191134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1912af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1913af66d3e1SGeliang Tang chk_csum_nr "checksum test 0 0" 1914af66d3e1SGeliang Tang 1915af66d3e1SGeliang Tang # checksum test 1 1 1916af66d3e1SGeliang Tang reset_with_checksum 1 1 191734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 191834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1919af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1920af66d3e1SGeliang Tang chk_csum_nr "checksum test 1 1" 1921af66d3e1SGeliang Tang 1922af66d3e1SGeliang Tang # checksum test 0 1 1923af66d3e1SGeliang Tang reset_with_checksum 0 1 192434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 192534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1926af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1927af66d3e1SGeliang Tang chk_csum_nr "checksum test 0 1" 1928af66d3e1SGeliang Tang 1929af66d3e1SGeliang Tang # checksum test 1 0 1930af66d3e1SGeliang Tang reset_with_checksum 1 0 193134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 193234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1933af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1934af66d3e1SGeliang Tang chk_csum_nr "checksum test 1 0" 1935af66d3e1SGeliang Tang} 1936af66d3e1SGeliang Tang 19370cddb4a6SGeliang Tangdeny_join_id0_tests() 19380cddb4a6SGeliang Tang{ 19390cddb4a6SGeliang Tang # subflow allow join id0 ns1 19400cddb4a6SGeliang Tang reset_with_allow_join_id0 1 0 194134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 194234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 194334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19440cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19450cddb4a6SGeliang Tang chk_join_nr "single subflow allow join id0 ns1" 1 1 1 19460cddb4a6SGeliang Tang 19470cddb4a6SGeliang Tang # subflow allow join id0 ns2 19480cddb4a6SGeliang Tang reset_with_allow_join_id0 0 1 194934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 195034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 195134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19520cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19530cddb4a6SGeliang Tang chk_join_nr "single subflow allow join id0 ns2" 0 0 0 19540cddb4a6SGeliang Tang 19550cddb4a6SGeliang Tang # signal address allow join id0 ns1 19560cddb4a6SGeliang Tang # ADD_ADDRs are not affected by allow_join_id0 value. 19570cddb4a6SGeliang Tang reset_with_allow_join_id0 1 0 195834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 195934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 196034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 19610cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19620cddb4a6SGeliang Tang chk_join_nr "signal address allow join id0 ns1" 1 1 1 19630cddb4a6SGeliang Tang chk_add_nr 1 1 19640cddb4a6SGeliang Tang 19650cddb4a6SGeliang Tang # signal address allow join id0 ns2 19660cddb4a6SGeliang Tang # ADD_ADDRs are not affected by allow_join_id0 value. 19670cddb4a6SGeliang Tang reset_with_allow_join_id0 0 1 196834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 196934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 197034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 19710cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19720cddb4a6SGeliang Tang chk_join_nr "signal address allow join id0 ns2" 1 1 1 19730cddb4a6SGeliang Tang chk_add_nr 1 1 19740cddb4a6SGeliang Tang 19750cddb4a6SGeliang Tang # subflow and address allow join id0 ns1 19760cddb4a6SGeliang Tang reset_with_allow_join_id0 1 0 197734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 197834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 197934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 198034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19810cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19820cddb4a6SGeliang Tang chk_join_nr "subflow and address allow join id0 1" 2 2 2 19830cddb4a6SGeliang Tang 19840cddb4a6SGeliang Tang # subflow and address allow join id0 ns2 19850cddb4a6SGeliang Tang reset_with_allow_join_id0 0 1 198634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 198734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 198834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 198934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19900cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19910cddb4a6SGeliang Tang chk_join_nr "subflow and address allow join id0 2" 1 1 1 19920cddb4a6SGeliang Tang} 19930cddb4a6SGeliang Tang 19944f49d633SGeliang Tangfullmesh_tests() 19954f49d633SGeliang Tang{ 19964f49d633SGeliang Tang # fullmesh 1 19974f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added before the connection, 19984f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added during the connection. 19994f49d633SGeliang Tang reset 200034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 4 200134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 4 200234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,fullmesh 200334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,fullmesh 20044f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 20054f49d633SGeliang Tang chk_join_nr "fullmesh test 2x1" 4 4 4 20064f49d633SGeliang Tang chk_add_nr 1 1 20074f49d633SGeliang Tang 20084f49d633SGeliang Tang # fullmesh 2 20094f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 20104f49d633SGeliang Tang # 1 fullmesh addr in ns2, added during the connection. 20114f49d633SGeliang Tang reset 201234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 3 201334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 201434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 20154f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow 20164f49d633SGeliang Tang chk_join_nr "fullmesh test 1x1" 3 3 3 20174f49d633SGeliang Tang chk_add_nr 1 1 20184f49d633SGeliang Tang 20194f49d633SGeliang Tang # fullmesh 3 20204f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 20214f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added during the connection. 20224f49d633SGeliang Tang reset 202334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 5 202434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 5 202534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 20264f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow 20274f49d633SGeliang Tang chk_join_nr "fullmesh test 1x2" 5 5 5 20284f49d633SGeliang Tang chk_add_nr 1 1 20294f49d633SGeliang Tang 20304f49d633SGeliang Tang # fullmesh 4 20314f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 20324f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added during the connection, 20334f49d633SGeliang Tang # limit max_subflows to 4. 20344f49d633SGeliang Tang reset 203534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 4 203634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 4 203734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 20384f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow 20394f49d633SGeliang Tang chk_join_nr "fullmesh test 1x2, limited" 4 4 4 20404f49d633SGeliang Tang chk_add_nr 1 1 20416a0653b9SGeliang Tang 20426a0653b9SGeliang Tang # set fullmesh flag 20436a0653b9SGeliang Tang reset 204434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 204534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow 204634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 20476a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow fullmesh 20486a0653b9SGeliang Tang chk_join_nr "set fullmesh flag test" 2 2 2 20496a0653b9SGeliang Tang chk_rm_nr 0 1 20506a0653b9SGeliang Tang 20516a0653b9SGeliang Tang # set nofullmesh flag 20526a0653b9SGeliang Tang reset 205334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 205434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow,fullmesh 205534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 20566a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow nofullmesh 20576a0653b9SGeliang Tang chk_join_nr "set nofullmesh flag test" 2 2 2 20586a0653b9SGeliang Tang chk_rm_nr 0 1 20596a0653b9SGeliang Tang 20606a0653b9SGeliang Tang # set backup,fullmesh flags 20616a0653b9SGeliang Tang reset 206234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 206334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow 206434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 20656a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow backup,fullmesh 20666a0653b9SGeliang Tang chk_join_nr "set backup,fullmesh flags test" 2 2 2 20676a0653b9SGeliang Tang chk_prio_nr 0 1 20686a0653b9SGeliang Tang chk_rm_nr 0 1 20696a0653b9SGeliang Tang 20706a0653b9SGeliang Tang # set nobackup,nofullmesh flags 20716a0653b9SGeliang Tang reset 207234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 207334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 207434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,backup,fullmesh 20756a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup,nofullmesh 20766a0653b9SGeliang Tang chk_join_nr "set nobackup,nofullmesh flags test" 2 2 2 20776a0653b9SGeliang Tang chk_prio_nr 0 1 20786a0653b9SGeliang Tang chk_rm_nr 0 1 20794f49d633SGeliang Tang} 20804f49d633SGeliang Tang 20811002b89fSGeliang Tangall_tests() 20821002b89fSGeliang Tang{ 20831002b89fSGeliang Tang subflows_tests 208446e967d1SPaolo Abeni subflows_error_tests 20851002b89fSGeliang Tang signal_address_tests 20861002b89fSGeliang Tang link_failure_tests 20871002b89fSGeliang Tang add_addr_timeout_tests 20881002b89fSGeliang Tang remove_tests 20891002b89fSGeliang Tang add_tests 20901002b89fSGeliang Tang ipv6_tests 20911002b89fSGeliang Tang v4mapped_tests 20921002b89fSGeliang Tang backup_tests 20931002b89fSGeliang Tang add_addr_ports_tests 20941002b89fSGeliang Tang syncookies_tests 2095af66d3e1SGeliang Tang checksum_tests 20960cddb4a6SGeliang Tang deny_join_id0_tests 20974f49d633SGeliang Tang fullmesh_tests 20981002b89fSGeliang Tang} 20991002b89fSGeliang Tang 210022514d52SMatthieu Baerts# [$1: error message] 21011002b89fSGeliang Tangusage() 21021002b89fSGeliang Tang{ 210322514d52SMatthieu Baerts if [ -n "${1}" ]; then 210422514d52SMatthieu Baerts echo "${1}" 210522514d52SMatthieu Baerts ret=1 210622514d52SMatthieu Baerts fi 210722514d52SMatthieu Baerts 21081002b89fSGeliang Tang echo "mptcp_join usage:" 21091002b89fSGeliang Tang echo " -f subflows_tests" 211046e967d1SPaolo Abeni echo " -e subflows_error_tests" 21111002b89fSGeliang Tang echo " -s signal_address_tests" 21121002b89fSGeliang Tang echo " -l link_failure_tests" 21131002b89fSGeliang Tang echo " -t add_addr_timeout_tests" 21141002b89fSGeliang Tang echo " -r remove_tests" 21151002b89fSGeliang Tang echo " -a add_tests" 21161002b89fSGeliang Tang echo " -6 ipv6_tests" 21171002b89fSGeliang Tang echo " -4 v4mapped_tests" 21181002b89fSGeliang Tang echo " -b backup_tests" 21191002b89fSGeliang Tang echo " -p add_addr_ports_tests" 2120a673321aSMat Martineau echo " -k syncookies_tests" 2121af66d3e1SGeliang Tang echo " -S checksum_tests" 21220cddb4a6SGeliang Tang echo " -d deny_join_id0_tests" 21234f49d633SGeliang Tang echo " -m fullmesh_tests" 2124a673321aSMat Martineau echo " -c capture pcap files" 2125af66d3e1SGeliang Tang echo " -C enable data checksum" 2126621bd393SGeliang Tang echo " -i use ip mptcp" 21271002b89fSGeliang Tang echo " -h help" 212822514d52SMatthieu Baerts 212922514d52SMatthieu Baerts exit ${ret} 21301002b89fSGeliang Tang} 21311002b89fSGeliang Tang 2132a673321aSMat Martineaufor arg in "$@"; do 2133af66d3e1SGeliang Tang # check for "capture/checksum" args before launching tests 2134a673321aSMat Martineau if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"c"[0-9a-zA-Z]*$ ]]; then 2135a673321aSMat Martineau capture=1 2136a673321aSMat Martineau fi 2137af66d3e1SGeliang Tang if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"C"[0-9a-zA-Z]*$ ]]; then 2138af66d3e1SGeliang Tang checksum=1 2139af66d3e1SGeliang Tang fi 2140621bd393SGeliang Tang if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"i"[0-9a-zA-Z]*$ ]]; then 2141621bd393SGeliang Tang ip_mptcp=1 2142621bd393SGeliang Tang fi 2143a673321aSMat Martineau 2144621bd393SGeliang Tang # exception for the capture/checksum/ip_mptcp options, the rest means: a part of the tests 2145621bd393SGeliang Tang if [ "${arg}" != "-c" ] && [ "${arg}" != "-C" ] && [ "${arg}" != "-i" ]; then 2146a673321aSMat Martineau do_all_tests=0 2147a673321aSMat Martineau fi 2148a673321aSMat Martineaudone 2149a673321aSMat Martineau 2150a673321aSMat Martineauif [ $do_all_tests -eq 1 ]; then 21511002b89fSGeliang Tang all_tests 21521002b89fSGeliang Tang exit $ret 21531002b89fSGeliang Tangfi 21541002b89fSGeliang Tang 2155621bd393SGeliang Tangwhile getopts 'fesltra64bpkdmchCSi' opt; do 21561002b89fSGeliang Tang case $opt in 21571002b89fSGeliang Tang f) 21581002b89fSGeliang Tang subflows_tests 21591002b89fSGeliang Tang ;; 216046e967d1SPaolo Abeni e) 216146e967d1SPaolo Abeni subflows_error_tests 216246e967d1SPaolo Abeni ;; 21631002b89fSGeliang Tang s) 21641002b89fSGeliang Tang signal_address_tests 21651002b89fSGeliang Tang ;; 21661002b89fSGeliang Tang l) 21671002b89fSGeliang Tang link_failure_tests 21681002b89fSGeliang Tang ;; 21691002b89fSGeliang Tang t) 21701002b89fSGeliang Tang add_addr_timeout_tests 21711002b89fSGeliang Tang ;; 21721002b89fSGeliang Tang r) 21731002b89fSGeliang Tang remove_tests 21741002b89fSGeliang Tang ;; 21751002b89fSGeliang Tang a) 21761002b89fSGeliang Tang add_tests 21771002b89fSGeliang Tang ;; 21781002b89fSGeliang Tang 6) 21791002b89fSGeliang Tang ipv6_tests 21801002b89fSGeliang Tang ;; 21811002b89fSGeliang Tang 4) 21821002b89fSGeliang Tang v4mapped_tests 21831002b89fSGeliang Tang ;; 21841002b89fSGeliang Tang b) 21851002b89fSGeliang Tang backup_tests 21861002b89fSGeliang Tang ;; 21871002b89fSGeliang Tang p) 21881002b89fSGeliang Tang add_addr_ports_tests 21891002b89fSGeliang Tang ;; 2190a673321aSMat Martineau k) 21911002b89fSGeliang Tang syncookies_tests 21921002b89fSGeliang Tang ;; 2193af66d3e1SGeliang Tang S) 2194af66d3e1SGeliang Tang checksum_tests 2195af66d3e1SGeliang Tang ;; 21960cddb4a6SGeliang Tang d) 21970cddb4a6SGeliang Tang deny_join_id0_tests 21980cddb4a6SGeliang Tang ;; 21994f49d633SGeliang Tang m) 22004f49d633SGeliang Tang fullmesh_tests 22014f49d633SGeliang Tang ;; 2202a673321aSMat Martineau c) 2203a673321aSMat Martineau ;; 2204af66d3e1SGeliang Tang C) 2205af66d3e1SGeliang Tang ;; 2206621bd393SGeliang Tang i) 2207621bd393SGeliang Tang ;; 220822514d52SMatthieu Baerts h) 22091002b89fSGeliang Tang usage 22101002b89fSGeliang Tang ;; 221122514d52SMatthieu Baerts *) 221222514d52SMatthieu Baerts usage "Unknown option: -${opt}" 221322514d52SMatthieu Baerts ;; 22141002b89fSGeliang Tang esac 22151002b89fSGeliang Tangdone 221600587187SFlorian Westphal 2217b08fbf24SPaolo Abeniexit $ret 2218