1b08fbf24SPaolo Abeni#!/bin/bash 2b08fbf24SPaolo Abeni# SPDX-License-Identifier: GPL-2.0 3b08fbf24SPaolo Abeni 4b08fbf24SPaolo Abeniret=0 5b08fbf24SPaolo Abenisin="" 6b08fbf24SPaolo Abenisout="" 7b08fbf24SPaolo Abenicin="" 88b819a84SFlorian Westphalcinsent="" 9b08fbf24SPaolo Abenicout="" 10b08fbf24SPaolo Abeniksft_skip=4 11b08fbf24SPaolo Abenitimeout=30 12dd72b0feSGeliang Tangmptcp_connect="" 13b08fbf24SPaolo Abenicapture=0 14a673321aSMat Martineaudo_all_tests=1 15b08fbf24SPaolo Abeni 16b08fbf24SPaolo AbeniTEST_COUNT=0 17b08fbf24SPaolo Abeni 188d014eaaSGeliang Tang# generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) || 198d014eaaSGeliang Tang# (ip6 && (ip6[74] & 0xf0) == 0x30)'" 208d014eaaSGeliang TangCBPF_MPTCP_SUBOPTION_ADD_ADDR="14, 218d014eaaSGeliang Tang 48 0 0 0, 228d014eaaSGeliang Tang 84 0 0 240, 238d014eaaSGeliang Tang 21 0 3 64, 248d014eaaSGeliang Tang 48 0 0 54, 258d014eaaSGeliang Tang 84 0 0 240, 268d014eaaSGeliang Tang 21 6 7 48, 278d014eaaSGeliang Tang 48 0 0 0, 288d014eaaSGeliang Tang 84 0 0 240, 298d014eaaSGeliang Tang 21 0 4 96, 308d014eaaSGeliang Tang 48 0 0 74, 318d014eaaSGeliang Tang 84 0 0 240, 328d014eaaSGeliang Tang 21 0 1 48, 338d014eaaSGeliang Tang 6 0 0 65535, 348d014eaaSGeliang Tang 6 0 0 0" 358d014eaaSGeliang Tang 36b08fbf24SPaolo Abeniinit() 37b08fbf24SPaolo Abeni{ 38b08fbf24SPaolo Abeni capout=$(mktemp) 39b08fbf24SPaolo Abeni 40b08fbf24SPaolo Abeni rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) 41b08fbf24SPaolo Abeni 42b08fbf24SPaolo Abeni ns1="ns1-$rndh" 43b08fbf24SPaolo Abeni ns2="ns2-$rndh" 44b08fbf24SPaolo Abeni 45b08fbf24SPaolo Abeni for netns in "$ns1" "$ns2";do 46b08fbf24SPaolo Abeni ip netns add $netns || exit $ksft_skip 47b08fbf24SPaolo Abeni ip -net $netns link set lo up 48b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.mptcp.enabled=1 49b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 50b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 51b08fbf24SPaolo Abeni done 52b08fbf24SPaolo Abeni 53b08fbf24SPaolo Abeni # ns1 ns2 54b08fbf24SPaolo Abeni # ns1eth1 ns2eth1 55b08fbf24SPaolo Abeni # ns1eth2 ns2eth2 56b08fbf24SPaolo Abeni # ns1eth3 ns2eth3 57b08fbf24SPaolo Abeni # ns1eth4 ns2eth4 58b08fbf24SPaolo Abeni 59b08fbf24SPaolo Abeni for i in `seq 1 4`; do 60b08fbf24SPaolo Abeni ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2" 61b08fbf24SPaolo Abeni ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i 62b08fbf24SPaolo Abeni ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad 63b08fbf24SPaolo Abeni ip -net "$ns1" link set ns1eth$i up 64b08fbf24SPaolo Abeni 65b08fbf24SPaolo Abeni ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i 66b08fbf24SPaolo Abeni ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad 67b08fbf24SPaolo Abeni ip -net "$ns2" link set ns2eth$i up 68b08fbf24SPaolo Abeni 69b08fbf24SPaolo Abeni # let $ns2 reach any $ns1 address from any interface 70b08fbf24SPaolo Abeni ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i 71b08fbf24SPaolo Abeni done 72b08fbf24SPaolo Abeni} 73b08fbf24SPaolo Abeni 74b08fbf24SPaolo Abenicleanup_partial() 75b08fbf24SPaolo Abeni{ 76b08fbf24SPaolo Abeni rm -f "$capout" 77b08fbf24SPaolo Abeni 78b08fbf24SPaolo Abeni for netns in "$ns1" "$ns2"; do 79b08fbf24SPaolo Abeni ip netns del $netns 80b08fbf24SPaolo Abeni done 81b08fbf24SPaolo Abeni} 82b08fbf24SPaolo Abeni 83b08fbf24SPaolo Abenicleanup() 84b08fbf24SPaolo Abeni{ 85b08fbf24SPaolo Abeni rm -f "$cin" "$cout" 868b819a84SFlorian Westphal rm -f "$sin" "$sout" "$cinsent" 87b08fbf24SPaolo Abeni cleanup_partial 88b08fbf24SPaolo Abeni} 89b08fbf24SPaolo Abeni 90b08fbf24SPaolo Abenireset() 91b08fbf24SPaolo Abeni{ 92b08fbf24SPaolo Abeni cleanup_partial 93b08fbf24SPaolo Abeni init 94b08fbf24SPaolo Abeni} 95b08fbf24SPaolo Abeni 9600587187SFlorian Westphalreset_with_cookies() 9700587187SFlorian Westphal{ 9800587187SFlorian Westphal reset 9900587187SFlorian Westphal 10000587187SFlorian Westphal for netns in "$ns1" "$ns2";do 10100587187SFlorian Westphal ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2 10200587187SFlorian Westphal done 10300587187SFlorian Westphal} 10400587187SFlorian Westphal 1058d014eaaSGeliang Tangreset_with_add_addr_timeout() 1068d014eaaSGeliang Tang{ 1078d014eaaSGeliang Tang local ip="${1:-4}" 1088d014eaaSGeliang Tang local tables 1098d014eaaSGeliang Tang 1108d014eaaSGeliang Tang tables="iptables" 1118d014eaaSGeliang Tang if [ $ip -eq 6 ]; then 1128d014eaaSGeliang Tang tables="ip6tables" 1138d014eaaSGeliang Tang fi 1148d014eaaSGeliang Tang 1158d014eaaSGeliang Tang reset 1168d014eaaSGeliang Tang 1178d014eaaSGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 1188d014eaaSGeliang Tang ip netns exec $ns2 $tables -A OUTPUT -p tcp \ 1198d014eaaSGeliang Tang -m tcp --tcp-option 30 \ 1208d014eaaSGeliang Tang -m bpf --bytecode \ 1218d014eaaSGeliang Tang "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \ 1228d014eaaSGeliang Tang -j DROP 1238d014eaaSGeliang Tang} 1248d014eaaSGeliang Tang 125b08fbf24SPaolo Abeniip -Version > /dev/null 2>&1 126b08fbf24SPaolo Abeniif [ $? -ne 0 ];then 127b08fbf24SPaolo Abeni echo "SKIP: Could not run test without ip tool" 128b08fbf24SPaolo Abeni exit $ksft_skip 129b08fbf24SPaolo Abenifi 130b08fbf24SPaolo Abeni 1318d014eaaSGeliang Tangiptables -V > /dev/null 2>&1 1328d014eaaSGeliang Tangif [ $? -ne 0 ];then 1338d014eaaSGeliang Tang echo "SKIP: Could not run all tests without iptables tool" 1348d014eaaSGeliang Tang exit $ksft_skip 1358d014eaaSGeliang Tangfi 1368d014eaaSGeliang Tang 1378d014eaaSGeliang Tangip6tables -V > /dev/null 2>&1 1388d014eaaSGeliang Tangif [ $? -ne 0 ];then 1398d014eaaSGeliang Tang echo "SKIP: Could not run all tests without ip6tables tool" 1408d014eaaSGeliang Tang exit $ksft_skip 1418d014eaaSGeliang Tangfi 142b08fbf24SPaolo Abeni 1438b819a84SFlorian Westphalprint_file_err() 1448b819a84SFlorian Westphal{ 1458b819a84SFlorian Westphal ls -l "$1" 1>&2 1468b819a84SFlorian Westphal echo "Trailing bytes are: " 1478b819a84SFlorian Westphal tail -c 27 "$1" 1488b819a84SFlorian Westphal} 1498b819a84SFlorian Westphal 150b08fbf24SPaolo Abenicheck_transfer() 151b08fbf24SPaolo Abeni{ 152b08fbf24SPaolo Abeni in=$1 153b08fbf24SPaolo Abeni out=$2 154b08fbf24SPaolo Abeni what=$3 155b08fbf24SPaolo Abeni 156b08fbf24SPaolo Abeni cmp "$in" "$out" > /dev/null 2>&1 157b08fbf24SPaolo Abeni if [ $? -ne 0 ] ;then 158b08fbf24SPaolo Abeni echo "[ FAIL ] $what does not match (in, out):" 159b08fbf24SPaolo Abeni print_file_err "$in" 160b08fbf24SPaolo Abeni print_file_err "$out" 1618b819a84SFlorian Westphal ret=1 162b08fbf24SPaolo Abeni 163b08fbf24SPaolo Abeni return 1 164b08fbf24SPaolo Abeni fi 165b08fbf24SPaolo Abeni 166b08fbf24SPaolo Abeni return 0 167b08fbf24SPaolo Abeni} 168b08fbf24SPaolo Abeni 169b08fbf24SPaolo Abenido_ping() 170b08fbf24SPaolo Abeni{ 171b08fbf24SPaolo Abeni listener_ns="$1" 172b08fbf24SPaolo Abeni connector_ns="$2" 173b08fbf24SPaolo Abeni connect_addr="$3" 174b08fbf24SPaolo Abeni 175b08fbf24SPaolo Abeni ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null 176b08fbf24SPaolo Abeni if [ $? -ne 0 ] ; then 177b08fbf24SPaolo Abeni echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2 178b08fbf24SPaolo Abeni ret=1 179b08fbf24SPaolo Abeni fi 180b08fbf24SPaolo Abeni} 181b08fbf24SPaolo Abeni 1828b819a84SFlorian Westphallink_failure() 1838b819a84SFlorian Westphal{ 1848b819a84SFlorian Westphal ns="$1" 1858b819a84SFlorian Westphal 1868b819a84SFlorian Westphal l=$((RANDOM%4)) 1878b819a84SFlorian Westphal l=$((l+1)) 1888b819a84SFlorian Westphal 1898b819a84SFlorian Westphal veth="ns1eth$l" 1908b819a84SFlorian Westphal ip -net "$ns" link set "$veth" down 1918b819a84SFlorian Westphal} 1928b819a84SFlorian Westphal 193523514edSGeliang Tang# $1: IP address 194523514edSGeliang Tangis_v6() 195523514edSGeliang Tang{ 196523514edSGeliang Tang [ -z "${1##*:*}" ] 197523514edSGeliang Tang} 198523514edSGeliang Tang 199b08fbf24SPaolo Abenido_transfer() 200b08fbf24SPaolo Abeni{ 201b08fbf24SPaolo Abeni listener_ns="$1" 202b08fbf24SPaolo Abeni connector_ns="$2" 203b08fbf24SPaolo Abeni cl_proto="$3" 204b08fbf24SPaolo Abeni srv_proto="$4" 205b08fbf24SPaolo Abeni connect_addr="$5" 2068b819a84SFlorian Westphal test_link_fail="$6" 2072e8cbf45SGeliang Tang addr_nr_ns1="$7" 2082e8cbf45SGeliang Tang addr_nr_ns2="$8" 2098b819a84SFlorian Westphal speed="$9" 210718eb44eSGeliang Tang bkup="${10}" 211b08fbf24SPaolo Abeni 212b08fbf24SPaolo Abeni port=$((10000+$TEST_COUNT)) 213b08fbf24SPaolo Abeni TEST_COUNT=$((TEST_COUNT+1)) 214b08fbf24SPaolo Abeni 215b08fbf24SPaolo Abeni :> "$cout" 216b08fbf24SPaolo Abeni :> "$sout" 217b08fbf24SPaolo Abeni :> "$capout" 218b08fbf24SPaolo Abeni 219b08fbf24SPaolo Abeni if [ $capture -eq 1 ]; then 220b08fbf24SPaolo Abeni if [ -z $SUDO_USER ] ; then 221b08fbf24SPaolo Abeni capuser="" 222b08fbf24SPaolo Abeni else 223b08fbf24SPaolo Abeni capuser="-Z $SUDO_USER" 224b08fbf24SPaolo Abeni fi 225b08fbf24SPaolo Abeni 22600587187SFlorian Westphal capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}") 227b08fbf24SPaolo Abeni 228b08fbf24SPaolo Abeni echo "Capturing traffic for test $TEST_COUNT into $capfile" 229b08fbf24SPaolo Abeni ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & 230b08fbf24SPaolo Abeni cappid=$! 231b08fbf24SPaolo Abeni 232b08fbf24SPaolo Abeni sleep 1 233b08fbf24SPaolo Abeni fi 234b08fbf24SPaolo Abeni 2358d014eaaSGeliang Tang if [ $speed = "fast" ]; then 236dd72b0feSGeliang Tang mptcp_connect="./mptcp_connect -j" 2378da6229bSGeliang Tang elif [ $speed = "slow" ]; then 2388da6229bSGeliang Tang mptcp_connect="./mptcp_connect -r 50" 2398da6229bSGeliang Tang elif [ $speed = "least" ]; then 2408da6229bSGeliang Tang mptcp_connect="./mptcp_connect -r 10" 241dd72b0feSGeliang Tang fi 242dd72b0feSGeliang Tang 243523514edSGeliang Tang local local_addr 244523514edSGeliang Tang if is_v6 "${connect_addr}"; then 245523514edSGeliang Tang local_addr="::" 246523514edSGeliang Tang else 247523514edSGeliang Tang local_addr="0.0.0.0" 248523514edSGeliang Tang fi 249523514edSGeliang Tang 250523514edSGeliang Tang ip netns exec ${listener_ns} $mptcp_connect -t $timeout -l -p $port \ 251523514edSGeliang Tang -s ${srv_proto} ${local_addr} < "$sin" > "$sout" & 252b08fbf24SPaolo Abeni spid=$! 253b08fbf24SPaolo Abeni 254b08fbf24SPaolo Abeni sleep 1 255b08fbf24SPaolo Abeni 2568b819a84SFlorian Westphal if [ "$test_link_fail" -eq 0 ];then 257dd72b0feSGeliang Tang ip netns exec ${connector_ns} $mptcp_connect -t $timeout -p $port -s ${cl_proto} $connect_addr < "$cin" > "$cout" & 2588b819a84SFlorian Westphal else 2598b819a84SFlorian Westphal ( cat "$cin" ; sleep 2; link_failure $listener_ns ; cat "$cin" ) | tee "$cinsent" | \ 2608b819a84SFlorian Westphal ip netns exec ${connector_ns} $mptcp_connect -t $timeout -p $port -s ${cl_proto} $connect_addr > "$cout" & 2618b819a84SFlorian Westphal fi 262b08fbf24SPaolo Abeni cpid=$! 263b08fbf24SPaolo Abeni 2646208fd82SGeliang Tang if [ $addr_nr_ns1 -gt 0 ]; then 2656208fd82SGeliang Tang let add_nr_ns1=addr_nr_ns1 2666208fd82SGeliang Tang counter=2 2676208fd82SGeliang Tang sleep 1 2686208fd82SGeliang Tang while [ $add_nr_ns1 -gt 0 ]; do 2696208fd82SGeliang Tang local addr 2706208fd82SGeliang Tang if is_v6 "${connect_addr}"; then 2716208fd82SGeliang Tang addr="dead:beef:$counter::1" 2726208fd82SGeliang Tang else 2736208fd82SGeliang Tang addr="10.0.$counter.1" 2746208fd82SGeliang Tang fi 2756208fd82SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add $addr flags signal 2766208fd82SGeliang Tang let counter+=1 2776208fd82SGeliang Tang let add_nr_ns1-=1 2786208fd82SGeliang Tang done 2796208fd82SGeliang Tang sleep 1 2806208fd82SGeliang Tang elif [ $addr_nr_ns1 -lt 0 ]; then 2812e8cbf45SGeliang Tang let rm_nr_ns1=-addr_nr_ns1 2826fe4ccdcSGeliang Tang if [ $rm_nr_ns1 -lt 8 ]; then 283dd72b0feSGeliang Tang counter=1 284f87744adSGeliang Tang dump=(`ip netns exec ${listener_ns} ./pm_nl_ctl dump`) 285f87744adSGeliang Tang if [ ${#dump[@]} -gt 0 ]; then 286f87744adSGeliang Tang id=${dump[1]} 287dd72b0feSGeliang Tang sleep 1 288dd72b0feSGeliang Tang 289dd72b0feSGeliang Tang while [ $counter -le $rm_nr_ns1 ] 290dd72b0feSGeliang Tang do 291f87744adSGeliang Tang ip netns exec ${listener_ns} ./pm_nl_ctl del $id 292dd72b0feSGeliang Tang sleep 1 293dd72b0feSGeliang Tang let counter+=1 294f87744adSGeliang Tang let id+=1 295dd72b0feSGeliang Tang done 296f87744adSGeliang Tang fi 297*5e287fe7SGeliang Tang elif [ $rm_nr_ns1 -eq 8 ]; then 2986fe4ccdcSGeliang Tang sleep 1 2996fe4ccdcSGeliang Tang ip netns exec ${listener_ns} ./pm_nl_ctl flush 300*5e287fe7SGeliang Tang elif [ $rm_nr_ns1 -eq 9 ]; then 301*5e287fe7SGeliang Tang sleep 1 302*5e287fe7SGeliang Tang ip netns exec ${listener_ns} ./pm_nl_ctl del 0 ${connect_addr} 3036fe4ccdcSGeliang Tang fi 304dd72b0feSGeliang Tang fi 305dd72b0feSGeliang Tang 3066208fd82SGeliang Tang if [ $addr_nr_ns2 -gt 0 ]; then 3076208fd82SGeliang Tang let add_nr_ns2=addr_nr_ns2 3086208fd82SGeliang Tang counter=3 3096208fd82SGeliang Tang sleep 1 3106208fd82SGeliang Tang while [ $add_nr_ns2 -gt 0 ]; do 3116208fd82SGeliang Tang local addr 3126208fd82SGeliang Tang if is_v6 "${connect_addr}"; then 3136208fd82SGeliang Tang addr="dead:beef:$counter::2" 3146208fd82SGeliang Tang else 3156208fd82SGeliang Tang addr="10.0.$counter.2" 3166208fd82SGeliang Tang fi 3176208fd82SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add $addr flags subflow 3186208fd82SGeliang Tang let counter+=1 3196208fd82SGeliang Tang let add_nr_ns2-=1 3206208fd82SGeliang Tang done 3216208fd82SGeliang Tang sleep 1 3226208fd82SGeliang Tang elif [ $addr_nr_ns2 -lt 0 ]; then 3232e8cbf45SGeliang Tang let rm_nr_ns2=-addr_nr_ns2 3246fe4ccdcSGeliang Tang if [ $rm_nr_ns2 -lt 8 ]; then 325dd72b0feSGeliang Tang counter=1 326f87744adSGeliang Tang dump=(`ip netns exec ${connector_ns} ./pm_nl_ctl dump`) 327f87744adSGeliang Tang if [ ${#dump[@]} -gt 0 ]; then 328f87744adSGeliang Tang id=${dump[1]} 329dd72b0feSGeliang Tang sleep 1 330dd72b0feSGeliang Tang 331dd72b0feSGeliang Tang while [ $counter -le $rm_nr_ns2 ] 332dd72b0feSGeliang Tang do 333f87744adSGeliang Tang ip netns exec ${connector_ns} ./pm_nl_ctl del $id 334dd72b0feSGeliang Tang sleep 1 335dd72b0feSGeliang Tang let counter+=1 336f87744adSGeliang Tang let id+=1 337dd72b0feSGeliang Tang done 338f87744adSGeliang Tang fi 339*5e287fe7SGeliang Tang elif [ $rm_nr_ns2 -eq 8 ]; then 3406fe4ccdcSGeliang Tang sleep 1 3416fe4ccdcSGeliang Tang ip netns exec ${connector_ns} ./pm_nl_ctl flush 342*5e287fe7SGeliang Tang elif [ $rm_nr_ns2 -eq 9 ]; then 343*5e287fe7SGeliang Tang local addr 344*5e287fe7SGeliang Tang if is_v6 "${connect_addr}"; then 345*5e287fe7SGeliang Tang addr="dead:beef:1::2" 346*5e287fe7SGeliang Tang else 347*5e287fe7SGeliang Tang addr="10.0.1.2" 348*5e287fe7SGeliang Tang fi 349*5e287fe7SGeliang Tang sleep 1 350*5e287fe7SGeliang Tang ip netns exec ${connector_ns} ./pm_nl_ctl del 0 $addr 3516fe4ccdcSGeliang Tang fi 352dd72b0feSGeliang Tang fi 353dd72b0feSGeliang Tang 354718eb44eSGeliang Tang if [ ! -z $bkup ]; then 355718eb44eSGeliang Tang sleep 1 356718eb44eSGeliang Tang for netns in "$ns1" "$ns2"; do 357718eb44eSGeliang Tang dump=(`ip netns exec $netns ./pm_nl_ctl dump`) 358718eb44eSGeliang Tang if [ ${#dump[@]} -gt 0 ]; then 359718eb44eSGeliang Tang addr=${dump[${#dump[@]} - 1]} 360718eb44eSGeliang Tang backup="ip netns exec $netns ./pm_nl_ctl set $addr flags $bkup" 361718eb44eSGeliang Tang $backup 362718eb44eSGeliang Tang fi 363718eb44eSGeliang Tang done 364718eb44eSGeliang Tang fi 365718eb44eSGeliang Tang 366b08fbf24SPaolo Abeni wait $cpid 367b08fbf24SPaolo Abeni retc=$? 368b08fbf24SPaolo Abeni wait $spid 369b08fbf24SPaolo Abeni rets=$? 370b08fbf24SPaolo Abeni 371b08fbf24SPaolo Abeni if [ $capture -eq 1 ]; then 372b08fbf24SPaolo Abeni sleep 1 373b08fbf24SPaolo Abeni kill $cappid 374b08fbf24SPaolo Abeni fi 375b08fbf24SPaolo Abeni 376b08fbf24SPaolo Abeni if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then 377b08fbf24SPaolo Abeni echo " client exit code $retc, server $rets" 1>&2 3788b974778SMatthieu Baerts echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 379b08fbf24SPaolo Abeni ip netns exec ${listener_ns} ss -nita 1>&2 -o "sport = :$port" 3808b974778SMatthieu Baerts echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2 381b08fbf24SPaolo Abeni ip netns exec ${connector_ns} ss -nita 1>&2 -o "dport = :$port" 382b08fbf24SPaolo Abeni 383b08fbf24SPaolo Abeni cat "$capout" 3848b819a84SFlorian Westphal ret=1 385b08fbf24SPaolo Abeni return 1 386b08fbf24SPaolo Abeni fi 387b08fbf24SPaolo Abeni 388b08fbf24SPaolo Abeni check_transfer $sin $cout "file received by client" 389b08fbf24SPaolo Abeni retc=$? 3908b819a84SFlorian Westphal if [ "$test_link_fail" -eq 0 ];then 391b08fbf24SPaolo Abeni check_transfer $cin $sout "file received by server" 3928b819a84SFlorian Westphal else 3938b819a84SFlorian Westphal check_transfer $cinsent $sout "file received by server" 3948b819a84SFlorian Westphal fi 395b08fbf24SPaolo Abeni rets=$? 396b08fbf24SPaolo Abeni 397b08fbf24SPaolo Abeni if [ $retc -eq 0 ] && [ $rets -eq 0 ];then 398b08fbf24SPaolo Abeni cat "$capout" 399b08fbf24SPaolo Abeni return 0 400b08fbf24SPaolo Abeni fi 401b08fbf24SPaolo Abeni 402b08fbf24SPaolo Abeni cat "$capout" 403b08fbf24SPaolo Abeni return 1 404b08fbf24SPaolo Abeni} 405b08fbf24SPaolo Abeni 406b08fbf24SPaolo Abenimake_file() 407b08fbf24SPaolo Abeni{ 408b08fbf24SPaolo Abeni name=$1 409b08fbf24SPaolo Abeni who=$2 4108b819a84SFlorian Westphal size=$3 411b08fbf24SPaolo Abeni 4128b819a84SFlorian Westphal dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null 413b08fbf24SPaolo Abeni echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" 414b08fbf24SPaolo Abeni 4158b819a84SFlorian Westphal echo "Created $name (size $size KB) containing data sent by $who" 416b08fbf24SPaolo Abeni} 417b08fbf24SPaolo Abeni 418b08fbf24SPaolo Abenirun_tests() 419b08fbf24SPaolo Abeni{ 420b08fbf24SPaolo Abeni listener_ns="$1" 421b08fbf24SPaolo Abeni connector_ns="$2" 422b08fbf24SPaolo Abeni connect_addr="$3" 4238b819a84SFlorian Westphal test_linkfail="${4:-0}" 4242e8cbf45SGeliang Tang addr_nr_ns1="${5:-0}" 4252e8cbf45SGeliang Tang addr_nr_ns2="${6:-0}" 4268b819a84SFlorian Westphal speed="${7:-fast}" 427718eb44eSGeliang Tang bkup="${8:-""}" 428b08fbf24SPaolo Abeni lret=0 4298b819a84SFlorian Westphal oldin="" 4308b819a84SFlorian Westphal 4318b819a84SFlorian Westphal if [ "$test_linkfail" -eq 1 ];then 4328b819a84SFlorian Westphal size=$((RANDOM%1024)) 4338b819a84SFlorian Westphal size=$((size+1)) 4348b819a84SFlorian Westphal size=$((size*128)) 4358b819a84SFlorian Westphal 4368b819a84SFlorian Westphal oldin=$(mktemp) 4378b819a84SFlorian Westphal cp "$cin" "$oldin" 4388b819a84SFlorian Westphal make_file "$cin" "client" $size 4398b819a84SFlorian Westphal fi 440b08fbf24SPaolo Abeni 4418d014eaaSGeliang Tang do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \ 4422e8cbf45SGeliang Tang ${test_linkfail} ${addr_nr_ns1} ${addr_nr_ns2} ${speed} ${bkup} 443b08fbf24SPaolo Abeni lret=$? 4448b819a84SFlorian Westphal 4458b819a84SFlorian Westphal if [ "$test_linkfail" -eq 1 ];then 4468b819a84SFlorian Westphal cp "$oldin" "$cin" 4478b819a84SFlorian Westphal rm -f "$oldin" 4488b819a84SFlorian Westphal fi 4498b819a84SFlorian Westphal 450b08fbf24SPaolo Abeni if [ $lret -ne 0 ]; then 451b08fbf24SPaolo Abeni ret=$lret 452b08fbf24SPaolo Abeni return 453b08fbf24SPaolo Abeni fi 454b08fbf24SPaolo Abeni} 455b08fbf24SPaolo Abeni 456b08fbf24SPaolo Abenichk_join_nr() 457b08fbf24SPaolo Abeni{ 458b08fbf24SPaolo Abeni local msg="$1" 459b08fbf24SPaolo Abeni local syn_nr=$2 460b08fbf24SPaolo Abeni local syn_ack_nr=$3 461b08fbf24SPaolo Abeni local ack_nr=$4 462b08fbf24SPaolo Abeni local count 463b08fbf24SPaolo Abeni local dump_stats 464b08fbf24SPaolo Abeni 46500587187SFlorian Westphal printf "%02u %-36s %s" "$TEST_COUNT" "$msg" "syn" 466b08fbf24SPaolo Abeni count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'` 467b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 468b08fbf24SPaolo Abeni if [ "$count" != "$syn_nr" ]; then 469b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] syn expected $syn_nr" 470b08fbf24SPaolo Abeni ret=1 471b08fbf24SPaolo Abeni dump_stats=1 472b08fbf24SPaolo Abeni else 473b08fbf24SPaolo Abeni echo -n "[ ok ]" 474b08fbf24SPaolo Abeni fi 475b08fbf24SPaolo Abeni 476b08fbf24SPaolo Abeni echo -n " - synack" 477b08fbf24SPaolo Abeni count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'` 478b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 479b08fbf24SPaolo Abeni if [ "$count" != "$syn_ack_nr" ]; then 480b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr" 481b08fbf24SPaolo Abeni ret=1 482b08fbf24SPaolo Abeni dump_stats=1 483b08fbf24SPaolo Abeni else 484b08fbf24SPaolo Abeni echo -n "[ ok ]" 485b08fbf24SPaolo Abeni fi 486b08fbf24SPaolo Abeni 487b08fbf24SPaolo Abeni echo -n " - ack" 488b08fbf24SPaolo Abeni count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'` 489b08fbf24SPaolo Abeni [ -z "$count" ] && count=0 490b08fbf24SPaolo Abeni if [ "$count" != "$ack_nr" ]; then 491b08fbf24SPaolo Abeni echo "[fail] got $count JOIN[s] ack expected $ack_nr" 492b08fbf24SPaolo Abeni ret=1 493b08fbf24SPaolo Abeni dump_stats=1 494b08fbf24SPaolo Abeni else 495b08fbf24SPaolo Abeni echo "[ ok ]" 496b08fbf24SPaolo Abeni fi 497b08fbf24SPaolo Abeni if [ "${dump_stats}" = 1 ]; then 498b08fbf24SPaolo Abeni echo Server ns stats 499b08fbf24SPaolo Abeni ip netns exec $ns1 nstat -as | grep MPTcp 500b08fbf24SPaolo Abeni echo Client ns stats 501b08fbf24SPaolo Abeni ip netns exec $ns2 nstat -as | grep MPTcp 502b08fbf24SPaolo Abeni fi 503b08fbf24SPaolo Abeni} 504b08fbf24SPaolo Abeni 505be613160SGeliang Tangchk_add_nr() 506be613160SGeliang Tang{ 507be613160SGeliang Tang local add_nr=$1 508be613160SGeliang Tang local echo_nr=$2 5098a127bf6SGeliang Tang local port_nr=${3:-0} 5108a127bf6SGeliang Tang local syn_nr=${4:-$port_nr} 5118a127bf6SGeliang Tang local syn_ack_nr=${5:-$port_nr} 5128a127bf6SGeliang Tang local ack_nr=${6:-$port_nr} 5138a127bf6SGeliang Tang local mis_syn_nr=${7:-0} 5148a127bf6SGeliang Tang local mis_ack_nr=${8:-0} 515be613160SGeliang Tang local count 516be613160SGeliang Tang local dump_stats 517be613160SGeliang Tang 518be613160SGeliang Tang printf "%-39s %s" " " "add" 519be613160SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtAddAddr | awk '{print $2}'` 520be613160SGeliang Tang [ -z "$count" ] && count=0 521be613160SGeliang Tang if [ "$count" != "$add_nr" ]; then 522be613160SGeliang Tang echo "[fail] got $count ADD_ADDR[s] expected $add_nr" 523be613160SGeliang Tang ret=1 524be613160SGeliang Tang dump_stats=1 525be613160SGeliang Tang else 526be613160SGeliang Tang echo -n "[ ok ]" 527be613160SGeliang Tang fi 528be613160SGeliang Tang 529be613160SGeliang Tang echo -n " - echo " 530be613160SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtEchoAdd | awk '{print $2}'` 531be613160SGeliang Tang [ -z "$count" ] && count=0 532be613160SGeliang Tang if [ "$count" != "$echo_nr" ]; then 533be613160SGeliang Tang echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr" 534be613160SGeliang Tang ret=1 535be613160SGeliang Tang dump_stats=1 536be613160SGeliang Tang else 5378a127bf6SGeliang Tang echo -n "[ ok ]" 5388a127bf6SGeliang Tang fi 5398a127bf6SGeliang Tang 5408a127bf6SGeliang Tang if [ $port_nr -gt 0 ]; then 5418a127bf6SGeliang Tang echo -n " - pt " 5428a127bf6SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtPortAdd | awk '{print $2}'` 5438a127bf6SGeliang Tang [ -z "$count" ] && count=0 5448a127bf6SGeliang Tang if [ "$count" != "$port_nr" ]; then 5458a127bf6SGeliang Tang echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr" 5468a127bf6SGeliang Tang ret=1 5478a127bf6SGeliang Tang dump_stats=1 5488a127bf6SGeliang Tang else 549be613160SGeliang Tang echo "[ ok ]" 550be613160SGeliang Tang fi 551be613160SGeliang Tang 5528a127bf6SGeliang Tang printf "%-39s %s" " " "syn" 5538a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortSynRx | 5548a127bf6SGeliang Tang awk '{print $2}'` 5558a127bf6SGeliang Tang [ -z "$count" ] && count=0 5568a127bf6SGeliang Tang if [ "$count" != "$syn_nr" ]; then 5578a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] syn with a different \ 5588a127bf6SGeliang Tang port-number expected $syn_nr" 5598a127bf6SGeliang Tang ret=1 5608a127bf6SGeliang Tang dump_stats=1 5618a127bf6SGeliang Tang else 5628a127bf6SGeliang Tang echo -n "[ ok ]" 5638a127bf6SGeliang Tang fi 5648a127bf6SGeliang Tang 5658a127bf6SGeliang Tang echo -n " - synack" 5668a127bf6SGeliang Tang count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinPortSynAckRx | 5678a127bf6SGeliang Tang awk '{print $2}'` 5688a127bf6SGeliang Tang [ -z "$count" ] && count=0 5698a127bf6SGeliang Tang if [ "$count" != "$syn_ack_nr" ]; then 5708a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] synack with a different \ 5718a127bf6SGeliang Tang port-number expected $syn_ack_nr" 5728a127bf6SGeliang Tang ret=1 5738a127bf6SGeliang Tang dump_stats=1 5748a127bf6SGeliang Tang else 5758a127bf6SGeliang Tang echo -n "[ ok ]" 5768a127bf6SGeliang Tang fi 5778a127bf6SGeliang Tang 5788a127bf6SGeliang Tang echo -n " - ack" 5798a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortAckRx | 5808a127bf6SGeliang Tang awk '{print $2}'` 5818a127bf6SGeliang Tang [ -z "$count" ] && count=0 5828a127bf6SGeliang Tang if [ "$count" != "$ack_nr" ]; then 5838a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] ack with a different \ 5848a127bf6SGeliang Tang port-number expected $ack_nr" 5858a127bf6SGeliang Tang ret=1 5868a127bf6SGeliang Tang dump_stats=1 5878a127bf6SGeliang Tang else 5888a127bf6SGeliang Tang echo "[ ok ]" 5898a127bf6SGeliang Tang fi 5908a127bf6SGeliang Tang 5918a127bf6SGeliang Tang printf "%-39s %s" " " "syn" 5928a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortSynRx | 5938a127bf6SGeliang Tang awk '{print $2}'` 5948a127bf6SGeliang Tang [ -z "$count" ] && count=0 5958a127bf6SGeliang Tang if [ "$count" != "$mis_syn_nr" ]; then 5968a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] syn with a mismatched \ 5978a127bf6SGeliang Tang port-number expected $mis_syn_nr" 5988a127bf6SGeliang Tang ret=1 5998a127bf6SGeliang Tang dump_stats=1 6008a127bf6SGeliang Tang else 6018a127bf6SGeliang Tang echo -n "[ ok ]" 6028a127bf6SGeliang Tang fi 6038a127bf6SGeliang Tang 6048a127bf6SGeliang Tang echo -n " - ack " 6058a127bf6SGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortAckRx | 6068a127bf6SGeliang Tang awk '{print $2}'` 6078a127bf6SGeliang Tang [ -z "$count" ] && count=0 6088a127bf6SGeliang Tang if [ "$count" != "$mis_ack_nr" ]; then 6098a127bf6SGeliang Tang echo "[fail] got $count JOIN[s] ack with a mismatched \ 6108a127bf6SGeliang Tang port-number expected $mis_ack_nr" 6118a127bf6SGeliang Tang ret=1 6128a127bf6SGeliang Tang dump_stats=1 6138a127bf6SGeliang Tang else 6148a127bf6SGeliang Tang echo "[ ok ]" 6158a127bf6SGeliang Tang fi 6168a127bf6SGeliang Tang else 6178a127bf6SGeliang Tang echo "" 6188a127bf6SGeliang Tang fi 6198a127bf6SGeliang Tang 620be613160SGeliang Tang if [ "${dump_stats}" = 1 ]; then 621be613160SGeliang Tang echo Server ns stats 622be613160SGeliang Tang ip netns exec $ns1 nstat -as | grep MPTcp 623be613160SGeliang Tang echo Client ns stats 624be613160SGeliang Tang ip netns exec $ns2 nstat -as | grep MPTcp 625be613160SGeliang Tang fi 626be613160SGeliang Tang} 627be613160SGeliang Tang 628dd72b0feSGeliang Tangchk_rm_nr() 629dd72b0feSGeliang Tang{ 630dd72b0feSGeliang Tang local rm_addr_nr=$1 631dd72b0feSGeliang Tang local rm_subflow_nr=$2 6327028ba8aSGeliang Tang local invert=${3:-""} 633dd72b0feSGeliang Tang local count 634dd72b0feSGeliang Tang local dump_stats 6357028ba8aSGeliang Tang local addr_ns 6367028ba8aSGeliang Tang local subflow_ns 6377028ba8aSGeliang Tang 6387028ba8aSGeliang Tang if [ -z $invert ]; then 6397028ba8aSGeliang Tang addr_ns=$ns1 6407028ba8aSGeliang Tang subflow_ns=$ns2 6417028ba8aSGeliang Tang elif [ $invert = "invert" ]; then 6427028ba8aSGeliang Tang addr_ns=$ns2 6437028ba8aSGeliang Tang subflow_ns=$ns1 6447028ba8aSGeliang Tang fi 645dd72b0feSGeliang Tang 646dd72b0feSGeliang Tang printf "%-39s %s" " " "rm " 6477028ba8aSGeliang Tang count=`ip netns exec $addr_ns nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'` 648dd72b0feSGeliang Tang [ -z "$count" ] && count=0 649dd72b0feSGeliang Tang if [ "$count" != "$rm_addr_nr" ]; then 650dd72b0feSGeliang Tang echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" 651dd72b0feSGeliang Tang ret=1 652dd72b0feSGeliang Tang dump_stats=1 653dd72b0feSGeliang Tang else 654dd72b0feSGeliang Tang echo -n "[ ok ]" 655dd72b0feSGeliang Tang fi 656dd72b0feSGeliang Tang 657dd72b0feSGeliang Tang echo -n " - sf " 6587028ba8aSGeliang Tang count=`ip netns exec $subflow_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'` 659dd72b0feSGeliang Tang [ -z "$count" ] && count=0 660dd72b0feSGeliang Tang if [ "$count" != "$rm_subflow_nr" ]; then 661dd72b0feSGeliang Tang echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr" 662dd72b0feSGeliang Tang ret=1 663dd72b0feSGeliang Tang dump_stats=1 664dd72b0feSGeliang Tang else 665dd72b0feSGeliang Tang echo "[ ok ]" 666dd72b0feSGeliang Tang fi 667dd72b0feSGeliang Tang 668dd72b0feSGeliang Tang if [ "${dump_stats}" = 1 ]; then 669dd72b0feSGeliang Tang echo Server ns stats 670dd72b0feSGeliang Tang ip netns exec $ns1 nstat -as | grep MPTcp 671dd72b0feSGeliang Tang echo Client ns stats 672dd72b0feSGeliang Tang ip netns exec $ns2 nstat -as | grep MPTcp 673dd72b0feSGeliang Tang fi 674dd72b0feSGeliang Tang} 675dd72b0feSGeliang Tang 676718eb44eSGeliang Tangchk_prio_nr() 677718eb44eSGeliang Tang{ 678718eb44eSGeliang Tang local mp_prio_nr_tx=$1 679718eb44eSGeliang Tang local mp_prio_nr_rx=$2 680718eb44eSGeliang Tang local count 681718eb44eSGeliang Tang local dump_stats 682718eb44eSGeliang Tang 683718eb44eSGeliang Tang printf "%-39s %s" " " "ptx" 684718eb44eSGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}'` 685718eb44eSGeliang Tang [ -z "$count" ] && count=0 686718eb44eSGeliang Tang if [ "$count" != "$mp_prio_nr_tx" ]; then 687718eb44eSGeliang Tang echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" 688718eb44eSGeliang Tang ret=1 689718eb44eSGeliang Tang dump_stats=1 690718eb44eSGeliang Tang else 691718eb44eSGeliang Tang echo -n "[ ok ]" 692718eb44eSGeliang Tang fi 693718eb44eSGeliang Tang 694718eb44eSGeliang Tang echo -n " - prx " 695718eb44eSGeliang Tang count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}'` 696718eb44eSGeliang Tang [ -z "$count" ] && count=0 697718eb44eSGeliang Tang if [ "$count" != "$mp_prio_nr_rx" ]; then 698718eb44eSGeliang Tang echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" 699718eb44eSGeliang Tang ret=1 700718eb44eSGeliang Tang dump_stats=1 701718eb44eSGeliang Tang else 702718eb44eSGeliang Tang echo "[ ok ]" 703718eb44eSGeliang Tang fi 704718eb44eSGeliang Tang 705718eb44eSGeliang Tang if [ "${dump_stats}" = 1 ]; then 706718eb44eSGeliang Tang echo Server ns stats 707718eb44eSGeliang Tang ip netns exec $ns1 nstat -as | grep MPTcp 708718eb44eSGeliang Tang echo Client ns stats 709718eb44eSGeliang Tang ip netns exec $ns2 nstat -as | grep MPTcp 710718eb44eSGeliang Tang fi 711718eb44eSGeliang Tang} 712718eb44eSGeliang Tang 7131002b89fSGeliang Tangsubflows_tests() 7141002b89fSGeliang Tang{ 7151002b89fSGeliang Tang reset 716b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 717b08fbf24SPaolo Abeni chk_join_nr "no JOIN" "0" "0" "0" 718b08fbf24SPaolo Abeni 7191002b89fSGeliang Tang # subflow limited by client 720b08fbf24SPaolo Abeni reset 721b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 722b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 723b08fbf24SPaolo Abeni chk_join_nr "single subflow, limited by client" 0 0 0 724b08fbf24SPaolo Abeni 7251002b89fSGeliang Tang # subflow limited by server 726b08fbf24SPaolo Abeni reset 727b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl limits 0 1 728b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 729b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 730b08fbf24SPaolo Abeni chk_join_nr "single subflow, limited by server" 1 1 0 731b08fbf24SPaolo Abeni 732b08fbf24SPaolo Abeni # subflow 733b08fbf24SPaolo Abeni reset 734b08fbf24SPaolo Abeni ip netns exec $ns1 ./pm_nl_ctl limits 0 1 735b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl limits 0 1 736b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 737b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 738b08fbf24SPaolo Abeni chk_join_nr "single subflow" 1 1 1 739b08fbf24SPaolo Abeni 740b08fbf24SPaolo Abeni # multiple subflows 741b08fbf24SPaolo Abeni reset 742b08fbf24SPaolo Abeni ip netns exec $ns1 ./pm_nl_ctl limits 0 2 743b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl limits 0 2 744b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 745b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 746b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 747b08fbf24SPaolo Abeni chk_join_nr "multiple subflows" 2 2 2 748b08fbf24SPaolo Abeni 749b08fbf24SPaolo Abeni # multiple subflows limited by serverf 750b08fbf24SPaolo Abeni reset 751b08fbf24SPaolo Abeni ip netns exec $ns1 ./pm_nl_ctl limits 0 1 752b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl limits 0 2 753b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 754b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 755b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 756b08fbf24SPaolo Abeni chk_join_nr "multiple subflows, limited by server" 2 2 1 7571002b89fSGeliang Tang} 758b08fbf24SPaolo Abeni 7591002b89fSGeliang Tangsignal_address_tests() 7601002b89fSGeliang Tang{ 761b08fbf24SPaolo Abeni # add_address, unused 762b08fbf24SPaolo Abeni reset 763b08fbf24SPaolo Abeni ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 764b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 765b08fbf24SPaolo Abeni chk_join_nr "unused signal address" 0 0 0 766be613160SGeliang Tang chk_add_nr 1 1 767b08fbf24SPaolo Abeni 768b08fbf24SPaolo Abeni # accept and use add_addr 769b08fbf24SPaolo Abeni reset 770b08fbf24SPaolo Abeni ip netns exec $ns1 ./pm_nl_ctl limits 0 1 771b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl limits 1 1 772b08fbf24SPaolo Abeni ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 773b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 774b08fbf24SPaolo Abeni chk_join_nr "signal address" 1 1 1 775be613160SGeliang Tang chk_add_nr 1 1 776b08fbf24SPaolo Abeni 777b08fbf24SPaolo Abeni # accept and use add_addr with an additional subflow 778b08fbf24SPaolo Abeni # note: signal address in server ns and local addresses in client ns must 779b08fbf24SPaolo Abeni # belong to different subnets or one of the listed local address could be 780b08fbf24SPaolo Abeni # used for 'add_addr' subflow 781b08fbf24SPaolo Abeni reset 782b08fbf24SPaolo Abeni ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 783b08fbf24SPaolo Abeni ip netns exec $ns1 ./pm_nl_ctl limits 0 2 784b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl limits 1 2 785b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 786b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 787b08fbf24SPaolo Abeni chk_join_nr "subflow and signal" 2 2 2 788be613160SGeliang Tang chk_add_nr 1 1 789b08fbf24SPaolo Abeni 790b08fbf24SPaolo Abeni # accept and use add_addr with additional subflows 791b08fbf24SPaolo Abeni reset 792b08fbf24SPaolo Abeni ip netns exec $ns1 ./pm_nl_ctl limits 0 3 793b08fbf24SPaolo Abeni ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 794b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl limits 1 3 795b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 796b08fbf24SPaolo Abeni ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 797b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 798b08fbf24SPaolo Abeni chk_join_nr "multiple subflows and signal" 3 3 3 799be613160SGeliang Tang chk_add_nr 1 1 800ef360019SGeliang Tang 801ef360019SGeliang Tang # signal addresses 802ef360019SGeliang Tang reset 803ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 3 3 804ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 805ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 806ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal 807ef360019SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 3 3 808ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 809ef360019SGeliang Tang chk_join_nr "signal addresses" 3 3 3 810ef360019SGeliang Tang chk_add_nr 3 3 811ef360019SGeliang Tang 812ef360019SGeliang Tang # signal invalid addresses 813ef360019SGeliang Tang reset 814ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 3 3 815ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal 816ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 817ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.14.1 flags signal 818ef360019SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 3 3 819ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 820ef360019SGeliang Tang chk_join_nr "signal invalid addresses" 1 1 1 821ef360019SGeliang Tang chk_add_nr 3 3 8221002b89fSGeliang Tang} 823b08fbf24SPaolo Abeni 8241002b89fSGeliang Tanglink_failure_tests() 8251002b89fSGeliang Tang{ 8268b819a84SFlorian Westphal # accept and use add_addr with additional subflows and link loss 8278b819a84SFlorian Westphal reset 8288b819a84SFlorian Westphal ip netns exec $ns1 ./pm_nl_ctl limits 0 3 8298b819a84SFlorian Westphal ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 8308b819a84SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl limits 1 3 8318b819a84SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 8328b819a84SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 8338b819a84SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 1 8348b819a84SFlorian Westphal chk_join_nr "multiple flows, signal, link failure" 3 3 3 8358b819a84SFlorian Westphal chk_add_nr 1 1 8361002b89fSGeliang Tang} 8378b819a84SFlorian Westphal 8381002b89fSGeliang Tangadd_addr_timeout_tests() 8391002b89fSGeliang Tang{ 8408d014eaaSGeliang Tang # add_addr timeout 8418d014eaaSGeliang Tang reset_with_add_addr_timeout 8428d014eaaSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 8438d014eaaSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 8448d014eaaSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 8458b819a84SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 8468d014eaaSGeliang Tang chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1 8478d014eaaSGeliang Tang chk_add_nr 4 0 8488d014eaaSGeliang Tang 8491002b89fSGeliang Tang # add_addr timeout IPv6 8501002b89fSGeliang Tang reset_with_add_addr_timeout 6 8511002b89fSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 8521002b89fSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 8531002b89fSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 8541002b89fSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 8551002b89fSGeliang Tang chk_join_nr "signal address, ADD_ADDR6 timeout" 1 1 1 8561002b89fSGeliang Tang chk_add_nr 4 0 8578da6229bSGeliang Tang 8588da6229bSGeliang Tang # signal addresses timeout 8598da6229bSGeliang Tang reset_with_add_addr_timeout 8608da6229bSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 2 2 8618da6229bSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 8628da6229bSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 8638da6229bSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 2 2 8648da6229bSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 8658da6229bSGeliang Tang chk_join_nr "signal addresses, ADD_ADDR timeout" 2 2 2 8668da6229bSGeliang Tang chk_add_nr 8 0 8678da6229bSGeliang Tang 8688da6229bSGeliang Tang # signal invalid addresses timeout 8698da6229bSGeliang Tang reset_with_add_addr_timeout 8708da6229bSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 2 2 8718da6229bSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal 8728da6229bSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 8738da6229bSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 2 2 8748da6229bSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 8758da6229bSGeliang Tang chk_join_nr "invalid address, ADD_ADDR timeout" 1 1 1 8768da6229bSGeliang Tang chk_add_nr 8 0 8771002b89fSGeliang Tang} 8781002b89fSGeliang Tang 8791002b89fSGeliang Tangremove_tests() 8801002b89fSGeliang Tang{ 881dd72b0feSGeliang Tang # single subflow, remove 882dd72b0feSGeliang Tang reset 883dd72b0feSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 884dd72b0feSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 1 885dd72b0feSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 8862e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -1 slow 887dd72b0feSGeliang Tang chk_join_nr "remove single subflow" 1 1 1 888dd72b0feSGeliang Tang chk_rm_nr 1 1 889dd72b0feSGeliang Tang 890dd72b0feSGeliang Tang # multiple subflows, remove 891dd72b0feSGeliang Tang reset 892dd72b0feSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 2 893dd72b0feSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 2 894dd72b0feSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 895dd72b0feSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 8962e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -2 slow 897dd72b0feSGeliang Tang chk_join_nr "remove multiple subflows" 2 2 2 898dd72b0feSGeliang Tang chk_rm_nr 2 2 899dd72b0feSGeliang Tang 900dd72b0feSGeliang Tang # single address, remove 901dd72b0feSGeliang Tang reset 902dd72b0feSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 903dd72b0feSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 904dd72b0feSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 9052e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 906dd72b0feSGeliang Tang chk_join_nr "remove single address" 1 1 1 907dd72b0feSGeliang Tang chk_add_nr 1 1 9087028ba8aSGeliang Tang chk_rm_nr 1 1 invert 909dd72b0feSGeliang Tang 910dd72b0feSGeliang Tang # subflow and signal, remove 911dd72b0feSGeliang Tang reset 912dd72b0feSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 2 913dd72b0feSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 914dd72b0feSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 2 915dd72b0feSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 9162e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 917dd72b0feSGeliang Tang chk_join_nr "remove subflow and signal" 2 2 2 918dd72b0feSGeliang Tang chk_add_nr 1 1 919dd72b0feSGeliang Tang chk_rm_nr 1 1 920dd72b0feSGeliang Tang 921dd72b0feSGeliang Tang # subflows and signal, remove 922dd72b0feSGeliang Tang reset 923dd72b0feSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 3 924dd72b0feSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 925dd72b0feSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 3 926dd72b0feSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 927dd72b0feSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 9282e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -2 slow 929dd72b0feSGeliang Tang chk_join_nr "remove subflows and signal" 3 3 3 930dd72b0feSGeliang Tang chk_add_nr 1 1 931dd72b0feSGeliang Tang chk_rm_nr 2 2 932dd72b0feSGeliang Tang 933ef360019SGeliang Tang # addresses remove 934ef360019SGeliang Tang reset 935ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 3 3 936ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal id 250 937ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 938ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal 939ef360019SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 3 3 940ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 941ef360019SGeliang Tang chk_join_nr "remove addresses" 3 3 3 942ef360019SGeliang Tang chk_add_nr 3 3 943ef360019SGeliang Tang chk_rm_nr 3 3 invert 944ef360019SGeliang Tang 945ef360019SGeliang Tang # invalid addresses remove 946ef360019SGeliang Tang reset 947ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 3 3 948ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal 949ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 950ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.14.1 flags signal 951ef360019SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 3 3 952ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 953ef360019SGeliang Tang chk_join_nr "remove invalid addresses" 1 1 1 954ef360019SGeliang Tang chk_add_nr 3 3 955ef360019SGeliang Tang chk_rm_nr 3 1 invert 956ef360019SGeliang Tang 9576fe4ccdcSGeliang Tang # subflows and signal, flush 9586fe4ccdcSGeliang Tang reset 9596fe4ccdcSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 3 9606fe4ccdcSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 9616fe4ccdcSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 3 9626fe4ccdcSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 9636fe4ccdcSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 9642e8cbf45SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 9656fe4ccdcSGeliang Tang chk_join_nr "flush subflows and signal" 3 3 3 9666fe4ccdcSGeliang Tang chk_add_nr 1 1 9676fe4ccdcSGeliang Tang chk_rm_nr 2 2 968d2c4333aSGeliang Tang 969d2c4333aSGeliang Tang # subflows flush 970d2c4333aSGeliang Tang reset 971d2c4333aSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 3 3 972d2c4333aSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 3 3 973d2c4333aSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow id 150 974d2c4333aSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 975d2c4333aSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 976d2c4333aSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 977d2c4333aSGeliang Tang chk_join_nr "flush subflows" 3 3 3 978d2c4333aSGeliang Tang chk_rm_nr 3 3 979d2c4333aSGeliang Tang 980d2c4333aSGeliang Tang # addresses flush 981d2c4333aSGeliang Tang reset 982d2c4333aSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 3 3 983d2c4333aSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal id 250 984d2c4333aSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 985d2c4333aSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal 986d2c4333aSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 3 3 987d2c4333aSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 988d2c4333aSGeliang Tang chk_join_nr "flush addresses" 3 3 3 989d2c4333aSGeliang Tang chk_add_nr 3 3 990d2c4333aSGeliang Tang chk_rm_nr 3 3 invert 991ef360019SGeliang Tang 992ef360019SGeliang Tang # invalid addresses flush 993ef360019SGeliang Tang reset 994ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 3 3 995ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal 996ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 997ef360019SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.14.1 flags signal 998ef360019SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 3 3 999ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 0 slow 1000ef360019SGeliang Tang chk_join_nr "flush invalid addresses" 1 1 1 1001ef360019SGeliang Tang chk_add_nr 3 3 1002ef360019SGeliang Tang chk_rm_nr 3 1 invert 1003*5e287fe7SGeliang Tang 1004*5e287fe7SGeliang Tang # remove id 0 subflow 1005*5e287fe7SGeliang Tang reset 1006*5e287fe7SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1007*5e287fe7SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1008*5e287fe7SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1009*5e287fe7SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 -9 slow 1010*5e287fe7SGeliang Tang chk_join_nr "remove id 0 subflow" 1 1 1 1011*5e287fe7SGeliang Tang chk_rm_nr 1 1 1012*5e287fe7SGeliang Tang 1013*5e287fe7SGeliang Tang # remove id 0 address 1014*5e287fe7SGeliang Tang reset 1015*5e287fe7SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1016*5e287fe7SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1017*5e287fe7SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1018*5e287fe7SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -9 0 slow 1019*5e287fe7SGeliang Tang chk_join_nr "remove id 0 address" 1 1 1 1020*5e287fe7SGeliang Tang chk_add_nr 1 1 1021*5e287fe7SGeliang Tang chk_rm_nr 1 1 invert 10221002b89fSGeliang Tang} 10236fe4ccdcSGeliang Tang 10241002b89fSGeliang Tangadd_tests() 10251002b89fSGeliang Tang{ 10266208fd82SGeliang Tang # add single subflow 10276208fd82SGeliang Tang reset 10286208fd82SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 10296208fd82SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 1 10306208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow 10316208fd82SGeliang Tang chk_join_nr "add single subflow" 1 1 1 10326208fd82SGeliang Tang 10336208fd82SGeliang Tang # add signal address 10346208fd82SGeliang Tang reset 10356208fd82SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 10366208fd82SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 10376208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 10386208fd82SGeliang Tang chk_join_nr "add signal address" 1 1 1 10396208fd82SGeliang Tang chk_add_nr 1 1 10406208fd82SGeliang Tang 10416208fd82SGeliang Tang # add multiple subflows 10426208fd82SGeliang Tang reset 10436208fd82SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 2 10446208fd82SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 2 10456208fd82SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 2 slow 10466208fd82SGeliang Tang chk_join_nr "add multiple subflows" 2 2 2 10476208fd82SGeliang Tang 10486208fd82SGeliang Tang # add multiple subflows IPv6 10496208fd82SGeliang Tang reset 10506208fd82SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 2 10516208fd82SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 2 10526208fd82SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 2 slow 10536208fd82SGeliang Tang chk_join_nr "add multiple subflows IPv6" 2 2 2 10546208fd82SGeliang Tang 10556208fd82SGeliang Tang # add multiple addresses IPv6 10566208fd82SGeliang Tang reset 10576208fd82SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 2 10586208fd82SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 2 2 10596208fd82SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 2 0 slow 10606208fd82SGeliang Tang chk_join_nr "add multiple addresses IPv6" 2 2 2 10616208fd82SGeliang Tang chk_add_nr 2 2 10621002b89fSGeliang Tang} 10636208fd82SGeliang Tang 10641002b89fSGeliang Tangipv6_tests() 10651002b89fSGeliang Tang{ 1066523514edSGeliang Tang # subflow IPv6 1067523514edSGeliang Tang reset 1068523514edSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1069523514edSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1070523514edSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 flags subflow 1071523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1072523514edSGeliang Tang chk_join_nr "single subflow IPv6" 1 1 1 1073523514edSGeliang Tang 1074523514edSGeliang Tang # add_address, unused IPv6 1075523514edSGeliang Tang reset 1076523514edSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1077523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1078523514edSGeliang Tang chk_join_nr "unused signal address IPv6" 0 0 0 1079523514edSGeliang Tang chk_add_nr 1 1 1080523514edSGeliang Tang 1081523514edSGeliang Tang # signal address IPv6 1082523514edSGeliang Tang reset 1083523514edSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1084523514edSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1085523514edSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1086523514edSGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1087523514edSGeliang Tang chk_join_nr "single address IPv6" 1 1 1 1088523514edSGeliang Tang chk_add_nr 1 1 1089523514edSGeliang Tang 1090523514edSGeliang Tang # single address IPv6, remove 1091523514edSGeliang Tang reset 1092523514edSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1093523514edSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1094523514edSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 10952e8cbf45SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 -1 0 slow 1096523514edSGeliang Tang chk_join_nr "remove single address IPv6" 1 1 1 1097523514edSGeliang Tang chk_add_nr 1 1 10987028ba8aSGeliang Tang chk_rm_nr 1 1 invert 1099523514edSGeliang Tang 1100523514edSGeliang Tang # subflow and signal IPv6, remove 1101523514edSGeliang Tang reset 1102523514edSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1103523514edSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1104523514edSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1105523514edSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 flags subflow 11062e8cbf45SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 0 -1 -1 slow 1107523514edSGeliang Tang chk_join_nr "remove subflow and signal IPv6" 2 2 2 1108523514edSGeliang Tang chk_add_nr 1 1 1109523514edSGeliang Tang chk_rm_nr 1 1 11101002b89fSGeliang Tang} 1111523514edSGeliang Tang 11121002b89fSGeliang Tangv4mapped_tests() 11131002b89fSGeliang Tang{ 1114a6094788SGeliang Tang # subflow IPv4-mapped to IPv4-mapped 1115a6094788SGeliang Tang reset 1116a6094788SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1117a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1118a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add "::ffff:10.0.3.2" flags subflow 1119a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1120a6094788SGeliang Tang chk_join_nr "single subflow IPv4-mapped" 1 1 1 1121a6094788SGeliang Tang 1122a6094788SGeliang Tang # signal address IPv4-mapped with IPv4-mapped sk 1123a6094788SGeliang Tang reset 1124a6094788SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1125a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1126a6094788SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add "::ffff:10.0.2.1" flags signal 1127a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1128a6094788SGeliang Tang chk_join_nr "signal address IPv4-mapped" 1 1 1 1129a6094788SGeliang Tang chk_add_nr 1 1 1130a6094788SGeliang Tang 1131a6094788SGeliang Tang # subflow v4-map-v6 1132a6094788SGeliang Tang reset 1133a6094788SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1134a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1135a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1136a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1137a6094788SGeliang Tang chk_join_nr "single subflow v4-map-v6" 1 1 1 1138a6094788SGeliang Tang 1139a6094788SGeliang Tang # signal address v4-map-v6 1140a6094788SGeliang Tang reset 1141a6094788SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1142a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1143a6094788SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1144a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1145a6094788SGeliang Tang chk_join_nr "signal address v4-map-v6" 1 1 1 1146a6094788SGeliang Tang chk_add_nr 1 1 1147a6094788SGeliang Tang 1148a6094788SGeliang Tang # subflow v6-map-v4 1149a6094788SGeliang Tang reset 1150a6094788SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1151a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1152a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add "::ffff:10.0.3.2" flags subflow 1153a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1154a6094788SGeliang Tang chk_join_nr "single subflow v6-map-v4" 1 1 1 1155a6094788SGeliang Tang 1156a6094788SGeliang Tang # signal address v6-map-v4 1157a6094788SGeliang Tang reset 1158a6094788SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1159a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1160a6094788SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add "::ffff:10.0.2.1" flags signal 1161a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1162a6094788SGeliang Tang chk_join_nr "signal address v6-map-v4" 1 1 1 1163a6094788SGeliang Tang chk_add_nr 1 1 1164a6094788SGeliang Tang 1165a6094788SGeliang Tang # no subflow IPv6 to v4 address 1166a6094788SGeliang Tang reset 1167a6094788SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1168a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1169a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add dead:beef:2::2 flags subflow 1170a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1171a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v4-v6" 0 0 0 1172a6094788SGeliang Tang 1173a6094788SGeliang Tang # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end 1174a6094788SGeliang Tang reset 1175a6094788SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1176a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1177a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add dead:beef:2::10.0.3.2 flags subflow 1178a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1179a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v4-v6-2" 0 0 0 1180a6094788SGeliang Tang 1181a6094788SGeliang Tang # no subflow IPv4 to v6 address, no need to slow down too then 1182a6094788SGeliang Tang reset 1183a6094788SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1184a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1185a6094788SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1186a6094788SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 1187a6094788SGeliang Tang chk_join_nr "no JOIN with diff families v6-v4" 0 0 0 11881002b89fSGeliang Tang} 1189a6094788SGeliang Tang 11901002b89fSGeliang Tangbackup_tests() 11911002b89fSGeliang Tang{ 1192718eb44eSGeliang Tang # single subflow, backup 1193718eb44eSGeliang Tang reset 1194718eb44eSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1195718eb44eSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1196718eb44eSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow,backup 1197718eb44eSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup 1198718eb44eSGeliang Tang chk_join_nr "single subflow, backup" 1 1 1 1199718eb44eSGeliang Tang chk_prio_nr 0 1 1200718eb44eSGeliang Tang 1201718eb44eSGeliang Tang # single address, backup 1202718eb44eSGeliang Tang reset 1203718eb44eSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1204718eb44eSGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1205718eb44eSGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1206718eb44eSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup 1207718eb44eSGeliang Tang chk_join_nr "single address, backup" 1 1 1 1208718eb44eSGeliang Tang chk_add_nr 1 1 1209718eb44eSGeliang Tang chk_prio_nr 1 0 12101002b89fSGeliang Tang} 1211718eb44eSGeliang Tang 12121002b89fSGeliang Tangadd_addr_ports_tests() 12131002b89fSGeliang Tang{ 12148a127bf6SGeliang Tang # signal address with port 12158a127bf6SGeliang Tang reset 12168a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 12178a127bf6SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 12188a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 12198a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 12208a127bf6SGeliang Tang chk_join_nr "signal address with port" 1 1 1 12218a127bf6SGeliang Tang chk_add_nr 1 1 1 12228a127bf6SGeliang Tang 12238a127bf6SGeliang Tang # subflow and signal with port 12248a127bf6SGeliang Tang reset 12258a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 12268a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 2 12278a127bf6SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 2 12288a127bf6SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 12298a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 12308a127bf6SGeliang Tang chk_join_nr "subflow and signal with port" 2 2 2 12318a127bf6SGeliang Tang chk_add_nr 1 1 1 12328a127bf6SGeliang Tang 12338a127bf6SGeliang Tang # single address with port, remove 12348a127bf6SGeliang Tang reset 12358a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 1 12368a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 12378a127bf6SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 1 12388a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 12398a127bf6SGeliang Tang chk_join_nr "remove single address with port" 1 1 1 12408a127bf6SGeliang Tang chk_add_nr 1 1 1 12417028ba8aSGeliang Tang chk_rm_nr 1 1 invert 12428a127bf6SGeliang Tang 12438a127bf6SGeliang Tang # subflow and signal with port, remove 12448a127bf6SGeliang Tang reset 12458a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 2 12468a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 12478a127bf6SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 2 12488a127bf6SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 12498a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 12508a127bf6SGeliang Tang chk_join_nr "remove subflow and signal with port" 2 2 2 12518a127bf6SGeliang Tang chk_add_nr 1 1 1 12528a127bf6SGeliang Tang chk_rm_nr 1 1 12538a127bf6SGeliang Tang 12548a127bf6SGeliang Tang # subflows and signal with port, flush 12558a127bf6SGeliang Tang reset 12568a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 0 3 12578a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 12588a127bf6SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 1 3 12598a127bf6SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 12608a127bf6SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 12618a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 12628a127bf6SGeliang Tang chk_join_nr "flush subflows and signal with port" 3 3 3 12638a127bf6SGeliang Tang chk_add_nr 1 1 12648a127bf6SGeliang Tang chk_rm_nr 2 2 12658a127bf6SGeliang Tang 12668a127bf6SGeliang Tang # multiple addresses with port 12678a127bf6SGeliang Tang reset 12688a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 2 2 12698a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 12708a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal port 10100 12718a127bf6SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 2 2 12728a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 12738a127bf6SGeliang Tang chk_join_nr "multiple addresses with port" 2 2 2 12748a127bf6SGeliang Tang chk_add_nr 2 2 2 12758a127bf6SGeliang Tang 12768a127bf6SGeliang Tang # multiple addresses with ports 12778a127bf6SGeliang Tang reset 12788a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl limits 2 2 12798a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 12808a127bf6SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal port 10101 12818a127bf6SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl limits 2 2 12828a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 12838a127bf6SGeliang Tang chk_join_nr "multiple addresses with ports" 2 2 2 12848a127bf6SGeliang Tang chk_add_nr 2 2 2 12851002b89fSGeliang Tang} 12868a127bf6SGeliang Tang 12871002b89fSGeliang Tangsyncookies_tests() 12881002b89fSGeliang Tang{ 128900587187SFlorian Westphal # single subflow, syncookies 129000587187SFlorian Westphal reset_with_cookies 129100587187SFlorian Westphal ip netns exec $ns1 ./pm_nl_ctl limits 0 1 129200587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl limits 0 1 129300587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 129400587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 129500587187SFlorian Westphal chk_join_nr "single subflow with syn cookies" 1 1 1 129600587187SFlorian Westphal 129700587187SFlorian Westphal # multiple subflows with syn cookies 129800587187SFlorian Westphal reset_with_cookies 129900587187SFlorian Westphal ip netns exec $ns1 ./pm_nl_ctl limits 0 2 130000587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl limits 0 2 130100587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 130200587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 130300587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 130400587187SFlorian Westphal chk_join_nr "multiple subflows with syn cookies" 2 2 2 130500587187SFlorian Westphal 130600587187SFlorian Westphal # multiple subflows limited by server 130700587187SFlorian Westphal reset_with_cookies 130800587187SFlorian Westphal ip netns exec $ns1 ./pm_nl_ctl limits 0 1 130900587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl limits 0 2 131000587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 131100587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 131200587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 131300587187SFlorian Westphal chk_join_nr "subflows limited by server w cookies" 2 2 1 131400587187SFlorian Westphal 131500587187SFlorian Westphal # test signal address with cookies 131600587187SFlorian Westphal reset_with_cookies 131700587187SFlorian Westphal ip netns exec $ns1 ./pm_nl_ctl limits 0 1 131800587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl limits 1 1 131900587187SFlorian Westphal ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 132000587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 132100587187SFlorian Westphal chk_join_nr "signal address with syn cookies" 1 1 1 1322be613160SGeliang Tang chk_add_nr 1 1 132300587187SFlorian Westphal 132400587187SFlorian Westphal # test cookie with subflow and signal 132500587187SFlorian Westphal reset_with_cookies 132600587187SFlorian Westphal ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 132700587187SFlorian Westphal ip netns exec $ns1 ./pm_nl_ctl limits 0 2 132800587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl limits 1 2 132900587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 133000587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 133100587187SFlorian Westphal chk_join_nr "subflow and signal w cookies" 2 2 2 1332be613160SGeliang Tang chk_add_nr 1 1 133300587187SFlorian Westphal 133400587187SFlorian Westphal # accept and use add_addr with additional subflows 133500587187SFlorian Westphal reset_with_cookies 133600587187SFlorian Westphal ip netns exec $ns1 ./pm_nl_ctl limits 0 3 133700587187SFlorian Westphal ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 133800587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl limits 1 3 133900587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 134000587187SFlorian Westphal ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 134100587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 134200587187SFlorian Westphal chk_join_nr "subflows and signal w. cookies" 3 3 3 1343be613160SGeliang Tang chk_add_nr 1 1 13441002b89fSGeliang Tang} 13451002b89fSGeliang Tang 13461002b89fSGeliang Tangall_tests() 13471002b89fSGeliang Tang{ 13481002b89fSGeliang Tang subflows_tests 13491002b89fSGeliang Tang signal_address_tests 13501002b89fSGeliang Tang link_failure_tests 13511002b89fSGeliang Tang add_addr_timeout_tests 13521002b89fSGeliang Tang remove_tests 13531002b89fSGeliang Tang add_tests 13541002b89fSGeliang Tang ipv6_tests 13551002b89fSGeliang Tang v4mapped_tests 13561002b89fSGeliang Tang backup_tests 13571002b89fSGeliang Tang add_addr_ports_tests 13581002b89fSGeliang Tang syncookies_tests 13591002b89fSGeliang Tang} 13601002b89fSGeliang Tang 13611002b89fSGeliang Tangusage() 13621002b89fSGeliang Tang{ 13631002b89fSGeliang Tang echo "mptcp_join usage:" 13641002b89fSGeliang Tang echo " -f subflows_tests" 13651002b89fSGeliang Tang echo " -s signal_address_tests" 13661002b89fSGeliang Tang echo " -l link_failure_tests" 13671002b89fSGeliang Tang echo " -t add_addr_timeout_tests" 13681002b89fSGeliang Tang echo " -r remove_tests" 13691002b89fSGeliang Tang echo " -a add_tests" 13701002b89fSGeliang Tang echo " -6 ipv6_tests" 13711002b89fSGeliang Tang echo " -4 v4mapped_tests" 13721002b89fSGeliang Tang echo " -b backup_tests" 13731002b89fSGeliang Tang echo " -p add_addr_ports_tests" 1374a673321aSMat Martineau echo " -k syncookies_tests" 1375a673321aSMat Martineau echo " -c capture pcap files" 13761002b89fSGeliang Tang echo " -h help" 13771002b89fSGeliang Tang} 13781002b89fSGeliang Tang 13791002b89fSGeliang Tangsin=$(mktemp) 13801002b89fSGeliang Tangsout=$(mktemp) 13811002b89fSGeliang Tangcin=$(mktemp) 13821002b89fSGeliang Tangcinsent=$(mktemp) 13831002b89fSGeliang Tangcout=$(mktemp) 13841002b89fSGeliang Tanginit 13851002b89fSGeliang Tangmake_file "$cin" "client" 1 13861002b89fSGeliang Tangmake_file "$sin" "server" 1 13871002b89fSGeliang Tangtrap cleanup EXIT 13881002b89fSGeliang Tang 1389a673321aSMat Martineaufor arg in "$@"; do 1390a673321aSMat Martineau # check for "capture" arg before launching tests 1391a673321aSMat Martineau if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"c"[0-9a-zA-Z]*$ ]]; then 1392a673321aSMat Martineau capture=1 1393a673321aSMat Martineau fi 1394a673321aSMat Martineau 1395a673321aSMat Martineau # exception for the capture option, the rest means: a part of the tests 1396a673321aSMat Martineau if [ "${arg}" != "-c" ]; then 1397a673321aSMat Martineau do_all_tests=0 1398a673321aSMat Martineau fi 1399a673321aSMat Martineaudone 1400a673321aSMat Martineau 1401a673321aSMat Martineauif [ $do_all_tests -eq 1 ]; then 14021002b89fSGeliang Tang all_tests 14031002b89fSGeliang Tang exit $ret 14041002b89fSGeliang Tangfi 14051002b89fSGeliang Tang 1406a673321aSMat Martineauwhile getopts 'fsltra64bpkch' opt; do 14071002b89fSGeliang Tang case $opt in 14081002b89fSGeliang Tang f) 14091002b89fSGeliang Tang subflows_tests 14101002b89fSGeliang Tang ;; 14111002b89fSGeliang Tang s) 14121002b89fSGeliang Tang signal_address_tests 14131002b89fSGeliang Tang ;; 14141002b89fSGeliang Tang l) 14151002b89fSGeliang Tang link_failure_tests 14161002b89fSGeliang Tang ;; 14171002b89fSGeliang Tang t) 14181002b89fSGeliang Tang add_addr_timeout_tests 14191002b89fSGeliang Tang ;; 14201002b89fSGeliang Tang r) 14211002b89fSGeliang Tang remove_tests 14221002b89fSGeliang Tang ;; 14231002b89fSGeliang Tang a) 14241002b89fSGeliang Tang add_tests 14251002b89fSGeliang Tang ;; 14261002b89fSGeliang Tang 6) 14271002b89fSGeliang Tang ipv6_tests 14281002b89fSGeliang Tang ;; 14291002b89fSGeliang Tang 4) 14301002b89fSGeliang Tang v4mapped_tests 14311002b89fSGeliang Tang ;; 14321002b89fSGeliang Tang b) 14331002b89fSGeliang Tang backup_tests 14341002b89fSGeliang Tang ;; 14351002b89fSGeliang Tang p) 14361002b89fSGeliang Tang add_addr_ports_tests 14371002b89fSGeliang Tang ;; 1438a673321aSMat Martineau k) 14391002b89fSGeliang Tang syncookies_tests 14401002b89fSGeliang Tang ;; 1441a673321aSMat Martineau c) 1442a673321aSMat Martineau ;; 14431002b89fSGeliang Tang h | *) 14441002b89fSGeliang Tang usage 14451002b89fSGeliang Tang ;; 14461002b89fSGeliang Tang esac 14471002b89fSGeliang Tangdone 144800587187SFlorian Westphal 1449b08fbf24SPaolo Abeniexit $ret 1450