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 23*9a0a9367SGeliang Tangnr_blank=40 24b08fbf24SPaolo Abeni 258d014eaaSGeliang Tang# generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) || 268d014eaaSGeliang Tang# (ip6 && (ip6[74] & 0xf0) == 0x30)'" 278d014eaaSGeliang TangCBPF_MPTCP_SUBOPTION_ADD_ADDR="14, 288d014eaaSGeliang Tang 48 0 0 0, 298d014eaaSGeliang Tang 84 0 0 240, 308d014eaaSGeliang Tang 21 0 3 64, 318d014eaaSGeliang Tang 48 0 0 54, 328d014eaaSGeliang Tang 84 0 0 240, 338d014eaaSGeliang Tang 21 6 7 48, 348d014eaaSGeliang Tang 48 0 0 0, 358d014eaaSGeliang Tang 84 0 0 240, 368d014eaaSGeliang Tang 21 0 4 96, 378d014eaaSGeliang Tang 48 0 0 74, 388d014eaaSGeliang Tang 84 0 0 240, 398d014eaaSGeliang Tang 21 0 1 48, 408d014eaaSGeliang Tang 6 0 0 65535, 418d014eaaSGeliang Tang 6 0 0 0" 428d014eaaSGeliang Tang 4393827ad5SMatthieu Baertsinit_partial() 44b08fbf24SPaolo Abeni{ 45b08fbf24SPaolo Abeni capout=$(mktemp) 46b08fbf24SPaolo Abeni 470a40e273SMatthieu Baerts rndh=$(mktemp -u XXXXXX) 48b08fbf24SPaolo Abeni 49b08fbf24SPaolo Abeni ns1="ns1-$rndh" 50b08fbf24SPaolo Abeni ns2="ns2-$rndh" 51b08fbf24SPaolo Abeni 52b08fbf24SPaolo Abeni for netns in "$ns1" "$ns2";do 53b08fbf24SPaolo Abeni ip netns add $netns || exit $ksft_skip 54b08fbf24SPaolo Abeni ip -net $netns link set lo up 55b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.mptcp.enabled=1 56b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 57b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 58af66d3e1SGeliang Tang if [ $checksum -eq 1 ]; then 59af66d3e1SGeliang Tang ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1 60af66d3e1SGeliang Tang fi 61b08fbf24SPaolo Abeni done 62b08fbf24SPaolo Abeni 63b08fbf24SPaolo Abeni # ns1 ns2 64b08fbf24SPaolo Abeni # ns1eth1 ns2eth1 65b08fbf24SPaolo Abeni # ns1eth2 ns2eth2 66b08fbf24SPaolo Abeni # ns1eth3 ns2eth3 67b08fbf24SPaolo Abeni # ns1eth4 ns2eth4 68b08fbf24SPaolo Abeni 69b08fbf24SPaolo Abeni for i in `seq 1 4`; do 70b08fbf24SPaolo Abeni ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2" 71b08fbf24SPaolo Abeni ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i 72b08fbf24SPaolo Abeni ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad 73b08fbf24SPaolo Abeni ip -net "$ns1" link set ns1eth$i up 74b08fbf24SPaolo Abeni 75b08fbf24SPaolo Abeni ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i 76b08fbf24SPaolo Abeni ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad 77b08fbf24SPaolo Abeni ip -net "$ns2" link set ns2eth$i up 78b08fbf24SPaolo Abeni 79b08fbf24SPaolo Abeni # let $ns2 reach any $ns1 address from any interface 80b08fbf24SPaolo Abeni ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i 819846921dSPaolo Abeni ip -net "$ns2" route add default via dead:beef:$i::1 dev ns2eth$i metric 10$i 82b08fbf24SPaolo Abeni done 83b08fbf24SPaolo Abeni} 84b08fbf24SPaolo Abeni 857d1e6f16SPaolo Abeniinit_shapers() 867d1e6f16SPaolo Abeni{ 877d1e6f16SPaolo Abeni for i in `seq 1 4`; do 887d1e6f16SPaolo Abeni tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1 897d1e6f16SPaolo Abeni tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1 907d1e6f16SPaolo Abeni done 917d1e6f16SPaolo Abeni} 927d1e6f16SPaolo Abeni 93b08fbf24SPaolo Abenicleanup_partial() 94b08fbf24SPaolo Abeni{ 95b08fbf24SPaolo Abeni rm -f "$capout" 96b08fbf24SPaolo Abeni 97b08fbf24SPaolo Abeni for netns in "$ns1" "$ns2"; do 98b08fbf24SPaolo Abeni ip netns del $netns 99c2a55e8fSMatthieu Baerts rm -f /tmp/$netns.{nstat,out} 100b08fbf24SPaolo Abeni done 101b08fbf24SPaolo Abeni} 102b08fbf24SPaolo Abeni 10387154755SMatthieu Baertscheck_tools() 10487154755SMatthieu Baerts{ 10587154755SMatthieu Baerts if ! ip -Version &> /dev/null; then 10687154755SMatthieu Baerts echo "SKIP: Could not run test without ip tool" 10787154755SMatthieu Baerts exit $ksft_skip 10887154755SMatthieu Baerts fi 10987154755SMatthieu Baerts 11087154755SMatthieu Baerts if ! iptables -V &> /dev/null; then 11187154755SMatthieu Baerts echo "SKIP: Could not run all tests without iptables tool" 11287154755SMatthieu Baerts exit $ksft_skip 11387154755SMatthieu Baerts fi 11487154755SMatthieu Baerts 11587154755SMatthieu Baerts if ! ip6tables -V &> /dev/null; then 11687154755SMatthieu Baerts echo "SKIP: Could not run all tests without ip6tables tool" 11787154755SMatthieu Baerts exit $ksft_skip 11887154755SMatthieu Baerts fi 11987154755SMatthieu Baerts} 12087154755SMatthieu Baerts 12193827ad5SMatthieu Baertsinit() { 12293827ad5SMatthieu Baerts init=1 12393827ad5SMatthieu Baerts 12487154755SMatthieu Baerts check_tools 12587154755SMatthieu Baerts 12693827ad5SMatthieu Baerts sin=$(mktemp) 12793827ad5SMatthieu Baerts sout=$(mktemp) 12893827ad5SMatthieu Baerts cin=$(mktemp) 12993827ad5SMatthieu Baerts cinsent=$(mktemp) 13093827ad5SMatthieu Baerts cout=$(mktemp) 13193827ad5SMatthieu Baerts 13293827ad5SMatthieu Baerts trap cleanup EXIT 13393827ad5SMatthieu Baerts 13493827ad5SMatthieu Baerts make_file "$cin" "client" 1 13593827ad5SMatthieu Baerts make_file "$sin" "server" 1 13693827ad5SMatthieu Baerts} 13793827ad5SMatthieu Baerts 138b08fbf24SPaolo Abenicleanup() 139b08fbf24SPaolo Abeni{ 1407d1e6f16SPaolo Abeni rm -f "$cin" "$cout" "$sinfail" 1417d1e6f16SPaolo Abeni rm -f "$sin" "$sout" "$cinsent" "$cinfail" 142b08fbf24SPaolo Abeni cleanup_partial 143b08fbf24SPaolo Abeni} 144b08fbf24SPaolo Abeni 145b08fbf24SPaolo Abenireset() 146b08fbf24SPaolo Abeni{ 14793827ad5SMatthieu Baerts if [ "${init}" != "1" ]; then 148b08fbf24SPaolo Abeni init 14993827ad5SMatthieu Baerts else 15093827ad5SMatthieu Baerts cleanup_partial 15193827ad5SMatthieu Baerts fi 15293827ad5SMatthieu Baerts 15393827ad5SMatthieu Baerts init_partial 154b08fbf24SPaolo Abeni} 155b08fbf24SPaolo Abeni 15600587187SFlorian Westphalreset_with_cookies() 15700587187SFlorian Westphal{ 15800587187SFlorian Westphal reset 15900587187SFlorian Westphal 16000587187SFlorian Westphal for netns in "$ns1" "$ns2";do 16100587187SFlorian Westphal ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2 16200587187SFlorian Westphal done 16300587187SFlorian Westphal} 16400587187SFlorian Westphal 1658d014eaaSGeliang Tangreset_with_add_addr_timeout() 1668d014eaaSGeliang Tang{ 1678d014eaaSGeliang Tang local ip="${1:-4}" 1688d014eaaSGeliang Tang local tables 1698d014eaaSGeliang Tang 1708d014eaaSGeliang Tang tables="iptables" 1718d014eaaSGeliang Tang if [ $ip -eq 6 ]; then 1728d014eaaSGeliang Tang tables="ip6tables" 1738d014eaaSGeliang Tang fi 1748d014eaaSGeliang Tang 1758d014eaaSGeliang Tang reset 1768d014eaaSGeliang Tang 1778d014eaaSGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 1788d014eaaSGeliang Tang ip netns exec $ns2 $tables -A OUTPUT -p tcp \ 1798d014eaaSGeliang Tang -m tcp --tcp-option 30 \ 1808d014eaaSGeliang Tang -m bpf --bytecode \ 1818d014eaaSGeliang Tang "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \ 1828d014eaaSGeliang Tang -j DROP 1838d014eaaSGeliang Tang} 1848d014eaaSGeliang Tang 185af66d3e1SGeliang Tangreset_with_checksum() 186af66d3e1SGeliang Tang{ 187af66d3e1SGeliang Tang local ns1_enable=$1 188af66d3e1SGeliang Tang local ns2_enable=$2 189af66d3e1SGeliang Tang 190af66d3e1SGeliang Tang reset 191af66d3e1SGeliang Tang 192af66d3e1SGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=$ns1_enable 193af66d3e1SGeliang Tang ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=$ns2_enable 194af66d3e1SGeliang Tang} 195af66d3e1SGeliang Tang 1960cddb4a6SGeliang Tangreset_with_allow_join_id0() 1970cddb4a6SGeliang Tang{ 1980cddb4a6SGeliang Tang local ns1_enable=$1 1990cddb4a6SGeliang Tang local ns2_enable=$2 2000cddb4a6SGeliang Tang 2010cddb4a6SGeliang Tang reset 2020cddb4a6SGeliang Tang 2030cddb4a6SGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns1_enable 2040cddb4a6SGeliang Tang ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable 2050cddb4a6SGeliang Tang} 2060cddb4a6SGeliang Tang 2078b819a84SFlorian Westphalprint_file_err() 2088b819a84SFlorian Westphal{ 2098b819a84SFlorian Westphal ls -l "$1" 1>&2 2108b819a84SFlorian Westphal echo "Trailing bytes are: " 2118b819a84SFlorian Westphal tail -c 27 "$1" 2128b819a84SFlorian Westphal} 2138b819a84SFlorian Westphal 214b08fbf24SPaolo Abenicheck_transfer() 215b08fbf24SPaolo Abeni{ 216b08fbf24SPaolo Abeni in=$1 217b08fbf24SPaolo Abeni out=$2 218b08fbf24SPaolo Abeni what=$3 219b08fbf24SPaolo Abeni 220b08fbf24SPaolo Abeni cmp "$in" "$out" > /dev/null 2>&1 221b08fbf24SPaolo Abeni if [ $? -ne 0 ] ;then 222b08fbf24SPaolo Abeni echo "[ FAIL ] $what does not match (in, out):" 223b08fbf24SPaolo Abeni print_file_err "$in" 224b08fbf24SPaolo Abeni print_file_err "$out" 2258b819a84SFlorian Westphal ret=1 226b08fbf24SPaolo Abeni 227b08fbf24SPaolo Abeni return 1 228b08fbf24SPaolo Abeni fi 229b08fbf24SPaolo Abeni 230b08fbf24SPaolo Abeni return 0 231b08fbf24SPaolo Abeni} 232b08fbf24SPaolo Abeni 233b08fbf24SPaolo Abenido_ping() 234b08fbf24SPaolo Abeni{ 235b08fbf24SPaolo Abeni listener_ns="$1" 236b08fbf24SPaolo Abeni connector_ns="$2" 237b08fbf24SPaolo Abeni connect_addr="$3" 238b08fbf24SPaolo Abeni 239b08fbf24SPaolo Abeni ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null 240b08fbf24SPaolo Abeni if [ $? -ne 0 ] ; then 241b08fbf24SPaolo Abeni echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2 242b08fbf24SPaolo Abeni ret=1 243b08fbf24SPaolo Abeni fi 244b08fbf24SPaolo Abeni} 245b08fbf24SPaolo Abeni 2468b819a84SFlorian Westphallink_failure() 2478b819a84SFlorian Westphal{ 2488b819a84SFlorian Westphal ns="$1" 2498b819a84SFlorian Westphal 2507d1e6f16SPaolo Abeni if [ -z "$FAILING_LINKS" ]; then 2518b819a84SFlorian Westphal l=$((RANDOM%4)) 2527d1e6f16SPaolo Abeni FAILING_LINKS=$((l+1)) 2537d1e6f16SPaolo Abeni fi 2548b819a84SFlorian Westphal 2557d1e6f16SPaolo Abeni for l in $FAILING_LINKS; do 2568b819a84SFlorian Westphal veth="ns1eth$l" 2578b819a84SFlorian Westphal ip -net "$ns" link set "$veth" down 2587d1e6f16SPaolo Abeni done 2598b819a84SFlorian Westphal} 2608b819a84SFlorian Westphal 261523514edSGeliang Tang# $1: IP address 262523514edSGeliang Tangis_v6() 263523514edSGeliang Tang{ 264523514edSGeliang Tang [ -z "${1##*:*}" ] 265523514edSGeliang Tang} 266523514edSGeliang Tang 267327b9a94SPaolo Abeni# $1: ns, $2: port 268327b9a94SPaolo Abeniwait_local_port_listen() 269327b9a94SPaolo Abeni{ 270327b9a94SPaolo Abeni local listener_ns="${1}" 271327b9a94SPaolo Abeni local port="${2}" 272327b9a94SPaolo Abeni 273327b9a94SPaolo Abeni local port_hex i 274327b9a94SPaolo Abeni 275327b9a94SPaolo Abeni port_hex="$(printf "%04X" "${port}")" 276327b9a94SPaolo Abeni for i in $(seq 10); do 277327b9a94SPaolo Abeni ip netns exec "${listener_ns}" cat /proc/net/tcp* | \ 278327b9a94SPaolo Abeni awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" && 279327b9a94SPaolo Abeni break 280327b9a94SPaolo Abeni sleep 0.1 281327b9a94SPaolo Abeni done 282327b9a94SPaolo Abeni} 283327b9a94SPaolo Abeni 284327b9a94SPaolo Abenirm_addr_count() 285327b9a94SPaolo Abeni{ 286327b9a94SPaolo Abeni ns=${1} 287327b9a94SPaolo Abeni 288327b9a94SPaolo Abeni ip netns exec ${ns} nstat -as | grep MPTcpExtRmAddr | awk '{print $2}' 289327b9a94SPaolo Abeni} 290327b9a94SPaolo Abeni 291327b9a94SPaolo Abeni# $1: ns, $2: old rm_addr counter in $ns 292327b9a94SPaolo Abeniwait_rm_addr() 293327b9a94SPaolo Abeni{ 294327b9a94SPaolo Abeni local ns="${1}" 295327b9a94SPaolo Abeni local old_cnt="${2}" 296327b9a94SPaolo Abeni local cnt 297327b9a94SPaolo Abeni local i 298327b9a94SPaolo Abeni 299327b9a94SPaolo Abeni for i in $(seq 10); do 300327b9a94SPaolo Abeni cnt=$(rm_addr_count ${ns}) 301327b9a94SPaolo Abeni [ "$cnt" = "${old_cnt}" ] || break 302327b9a94SPaolo Abeni sleep 0.1 303327b9a94SPaolo Abeni done 304327b9a94SPaolo Abeni} 305327b9a94SPaolo Abeni 30634aa6e3bSGeliang Tangpm_nl_set_limits() 30734aa6e3bSGeliang Tang{ 30834aa6e3bSGeliang Tang local ns=$1 30934aa6e3bSGeliang Tang local addrs=$2 31034aa6e3bSGeliang Tang local subflows=$3 31134aa6e3bSGeliang Tang 31234aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 31334aa6e3bSGeliang Tang ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows 31434aa6e3bSGeliang Tang else 31534aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows 31634aa6e3bSGeliang Tang fi 31734aa6e3bSGeliang Tang} 31834aa6e3bSGeliang Tang 31934aa6e3bSGeliang Tangpm_nl_add_endpoint() 32034aa6e3bSGeliang Tang{ 32134aa6e3bSGeliang Tang local ns=$1 32234aa6e3bSGeliang Tang local addr=$2 32334aa6e3bSGeliang Tang local flags 32434aa6e3bSGeliang Tang local port 32534aa6e3bSGeliang Tang local dev 32634aa6e3bSGeliang Tang local id 32734aa6e3bSGeliang Tang local nr=2 32834aa6e3bSGeliang Tang 32934aa6e3bSGeliang Tang for p in $@ 33034aa6e3bSGeliang Tang do 33134aa6e3bSGeliang Tang if [ $p = "flags" ]; then 33234aa6e3bSGeliang Tang eval _flags=\$"$nr" 33334aa6e3bSGeliang Tang [ ! -z $_flags ]; flags="flags $_flags" 33434aa6e3bSGeliang Tang fi 33534aa6e3bSGeliang Tang if [ $p = "dev" ]; then 33634aa6e3bSGeliang Tang eval _dev=\$"$nr" 33734aa6e3bSGeliang Tang [ ! -z $_dev ]; dev="dev $_dev" 33834aa6e3bSGeliang Tang fi 33934aa6e3bSGeliang Tang if [ $p = "id" ]; then 34034aa6e3bSGeliang Tang eval _id=\$"$nr" 34134aa6e3bSGeliang Tang [ ! -z $_id ]; id="id $_id" 34234aa6e3bSGeliang Tang fi 34334aa6e3bSGeliang Tang if [ $p = "port" ]; then 34434aa6e3bSGeliang Tang eval _port=\$"$nr" 34534aa6e3bSGeliang Tang [ ! -z $_port ]; port="port $_port" 34634aa6e3bSGeliang Tang fi 34734aa6e3bSGeliang Tang 34834aa6e3bSGeliang Tang let nr+=1 34934aa6e3bSGeliang Tang done 35034aa6e3bSGeliang Tang 35134aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 35234aa6e3bSGeliang Tang ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port 35334aa6e3bSGeliang Tang else 35434aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port 35534aa6e3bSGeliang Tang fi 35634aa6e3bSGeliang Tang} 35734aa6e3bSGeliang Tang 35834aa6e3bSGeliang Tangpm_nl_del_endpoint() 35934aa6e3bSGeliang Tang{ 36034aa6e3bSGeliang Tang local ns=$1 36134aa6e3bSGeliang Tang local id=$2 36234aa6e3bSGeliang Tang local addr=$3 36334aa6e3bSGeliang Tang 36434aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 36534aa6e3bSGeliang Tang ip -n $ns mptcp endpoint delete id $id $addr 36634aa6e3bSGeliang Tang else 36734aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl del $id $addr 36834aa6e3bSGeliang Tang fi 36934aa6e3bSGeliang Tang} 37034aa6e3bSGeliang Tang 37134aa6e3bSGeliang Tangpm_nl_flush_endpoint() 37234aa6e3bSGeliang Tang{ 37334aa6e3bSGeliang Tang local ns=$1 37434aa6e3bSGeliang Tang 37534aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 37634aa6e3bSGeliang Tang ip -n $ns mptcp endpoint flush 37734aa6e3bSGeliang Tang else 37834aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl flush 37934aa6e3bSGeliang Tang fi 38034aa6e3bSGeliang Tang} 38134aa6e3bSGeliang Tang 382dda61b3dSGeliang Tangpm_nl_show_endpoints() 383dda61b3dSGeliang Tang{ 384dda61b3dSGeliang Tang local ns=$1 385dda61b3dSGeliang Tang 386dda61b3dSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 387dda61b3dSGeliang Tang ip -n $ns mptcp endpoint show 388dda61b3dSGeliang Tang else 389dda61b3dSGeliang Tang ip netns exec $ns ./pm_nl_ctl dump 390dda61b3dSGeliang Tang fi 391dda61b3dSGeliang Tang} 392dda61b3dSGeliang Tang 393f0140386SGeliang Tangpm_nl_change_endpoint() 394f0140386SGeliang Tang{ 395f0140386SGeliang Tang local ns=$1 396bccefb76SGeliang Tang local id=$2 397bccefb76SGeliang Tang local flags=$3 398f0140386SGeliang Tang 399f0140386SGeliang Tang if [ $ip_mptcp -eq 1 ]; then 400f0140386SGeliang Tang ip -n $ns mptcp endpoint change id $id ${flags//","/" "} 401f0140386SGeliang Tang else 402bccefb76SGeliang Tang ip netns exec $ns ./pm_nl_ctl set id $id flags $flags 403f0140386SGeliang Tang fi 404f0140386SGeliang Tang} 405f0140386SGeliang Tang 406b08fbf24SPaolo Abenido_transfer() 407b08fbf24SPaolo Abeni{ 408b08fbf24SPaolo Abeni listener_ns="$1" 409b08fbf24SPaolo Abeni connector_ns="$2" 410b08fbf24SPaolo Abeni cl_proto="$3" 411b08fbf24SPaolo Abeni srv_proto="$4" 412b08fbf24SPaolo Abeni connect_addr="$5" 4138b819a84SFlorian Westphal test_link_fail="$6" 4142e8cbf45SGeliang Tang addr_nr_ns1="$7" 4152e8cbf45SGeliang Tang addr_nr_ns2="$8" 4168b819a84SFlorian Westphal speed="$9" 4176a0653b9SGeliang Tang sflags="${10}" 418b08fbf24SPaolo Abeni 419b08fbf24SPaolo Abeni port=$((10000+$TEST_COUNT)) 420b08fbf24SPaolo Abeni TEST_COUNT=$((TEST_COUNT+1)) 421b08fbf24SPaolo Abeni 422b08fbf24SPaolo Abeni :> "$cout" 423b08fbf24SPaolo Abeni :> "$sout" 424b08fbf24SPaolo Abeni :> "$capout" 425b08fbf24SPaolo Abeni 426b08fbf24SPaolo Abeni if [ $capture -eq 1 ]; then 427b08fbf24SPaolo Abeni if [ -z $SUDO_USER ] ; then 428b08fbf24SPaolo Abeni capuser="" 429b08fbf24SPaolo Abeni else 430b08fbf24SPaolo Abeni capuser="-Z $SUDO_USER" 431b08fbf24SPaolo Abeni fi 432b08fbf24SPaolo Abeni 43300587187SFlorian Westphal capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}") 434b08fbf24SPaolo Abeni 435b08fbf24SPaolo Abeni echo "Capturing traffic for test $TEST_COUNT into $capfile" 436b08fbf24SPaolo Abeni ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & 437b08fbf24SPaolo Abeni cappid=$! 438b08fbf24SPaolo Abeni 439b08fbf24SPaolo Abeni sleep 1 440b08fbf24SPaolo Abeni fi 441b08fbf24SPaolo Abeni 442c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 443c2a55e8fSMatthieu Baerts nstat -n 444c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 445c2a55e8fSMatthieu Baerts nstat -n 446c2a55e8fSMatthieu Baerts 4478d014eaaSGeliang Tang if [ $speed = "fast" ]; then 448dd72b0feSGeliang Tang mptcp_connect="./mptcp_connect -j" 4498da6229bSGeliang Tang elif [ $speed = "slow" ]; then 4508da6229bSGeliang Tang mptcp_connect="./mptcp_connect -r 50" 4518da6229bSGeliang Tang elif [ $speed = "least" ]; then 4528da6229bSGeliang Tang mptcp_connect="./mptcp_connect -r 10" 453dd72b0feSGeliang Tang fi 454dd72b0feSGeliang Tang 455523514edSGeliang Tang local local_addr 456523514edSGeliang Tang if is_v6 "${connect_addr}"; then 457523514edSGeliang Tang local_addr="::" 458523514edSGeliang Tang else 459523514edSGeliang Tang local_addr="0.0.0.0" 460523514edSGeliang Tang fi 461523514edSGeliang Tang 4627d1e6f16SPaolo Abeni if [ "$test_link_fail" -eq 2 ];then 4637d1e6f16SPaolo Abeni timeout ${timeout_test} \ 4647d1e6f16SPaolo Abeni ip netns exec ${listener_ns} \ 4657c909a98SGeliang Tang $mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 4667d1e6f16SPaolo Abeni ${local_addr} < "$sinfail" > "$sout" & 4677d1e6f16SPaolo Abeni else 4685888a61cSMatthieu Baerts timeout ${timeout_test} \ 4695888a61cSMatthieu Baerts ip netns exec ${listener_ns} \ 4705888a61cSMatthieu Baerts $mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 4715888a61cSMatthieu Baerts ${local_addr} < "$sin" > "$sout" & 4727d1e6f16SPaolo Abeni fi 473b08fbf24SPaolo Abeni spid=$! 474b08fbf24SPaolo Abeni 475327b9a94SPaolo Abeni wait_local_port_listen "${listener_ns}" "${port}" 476b08fbf24SPaolo Abeni 4778b819a84SFlorian Westphal if [ "$test_link_fail" -eq 0 ];then 4785888a61cSMatthieu Baerts timeout ${timeout_test} \ 4795888a61cSMatthieu Baerts ip netns exec ${connector_ns} \ 4805888a61cSMatthieu Baerts $mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 4815888a61cSMatthieu Baerts $connect_addr < "$cin" > "$cout" & 4828b819a84SFlorian Westphal else 4837d1e6f16SPaolo Abeni ( cat "$cinfail" ; sleep 2; link_failure $listener_ns ; cat "$cinfail" ) | \ 4845888a61cSMatthieu Baerts tee "$cinsent" | \ 4855888a61cSMatthieu Baerts timeout ${timeout_test} \ 4865888a61cSMatthieu Baerts ip netns exec ${connector_ns} \ 4875888a61cSMatthieu Baerts $mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 4885888a61cSMatthieu Baerts $connect_addr > "$cout" & 4898b819a84SFlorian Westphal fi 490b08fbf24SPaolo Abeni cpid=$! 491b08fbf24SPaolo Abeni 492327b9a94SPaolo Abeni # let the mptcp subflow be established in background before 493327b9a94SPaolo Abeni # do endpoint manipulation 494327b9a94SPaolo Abeni [ $addr_nr_ns1 = "0" -a $addr_nr_ns2 = "0" ] || sleep 1 495327b9a94SPaolo Abeni 4966208fd82SGeliang Tang if [ $addr_nr_ns1 -gt 0 ]; then 4976208fd82SGeliang Tang let add_nr_ns1=addr_nr_ns1 4986208fd82SGeliang Tang counter=2 4996208fd82SGeliang Tang while [ $add_nr_ns1 -gt 0 ]; do 5006208fd82SGeliang Tang local addr 5016208fd82SGeliang Tang if is_v6 "${connect_addr}"; then 5026208fd82SGeliang Tang addr="dead:beef:$counter::1" 5036208fd82SGeliang Tang else 5046208fd82SGeliang Tang addr="10.0.$counter.1" 5056208fd82SGeliang Tang fi 50634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 $addr flags signal 5076208fd82SGeliang Tang let counter+=1 5086208fd82SGeliang Tang let add_nr_ns1-=1 5096208fd82SGeliang Tang done 5106208fd82SGeliang Tang elif [ $addr_nr_ns1 -lt 0 ]; then 5112e8cbf45SGeliang Tang let rm_nr_ns1=-addr_nr_ns1 5126fe4ccdcSGeliang Tang if [ $rm_nr_ns1 -lt 8 ]; then 513dda61b3dSGeliang Tang counter=0 514dda61b3dSGeliang Tang pm_nl_show_endpoints ${listener_ns} | while read line; do 515dda61b3dSGeliang Tang local arr=($line) 516dda61b3dSGeliang Tang local nr=0 517dda61b3dSGeliang Tang 518dda61b3dSGeliang Tang for i in ${arr[@]}; do 519dda61b3dSGeliang Tang if [ $i = "id" ]; then 520dda61b3dSGeliang Tang if [ $counter -eq $rm_nr_ns1 ]; then 521dda61b3dSGeliang Tang break 522dda61b3dSGeliang Tang fi 523dda61b3dSGeliang Tang id=${arr[$nr+1]} 524327b9a94SPaolo Abeni rm_addr=$(rm_addr_count ${connector_ns}) 52534aa6e3bSGeliang Tang pm_nl_del_endpoint ${listener_ns} $id 526327b9a94SPaolo Abeni wait_rm_addr ${connector_ns} ${rm_addr} 527dd72b0feSGeliang Tang let counter+=1 528f87744adSGeliang Tang fi 529dda61b3dSGeliang Tang let nr+=1 530dda61b3dSGeliang Tang done 531dda61b3dSGeliang Tang done 5325e287fe7SGeliang Tang elif [ $rm_nr_ns1 -eq 8 ]; then 53334aa6e3bSGeliang Tang pm_nl_flush_endpoint ${listener_ns} 5345e287fe7SGeliang Tang elif [ $rm_nr_ns1 -eq 9 ]; then 53534aa6e3bSGeliang Tang pm_nl_del_endpoint ${listener_ns} 0 ${connect_addr} 5366fe4ccdcSGeliang Tang fi 537dd72b0feSGeliang Tang fi 538dd72b0feSGeliang Tang 5394f49d633SGeliang Tang flags="subflow" 5404f49d633SGeliang Tang if [[ "${addr_nr_ns2}" = "fullmesh_"* ]]; then 5414f49d633SGeliang Tang flags="${flags},fullmesh" 5424f49d633SGeliang Tang addr_nr_ns2=${addr_nr_ns2:9} 5434f49d633SGeliang Tang fi 5444f49d633SGeliang Tang 545327b9a94SPaolo Abeni # if newly added endpoints must be deleted, give the background msk 546327b9a94SPaolo Abeni # some time to created them 547327b9a94SPaolo Abeni [ $addr_nr_ns1 -gt 0 -a $addr_nr_ns2 -lt 0 ] && sleep 1 548327b9a94SPaolo Abeni 5496208fd82SGeliang Tang if [ $addr_nr_ns2 -gt 0 ]; then 5506208fd82SGeliang Tang let add_nr_ns2=addr_nr_ns2 5516208fd82SGeliang Tang counter=3 5526208fd82SGeliang Tang while [ $add_nr_ns2 -gt 0 ]; do 5536208fd82SGeliang Tang local addr 5546208fd82SGeliang Tang if is_v6 "${connect_addr}"; then 5556208fd82SGeliang Tang addr="dead:beef:$counter::2" 5566208fd82SGeliang Tang else 5576208fd82SGeliang Tang addr="10.0.$counter.2" 5586208fd82SGeliang Tang fi 55934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 $addr flags $flags 5606208fd82SGeliang Tang let counter+=1 5616208fd82SGeliang Tang let add_nr_ns2-=1 5626208fd82SGeliang Tang done 5636208fd82SGeliang Tang elif [ $addr_nr_ns2 -lt 0 ]; then 5642e8cbf45SGeliang Tang let rm_nr_ns2=-addr_nr_ns2 5656fe4ccdcSGeliang Tang if [ $rm_nr_ns2 -lt 8 ]; then 566dda61b3dSGeliang Tang counter=0 567dda61b3dSGeliang Tang pm_nl_show_endpoints ${connector_ns} | while read line; do 568dda61b3dSGeliang Tang local arr=($line) 569dda61b3dSGeliang Tang local nr=0 570dda61b3dSGeliang Tang 571dda61b3dSGeliang Tang for i in ${arr[@]}; do 572dda61b3dSGeliang Tang if [ $i = "id" ]; then 573dda61b3dSGeliang Tang if [ $counter -eq $rm_nr_ns2 ]; then 574dda61b3dSGeliang Tang break 575dda61b3dSGeliang Tang fi 576dda61b3dSGeliang Tang # rm_addr are serialized, allow the previous one to 577dda61b3dSGeliang Tang # complete 578dda61b3dSGeliang Tang id=${arr[$nr+1]} 579327b9a94SPaolo Abeni rm_addr=$(rm_addr_count ${listener_ns}) 58034aa6e3bSGeliang Tang pm_nl_del_endpoint ${connector_ns} $id 581327b9a94SPaolo Abeni wait_rm_addr ${listener_ns} ${rm_addr} 582dd72b0feSGeliang Tang let counter+=1 583f87744adSGeliang Tang fi 584dda61b3dSGeliang Tang let nr+=1 585dda61b3dSGeliang Tang done 586dda61b3dSGeliang Tang done 5875e287fe7SGeliang Tang elif [ $rm_nr_ns2 -eq 8 ]; then 58834aa6e3bSGeliang Tang pm_nl_flush_endpoint ${connector_ns} 5895e287fe7SGeliang Tang elif [ $rm_nr_ns2 -eq 9 ]; then 5905e287fe7SGeliang Tang local addr 5915e287fe7SGeliang Tang if is_v6 "${connect_addr}"; then 5925e287fe7SGeliang Tang addr="dead:beef:1::2" 5935e287fe7SGeliang Tang else 5945e287fe7SGeliang Tang addr="10.0.1.2" 5955e287fe7SGeliang Tang fi 59634aa6e3bSGeliang Tang pm_nl_del_endpoint ${connector_ns} 0 $addr 5976fe4ccdcSGeliang Tang fi 598dd72b0feSGeliang Tang fi 599dd72b0feSGeliang Tang 6006a0653b9SGeliang Tang if [ ! -z $sflags ]; then 601718eb44eSGeliang Tang sleep 1 602718eb44eSGeliang Tang for netns in "$ns1" "$ns2"; do 603dda61b3dSGeliang Tang pm_nl_show_endpoints $netns | while read line; do 60433397b83SGeliang Tang local arr=($line) 605bccefb76SGeliang Tang local nr=0 606f0140386SGeliang Tang local id 60733397b83SGeliang Tang 60833397b83SGeliang Tang for i in ${arr[@]}; do 609bccefb76SGeliang Tang if [ $i = "id" ]; then 610bccefb76SGeliang Tang id=${arr[$nr+1]} 611718eb44eSGeliang Tang fi 612bccefb76SGeliang Tang let nr+=1 61333397b83SGeliang Tang done 614bccefb76SGeliang Tang pm_nl_change_endpoint $netns $id $sflags 61533397b83SGeliang Tang done 616718eb44eSGeliang Tang done 617718eb44eSGeliang Tang fi 618718eb44eSGeliang Tang 619b08fbf24SPaolo Abeni wait $cpid 620b08fbf24SPaolo Abeni retc=$? 621b08fbf24SPaolo Abeni wait $spid 622b08fbf24SPaolo Abeni rets=$? 623b08fbf24SPaolo Abeni 624b08fbf24SPaolo Abeni if [ $capture -eq 1 ]; then 625b08fbf24SPaolo Abeni sleep 1 626b08fbf24SPaolo Abeni kill $cappid 627b08fbf24SPaolo Abeni fi 628b08fbf24SPaolo Abeni 629c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 630c2a55e8fSMatthieu Baerts nstat | grep Tcp > /tmp/${listener_ns}.out 631c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 632c2a55e8fSMatthieu Baerts nstat | grep Tcp > /tmp/${connector_ns}.out 633c2a55e8fSMatthieu Baerts 634b08fbf24SPaolo Abeni if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then 635b08fbf24SPaolo Abeni echo " client exit code $retc, server $rets" 1>&2 6368b974778SMatthieu Baerts echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 637c2a55e8fSMatthieu Baerts ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port" 638c2a55e8fSMatthieu Baerts cat /tmp/${listener_ns}.out 6398b974778SMatthieu Baerts echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2 640c2a55e8fSMatthieu Baerts ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port" 641c2a55e8fSMatthieu Baerts cat /tmp/${connector_ns}.out 642b08fbf24SPaolo Abeni 643b08fbf24SPaolo Abeni cat "$capout" 6448b819a84SFlorian Westphal ret=1 645b08fbf24SPaolo Abeni return 1 646b08fbf24SPaolo Abeni fi 647b08fbf24SPaolo Abeni 6487d1e6f16SPaolo Abeni if [ "$test_link_fail" -eq 2 ];then 6497d1e6f16SPaolo Abeni check_transfer $sinfail $cout "file received by client" 6507d1e6f16SPaolo Abeni else 651b08fbf24SPaolo Abeni check_transfer $sin $cout "file received by client" 6527d1e6f16SPaolo Abeni fi 653b08fbf24SPaolo Abeni retc=$? 6548b819a84SFlorian Westphal if [ "$test_link_fail" -eq 0 ];then 655b08fbf24SPaolo Abeni check_transfer $cin $sout "file received by server" 6568b819a84SFlorian Westphal else 6578b819a84SFlorian Westphal check_transfer $cinsent $sout "file received by server" 6588b819a84SFlorian Westphal fi 659b08fbf24SPaolo Abeni rets=$? 660b08fbf24SPaolo Abeni 661b08fbf24SPaolo Abeni if [ $retc -eq 0 ] && [ $rets -eq 0 ];then 662b08fbf24SPaolo Abeni cat "$capout" 663b08fbf24SPaolo Abeni return 0 664b08fbf24SPaolo Abeni fi 665b08fbf24SPaolo Abeni 666b08fbf24SPaolo Abeni cat "$capout" 667b08fbf24SPaolo Abeni return 1 668b08fbf24SPaolo Abeni} 669b08fbf24SPaolo Abeni 670b08fbf24SPaolo Abenimake_file() 671b08fbf24SPaolo Abeni{ 672b08fbf24SPaolo Abeni name=$1 673b08fbf24SPaolo Abeni who=$2 6748b819a84SFlorian Westphal size=$3 675b08fbf24SPaolo Abeni 6768b819a84SFlorian Westphal dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null 677b08fbf24SPaolo Abeni echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" 678b08fbf24SPaolo Abeni 6798b819a84SFlorian Westphal echo "Created $name (size $size KB) containing data sent by $who" 680b08fbf24SPaolo Abeni} 681b08fbf24SPaolo Abeni 682b08fbf24SPaolo Abenirun_tests() 683b08fbf24SPaolo Abeni{ 684b08fbf24SPaolo Abeni listener_ns="$1" 685b08fbf24SPaolo Abeni connector_ns="$2" 686b08fbf24SPaolo Abeni connect_addr="$3" 6878b819a84SFlorian Westphal test_linkfail="${4:-0}" 6882e8cbf45SGeliang Tang addr_nr_ns1="${5:-0}" 6892e8cbf45SGeliang Tang addr_nr_ns2="${6:-0}" 6908b819a84SFlorian Westphal speed="${7:-fast}" 6916a0653b9SGeliang Tang sflags="${8:-""}" 6928b819a84SFlorian Westphal 6937d1e6f16SPaolo Abeni # create the input file for the failure test when 6947d1e6f16SPaolo Abeni # the first failure test run 6957d1e6f16SPaolo Abeni if [ "$test_linkfail" -ne 0 -a -z "$cinfail" ]; then 6967d1e6f16SPaolo Abeni # the client file must be considerably larger 6977d1e6f16SPaolo Abeni # of the maximum expected cwin value, or the 6987d1e6f16SPaolo Abeni # link utilization will be not predicable 6997d1e6f16SPaolo Abeni size=$((RANDOM%2)) 7008b819a84SFlorian Westphal size=$((size+1)) 7017d1e6f16SPaolo Abeni size=$((size*8192)) 7027d1e6f16SPaolo Abeni size=$((size + ( $RANDOM % 8192) )) 7038b819a84SFlorian Westphal 7047d1e6f16SPaolo Abeni cinfail=$(mktemp) 7057d1e6f16SPaolo Abeni make_file "$cinfail" "client" $size 7067d1e6f16SPaolo Abeni fi 7077d1e6f16SPaolo Abeni 7087d1e6f16SPaolo Abeni if [ "$test_linkfail" -eq 2 -a -z "$sinfail" ]; then 7097d1e6f16SPaolo Abeni size=$((RANDOM%16)) 7107d1e6f16SPaolo Abeni size=$((size+1)) 7117d1e6f16SPaolo Abeni size=$((size*2048)) 7127d1e6f16SPaolo Abeni 7137d1e6f16SPaolo Abeni sinfail=$(mktemp) 7147d1e6f16SPaolo Abeni make_file "$sinfail" "server" $size 7158b819a84SFlorian Westphal fi 716b08fbf24SPaolo Abeni 7178d014eaaSGeliang Tang do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \ 7186a0653b9SGeliang Tang ${test_linkfail} ${addr_nr_ns1} ${addr_nr_ns2} ${speed} ${sflags} 719b08fbf24SPaolo Abeni} 720b08fbf24SPaolo Abeni 721327b9a94SPaolo Abenidump_stats() 722327b9a94SPaolo Abeni{ 723327b9a94SPaolo Abeni echo Server ns stats 724327b9a94SPaolo Abeni ip netns exec $ns1 nstat -as | grep Tcp 725327b9a94SPaolo Abeni echo Client ns stats 726327b9a94SPaolo Abeni ip netns exec $ns2 nstat -as | grep Tcp 727327b9a94SPaolo Abeni} 728327b9a94SPaolo Abeni 729af66d3e1SGeliang Tangchk_csum_nr() 730af66d3e1SGeliang Tang{ 731af66d3e1SGeliang Tang local msg=${1:-""} 732af66d3e1SGeliang Tang local count 733af66d3e1SGeliang Tang local dump_stats 734af66d3e1SGeliang Tang 735af66d3e1SGeliang Tang if [ ! -z "$msg" ]; then 736*9a0a9367SGeliang Tang printf "%03u" "$TEST_COUNT" 737af66d3e1SGeliang Tang else 738af66d3e1SGeliang Tang echo -n " " 739af66d3e1SGeliang Tang fi 740af66d3e1SGeliang Tang printf " %-36s %s" "$msg" "sum" 741af66d3e1SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'` 742af66d3e1SGeliang Tang [ -z "$count" ] && count=0 743af66d3e1SGeliang Tang if [ "$count" != 0 ]; then 744af66d3e1SGeliang Tang echo "[fail] got $count data checksum error[s] expected 0" 745af66d3e1SGeliang Tang ret=1 746af66d3e1SGeliang Tang dump_stats=1 747af66d3e1SGeliang Tang else 748af66d3e1SGeliang Tang echo -n "[ ok ]" 749af66d3e1SGeliang Tang fi 750af66d3e1SGeliang Tang echo -n " - csum " 751af66d3e1SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'` 752af66d3e1SGeliang Tang [ -z "$count" ] && count=0 753af66d3e1SGeliang Tang if [ "$count" != 0 ]; then 754af66d3e1SGeliang Tang echo "[fail] got $count data checksum error[s] expected 0" 755af66d3e1SGeliang Tang ret=1 756af66d3e1SGeliang Tang dump_stats=1 757af66d3e1SGeliang Tang else 758af66d3e1SGeliang Tang echo "[ ok ]" 759af66d3e1SGeliang Tang fi 760327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 761af66d3e1SGeliang Tang} 762af66d3e1SGeliang Tang 7636bb3ab49SGeliang Tangchk_fail_nr() 7646bb3ab49SGeliang Tang{ 7656bb3ab49SGeliang Tang local mp_fail_nr_tx=$1 7666bb3ab49SGeliang Tang local mp_fail_nr_rx=$2 7676bb3ab49SGeliang Tang local count 7686bb3ab49SGeliang Tang local dump_stats 7696bb3ab49SGeliang Tang 770*9a0a9367SGeliang Tang printf "%-${nr_blank}s %s" " " "ftx" 7716bb3ab49SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPFailTx | awk '{print $2}'` 7726bb3ab49SGeliang Tang [ -z "$count" ] && count=0 7736bb3ab49SGeliang Tang if [ "$count" != "$mp_fail_nr_tx" ]; then 7746bb3ab49SGeliang Tang echo "[fail] got $count MP_FAIL[s] TX expected $mp_fail_nr_tx" 7756bb3ab49SGeliang Tang ret=1 7766bb3ab49SGeliang Tang dump_stats=1 7776bb3ab49SGeliang Tang else 7786bb3ab49SGeliang Tang echo -n "[ ok ]" 7796bb3ab49SGeliang Tang fi 7806bb3ab49SGeliang Tang 7816bb3ab49SGeliang Tang echo -n " - frx " 7826bb3ab49SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPFailRx | awk '{print $2}'` 7836bb3ab49SGeliang Tang [ -z "$count" ] && count=0 7846bb3ab49SGeliang Tang if [ "$count" != "$mp_fail_nr_rx" ]; then 7856bb3ab49SGeliang Tang echo "[fail] got $count MP_FAIL[s] RX expected $mp_fail_nr_rx" 7866bb3ab49SGeliang Tang ret=1 7876bb3ab49SGeliang Tang dump_stats=1 7886bb3ab49SGeliang Tang else 7896bb3ab49SGeliang Tang echo "[ ok ]" 7906bb3ab49SGeliang Tang fi 7916bb3ab49SGeliang Tang 792327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 7936bb3ab49SGeliang Tang} 7946bb3ab49SGeliang Tang 795b08fbf24SPaolo Abenichk_join_nr() 796b08fbf24SPaolo Abeni{ 797b08fbf24SPaolo Abeni local msg="$1" 798b08fbf24SPaolo Abeni local syn_nr=$2 799b08fbf24SPaolo Abeni local syn_ack_nr=$3 800b08fbf24SPaolo Abeni local ack_nr=$4 801b08fbf24SPaolo Abeni local count 802b08fbf24SPaolo Abeni local dump_stats 803e35f885bSPaolo Abeni local with_cookie 804b08fbf24SPaolo Abeni 805*9a0a9367SGeliang Tang printf "%03u %-36s %s" "$TEST_COUNT" "$msg" "syn" 806b08fbf24SPaolo Abeni count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'` 807b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 808b08fbf24SPaolo Abeni if [ "$count" != "$syn_nr" ]; then 809b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] syn expected $syn_nr" 810b08fbf24SPaolo Abeni ret=1 811b08fbf24SPaolo Abeni dump_stats=1 812b08fbf24SPaolo Abeni else 813b08fbf24SPaolo Abeni echo -n "[ ok ]" 814b08fbf24SPaolo Abeni fi 815b08fbf24SPaolo Abeni 816b08fbf24SPaolo Abeni echo -n " - synack" 817e35f885bSPaolo Abeni with_cookie=`ip netns exec $ns2 sysctl -n net.ipv4.tcp_syncookies` 818b08fbf24SPaolo Abeni count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'` 819b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 820b08fbf24SPaolo Abeni if [ "$count" != "$syn_ack_nr" ]; then 821e35f885bSPaolo Abeni # simult connections exceeding the limit with cookie enabled could go up to 822e35f885bSPaolo Abeni # synack validation as the conn limit can be enforced reliably only after 823e35f885bSPaolo Abeni # the subflow creation 824e35f885bSPaolo Abeni if [ "$with_cookie" = 2 ] && [ "$count" -gt "$syn_ack_nr" ] && [ "$count" -le "$syn_nr" ]; then 825e35f885bSPaolo Abeni echo -n "[ ok ]" 826e35f885bSPaolo Abeni else 827b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr" 828b08fbf24SPaolo Abeni ret=1 829b08fbf24SPaolo Abeni dump_stats=1 830e35f885bSPaolo Abeni fi 831b08fbf24SPaolo Abeni else 832b08fbf24SPaolo Abeni echo -n "[ ok ]" 833b08fbf24SPaolo Abeni fi 834b08fbf24SPaolo Abeni 835b08fbf24SPaolo Abeni echo -n " - ack" 836b08fbf24SPaolo Abeni count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'` 837b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 838b08fbf24SPaolo Abeni if [ "$count" != "$ack_nr" ]; then 839b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] ack expected $ack_nr" 840b08fbf24SPaolo Abeni ret=1 841b08fbf24SPaolo Abeni dump_stats=1 842b08fbf24SPaolo Abeni else 843b08fbf24SPaolo Abeni echo "[ ok ]" 844b08fbf24SPaolo Abeni fi 845327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 846af66d3e1SGeliang Tang if [ $checksum -eq 1 ]; then 847af66d3e1SGeliang Tang chk_csum_nr 8486bb3ab49SGeliang Tang chk_fail_nr 0 0 849af66d3e1SGeliang Tang fi 850b08fbf24SPaolo Abeni} 851b08fbf24SPaolo Abeni 8527d1e6f16SPaolo Abeni# a negative value for 'stale_max' means no upper bound: 8537d1e6f16SPaolo Abeni# for bidirectional transfer, if one peer sleep for a while 8547d1e6f16SPaolo Abeni# - as these tests do - we can have a quite high number of 8557d1e6f16SPaolo Abeni# stale/recover conversions, proportional to 8567d1e6f16SPaolo Abeni# sleep duration/ MPTCP-level RTX interval. 8577d1e6f16SPaolo Abenichk_stale_nr() 8587d1e6f16SPaolo Abeni{ 8597d1e6f16SPaolo Abeni local ns=$1 8607d1e6f16SPaolo Abeni local stale_min=$2 8617d1e6f16SPaolo Abeni local stale_max=$3 8627d1e6f16SPaolo Abeni local stale_delta=$4 8637d1e6f16SPaolo Abeni local dump_stats 8647d1e6f16SPaolo Abeni local stale_nr 8657d1e6f16SPaolo Abeni local recover_nr 8667d1e6f16SPaolo Abeni 867*9a0a9367SGeliang Tang printf "%-${nr_blank}s %-18s" " " "stale" 8687d1e6f16SPaolo Abeni stale_nr=`ip netns exec $ns nstat -as | grep MPTcpExtSubflowStale | awk '{print $2}'` 8697d1e6f16SPaolo Abeni [ -z "$stale_nr" ] && stale_nr=0 8707d1e6f16SPaolo Abeni recover_nr=`ip netns exec $ns nstat -as | grep MPTcpExtSubflowRecover | awk '{print $2}'` 8717d1e6f16SPaolo Abeni [ -z "$recover_nr" ] && recover_nr=0 8727d1e6f16SPaolo Abeni 8737d1e6f16SPaolo Abeni if [ $stale_nr -lt $stale_min ] || 8747d1e6f16SPaolo Abeni [ $stale_max -gt 0 -a $stale_nr -gt $stale_max ] || 8757d1e6f16SPaolo Abeni [ $((stale_nr - $recover_nr)) -ne $stale_delta ]; then 8767d1e6f16SPaolo Abeni echo "[fail] got $stale_nr stale[s] $recover_nr recover[s], " \ 8777d1e6f16SPaolo Abeni " expected stale in range [$stale_min..$stale_max]," \ 8787d1e6f16SPaolo Abeni " stale-recover delta $stale_delta " 8797d1e6f16SPaolo Abeni ret=1 8807d1e6f16SPaolo Abeni dump_stats=1 8817d1e6f16SPaolo Abeni else 8827d1e6f16SPaolo Abeni echo "[ ok ]" 8837d1e6f16SPaolo Abeni fi 8847d1e6f16SPaolo Abeni 8857d1e6f16SPaolo Abeni if [ "${dump_stats}" = 1 ]; then 8867d1e6f16SPaolo Abeni echo $ns stats 8877d1e6f16SPaolo Abeni ip netns exec $ns ip -s link show 8887d1e6f16SPaolo Abeni ip netns exec $ns nstat -as | grep MPTcp 8897d1e6f16SPaolo Abeni fi 8907d1e6f16SPaolo Abeni} 8917d1e6f16SPaolo Abeni 892be613160SGeliang Tangchk_add_nr() 893be613160SGeliang Tang{ 894be613160SGeliang Tang local add_nr=$1 895be613160SGeliang Tang local echo_nr=$2 8968a127bf6SGeliang Tang local port_nr=${3:-0} 8978a127bf6SGeliang Tang local syn_nr=${4:-$port_nr} 8988a127bf6SGeliang Tang local syn_ack_nr=${5:-$port_nr} 8998a127bf6SGeliang Tang local ack_nr=${6:-$port_nr} 9008a127bf6SGeliang Tang local mis_syn_nr=${7:-0} 9018a127bf6SGeliang Tang local mis_ack_nr=${8:-0} 902be613160SGeliang Tang local count 903be613160SGeliang Tang local dump_stats 9046ef84b15SPaolo Abeni local timeout 9056ef84b15SPaolo Abeni 9066ef84b15SPaolo Abeni timeout=`ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout` 907be613160SGeliang Tang 908*9a0a9367SGeliang Tang printf "%-${nr_blank}s %s" " " "add" 9096ef84b15SPaolo Abeni count=`ip netns exec $ns2 nstat -as MPTcpExtAddAddr | grep MPTcpExtAddAddr | awk '{print $2}'` 910be613160SGeliang Tang [ -z "$count" ] && count=0 9116ef84b15SPaolo Abeni 9126ef84b15SPaolo Abeni # if the test configured a short timeout tolerate greater then expected 9136ef84b15SPaolo Abeni # add addrs options, due to retransmissions 9146ef84b15SPaolo Abeni if [ "$count" != "$add_nr" ] && [ "$timeout" -gt 1 -o "$count" -lt "$add_nr" ]; then 915be613160SGeliang Tang echo "[fail] got $count ADD_ADDR[s] expected $add_nr" 916be613160SGeliang Tang ret=1 917be613160SGeliang Tang dump_stats=1 918be613160SGeliang Tang else 919be613160SGeliang Tang echo -n "[ ok ]" 920be613160SGeliang Tang fi 921be613160SGeliang Tang 922be613160SGeliang Tang echo -n " - echo " 923be613160SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtEchoAdd | awk '{print $2}'` 924be613160SGeliang Tang [ -z "$count" ] && count=0 925be613160SGeliang Tang if [ "$count" != "$echo_nr" ]; then 926be613160SGeliang Tang echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr" 927be613160SGeliang Tang ret=1 928be613160SGeliang Tang dump_stats=1 929be613160SGeliang Tang else 9308a127bf6SGeliang Tang echo -n "[ ok ]" 9318a127bf6SGeliang Tang fi 9328a127bf6SGeliang Tang 9338a127bf6SGeliang Tang if [ $port_nr -gt 0 ]; then 9348a127bf6SGeliang Tang echo -n " - pt " 9358a127bf6SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtPortAdd | awk '{print $2}'` 9368a127bf6SGeliang Tang [ -z "$count" ] && count=0 9378a127bf6SGeliang Tang if [ "$count" != "$port_nr" ]; then 9388a127bf6SGeliang Tang echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr" 9398a127bf6SGeliang Tang ret=1 9408a127bf6SGeliang Tang dump_stats=1 9418a127bf6SGeliang Tang else 942be613160SGeliang Tang echo "[ ok ]" 943be613160SGeliang Tang fi 944be613160SGeliang Tang 945*9a0a9367SGeliang Tang printf "%-${nr_blank}s %s" " " "syn" 9468a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortSynRx | 9478a127bf6SGeliang Tang awk '{print $2}'` 9488a127bf6SGeliang Tang [ -z "$count" ] && count=0 9498a127bf6SGeliang Tang if [ "$count" != "$syn_nr" ]; then 9508a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] syn with a different \ 9518a127bf6SGeliang Tang port-number expected $syn_nr" 9528a127bf6SGeliang Tang ret=1 9538a127bf6SGeliang Tang dump_stats=1 9548a127bf6SGeliang Tang else 9558a127bf6SGeliang Tang echo -n "[ ok ]" 9568a127bf6SGeliang Tang fi 9578a127bf6SGeliang Tang 9588a127bf6SGeliang Tang echo -n " - synack" 9598a127bf6SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinPortSynAckRx | 9608a127bf6SGeliang Tang awk '{print $2}'` 9618a127bf6SGeliang Tang [ -z "$count" ] && count=0 9628a127bf6SGeliang Tang if [ "$count" != "$syn_ack_nr" ]; then 9638a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] synack with a different \ 9648a127bf6SGeliang Tang port-number expected $syn_ack_nr" 9658a127bf6SGeliang Tang ret=1 9668a127bf6SGeliang Tang dump_stats=1 9678a127bf6SGeliang Tang else 9688a127bf6SGeliang Tang echo -n "[ ok ]" 9698a127bf6SGeliang Tang fi 9708a127bf6SGeliang Tang 9718a127bf6SGeliang Tang echo -n " - ack" 9728a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortAckRx | 9738a127bf6SGeliang Tang awk '{print $2}'` 9748a127bf6SGeliang Tang [ -z "$count" ] && count=0 9758a127bf6SGeliang Tang if [ "$count" != "$ack_nr" ]; then 9768a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] ack with a different \ 9778a127bf6SGeliang Tang port-number expected $ack_nr" 9788a127bf6SGeliang Tang ret=1 9798a127bf6SGeliang Tang dump_stats=1 9808a127bf6SGeliang Tang else 9818a127bf6SGeliang Tang echo "[ ok ]" 9828a127bf6SGeliang Tang fi 9838a127bf6SGeliang Tang 984*9a0a9367SGeliang Tang printf "%-${nr_blank}s %s" " " "syn" 9858a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortSynRx | 9868a127bf6SGeliang Tang awk '{print $2}'` 9878a127bf6SGeliang Tang [ -z "$count" ] && count=0 9888a127bf6SGeliang Tang if [ "$count" != "$mis_syn_nr" ]; then 9898a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] syn with a mismatched \ 9908a127bf6SGeliang Tang port-number expected $mis_syn_nr" 9918a127bf6SGeliang Tang ret=1 9928a127bf6SGeliang Tang dump_stats=1 9938a127bf6SGeliang Tang else 9948a127bf6SGeliang Tang echo -n "[ ok ]" 9958a127bf6SGeliang Tang fi 9968a127bf6SGeliang Tang 9978a127bf6SGeliang Tang echo -n " - ack " 9988a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortAckRx | 9998a127bf6SGeliang Tang awk '{print $2}'` 10008a127bf6SGeliang Tang [ -z "$count" ] && count=0 10018a127bf6SGeliang Tang if [ "$count" != "$mis_ack_nr" ]; then 10028a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] ack with a mismatched \ 10038a127bf6SGeliang Tang port-number expected $mis_ack_nr" 10048a127bf6SGeliang Tang ret=1 10058a127bf6SGeliang Tang dump_stats=1 10068a127bf6SGeliang Tang else 10078a127bf6SGeliang Tang echo "[ ok ]" 10088a127bf6SGeliang Tang fi 10098a127bf6SGeliang Tang else 10108a127bf6SGeliang Tang echo "" 10118a127bf6SGeliang Tang fi 10128a127bf6SGeliang Tang 1013327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 1014be613160SGeliang Tang} 1015be613160SGeliang Tang 1016dd72b0feSGeliang Tangchk_rm_nr() 1017dd72b0feSGeliang Tang{ 1018dd72b0feSGeliang Tang local rm_addr_nr=$1 1019dd72b0feSGeliang Tang local rm_subflow_nr=$2 10207028ba8aSGeliang Tang local invert=${3:-""} 1021dd72b0feSGeliang Tang local count 1022dd72b0feSGeliang Tang local dump_stats 10237028ba8aSGeliang Tang local addr_ns 10247028ba8aSGeliang Tang local subflow_ns 10257028ba8aSGeliang Tang 10267028ba8aSGeliang Tang if [ -z $invert ]; then 10277028ba8aSGeliang Tang addr_ns=$ns1 10287028ba8aSGeliang Tang subflow_ns=$ns2 10297028ba8aSGeliang Tang elif [ $invert = "invert" ]; then 10307028ba8aSGeliang Tang addr_ns=$ns2 10317028ba8aSGeliang Tang subflow_ns=$ns1 10327028ba8aSGeliang Tang fi 1033dd72b0feSGeliang Tang 1034*9a0a9367SGeliang Tang printf "%-${nr_blank}s %s" " " "rm " 10357028ba8aSGeliang Tang count=`ip netns exec $addr_ns nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'` 1036dd72b0feSGeliang Tang [ -z "$count" ] && count=0 1037dd72b0feSGeliang Tang if [ "$count" != "$rm_addr_nr" ]; then 1038dd72b0feSGeliang Tang echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" 1039dd72b0feSGeliang Tang ret=1 1040dd72b0feSGeliang Tang dump_stats=1 1041dd72b0feSGeliang Tang else 1042dd72b0feSGeliang Tang echo -n "[ ok ]" 1043dd72b0feSGeliang Tang fi 1044dd72b0feSGeliang Tang 1045dd72b0feSGeliang Tang echo -n " - sf " 10467028ba8aSGeliang Tang count=`ip netns exec $subflow_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'` 1047dd72b0feSGeliang Tang [ -z "$count" ] && count=0 1048dd72b0feSGeliang Tang if [ "$count" != "$rm_subflow_nr" ]; then 1049dd72b0feSGeliang Tang echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr" 1050dd72b0feSGeliang Tang ret=1 1051dd72b0feSGeliang Tang dump_stats=1 1052dd72b0feSGeliang Tang else 1053dd72b0feSGeliang Tang echo "[ ok ]" 1054dd72b0feSGeliang Tang fi 1055dd72b0feSGeliang Tang 1056327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 1057dd72b0feSGeliang Tang} 1058dd72b0feSGeliang Tang 1059718eb44eSGeliang Tangchk_prio_nr() 1060718eb44eSGeliang Tang{ 1061718eb44eSGeliang Tang local mp_prio_nr_tx=$1 1062718eb44eSGeliang Tang local mp_prio_nr_rx=$2 1063718eb44eSGeliang Tang local count 1064718eb44eSGeliang Tang local dump_stats 1065718eb44eSGeliang Tang 1066*9a0a9367SGeliang Tang printf "%-${nr_blank}s %s" " " "ptx" 1067718eb44eSGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}'` 1068718eb44eSGeliang Tang [ -z "$count" ] && count=0 1069718eb44eSGeliang Tang if [ "$count" != "$mp_prio_nr_tx" ]; then 1070718eb44eSGeliang Tang echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" 1071718eb44eSGeliang Tang ret=1 1072718eb44eSGeliang Tang dump_stats=1 1073718eb44eSGeliang Tang else 1074718eb44eSGeliang Tang echo -n "[ ok ]" 1075718eb44eSGeliang Tang fi 1076718eb44eSGeliang Tang 1077718eb44eSGeliang Tang echo -n " - prx " 1078718eb44eSGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}'` 1079718eb44eSGeliang Tang [ -z "$count" ] && count=0 1080718eb44eSGeliang Tang if [ "$count" != "$mp_prio_nr_rx" ]; then 1081718eb44eSGeliang Tang echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" 1082718eb44eSGeliang Tang ret=1 1083718eb44eSGeliang Tang dump_stats=1 1084718eb44eSGeliang Tang else 1085718eb44eSGeliang Tang echo "[ ok ]" 1086718eb44eSGeliang Tang fi 1087718eb44eSGeliang Tang 1088327b9a94SPaolo Abeni [ "${dump_stats}" = 1 ] && dump_stats 1089718eb44eSGeliang Tang} 1090718eb44eSGeliang Tang 10917d1e6f16SPaolo Abenichk_link_usage() 10927d1e6f16SPaolo Abeni{ 10937d1e6f16SPaolo Abeni local ns=$1 10947d1e6f16SPaolo Abeni local link=$2 10957d1e6f16SPaolo Abeni local out=$3 10967d1e6f16SPaolo Abeni local expected_rate=$4 10977d1e6f16SPaolo Abeni local tx_link=`ip netns exec $ns cat /sys/class/net/$link/statistics/tx_bytes` 10987d1e6f16SPaolo Abeni local tx_total=`ls -l $out | awk '{print $5}'` 10997d1e6f16SPaolo Abeni local tx_rate=$((tx_link * 100 / $tx_total)) 11007d1e6f16SPaolo Abeni local tolerance=5 11017d1e6f16SPaolo Abeni 1102*9a0a9367SGeliang Tang printf "%-${nr_blank}s %-18s" " " "link usage" 11037d1e6f16SPaolo Abeni if [ $tx_rate -lt $((expected_rate - $tolerance)) -o \ 11047d1e6f16SPaolo Abeni $tx_rate -gt $((expected_rate + $tolerance)) ]; then 11057d1e6f16SPaolo Abeni echo "[fail] got $tx_rate% usage, expected $expected_rate%" 11067d1e6f16SPaolo Abeni ret=1 11077d1e6f16SPaolo Abeni else 11087d1e6f16SPaolo Abeni echo "[ ok ]" 11097d1e6f16SPaolo Abeni fi 11107d1e6f16SPaolo Abeni} 11117d1e6f16SPaolo Abeni 111246e967d1SPaolo Abeniwait_for_tw() 111346e967d1SPaolo Abeni{ 111446e967d1SPaolo Abeni local timeout_ms=$((timeout_poll * 1000)) 111546e967d1SPaolo Abeni local time=0 111646e967d1SPaolo Abeni local ns=$1 111746e967d1SPaolo Abeni 111846e967d1SPaolo Abeni while [ $time -lt $timeout_ms ]; do 11195b31dda7SPaolo Abeni local cnt=$(ip netns exec $ns nstat -as TcpAttemptFails | grep TcpAttemptFails | awk '{print $2}') 112046e967d1SPaolo Abeni 112146e967d1SPaolo Abeni [ "$cnt" = 1 ] && return 1 112246e967d1SPaolo Abeni time=$((time + 100)) 112346e967d1SPaolo Abeni sleep 0.1 112446e967d1SPaolo Abeni done 112546e967d1SPaolo Abeni return 1 112646e967d1SPaolo Abeni} 112746e967d1SPaolo Abeni 11281002b89fSGeliang Tangsubflows_tests() 11291002b89fSGeliang Tang{ 11301002b89fSGeliang Tang reset 1131b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1132b08fbf24SPaolo Abeni chk_join_nr "no JOIN" "0" "0" "0" 1133b08fbf24SPaolo Abeni 11341002b89fSGeliang Tang # subflow limited by client 1135b08fbf24SPaolo Abeni reset 113634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 0 113734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 0 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, limited by client" 0 0 0 1141b08fbf24SPaolo Abeni 11421002b89fSGeliang Tang # subflow limited by server 1143b08fbf24SPaolo Abeni reset 114434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 0 114534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 114634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1147b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1148b08fbf24SPaolo Abeni chk_join_nr "single subflow, limited by server" 1 1 0 1149b08fbf24SPaolo Abeni 1150b08fbf24SPaolo Abeni # subflow 1151b08fbf24SPaolo Abeni reset 115234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 115334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 115434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1155b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1156b08fbf24SPaolo Abeni chk_join_nr "single subflow" 1 1 1 1157b08fbf24SPaolo Abeni 1158b08fbf24SPaolo Abeni # multiple subflows 1159b08fbf24SPaolo Abeni reset 116034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 116134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 116234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 116334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 1164b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1165b08fbf24SPaolo Abeni chk_join_nr "multiple subflows" 2 2 2 1166b08fbf24SPaolo Abeni 116772bcbc46SPaolo Abeni # multiple subflows limited by server 1168b08fbf24SPaolo Abeni reset 116934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 117034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 117134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 117234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 1173b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1174b08fbf24SPaolo Abeni chk_join_nr "multiple subflows, limited by server" 2 2 1 1175c3eaa5f6SGeliang Tang 1176c3eaa5f6SGeliang Tang # single subflow, dev 1177c3eaa5f6SGeliang Tang reset 117834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 117934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 118034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow dev ns2eth3 1181c3eaa5f6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1182c3eaa5f6SGeliang Tang chk_join_nr "single subflow, dev" 1 1 1 11831002b89fSGeliang Tang} 1184b08fbf24SPaolo Abeni 118546e967d1SPaolo Abenisubflows_error_tests() 118646e967d1SPaolo Abeni{ 118746e967d1SPaolo Abeni # If a single subflow is configured, and matches the MPC src 118846e967d1SPaolo Abeni # address, no additional subflow should be created 118946e967d1SPaolo Abeni reset 119034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 119134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 119234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow 119346e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 119446e967d1SPaolo Abeni chk_join_nr "no MPC reuse with single endpoint" 0 0 0 119546e967d1SPaolo Abeni 119646e967d1SPaolo Abeni # multiple subflows, with subflow creation error 119746e967d1SPaolo Abeni reset 119834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 119934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 120034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 120134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 120246e967d1SPaolo Abeni ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT 120346e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 120446e967d1SPaolo Abeni chk_join_nr "multi subflows, with failing subflow" 1 1 1 120546e967d1SPaolo Abeni 120646e967d1SPaolo Abeni # multiple subflows, with subflow timeout on MPJ 120746e967d1SPaolo Abeni reset 120834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 120934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 121034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 121134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 121246e967d1SPaolo Abeni ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j DROP 121346e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 121446e967d1SPaolo Abeni chk_join_nr "multi subflows, with subflow timeout" 1 1 1 121546e967d1SPaolo Abeni 121646e967d1SPaolo Abeni # multiple subflows, check that the endpoint corresponding to 121746e967d1SPaolo Abeni # closed subflow (due to reset) is not reused if additional 121846e967d1SPaolo Abeni # subflows are added later 121946e967d1SPaolo Abeni reset 122034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 122134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 122234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 122346e967d1SPaolo Abeni ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT 122446e967d1SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow & 122546e967d1SPaolo Abeni 122646e967d1SPaolo Abeni # updates in the child shell do not have any effect here, we 122746e967d1SPaolo Abeni # need to bump the test counter for the above case 122846e967d1SPaolo Abeni TEST_COUNT=$((TEST_COUNT+1)) 122946e967d1SPaolo Abeni 123046e967d1SPaolo Abeni # mpj subflow will be in TW after the reset 123146e967d1SPaolo Abeni wait_for_tw $ns2 123234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 123346e967d1SPaolo Abeni wait 123446e967d1SPaolo Abeni 123546e967d1SPaolo Abeni # additional subflow could be created only if the PM select 123646e967d1SPaolo Abeni # the later endpoint, skipping the already used one 123746e967d1SPaolo Abeni chk_join_nr "multi subflows, fair usage on close" 1 1 1 123846e967d1SPaolo Abeni} 123946e967d1SPaolo Abeni 12401002b89fSGeliang Tangsignal_address_tests() 12411002b89fSGeliang Tang{ 1242b08fbf24SPaolo Abeni # add_address, unused 1243b08fbf24SPaolo Abeni reset 124434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 1245b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1246b08fbf24SPaolo Abeni chk_join_nr "unused signal address" 0 0 0 1247be613160SGeliang Tang chk_add_nr 1 1 1248b08fbf24SPaolo Abeni 1249b08fbf24SPaolo Abeni # accept and use add_addr 1250b08fbf24SPaolo Abeni reset 125134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 125234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 125334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 1254b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1255b08fbf24SPaolo Abeni chk_join_nr "signal address" 1 1 1 1256be613160SGeliang Tang chk_add_nr 1 1 1257b08fbf24SPaolo Abeni 1258b08fbf24SPaolo Abeni # accept and use add_addr with an additional subflow 1259b08fbf24SPaolo Abeni # note: signal address in server ns and local addresses in client ns must 1260b08fbf24SPaolo Abeni # belong to different subnets or one of the listed local address could be 1261b08fbf24SPaolo Abeni # used for 'add_addr' subflow 1262b08fbf24SPaolo Abeni reset 126334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 126434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 126534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 126634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1267b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1268b08fbf24SPaolo Abeni chk_join_nr "subflow and signal" 2 2 2 1269be613160SGeliang Tang chk_add_nr 1 1 1270b08fbf24SPaolo Abeni 1271b08fbf24SPaolo Abeni # accept and use add_addr with additional subflows 1272b08fbf24SPaolo Abeni reset 127334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 127434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 127534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 127634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 127734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 1278b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1279b08fbf24SPaolo Abeni chk_join_nr "multiple subflows and signal" 3 3 3 1280be613160SGeliang Tang chk_add_nr 1 1 1281ef360019SGeliang Tang 1282ef360019SGeliang Tang # signal addresses 1283ef360019SGeliang Tang reset 128434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 128534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 128634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 128734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 128834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1289ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1290ef360019SGeliang Tang chk_join_nr "signal addresses" 3 3 3 1291ef360019SGeliang Tang chk_add_nr 3 3 1292ef360019SGeliang Tang 1293ef360019SGeliang Tang # signal invalid addresses 1294ef360019SGeliang Tang reset 129534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 129634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 129734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 129834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 129934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1300ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1301ef360019SGeliang Tang chk_join_nr "signal invalid addresses" 1 1 1 1302ef360019SGeliang Tang chk_add_nr 3 3 130333c563adSYonglong Li 130433c563adSYonglong Li # signal addresses race test 130533c563adSYonglong Li reset 130634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 130734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 130834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.1.1 flags signal 130934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 131034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 131134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 131234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.1.2 flags signal 131334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags signal 131434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags signal 131534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags signal 13166ef84b15SPaolo Abeni 13176ef84b15SPaolo Abeni # the peer could possibly miss some addr notification, allow retransmission 13186ef84b15SPaolo Abeni ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 13196ef84b15SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 1320857898ebSMatthieu Baerts chk_join_nr "signal addresses race test" 3 3 3 132186e39e04SPaolo Abeni 132286e39e04SPaolo Abeni # the server will not signal the address terminating 132386e39e04SPaolo Abeni # the MPC subflow 132486e39e04SPaolo Abeni chk_add_nr 3 3 13251002b89fSGeliang Tang} 1326b08fbf24SPaolo Abeni 13271002b89fSGeliang Tanglink_failure_tests() 13281002b89fSGeliang Tang{ 13298b819a84SFlorian Westphal # accept and use add_addr with additional subflows and link loss 13308b819a84SFlorian Westphal reset 13317d1e6f16SPaolo Abeni 13327d1e6f16SPaolo Abeni # without any b/w limit each veth could spool the packets and get 13337d1e6f16SPaolo Abeni # them acked at xmit time, so that the corresponding subflow will 13347d1e6f16SPaolo Abeni # have almost always no outstanding pkts, the scheduler will pick 13357d1e6f16SPaolo Abeni # always the first subflow and we will have hard time testing 13367d1e6f16SPaolo Abeni # active backup and link switch-over. 13377d1e6f16SPaolo Abeni # Let's set some arbitrary (low) virtual link limits. 13387d1e6f16SPaolo Abeni init_shapers 133934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 134034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 134134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 134234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow 134334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow 13448b819a84SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 1 13458b819a84SFlorian Westphal chk_join_nr "multiple flows, signal, link failure" 3 3 3 13468b819a84SFlorian Westphal chk_add_nr 1 1 13477d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 5 1 13487d1e6f16SPaolo Abeni 13497d1e6f16SPaolo Abeni # accept and use add_addr with additional subflows and link loss 13507d1e6f16SPaolo Abeni # for bidirectional transfer 13517d1e6f16SPaolo Abeni reset 13527d1e6f16SPaolo Abeni init_shapers 135334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 135434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 135534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 135634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow 135734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow 13587d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2 13597d1e6f16SPaolo Abeni chk_join_nr "multi flows, signal, bidi, link fail" 3 3 3 13607d1e6f16SPaolo Abeni chk_add_nr 1 1 13617d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 -1 1 13627d1e6f16SPaolo Abeni 13637d1e6f16SPaolo Abeni # 2 subflows plus 1 backup subflow with a lossy link, backup 13647d1e6f16SPaolo Abeni # will never be used 13657d1e6f16SPaolo Abeni reset 13667d1e6f16SPaolo Abeni init_shapers 136734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 136834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 136934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 13707d1e6f16SPaolo Abeni export FAILING_LINKS="1" 137134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 13727d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1 13737d1e6f16SPaolo Abeni chk_join_nr "backup subflow unused, link failure" 2 2 2 13747d1e6f16SPaolo Abeni chk_add_nr 1 1 13757d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 0 13767d1e6f16SPaolo Abeni 13777d1e6f16SPaolo Abeni # 2 lossy links after half transfer, backup will get half of 13787d1e6f16SPaolo Abeni # the traffic 13797d1e6f16SPaolo Abeni reset 13807d1e6f16SPaolo Abeni init_shapers 138134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 138234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 138334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 138434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 13857d1e6f16SPaolo Abeni export FAILING_LINKS="1 2" 13867d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1 13877d1e6f16SPaolo Abeni chk_join_nr "backup flow used, multi links fail" 2 2 2 13887d1e6f16SPaolo Abeni chk_add_nr 1 1 13897d1e6f16SPaolo Abeni chk_stale_nr $ns2 2 4 2 13907d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 50 13917d1e6f16SPaolo Abeni 13927d1e6f16SPaolo Abeni # use a backup subflow with the first subflow on a lossy link 13937d1e6f16SPaolo Abeni # for bidirectional transfer 13947d1e6f16SPaolo Abeni reset 13957d1e6f16SPaolo Abeni init_shapers 139634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 139734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 139834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 139934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 14007d1e6f16SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2 14017d1e6f16SPaolo Abeni chk_join_nr "backup flow used, bidi, link failure" 2 2 2 14027d1e6f16SPaolo Abeni chk_add_nr 1 1 14037d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 -1 2 14047d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 50 14051002b89fSGeliang Tang} 14068b819a84SFlorian Westphal 14071002b89fSGeliang Tangadd_addr_timeout_tests() 14081002b89fSGeliang Tang{ 14098d014eaaSGeliang Tang # add_addr timeout 14108d014eaaSGeliang Tang reset_with_add_addr_timeout 141134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 141234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 141334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 14148b819a84SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 14158d014eaaSGeliang Tang chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1 14168d014eaaSGeliang Tang chk_add_nr 4 0 14178d014eaaSGeliang Tang 14181002b89fSGeliang Tang # add_addr timeout IPv6 14191002b89fSGeliang Tang reset_with_add_addr_timeout 6 142034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 142134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 142234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 14231002b89fSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 14241002b89fSGeliang Tang chk_join_nr "signal address, ADD_ADDR6 timeout" 1 1 1 14251002b89fSGeliang Tang chk_add_nr 4 0 14268da6229bSGeliang Tang 14278da6229bSGeliang Tang # signal addresses timeout 14288da6229bSGeliang Tang reset_with_add_addr_timeout 142934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 143034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 143134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 143234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 14338da6229bSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 14348da6229bSGeliang Tang chk_join_nr "signal addresses, ADD_ADDR timeout" 2 2 2 14358da6229bSGeliang Tang chk_add_nr 8 0 14368da6229bSGeliang Tang 14378da6229bSGeliang Tang # signal invalid addresses timeout 14388da6229bSGeliang Tang reset_with_add_addr_timeout 143934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 144034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 144134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 144234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 14438da6229bSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 14448da6229bSGeliang Tang chk_join_nr "invalid address, ADD_ADDR timeout" 1 1 1 14458da6229bSGeliang Tang chk_add_nr 8 0 14461002b89fSGeliang Tang} 14471002b89fSGeliang Tang 14481002b89fSGeliang Tangremove_tests() 14491002b89fSGeliang Tang{ 1450dd72b0feSGeliang Tang # single subflow, remove 1451dd72b0feSGeliang Tang reset 145234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 145334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 145434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 14552e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -1 slow 1456dd72b0feSGeliang Tang chk_join_nr "remove single subflow" 1 1 1 1457dd72b0feSGeliang Tang chk_rm_nr 1 1 1458dd72b0feSGeliang Tang 1459dd72b0feSGeliang Tang # multiple subflows, remove 1460dd72b0feSGeliang Tang reset 146134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 146234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 146334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 146434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 14652e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -2 slow 1466dd72b0feSGeliang Tang chk_join_nr "remove multiple subflows" 2 2 2 1467dd72b0feSGeliang Tang chk_rm_nr 2 2 1468dd72b0feSGeliang Tang 1469dd72b0feSGeliang Tang # single address, remove 1470dd72b0feSGeliang Tang reset 147134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 147234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 147334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 14742e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 1475dd72b0feSGeliang Tang chk_join_nr "remove single address" 1 1 1 1476dd72b0feSGeliang Tang chk_add_nr 1 1 14777028ba8aSGeliang Tang chk_rm_nr 1 1 invert 1478dd72b0feSGeliang Tang 1479dd72b0feSGeliang Tang # subflow and signal, remove 1480dd72b0feSGeliang Tang reset 148134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 148234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 148334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 148434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 14852e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 1486dd72b0feSGeliang Tang chk_join_nr "remove subflow and signal" 2 2 2 1487dd72b0feSGeliang Tang chk_add_nr 1 1 1488dd72b0feSGeliang Tang chk_rm_nr 1 1 1489dd72b0feSGeliang Tang 1490dd72b0feSGeliang Tang # subflows and signal, remove 1491dd72b0feSGeliang Tang reset 149234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 149334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 149434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 149534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 149634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 14972e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -2 slow 1498dd72b0feSGeliang Tang chk_join_nr "remove subflows and signal" 3 3 3 1499dd72b0feSGeliang Tang chk_add_nr 1 1 1500dd72b0feSGeliang Tang chk_rm_nr 2 2 1501dd72b0feSGeliang Tang 1502ef360019SGeliang Tang # addresses remove 1503ef360019SGeliang Tang reset 150434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 150534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 150634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 150734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 150834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1509ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 1510ef360019SGeliang Tang chk_join_nr "remove addresses" 3 3 3 1511ef360019SGeliang Tang chk_add_nr 3 3 1512ef360019SGeliang Tang chk_rm_nr 3 3 invert 1513ef360019SGeliang Tang 1514ef360019SGeliang Tang # invalid addresses remove 1515ef360019SGeliang Tang reset 151634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 151734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 151834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 151934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 152034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1521ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 1522ef360019SGeliang Tang chk_join_nr "remove invalid addresses" 1 1 1 1523ef360019SGeliang Tang chk_add_nr 3 3 1524ef360019SGeliang Tang chk_rm_nr 3 1 invert 1525ef360019SGeliang Tang 15266fe4ccdcSGeliang Tang # subflows and signal, flush 15276fe4ccdcSGeliang Tang reset 152834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 152934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 153034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 153134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 153234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 15332e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 15346fe4ccdcSGeliang Tang chk_join_nr "flush subflows and signal" 3 3 3 15356fe4ccdcSGeliang Tang chk_add_nr 1 1 15366fe4ccdcSGeliang Tang chk_rm_nr 2 2 1537d2c4333aSGeliang Tang 1538d2c4333aSGeliang Tang # subflows flush 1539d2c4333aSGeliang Tang reset 154034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 154134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 154234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow id 150 154334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 154434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 1545d2c4333aSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1546d2c4333aSGeliang Tang chk_join_nr "flush subflows" 3 3 3 1547d2c4333aSGeliang Tang chk_rm_nr 3 3 1548d2c4333aSGeliang Tang 1549d2c4333aSGeliang Tang # addresses flush 1550d2c4333aSGeliang Tang reset 155134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 155234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 155334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 155434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 155534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1556d2c4333aSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1557d2c4333aSGeliang Tang chk_join_nr "flush addresses" 3 3 3 1558d2c4333aSGeliang Tang chk_add_nr 3 3 1559d2c4333aSGeliang Tang chk_rm_nr 3 3 invert 1560ef360019SGeliang Tang 1561ef360019SGeliang Tang # invalid addresses flush 1562ef360019SGeliang Tang reset 156334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 156434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 156534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 156634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 156734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 1568ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 0 slow 1569ef360019SGeliang Tang chk_join_nr "flush invalid addresses" 1 1 1 1570ef360019SGeliang Tang chk_add_nr 3 3 1571ef360019SGeliang Tang chk_rm_nr 3 1 invert 15725e287fe7SGeliang Tang 15735e287fe7SGeliang Tang # remove id 0 subflow 15745e287fe7SGeliang Tang reset 157534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 157634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 157734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 15785e287fe7SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -9 slow 15795e287fe7SGeliang Tang chk_join_nr "remove id 0 subflow" 1 1 1 15805e287fe7SGeliang Tang chk_rm_nr 1 1 15815e287fe7SGeliang Tang 15825e287fe7SGeliang Tang # remove id 0 address 15835e287fe7SGeliang Tang reset 158434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 158534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 158634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 15875e287fe7SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -9 0 slow 15885e287fe7SGeliang Tang chk_join_nr "remove id 0 address" 1 1 1 15895e287fe7SGeliang Tang chk_add_nr 1 1 15905e287fe7SGeliang Tang chk_rm_nr 1 1 invert 15911002b89fSGeliang Tang} 15926fe4ccdcSGeliang Tang 15931002b89fSGeliang Tangadd_tests() 15941002b89fSGeliang Tang{ 15956208fd82SGeliang Tang # add single subflow 15966208fd82SGeliang Tang reset 159734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 159834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 15996208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow 16006208fd82SGeliang Tang chk_join_nr "add single subflow" 1 1 1 16016208fd82SGeliang Tang 16026208fd82SGeliang Tang # add signal address 16036208fd82SGeliang Tang reset 160434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 160534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 16066208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 16076208fd82SGeliang Tang chk_join_nr "add signal address" 1 1 1 16086208fd82SGeliang Tang chk_add_nr 1 1 16096208fd82SGeliang Tang 16106208fd82SGeliang Tang # add multiple subflows 16116208fd82SGeliang Tang reset 161234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 161334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 16146208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 2 slow 16156208fd82SGeliang Tang chk_join_nr "add multiple subflows" 2 2 2 16166208fd82SGeliang Tang 16176208fd82SGeliang Tang # add multiple subflows IPv6 16186208fd82SGeliang Tang reset 161934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 162034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 16216208fd82SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 2 slow 16226208fd82SGeliang Tang chk_join_nr "add multiple subflows IPv6" 2 2 2 16236208fd82SGeliang Tang 16246208fd82SGeliang Tang # add multiple addresses IPv6 16256208fd82SGeliang Tang reset 162634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 162734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 16286208fd82SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 2 0 slow 16296208fd82SGeliang Tang chk_join_nr "add multiple addresses IPv6" 2 2 2 16306208fd82SGeliang Tang chk_add_nr 2 2 16311002b89fSGeliang Tang} 16326208fd82SGeliang Tang 16331002b89fSGeliang Tangipv6_tests() 16341002b89fSGeliang Tang{ 1635523514edSGeliang Tang # subflow IPv6 1636523514edSGeliang Tang reset 163734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 163834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 163934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow 1640523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1641523514edSGeliang Tang chk_join_nr "single subflow IPv6" 1 1 1 1642523514edSGeliang Tang 1643523514edSGeliang Tang # add_address, unused IPv6 1644523514edSGeliang Tang reset 164534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 1646523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1647523514edSGeliang Tang chk_join_nr "unused signal address IPv6" 0 0 0 1648523514edSGeliang Tang chk_add_nr 1 1 1649523514edSGeliang Tang 1650523514edSGeliang Tang # signal address IPv6 1651523514edSGeliang Tang reset 165234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 165334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 165434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 1655523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1656523514edSGeliang Tang chk_join_nr "single address IPv6" 1 1 1 1657523514edSGeliang Tang chk_add_nr 1 1 1658523514edSGeliang Tang 1659523514edSGeliang Tang # single address IPv6, remove 1660523514edSGeliang Tang reset 166134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 166234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 166334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 16642e8cbf45SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 -1 0 slow 1665523514edSGeliang Tang chk_join_nr "remove single address IPv6" 1 1 1 1666523514edSGeliang Tang chk_add_nr 1 1 16677028ba8aSGeliang Tang chk_rm_nr 1 1 invert 1668523514edSGeliang Tang 1669523514edSGeliang Tang # subflow and signal IPv6, remove 1670523514edSGeliang Tang reset 167134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 167234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 167334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 167434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow 16752e8cbf45SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 -1 -1 slow 1676523514edSGeliang Tang chk_join_nr "remove subflow and signal IPv6" 2 2 2 1677523514edSGeliang Tang chk_add_nr 1 1 1678523514edSGeliang Tang chk_rm_nr 1 1 16791002b89fSGeliang Tang} 1680523514edSGeliang Tang 16811002b89fSGeliang Tangv4mapped_tests() 16821002b89fSGeliang Tang{ 1683a6094788SGeliang Tang # subflow IPv4-mapped to IPv4-mapped 1684a6094788SGeliang Tang reset 168534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 168634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 168734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow 1688a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1689a6094788SGeliang Tang chk_join_nr "single subflow IPv4-mapped" 1 1 1 1690a6094788SGeliang Tang 1691a6094788SGeliang Tang # signal address IPv4-mapped with IPv4-mapped sk 1692a6094788SGeliang Tang reset 169334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 169434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 169534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal 1696a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1697a6094788SGeliang Tang chk_join_nr "signal address IPv4-mapped" 1 1 1 1698a6094788SGeliang Tang chk_add_nr 1 1 1699a6094788SGeliang Tang 1700a6094788SGeliang Tang # subflow v4-map-v6 1701a6094788SGeliang Tang reset 170234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 170334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 170434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1705a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1706a6094788SGeliang Tang chk_join_nr "single subflow v4-map-v6" 1 1 1 1707a6094788SGeliang Tang 1708a6094788SGeliang Tang # signal address v4-map-v6 1709a6094788SGeliang Tang reset 171034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 171134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 171234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 1713a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1714a6094788SGeliang Tang chk_join_nr "signal address v4-map-v6" 1 1 1 1715a6094788SGeliang Tang chk_add_nr 1 1 1716a6094788SGeliang Tang 1717a6094788SGeliang Tang # subflow v6-map-v4 1718a6094788SGeliang Tang reset 171934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 172034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 172134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow 1722a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1723a6094788SGeliang Tang chk_join_nr "single subflow v6-map-v4" 1 1 1 1724a6094788SGeliang Tang 1725a6094788SGeliang Tang # signal address v6-map-v4 1726a6094788SGeliang Tang reset 172734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 172834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 172934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal 1730a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1731a6094788SGeliang Tang chk_join_nr "signal address v6-map-v4" 1 1 1 1732a6094788SGeliang Tang chk_add_nr 1 1 1733a6094788SGeliang Tang 1734a6094788SGeliang Tang # no subflow IPv6 to v4 address 1735a6094788SGeliang Tang reset 173634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 173734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 173834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow 1739a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1740a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v4-v6" 0 0 0 1741a6094788SGeliang Tang 1742a6094788SGeliang Tang # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end 1743a6094788SGeliang 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 dead:beef:2::10.0.3.2 flags subflow 1747a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1748a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v4-v6-2" 0 0 0 1749a6094788SGeliang Tang 1750a6094788SGeliang Tang # no subflow IPv4 to v6 address, no need to slow down too then 1751a6094788SGeliang Tang reset 175234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 175334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 175434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1755a6094788SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 1756a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v6-v4" 0 0 0 17571002b89fSGeliang Tang} 1758a6094788SGeliang Tang 17591002b89fSGeliang Tangbackup_tests() 17601002b89fSGeliang Tang{ 1761718eb44eSGeliang Tang # single subflow, backup 1762718eb44eSGeliang Tang reset 176334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 176434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 176534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup 1766718eb44eSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup 1767718eb44eSGeliang Tang chk_join_nr "single subflow, backup" 1 1 1 1768718eb44eSGeliang Tang chk_prio_nr 0 1 1769718eb44eSGeliang Tang 1770718eb44eSGeliang Tang # single address, backup 1771718eb44eSGeliang Tang reset 177234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 177334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 177434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 1775718eb44eSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup 1776718eb44eSGeliang Tang chk_join_nr "single address, backup" 1 1 1 1777718eb44eSGeliang Tang chk_add_nr 1 1 1778718eb44eSGeliang Tang chk_prio_nr 1 0 177933397b83SGeliang Tang 178033397b83SGeliang Tang # single address with port, backup 178133397b83SGeliang Tang reset 178234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 178334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 178434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 178533397b83SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup 178633397b83SGeliang Tang chk_join_nr "single address with port, backup" 1 1 1 178733397b83SGeliang Tang chk_add_nr 1 1 178833397b83SGeliang Tang chk_prio_nr 1 0 17891002b89fSGeliang Tang} 1790718eb44eSGeliang Tang 17911002b89fSGeliang Tangadd_addr_ports_tests() 17921002b89fSGeliang Tang{ 17938a127bf6SGeliang Tang # signal address with port 17948a127bf6SGeliang Tang reset 179534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 179634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 179734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 17988a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 17998a127bf6SGeliang Tang chk_join_nr "signal address with port" 1 1 1 18008a127bf6SGeliang Tang chk_add_nr 1 1 1 18018a127bf6SGeliang Tang 18028a127bf6SGeliang Tang # subflow and signal with port 18038a127bf6SGeliang Tang reset 180434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 180534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 180634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 180734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 18088a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 18098a127bf6SGeliang Tang chk_join_nr "subflow and signal with port" 2 2 2 18108a127bf6SGeliang Tang chk_add_nr 1 1 1 18118a127bf6SGeliang Tang 18128a127bf6SGeliang Tang # single address with port, remove 18138a127bf6SGeliang Tang reset 181434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 181534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 181634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 18178a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 18188a127bf6SGeliang Tang chk_join_nr "remove single address with port" 1 1 1 18198a127bf6SGeliang Tang chk_add_nr 1 1 1 18207028ba8aSGeliang Tang chk_rm_nr 1 1 invert 18218a127bf6SGeliang Tang 18228a127bf6SGeliang Tang # subflow and signal with port, remove 18238a127bf6SGeliang Tang reset 182434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 182534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 182634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 182734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 18288a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 18298a127bf6SGeliang Tang chk_join_nr "remove subflow and signal with port" 2 2 2 18308a127bf6SGeliang Tang chk_add_nr 1 1 1 18318a127bf6SGeliang Tang chk_rm_nr 1 1 18328a127bf6SGeliang Tang 18338a127bf6SGeliang Tang # subflows and signal with port, flush 18348a127bf6SGeliang Tang reset 183534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 183634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 183734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 183834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 183934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 1840327b9a94SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 0 -8 -2 slow 18418a127bf6SGeliang Tang chk_join_nr "flush subflows and signal with port" 3 3 3 18428a127bf6SGeliang Tang chk_add_nr 1 1 18438a127bf6SGeliang Tang chk_rm_nr 2 2 18448a127bf6SGeliang Tang 18458a127bf6SGeliang Tang # multiple addresses with port 18468a127bf6SGeliang Tang reset 184734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 184834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 184934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10100 185034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 18518a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 18528a127bf6SGeliang Tang chk_join_nr "multiple addresses with port" 2 2 2 18538a127bf6SGeliang Tang chk_add_nr 2 2 2 18548a127bf6SGeliang Tang 18558a127bf6SGeliang Tang # multiple addresses with ports 18568a127bf6SGeliang Tang reset 185734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 185834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 185934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10101 186034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 18618a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 18628a127bf6SGeliang Tang chk_join_nr "multiple addresses with ports" 2 2 2 18638a127bf6SGeliang Tang chk_add_nr 2 2 2 18641002b89fSGeliang Tang} 18658a127bf6SGeliang Tang 18661002b89fSGeliang Tangsyncookies_tests() 18671002b89fSGeliang Tang{ 186800587187SFlorian Westphal # single subflow, syncookies 186900587187SFlorian Westphal reset_with_cookies 187034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 187134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 187234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 187300587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 187400587187SFlorian Westphal chk_join_nr "single subflow with syn cookies" 1 1 1 187500587187SFlorian Westphal 187600587187SFlorian Westphal # multiple subflows with syn cookies 187700587187SFlorian Westphal reset_with_cookies 187834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 187934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 188034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 188134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 188200587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 188300587187SFlorian Westphal chk_join_nr "multiple subflows with syn cookies" 2 2 2 188400587187SFlorian Westphal 188500587187SFlorian Westphal # multiple subflows limited by server 188600587187SFlorian Westphal reset_with_cookies 188734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 188834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 188934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 189034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 189100587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 1892a7da4416SJianguo Wu chk_join_nr "subflows limited by server w cookies" 2 1 1 189300587187SFlorian Westphal 189400587187SFlorian Westphal # test signal address with cookies 189500587187SFlorian Westphal reset_with_cookies 189634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 189734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 189834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 189900587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 190000587187SFlorian Westphal chk_join_nr "signal address with syn cookies" 1 1 1 1901be613160SGeliang Tang chk_add_nr 1 1 190200587187SFlorian Westphal 190300587187SFlorian Westphal # test cookie with subflow and signal 190400587187SFlorian Westphal reset_with_cookies 190534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 190634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 190734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 190834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 190900587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 191000587187SFlorian Westphal chk_join_nr "subflow and signal w cookies" 2 2 2 1911be613160SGeliang Tang chk_add_nr 1 1 191200587187SFlorian Westphal 191300587187SFlorian Westphal # accept and use add_addr with additional subflows 191400587187SFlorian Westphal reset_with_cookies 191534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 191634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 191734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 191834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 191934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 192000587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 192100587187SFlorian Westphal chk_join_nr "subflows and signal w. cookies" 3 3 3 1922be613160SGeliang Tang chk_add_nr 1 1 19231002b89fSGeliang Tang} 19241002b89fSGeliang Tang 1925af66d3e1SGeliang Tangchecksum_tests() 1926af66d3e1SGeliang Tang{ 1927af66d3e1SGeliang Tang # checksum test 0 0 1928af66d3e1SGeliang Tang reset_with_checksum 0 0 192934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 193034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1931af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1932af66d3e1SGeliang Tang chk_csum_nr "checksum test 0 0" 1933af66d3e1SGeliang Tang 1934af66d3e1SGeliang Tang # checksum test 1 1 1935af66d3e1SGeliang Tang reset_with_checksum 1 1 193634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 193734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1938af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1939af66d3e1SGeliang Tang chk_csum_nr "checksum test 1 1" 1940af66d3e1SGeliang Tang 1941af66d3e1SGeliang Tang # checksum test 0 1 1942af66d3e1SGeliang Tang reset_with_checksum 0 1 194334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 194434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1945af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1946af66d3e1SGeliang Tang chk_csum_nr "checksum test 0 1" 1947af66d3e1SGeliang Tang 1948af66d3e1SGeliang Tang # checksum test 1 0 1949af66d3e1SGeliang Tang reset_with_checksum 1 0 195034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 195134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 1952af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1953af66d3e1SGeliang Tang chk_csum_nr "checksum test 1 0" 1954af66d3e1SGeliang Tang} 1955af66d3e1SGeliang Tang 19560cddb4a6SGeliang Tangdeny_join_id0_tests() 19570cddb4a6SGeliang Tang{ 19580cddb4a6SGeliang Tang # subflow allow join id0 ns1 19590cddb4a6SGeliang Tang reset_with_allow_join_id0 1 0 196034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 196134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 196234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 19630cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19640cddb4a6SGeliang Tang chk_join_nr "single subflow allow join id0 ns1" 1 1 1 19650cddb4a6SGeliang Tang 19660cddb4a6SGeliang Tang # subflow allow join id0 ns2 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 $ns2 10.0.3.2 flags subflow 19710cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19720cddb4a6SGeliang Tang chk_join_nr "single subflow allow join id0 ns2" 0 0 0 19730cddb4a6SGeliang Tang 19740cddb4a6SGeliang Tang # signal address allow join id0 ns1 19750cddb4a6SGeliang Tang # ADD_ADDRs are not affected by allow_join_id0 value. 19760cddb4a6SGeliang Tang reset_with_allow_join_id0 1 0 197734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 197834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 197934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 19800cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19810cddb4a6SGeliang Tang chk_join_nr "signal address allow join id0 ns1" 1 1 1 19820cddb4a6SGeliang Tang chk_add_nr 1 1 19830cddb4a6SGeliang Tang 19840cddb4a6SGeliang Tang # signal address allow join id0 ns2 19850cddb4a6SGeliang Tang # ADD_ADDRs are not affected by allow_join_id0 value. 19860cddb4a6SGeliang Tang reset_with_allow_join_id0 0 1 198734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 198834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 198934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 19900cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 19910cddb4a6SGeliang Tang chk_join_nr "signal address allow join id0 ns2" 1 1 1 19920cddb4a6SGeliang Tang chk_add_nr 1 1 19930cddb4a6SGeliang Tang 19940cddb4a6SGeliang Tang # subflow and address allow join id0 ns1 19950cddb4a6SGeliang Tang reset_with_allow_join_id0 1 0 199634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 199734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 199834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 199934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 20000cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 20010cddb4a6SGeliang Tang chk_join_nr "subflow and address allow join id0 1" 2 2 2 20020cddb4a6SGeliang Tang 20030cddb4a6SGeliang Tang # subflow and address allow join id0 ns2 20040cddb4a6SGeliang Tang reset_with_allow_join_id0 0 1 200534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 200634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 200734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 200834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 20090cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 20100cddb4a6SGeliang Tang chk_join_nr "subflow and address allow join id0 2" 1 1 1 20110cddb4a6SGeliang Tang} 20120cddb4a6SGeliang Tang 20134f49d633SGeliang Tangfullmesh_tests() 20144f49d633SGeliang Tang{ 20154f49d633SGeliang Tang # fullmesh 1 20164f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added before the connection, 20174f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added during the connection. 20184f49d633SGeliang Tang reset 201934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 4 202034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 4 202134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,fullmesh 202234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,fullmesh 20234f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 20244f49d633SGeliang Tang chk_join_nr "fullmesh test 2x1" 4 4 4 20254f49d633SGeliang Tang chk_add_nr 1 1 20264f49d633SGeliang Tang 20274f49d633SGeliang Tang # fullmesh 2 20284f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 20294f49d633SGeliang Tang # 1 fullmesh addr in ns2, added during the connection. 20304f49d633SGeliang Tang reset 203134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 3 203234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 203334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 20344f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow 20354f49d633SGeliang Tang chk_join_nr "fullmesh test 1x1" 3 3 3 20364f49d633SGeliang Tang chk_add_nr 1 1 20374f49d633SGeliang Tang 20384f49d633SGeliang Tang # fullmesh 3 20394f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 20404f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added during the connection. 20414f49d633SGeliang Tang reset 204234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 5 204334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 5 204434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 20454f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow 20464f49d633SGeliang Tang chk_join_nr "fullmesh test 1x2" 5 5 5 20474f49d633SGeliang Tang chk_add_nr 1 1 20484f49d633SGeliang Tang 20494f49d633SGeliang Tang # fullmesh 4 20504f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 20514f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added during the connection, 20524f49d633SGeliang Tang # limit max_subflows to 4. 20534f49d633SGeliang Tang reset 205434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 4 205534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 4 205634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 20574f49d633SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow 20584f49d633SGeliang Tang chk_join_nr "fullmesh test 1x2, limited" 4 4 4 20594f49d633SGeliang Tang chk_add_nr 1 1 20606a0653b9SGeliang Tang 20616a0653b9SGeliang Tang # set fullmesh flag 20626a0653b9SGeliang Tang reset 206334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 206434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow 206534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 20666a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow fullmesh 20676a0653b9SGeliang Tang chk_join_nr "set fullmesh flag test" 2 2 2 20686a0653b9SGeliang Tang chk_rm_nr 0 1 20696a0653b9SGeliang Tang 20706a0653b9SGeliang Tang # set nofullmesh flag 20716a0653b9SGeliang Tang reset 207234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 207334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow,fullmesh 207434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 20756a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow nofullmesh 20766a0653b9SGeliang Tang chk_join_nr "set nofullmesh flag test" 2 2 2 20776a0653b9SGeliang Tang chk_rm_nr 0 1 20786a0653b9SGeliang Tang 20796a0653b9SGeliang Tang # set backup,fullmesh flags 20806a0653b9SGeliang Tang reset 208134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 208234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow 208334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 20846a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow backup,fullmesh 20856a0653b9SGeliang Tang chk_join_nr "set backup,fullmesh flags test" 2 2 2 20866a0653b9SGeliang Tang chk_prio_nr 0 1 20876a0653b9SGeliang Tang chk_rm_nr 0 1 20886a0653b9SGeliang Tang 20896a0653b9SGeliang Tang # set nobackup,nofullmesh flags 20906a0653b9SGeliang Tang reset 209134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 209234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 209334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,backup,fullmesh 20946a0653b9SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup,nofullmesh 20956a0653b9SGeliang Tang chk_join_nr "set nobackup,nofullmesh flags test" 2 2 2 20966a0653b9SGeliang Tang chk_prio_nr 0 1 20976a0653b9SGeliang Tang chk_rm_nr 0 1 20984f49d633SGeliang Tang} 20994f49d633SGeliang Tang 21001002b89fSGeliang Tangall_tests() 21011002b89fSGeliang Tang{ 21021002b89fSGeliang Tang subflows_tests 210346e967d1SPaolo Abeni subflows_error_tests 21041002b89fSGeliang Tang signal_address_tests 21051002b89fSGeliang Tang link_failure_tests 21061002b89fSGeliang Tang add_addr_timeout_tests 21071002b89fSGeliang Tang remove_tests 21081002b89fSGeliang Tang add_tests 21091002b89fSGeliang Tang ipv6_tests 21101002b89fSGeliang Tang v4mapped_tests 21111002b89fSGeliang Tang backup_tests 21121002b89fSGeliang Tang add_addr_ports_tests 21131002b89fSGeliang Tang syncookies_tests 2114af66d3e1SGeliang Tang checksum_tests 21150cddb4a6SGeliang Tang deny_join_id0_tests 21164f49d633SGeliang Tang fullmesh_tests 21171002b89fSGeliang Tang} 21181002b89fSGeliang Tang 211922514d52SMatthieu Baerts# [$1: error message] 21201002b89fSGeliang Tangusage() 21211002b89fSGeliang Tang{ 212222514d52SMatthieu Baerts if [ -n "${1}" ]; then 212322514d52SMatthieu Baerts echo "${1}" 212422514d52SMatthieu Baerts ret=1 212522514d52SMatthieu Baerts fi 212622514d52SMatthieu Baerts 21271002b89fSGeliang Tang echo "mptcp_join usage:" 21281002b89fSGeliang Tang echo " -f subflows_tests" 212946e967d1SPaolo Abeni echo " -e subflows_error_tests" 21301002b89fSGeliang Tang echo " -s signal_address_tests" 21311002b89fSGeliang Tang echo " -l link_failure_tests" 21321002b89fSGeliang Tang echo " -t add_addr_timeout_tests" 21331002b89fSGeliang Tang echo " -r remove_tests" 21341002b89fSGeliang Tang echo " -a add_tests" 21351002b89fSGeliang Tang echo " -6 ipv6_tests" 21361002b89fSGeliang Tang echo " -4 v4mapped_tests" 21371002b89fSGeliang Tang echo " -b backup_tests" 21381002b89fSGeliang Tang echo " -p add_addr_ports_tests" 2139a673321aSMat Martineau echo " -k syncookies_tests" 2140af66d3e1SGeliang Tang echo " -S checksum_tests" 21410cddb4a6SGeliang Tang echo " -d deny_join_id0_tests" 21424f49d633SGeliang Tang echo " -m fullmesh_tests" 2143a673321aSMat Martineau echo " -c capture pcap files" 2144af66d3e1SGeliang Tang echo " -C enable data checksum" 2145621bd393SGeliang Tang echo " -i use ip mptcp" 21461002b89fSGeliang Tang echo " -h help" 214722514d52SMatthieu Baerts 214822514d52SMatthieu Baerts exit ${ret} 21491002b89fSGeliang Tang} 21501002b89fSGeliang Tang 2151a673321aSMat Martineaufor arg in "$@"; do 2152af66d3e1SGeliang Tang # check for "capture/checksum" args before launching tests 2153a673321aSMat Martineau if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"c"[0-9a-zA-Z]*$ ]]; then 2154a673321aSMat Martineau capture=1 2155a673321aSMat Martineau fi 2156af66d3e1SGeliang Tang if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"C"[0-9a-zA-Z]*$ ]]; then 2157af66d3e1SGeliang Tang checksum=1 2158af66d3e1SGeliang Tang fi 2159621bd393SGeliang Tang if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"i"[0-9a-zA-Z]*$ ]]; then 2160621bd393SGeliang Tang ip_mptcp=1 2161621bd393SGeliang Tang fi 2162a673321aSMat Martineau 2163621bd393SGeliang Tang # exception for the capture/checksum/ip_mptcp options, the rest means: a part of the tests 2164621bd393SGeliang Tang if [ "${arg}" != "-c" ] && [ "${arg}" != "-C" ] && [ "${arg}" != "-i" ]; then 2165a673321aSMat Martineau do_all_tests=0 2166a673321aSMat Martineau fi 2167a673321aSMat Martineaudone 2168a673321aSMat Martineau 2169a673321aSMat Martineauif [ $do_all_tests -eq 1 ]; then 21701002b89fSGeliang Tang all_tests 21711002b89fSGeliang Tang exit $ret 21721002b89fSGeliang Tangfi 21731002b89fSGeliang Tang 2174621bd393SGeliang Tangwhile getopts 'fesltra64bpkdmchCSi' opt; do 21751002b89fSGeliang Tang case $opt in 21761002b89fSGeliang Tang f) 21771002b89fSGeliang Tang subflows_tests 21781002b89fSGeliang Tang ;; 217946e967d1SPaolo Abeni e) 218046e967d1SPaolo Abeni subflows_error_tests 218146e967d1SPaolo Abeni ;; 21821002b89fSGeliang Tang s) 21831002b89fSGeliang Tang signal_address_tests 21841002b89fSGeliang Tang ;; 21851002b89fSGeliang Tang l) 21861002b89fSGeliang Tang link_failure_tests 21871002b89fSGeliang Tang ;; 21881002b89fSGeliang Tang t) 21891002b89fSGeliang Tang add_addr_timeout_tests 21901002b89fSGeliang Tang ;; 21911002b89fSGeliang Tang r) 21921002b89fSGeliang Tang remove_tests 21931002b89fSGeliang Tang ;; 21941002b89fSGeliang Tang a) 21951002b89fSGeliang Tang add_tests 21961002b89fSGeliang Tang ;; 21971002b89fSGeliang Tang 6) 21981002b89fSGeliang Tang ipv6_tests 21991002b89fSGeliang Tang ;; 22001002b89fSGeliang Tang 4) 22011002b89fSGeliang Tang v4mapped_tests 22021002b89fSGeliang Tang ;; 22031002b89fSGeliang Tang b) 22041002b89fSGeliang Tang backup_tests 22051002b89fSGeliang Tang ;; 22061002b89fSGeliang Tang p) 22071002b89fSGeliang Tang add_addr_ports_tests 22081002b89fSGeliang Tang ;; 2209a673321aSMat Martineau k) 22101002b89fSGeliang Tang syncookies_tests 22111002b89fSGeliang Tang ;; 2212af66d3e1SGeliang Tang S) 2213af66d3e1SGeliang Tang checksum_tests 2214af66d3e1SGeliang Tang ;; 22150cddb4a6SGeliang Tang d) 22160cddb4a6SGeliang Tang deny_join_id0_tests 22170cddb4a6SGeliang Tang ;; 22184f49d633SGeliang Tang m) 22194f49d633SGeliang Tang fullmesh_tests 22204f49d633SGeliang Tang ;; 2221a673321aSMat Martineau c) 2222a673321aSMat Martineau ;; 2223af66d3e1SGeliang Tang C) 2224af66d3e1SGeliang Tang ;; 2225621bd393SGeliang Tang i) 2226621bd393SGeliang Tang ;; 222722514d52SMatthieu Baerts h) 22281002b89fSGeliang Tang usage 22291002b89fSGeliang Tang ;; 223022514d52SMatthieu Baerts *) 223122514d52SMatthieu Baerts usage "Unknown option: -${opt}" 223222514d52SMatthieu Baerts ;; 22331002b89fSGeliang Tang esac 22341002b89fSGeliang Tangdone 223500587187SFlorian Westphal 2236b08fbf24SPaolo Abeniexit $ret 2237