1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4ret=0 5sin="" 6sinfail="" 7sout="" 8cin="" 9cinfail="" 10cinsent="" 11cout="" 12ksft_skip=4 13timeout_poll=30 14timeout_test=$((timeout_poll * 2 + 1)) 15mptcp_connect="" 16capture=0 17checksum=0 18do_all_tests=1 19 20TEST_COUNT=0 21 22# generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) || 23# (ip6 && (ip6[74] & 0xf0) == 0x30)'" 24CBPF_MPTCP_SUBOPTION_ADD_ADDR="14, 25 48 0 0 0, 26 84 0 0 240, 27 21 0 3 64, 28 48 0 0 54, 29 84 0 0 240, 30 21 6 7 48, 31 48 0 0 0, 32 84 0 0 240, 33 21 0 4 96, 34 48 0 0 74, 35 84 0 0 240, 36 21 0 1 48, 37 6 0 0 65535, 38 6 0 0 0" 39 40init() 41{ 42 capout=$(mktemp) 43 44 rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) 45 46 ns1="ns1-$rndh" 47 ns2="ns2-$rndh" 48 49 for netns in "$ns1" "$ns2";do 50 ip netns add $netns || exit $ksft_skip 51 ip -net $netns link set lo up 52 ip netns exec $netns sysctl -q net.mptcp.enabled=1 53 ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 54 ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 55 if [ $checksum -eq 1 ]; then 56 ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1 57 fi 58 done 59 60 # ns1 ns2 61 # ns1eth1 ns2eth1 62 # ns1eth2 ns2eth2 63 # ns1eth3 ns2eth3 64 # ns1eth4 ns2eth4 65 66 for i in `seq 1 4`; do 67 ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2" 68 ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i 69 ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad 70 ip -net "$ns1" link set ns1eth$i up 71 72 ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i 73 ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad 74 ip -net "$ns2" link set ns2eth$i up 75 76 # let $ns2 reach any $ns1 address from any interface 77 ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i 78 ip -net "$ns2" route add default via dead:beef:$i::1 dev ns2eth$i metric 10$i 79 done 80} 81 82init_shapers() 83{ 84 for i in `seq 1 4`; do 85 tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1 86 tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1 87 done 88} 89 90cleanup_partial() 91{ 92 rm -f "$capout" 93 94 for netns in "$ns1" "$ns2"; do 95 ip netns del $netns 96 rm -f /tmp/$netns.{nstat,out} 97 done 98} 99 100cleanup() 101{ 102 rm -f "$cin" "$cout" "$sinfail" 103 rm -f "$sin" "$sout" "$cinsent" "$cinfail" 104 cleanup_partial 105} 106 107reset() 108{ 109 cleanup_partial 110 init 111} 112 113reset_with_cookies() 114{ 115 reset 116 117 for netns in "$ns1" "$ns2";do 118 ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2 119 done 120} 121 122reset_with_add_addr_timeout() 123{ 124 local ip="${1:-4}" 125 local tables 126 127 tables="iptables" 128 if [ $ip -eq 6 ]; then 129 tables="ip6tables" 130 fi 131 132 reset 133 134 ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 135 ip netns exec $ns2 $tables -A OUTPUT -p tcp \ 136 -m tcp --tcp-option 30 \ 137 -m bpf --bytecode \ 138 "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \ 139 -j DROP 140} 141 142reset_with_checksum() 143{ 144 local ns1_enable=$1 145 local ns2_enable=$2 146 147 reset 148 149 ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=$ns1_enable 150 ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=$ns2_enable 151} 152 153reset_with_allow_join_id0() 154{ 155 local ns1_enable=$1 156 local ns2_enable=$2 157 158 reset 159 160 ip netns exec $ns1 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns1_enable 161 ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable 162} 163 164ip -Version > /dev/null 2>&1 165if [ $? -ne 0 ];then 166 echo "SKIP: Could not run test without ip tool" 167 exit $ksft_skip 168fi 169 170iptables -V > /dev/null 2>&1 171if [ $? -ne 0 ];then 172 echo "SKIP: Could not run all tests without iptables tool" 173 exit $ksft_skip 174fi 175 176ip6tables -V > /dev/null 2>&1 177if [ $? -ne 0 ];then 178 echo "SKIP: Could not run all tests without ip6tables tool" 179 exit $ksft_skip 180fi 181 182print_file_err() 183{ 184 ls -l "$1" 1>&2 185 echo "Trailing bytes are: " 186 tail -c 27 "$1" 187} 188 189check_transfer() 190{ 191 in=$1 192 out=$2 193 what=$3 194 195 cmp "$in" "$out" > /dev/null 2>&1 196 if [ $? -ne 0 ] ;then 197 echo "[ FAIL ] $what does not match (in, out):" 198 print_file_err "$in" 199 print_file_err "$out" 200 ret=1 201 202 return 1 203 fi 204 205 return 0 206} 207 208do_ping() 209{ 210 listener_ns="$1" 211 connector_ns="$2" 212 connect_addr="$3" 213 214 ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null 215 if [ $? -ne 0 ] ; then 216 echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2 217 ret=1 218 fi 219} 220 221link_failure() 222{ 223 ns="$1" 224 225 if [ -z "$FAILING_LINKS" ]; then 226 l=$((RANDOM%4)) 227 FAILING_LINKS=$((l+1)) 228 fi 229 230 for l in $FAILING_LINKS; do 231 veth="ns1eth$l" 232 ip -net "$ns" link set "$veth" down 233 done 234} 235 236# $1: IP address 237is_v6() 238{ 239 [ -z "${1##*:*}" ] 240} 241 242# $1: ns, $2: port 243wait_local_port_listen() 244{ 245 local listener_ns="${1}" 246 local port="${2}" 247 248 local port_hex i 249 250 port_hex="$(printf "%04X" "${port}")" 251 for i in $(seq 10); do 252 ip netns exec "${listener_ns}" cat /proc/net/tcp* | \ 253 awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" && 254 break 255 sleep 0.1 256 done 257} 258 259rm_addr_count() 260{ 261 ns=${1} 262 263 ip netns exec ${ns} nstat -as | grep MPTcpExtRmAddr | awk '{print $2}' 264} 265 266# $1: ns, $2: old rm_addr counter in $ns 267wait_rm_addr() 268{ 269 local ns="${1}" 270 local old_cnt="${2}" 271 local cnt 272 local i 273 274 for i in $(seq 10); do 275 cnt=$(rm_addr_count ${ns}) 276 [ "$cnt" = "${old_cnt}" ] || break 277 sleep 0.1 278 done 279} 280 281do_transfer() 282{ 283 listener_ns="$1" 284 connector_ns="$2" 285 cl_proto="$3" 286 srv_proto="$4" 287 connect_addr="$5" 288 test_link_fail="$6" 289 addr_nr_ns1="$7" 290 addr_nr_ns2="$8" 291 speed="$9" 292 bkup="${10}" 293 294 port=$((10000+$TEST_COUNT)) 295 TEST_COUNT=$((TEST_COUNT+1)) 296 297 :> "$cout" 298 :> "$sout" 299 :> "$capout" 300 301 if [ $capture -eq 1 ]; then 302 if [ -z $SUDO_USER ] ; then 303 capuser="" 304 else 305 capuser="-Z $SUDO_USER" 306 fi 307 308 capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}") 309 310 echo "Capturing traffic for test $TEST_COUNT into $capfile" 311 ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & 312 cappid=$! 313 314 sleep 1 315 fi 316 317 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 318 nstat -n 319 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 320 nstat -n 321 322 if [ $speed = "fast" ]; then 323 mptcp_connect="./mptcp_connect -j" 324 elif [ $speed = "slow" ]; then 325 mptcp_connect="./mptcp_connect -r 50" 326 elif [ $speed = "least" ]; then 327 mptcp_connect="./mptcp_connect -r 10" 328 fi 329 330 local local_addr 331 if is_v6 "${connect_addr}"; then 332 local_addr="::" 333 else 334 local_addr="0.0.0.0" 335 fi 336 337 if [ "$test_link_fail" -eq 2 ];then 338 timeout ${timeout_test} \ 339 ip netns exec ${listener_ns} \ 340 $mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 341 ${local_addr} < "$sinfail" > "$sout" & 342 else 343 timeout ${timeout_test} \ 344 ip netns exec ${listener_ns} \ 345 $mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 346 ${local_addr} < "$sin" > "$sout" & 347 fi 348 spid=$! 349 350 wait_local_port_listen "${listener_ns}" "${port}" 351 352 if [ "$test_link_fail" -eq 0 ];then 353 timeout ${timeout_test} \ 354 ip netns exec ${connector_ns} \ 355 $mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 356 $connect_addr < "$cin" > "$cout" & 357 else 358 ( cat "$cinfail" ; sleep 2; link_failure $listener_ns ; cat "$cinfail" ) | \ 359 tee "$cinsent" | \ 360 timeout ${timeout_test} \ 361 ip netns exec ${connector_ns} \ 362 $mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 363 $connect_addr > "$cout" & 364 fi 365 cpid=$! 366 367 # let the mptcp subflow be established in background before 368 # do endpoint manipulation 369 [ $addr_nr_ns1 = "0" -a $addr_nr_ns2 = "0" ] || sleep 1 370 371 if [ $addr_nr_ns1 -gt 0 ]; then 372 let add_nr_ns1=addr_nr_ns1 373 counter=2 374 while [ $add_nr_ns1 -gt 0 ]; do 375 local addr 376 if is_v6 "${connect_addr}"; then 377 addr="dead:beef:$counter::1" 378 else 379 addr="10.0.$counter.1" 380 fi 381 ip netns exec $ns1 ./pm_nl_ctl add $addr flags signal 382 let counter+=1 383 let add_nr_ns1-=1 384 done 385 elif [ $addr_nr_ns1 -lt 0 ]; then 386 let rm_nr_ns1=-addr_nr_ns1 387 if [ $rm_nr_ns1 -lt 8 ]; then 388 counter=1 389 pos=1 390 dump=(`ip netns exec ${listener_ns} ./pm_nl_ctl dump`) 391 if [ ${#dump[@]} -gt 0 ]; then 392 while [ $counter -le $rm_nr_ns1 ] 393 do 394 id=${dump[$pos]} 395 rm_addr=$(rm_addr_count ${connector_ns}) 396 ip netns exec ${listener_ns} ./pm_nl_ctl del $id 397 wait_rm_addr ${connector_ns} ${rm_addr} 398 let counter+=1 399 let pos+=5 400 done 401 fi 402 elif [ $rm_nr_ns1 -eq 8 ]; then 403 ip netns exec ${listener_ns} ./pm_nl_ctl flush 404 elif [ $rm_nr_ns1 -eq 9 ]; then 405 ip netns exec ${listener_ns} ./pm_nl_ctl del 0 ${connect_addr} 406 fi 407 fi 408 409 flags="subflow" 410 if [[ "${addr_nr_ns2}" = "fullmesh_"* ]]; then 411 flags="${flags},fullmesh" 412 addr_nr_ns2=${addr_nr_ns2:9} 413 fi 414 415 # if newly added endpoints must be deleted, give the background msk 416 # some time to created them 417 [ $addr_nr_ns1 -gt 0 -a $addr_nr_ns2 -lt 0 ] && sleep 1 418 419 if [ $addr_nr_ns2 -gt 0 ]; then 420 let add_nr_ns2=addr_nr_ns2 421 counter=3 422 while [ $add_nr_ns2 -gt 0 ]; do 423 local addr 424 if is_v6 "${connect_addr}"; then 425 addr="dead:beef:$counter::2" 426 else 427 addr="10.0.$counter.2" 428 fi 429 ip netns exec $ns2 ./pm_nl_ctl add $addr flags $flags 430 let counter+=1 431 let add_nr_ns2-=1 432 done 433 elif [ $addr_nr_ns2 -lt 0 ]; then 434 let rm_nr_ns2=-addr_nr_ns2 435 if [ $rm_nr_ns2 -lt 8 ]; then 436 counter=1 437 pos=1 438 dump=(`ip netns exec ${connector_ns} ./pm_nl_ctl dump`) 439 if [ ${#dump[@]} -gt 0 ]; then 440 while [ $counter -le $rm_nr_ns2 ] 441 do 442 # rm_addr are serialized, allow the previous one to complete 443 id=${dump[$pos]} 444 rm_addr=$(rm_addr_count ${listener_ns}) 445 ip netns exec ${connector_ns} ./pm_nl_ctl del $id 446 wait_rm_addr ${listener_ns} ${rm_addr} 447 let counter+=1 448 let pos+=5 449 done 450 fi 451 elif [ $rm_nr_ns2 -eq 8 ]; then 452 ip netns exec ${connector_ns} ./pm_nl_ctl flush 453 elif [ $rm_nr_ns2 -eq 9 ]; then 454 local addr 455 if is_v6 "${connect_addr}"; then 456 addr="dead:beef:1::2" 457 else 458 addr="10.0.1.2" 459 fi 460 ip netns exec ${connector_ns} ./pm_nl_ctl del 0 $addr 461 fi 462 fi 463 464 if [ ! -z $bkup ]; then 465 sleep 1 466 for netns in "$ns1" "$ns2"; do 467 dump=(`ip netns exec $netns ./pm_nl_ctl dump`) 468 if [ ${#dump[@]} -gt 0 ]; then 469 addr=${dump[${#dump[@]} - 1]} 470 backup="ip netns exec $netns ./pm_nl_ctl set $addr flags $bkup" 471 $backup 472 fi 473 done 474 fi 475 476 wait $cpid 477 retc=$? 478 wait $spid 479 rets=$? 480 481 if [ $capture -eq 1 ]; then 482 sleep 1 483 kill $cappid 484 fi 485 486 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 487 nstat | grep Tcp > /tmp/${listener_ns}.out 488 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 489 nstat | grep Tcp > /tmp/${connector_ns}.out 490 491 if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then 492 echo " client exit code $retc, server $rets" 1>&2 493 echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 494 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port" 495 cat /tmp/${listener_ns}.out 496 echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2 497 ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port" 498 cat /tmp/${connector_ns}.out 499 500 cat "$capout" 501 ret=1 502 return 1 503 fi 504 505 if [ "$test_link_fail" -eq 2 ];then 506 check_transfer $sinfail $cout "file received by client" 507 else 508 check_transfer $sin $cout "file received by client" 509 fi 510 retc=$? 511 if [ "$test_link_fail" -eq 0 ];then 512 check_transfer $cin $sout "file received by server" 513 else 514 check_transfer $cinsent $sout "file received by server" 515 fi 516 rets=$? 517 518 if [ $retc -eq 0 ] && [ $rets -eq 0 ];then 519 cat "$capout" 520 return 0 521 fi 522 523 cat "$capout" 524 return 1 525} 526 527make_file() 528{ 529 name=$1 530 who=$2 531 size=$3 532 533 dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null 534 echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" 535 536 echo "Created $name (size $size KB) containing data sent by $who" 537} 538 539run_tests() 540{ 541 listener_ns="$1" 542 connector_ns="$2" 543 connect_addr="$3" 544 test_linkfail="${4:-0}" 545 addr_nr_ns1="${5:-0}" 546 addr_nr_ns2="${6:-0}" 547 speed="${7:-fast}" 548 bkup="${8:-""}" 549 lret=0 550 oldin="" 551 552 # create the input file for the failure test when 553 # the first failure test run 554 if [ "$test_linkfail" -ne 0 -a -z "$cinfail" ]; then 555 # the client file must be considerably larger 556 # of the maximum expected cwin value, or the 557 # link utilization will be not predicable 558 size=$((RANDOM%2)) 559 size=$((size+1)) 560 size=$((size*8192)) 561 size=$((size + ( $RANDOM % 8192) )) 562 563 cinfail=$(mktemp) 564 make_file "$cinfail" "client" $size 565 fi 566 567 if [ "$test_linkfail" -eq 2 -a -z "$sinfail" ]; then 568 size=$((RANDOM%16)) 569 size=$((size+1)) 570 size=$((size*2048)) 571 572 sinfail=$(mktemp) 573 make_file "$sinfail" "server" $size 574 fi 575 576 do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \ 577 ${test_linkfail} ${addr_nr_ns1} ${addr_nr_ns2} ${speed} ${bkup} 578 lret=$? 579} 580 581dump_stats() 582{ 583 echo Server ns stats 584 ip netns exec $ns1 nstat -as | grep Tcp 585 echo Client ns stats 586 ip netns exec $ns2 nstat -as | grep Tcp 587} 588 589chk_csum_nr() 590{ 591 local msg=${1:-""} 592 local count 593 local dump_stats 594 595 if [ ! -z "$msg" ]; then 596 printf "%02u" "$TEST_COUNT" 597 else 598 echo -n " " 599 fi 600 printf " %-36s %s" "$msg" "sum" 601 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'` 602 [ -z "$count" ] && count=0 603 if [ "$count" != 0 ]; then 604 echo "[fail] got $count data checksum error[s] expected 0" 605 ret=1 606 dump_stats=1 607 else 608 echo -n "[ ok ]" 609 fi 610 echo -n " - csum " 611 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'` 612 [ -z "$count" ] && count=0 613 if [ "$count" != 0 ]; then 614 echo "[fail] got $count data checksum error[s] expected 0" 615 ret=1 616 dump_stats=1 617 else 618 echo "[ ok ]" 619 fi 620 [ "${dump_stats}" = 1 ] && dump_stats 621} 622 623chk_fail_nr() 624{ 625 local mp_fail_nr_tx=$1 626 local mp_fail_nr_rx=$2 627 local count 628 local dump_stats 629 630 printf "%-39s %s" " " "ftx" 631 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPFailTx | awk '{print $2}'` 632 [ -z "$count" ] && count=0 633 if [ "$count" != "$mp_fail_nr_tx" ]; then 634 echo "[fail] got $count MP_FAIL[s] TX expected $mp_fail_nr_tx" 635 ret=1 636 dump_stats=1 637 else 638 echo -n "[ ok ]" 639 fi 640 641 echo -n " - frx " 642 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPFailRx | awk '{print $2}'` 643 [ -z "$count" ] && count=0 644 if [ "$count" != "$mp_fail_nr_rx" ]; then 645 echo "[fail] got $count MP_FAIL[s] RX expected $mp_fail_nr_rx" 646 ret=1 647 dump_stats=1 648 else 649 echo "[ ok ]" 650 fi 651 652 [ "${dump_stats}" = 1 ] && dump_stats 653} 654 655chk_join_nr() 656{ 657 local msg="$1" 658 local syn_nr=$2 659 local syn_ack_nr=$3 660 local ack_nr=$4 661 local count 662 local dump_stats 663 664 printf "%02u %-36s %s" "$TEST_COUNT" "$msg" "syn" 665 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'` 666 [ -z "$count" ] && count=0 667 if [ "$count" != "$syn_nr" ]; then 668 echo "[fail] got $count JOIN[s] syn expected $syn_nr" 669 ret=1 670 dump_stats=1 671 else 672 echo -n "[ ok ]" 673 fi 674 675 echo -n " - synack" 676 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'` 677 [ -z "$count" ] && count=0 678 if [ "$count" != "$syn_ack_nr" ]; then 679 echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr" 680 ret=1 681 dump_stats=1 682 else 683 echo -n "[ ok ]" 684 fi 685 686 echo -n " - ack" 687 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'` 688 [ -z "$count" ] && count=0 689 if [ "$count" != "$ack_nr" ]; then 690 echo "[fail] got $count JOIN[s] ack expected $ack_nr" 691 ret=1 692 dump_stats=1 693 else 694 echo "[ ok ]" 695 fi 696 [ "${dump_stats}" = 1 ] && dump_stats 697 if [ $checksum -eq 1 ]; then 698 chk_csum_nr 699 chk_fail_nr 0 0 700 fi 701} 702 703# a negative value for 'stale_max' means no upper bound: 704# for bidirectional transfer, if one peer sleep for a while 705# - as these tests do - we can have a quite high number of 706# stale/recover conversions, proportional to 707# sleep duration/ MPTCP-level RTX interval. 708chk_stale_nr() 709{ 710 local ns=$1 711 local stale_min=$2 712 local stale_max=$3 713 local stale_delta=$4 714 local dump_stats 715 local stale_nr 716 local recover_nr 717 718 printf "%-39s %-18s" " " "stale" 719 stale_nr=`ip netns exec $ns nstat -as | grep MPTcpExtSubflowStale | awk '{print $2}'` 720 [ -z "$stale_nr" ] && stale_nr=0 721 recover_nr=`ip netns exec $ns nstat -as | grep MPTcpExtSubflowRecover | awk '{print $2}'` 722 [ -z "$recover_nr" ] && recover_nr=0 723 724 if [ $stale_nr -lt $stale_min ] || 725 [ $stale_max -gt 0 -a $stale_nr -gt $stale_max ] || 726 [ $((stale_nr - $recover_nr)) -ne $stale_delta ]; then 727 echo "[fail] got $stale_nr stale[s] $recover_nr recover[s], " \ 728 " expected stale in range [$stale_min..$stale_max]," \ 729 " stale-recover delta $stale_delta " 730 ret=1 731 dump_stats=1 732 else 733 echo "[ ok ]" 734 fi 735 736 if [ "${dump_stats}" = 1 ]; then 737 echo $ns stats 738 ip netns exec $ns ip -s link show 739 ip netns exec $ns nstat -as | grep MPTcp 740 fi 741} 742 743chk_add_nr() 744{ 745 local add_nr=$1 746 local echo_nr=$2 747 local port_nr=${3:-0} 748 local syn_nr=${4:-$port_nr} 749 local syn_ack_nr=${5:-$port_nr} 750 local ack_nr=${6:-$port_nr} 751 local mis_syn_nr=${7:-0} 752 local mis_ack_nr=${8:-0} 753 local count 754 local dump_stats 755 756 printf "%-39s %s" " " "add" 757 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtAddAddr | awk '{print $2}'` 758 [ -z "$count" ] && count=0 759 if [ "$count" != "$add_nr" ]; then 760 echo "[fail] got $count ADD_ADDR[s] expected $add_nr" 761 ret=1 762 dump_stats=1 763 else 764 echo -n "[ ok ]" 765 fi 766 767 echo -n " - echo " 768 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtEchoAdd | awk '{print $2}'` 769 [ -z "$count" ] && count=0 770 if [ "$count" != "$echo_nr" ]; then 771 echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr" 772 ret=1 773 dump_stats=1 774 else 775 echo -n "[ ok ]" 776 fi 777 778 if [ $port_nr -gt 0 ]; then 779 echo -n " - pt " 780 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtPortAdd | awk '{print $2}'` 781 [ -z "$count" ] && count=0 782 if [ "$count" != "$port_nr" ]; then 783 echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr" 784 ret=1 785 dump_stats=1 786 else 787 echo "[ ok ]" 788 fi 789 790 printf "%-39s %s" " " "syn" 791 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortSynRx | 792 awk '{print $2}'` 793 [ -z "$count" ] && count=0 794 if [ "$count" != "$syn_nr" ]; then 795 echo "[fail] got $count JOIN[s] syn with a different \ 796 port-number expected $syn_nr" 797 ret=1 798 dump_stats=1 799 else 800 echo -n "[ ok ]" 801 fi 802 803 echo -n " - synack" 804 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinPortSynAckRx | 805 awk '{print $2}'` 806 [ -z "$count" ] && count=0 807 if [ "$count" != "$syn_ack_nr" ]; then 808 echo "[fail] got $count JOIN[s] synack with a different \ 809 port-number expected $syn_ack_nr" 810 ret=1 811 dump_stats=1 812 else 813 echo -n "[ ok ]" 814 fi 815 816 echo -n " - ack" 817 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortAckRx | 818 awk '{print $2}'` 819 [ -z "$count" ] && count=0 820 if [ "$count" != "$ack_nr" ]; then 821 echo "[fail] got $count JOIN[s] ack with a different \ 822 port-number expected $ack_nr" 823 ret=1 824 dump_stats=1 825 else 826 echo "[ ok ]" 827 fi 828 829 printf "%-39s %s" " " "syn" 830 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortSynRx | 831 awk '{print $2}'` 832 [ -z "$count" ] && count=0 833 if [ "$count" != "$mis_syn_nr" ]; then 834 echo "[fail] got $count JOIN[s] syn with a mismatched \ 835 port-number expected $mis_syn_nr" 836 ret=1 837 dump_stats=1 838 else 839 echo -n "[ ok ]" 840 fi 841 842 echo -n " - ack " 843 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortAckRx | 844 awk '{print $2}'` 845 [ -z "$count" ] && count=0 846 if [ "$count" != "$mis_ack_nr" ]; then 847 echo "[fail] got $count JOIN[s] ack with a mismatched \ 848 port-number expected $mis_ack_nr" 849 ret=1 850 dump_stats=1 851 else 852 echo "[ ok ]" 853 fi 854 else 855 echo "" 856 fi 857 858 [ "${dump_stats}" = 1 ] && dump_stats 859} 860 861chk_rm_nr() 862{ 863 local rm_addr_nr=$1 864 local rm_subflow_nr=$2 865 local invert=${3:-""} 866 local count 867 local dump_stats 868 local addr_ns 869 local subflow_ns 870 871 if [ -z $invert ]; then 872 addr_ns=$ns1 873 subflow_ns=$ns2 874 elif [ $invert = "invert" ]; then 875 addr_ns=$ns2 876 subflow_ns=$ns1 877 fi 878 879 printf "%-39s %s" " " "rm " 880 count=`ip netns exec $addr_ns nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'` 881 [ -z "$count" ] && count=0 882 if [ "$count" != "$rm_addr_nr" ]; then 883 echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" 884 ret=1 885 dump_stats=1 886 else 887 echo -n "[ ok ]" 888 fi 889 890 echo -n " - sf " 891 count=`ip netns exec $subflow_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'` 892 [ -z "$count" ] && count=0 893 if [ "$count" != "$rm_subflow_nr" ]; then 894 echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr" 895 ret=1 896 dump_stats=1 897 else 898 echo "[ ok ]" 899 fi 900 901 [ "${dump_stats}" = 1 ] && dump_stats 902} 903 904chk_prio_nr() 905{ 906 local mp_prio_nr_tx=$1 907 local mp_prio_nr_rx=$2 908 local count 909 local dump_stats 910 911 printf "%-39s %s" " " "ptx" 912 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}'` 913 [ -z "$count" ] && count=0 914 if [ "$count" != "$mp_prio_nr_tx" ]; then 915 echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" 916 ret=1 917 dump_stats=1 918 else 919 echo -n "[ ok ]" 920 fi 921 922 echo -n " - prx " 923 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}'` 924 [ -z "$count" ] && count=0 925 if [ "$count" != "$mp_prio_nr_rx" ]; then 926 echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" 927 ret=1 928 dump_stats=1 929 else 930 echo "[ ok ]" 931 fi 932 933 [ "${dump_stats}" = 1 ] && dump_stats 934} 935 936chk_link_usage() 937{ 938 local ns=$1 939 local link=$2 940 local out=$3 941 local expected_rate=$4 942 local tx_link=`ip netns exec $ns cat /sys/class/net/$link/statistics/tx_bytes` 943 local tx_total=`ls -l $out | awk '{print $5}'` 944 local tx_rate=$((tx_link * 100 / $tx_total)) 945 local tolerance=5 946 947 printf "%-39s %-18s" " " "link usage" 948 if [ $tx_rate -lt $((expected_rate - $tolerance)) -o \ 949 $tx_rate -gt $((expected_rate + $tolerance)) ]; then 950 echo "[fail] got $tx_rate% usage, expected $expected_rate%" 951 ret=1 952 else 953 echo "[ ok ]" 954 fi 955} 956 957wait_for_tw() 958{ 959 local timeout_ms=$((timeout_poll * 1000)) 960 local time=0 961 local ns=$1 962 963 while [ $time -lt $timeout_ms ]; do 964 local cnt=$(ip netns exec $ns ss -t state time-wait |wc -l) 965 966 [ "$cnt" = 1 ] && return 1 967 time=$((time + 100)) 968 sleep 0.1 969 done 970 return 1 971} 972 973subflows_tests() 974{ 975 reset 976 run_tests $ns1 $ns2 10.0.1.1 977 chk_join_nr "no JOIN" "0" "0" "0" 978 979 # subflow limited by client 980 reset 981 ip netns exec $ns1 ./pm_nl_ctl limits 0 0 982 ip netns exec $ns2 ./pm_nl_ctl limits 0 0 983 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 984 run_tests $ns1 $ns2 10.0.1.1 985 chk_join_nr "single subflow, limited by client" 0 0 0 986 987 # subflow limited by server 988 reset 989 ip netns exec $ns1 ./pm_nl_ctl limits 0 0 990 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 991 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 992 run_tests $ns1 $ns2 10.0.1.1 993 chk_join_nr "single subflow, limited by server" 1 1 0 994 995 # subflow 996 reset 997 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 998 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 999 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1000 run_tests $ns1 $ns2 10.0.1.1 1001 chk_join_nr "single subflow" 1 1 1 1002 1003 # multiple subflows 1004 reset 1005 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1006 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1007 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1008 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 1009 run_tests $ns1 $ns2 10.0.1.1 1010 chk_join_nr "multiple subflows" 2 2 2 1011 1012 # multiple subflows limited by server 1013 reset 1014 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1015 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1016 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1017 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 1018 run_tests $ns1 $ns2 10.0.1.1 1019 chk_join_nr "multiple subflows, limited by server" 2 2 1 1020 1021 # single subflow, dev 1022 reset 1023 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1024 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1025 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow dev ns2eth3 1026 run_tests $ns1 $ns2 10.0.1.1 1027 chk_join_nr "single subflow, dev" 1 1 1 1028} 1029 1030subflows_error_tests() 1031{ 1032 # If a single subflow is configured, and matches the MPC src 1033 # address, no additional subflow should be created 1034 reset 1035 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1036 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1037 ip netns exec $ns2 ./pm_nl_ctl add 10.0.1.2 flags subflow 1038 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 1039 chk_join_nr "no MPC reuse with single endpoint" 0 0 0 1040 1041 # multiple subflows, with subflow creation error 1042 reset 1043 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1044 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1045 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1046 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 1047 ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT 1048 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 1049 chk_join_nr "multi subflows, with failing subflow" 1 1 1 1050 1051 # multiple subflows, with subflow timeout on MPJ 1052 reset 1053 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1054 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1055 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1056 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 1057 ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j DROP 1058 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 1059 chk_join_nr "multi subflows, with subflow timeout" 1 1 1 1060 1061 # multiple subflows, check that the endpoint corresponding to 1062 # closed subflow (due to reset) is not reused if additional 1063 # subflows are added later 1064 reset 1065 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1066 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1067 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1068 ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT 1069 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow & 1070 1071 # updates in the child shell do not have any effect here, we 1072 # need to bump the test counter for the above case 1073 TEST_COUNT=$((TEST_COUNT+1)) 1074 1075 # mpj subflow will be in TW after the reset 1076 wait_for_tw $ns2 1077 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 1078 wait 1079 1080 # additional subflow could be created only if the PM select 1081 # the later endpoint, skipping the already used one 1082 chk_join_nr "multi subflows, fair usage on close" 1 1 1 1083} 1084 1085signal_address_tests() 1086{ 1087 # add_address, unused 1088 reset 1089 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1090 run_tests $ns1 $ns2 10.0.1.1 1091 chk_join_nr "unused signal address" 0 0 0 1092 chk_add_nr 1 1 1093 1094 # accept and use add_addr 1095 reset 1096 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1097 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1098 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1099 run_tests $ns1 $ns2 10.0.1.1 1100 chk_join_nr "signal address" 1 1 1 1101 chk_add_nr 1 1 1102 1103 # accept and use add_addr with an additional subflow 1104 # note: signal address in server ns and local addresses in client ns must 1105 # belong to different subnets or one of the listed local address could be 1106 # used for 'add_addr' subflow 1107 reset 1108 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1109 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1110 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1111 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1112 run_tests $ns1 $ns2 10.0.1.1 1113 chk_join_nr "subflow and signal" 2 2 2 1114 chk_add_nr 1 1 1115 1116 # accept and use add_addr with additional subflows 1117 reset 1118 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 1119 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1120 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 1121 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1122 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 1123 run_tests $ns1 $ns2 10.0.1.1 1124 chk_join_nr "multiple subflows and signal" 3 3 3 1125 chk_add_nr 1 1 1126 1127 # signal addresses 1128 reset 1129 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 1130 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1131 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 1132 ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal 1133 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 1134 run_tests $ns1 $ns2 10.0.1.1 1135 chk_join_nr "signal addresses" 3 3 3 1136 chk_add_nr 3 3 1137 1138 # signal invalid addresses 1139 reset 1140 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 1141 ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal 1142 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 1143 ip netns exec $ns1 ./pm_nl_ctl add 10.0.14.1 flags signal 1144 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 1145 run_tests $ns1 $ns2 10.0.1.1 1146 chk_join_nr "signal invalid addresses" 1 1 1 1147 chk_add_nr 3 3 1148 1149 # signal addresses race test 1150 reset 1151 ip netns exec $ns1 ./pm_nl_ctl limits 4 4 1152 ip netns exec $ns2 ./pm_nl_ctl limits 4 4 1153 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 flags signal 1154 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1155 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 1156 ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal 1157 ip netns exec $ns2 ./pm_nl_ctl add 10.0.1.2 flags signal 1158 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags signal 1159 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags signal 1160 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags signal 1161 run_tests $ns1 $ns2 10.0.1.1 1162 1163 # the server will not signal the address terminating 1164 # the MPC subflow 1165 chk_add_nr 3 3 1166} 1167 1168link_failure_tests() 1169{ 1170 # accept and use add_addr with additional subflows and link loss 1171 reset 1172 1173 # without any b/w limit each veth could spool the packets and get 1174 # them acked at xmit time, so that the corresponding subflow will 1175 # have almost always no outstanding pkts, the scheduler will pick 1176 # always the first subflow and we will have hard time testing 1177 # active backup and link switch-over. 1178 # Let's set some arbitrary (low) virtual link limits. 1179 init_shapers 1180 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 1181 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 dev ns1eth2 flags signal 1182 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 1183 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 dev ns2eth3 flags subflow 1184 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 dev ns2eth4 flags subflow 1185 run_tests $ns1 $ns2 10.0.1.1 1 1186 chk_join_nr "multiple flows, signal, link failure" 3 3 3 1187 chk_add_nr 1 1 1188 chk_stale_nr $ns2 1 5 1 1189 1190 # accept and use add_addr with additional subflows and link loss 1191 # for bidirectional transfer 1192 reset 1193 init_shapers 1194 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 1195 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 dev ns1eth2 flags signal 1196 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 1197 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 dev ns2eth3 flags subflow 1198 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 dev ns2eth4 flags subflow 1199 run_tests $ns1 $ns2 10.0.1.1 2 1200 chk_join_nr "multi flows, signal, bidi, link fail" 3 3 3 1201 chk_add_nr 1 1 1202 chk_stale_nr $ns2 1 -1 1 1203 1204 # 2 subflows plus 1 backup subflow with a lossy link, backup 1205 # will never be used 1206 reset 1207 init_shapers 1208 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1209 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 dev ns1eth2 flags signal 1210 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1211 export FAILING_LINKS="1" 1212 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 dev ns2eth3 flags subflow,backup 1213 run_tests $ns1 $ns2 10.0.1.1 1 1214 chk_join_nr "backup subflow unused, link failure" 2 2 2 1215 chk_add_nr 1 1 1216 chk_link_usage $ns2 ns2eth3 $cinsent 0 1217 1218 # 2 lossy links after half transfer, backup will get half of 1219 # the traffic 1220 reset 1221 init_shapers 1222 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1223 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 dev ns1eth2 flags signal 1224 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1225 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 dev ns2eth3 flags subflow,backup 1226 export FAILING_LINKS="1 2" 1227 run_tests $ns1 $ns2 10.0.1.1 1 1228 chk_join_nr "backup flow used, multi links fail" 2 2 2 1229 chk_add_nr 1 1 1230 chk_stale_nr $ns2 2 4 2 1231 chk_link_usage $ns2 ns2eth3 $cinsent 50 1232 1233 # use a backup subflow with the first subflow on a lossy link 1234 # for bidirectional transfer 1235 reset 1236 init_shapers 1237 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1238 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 dev ns1eth2 flags signal 1239 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 1240 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 dev ns2eth3 flags subflow,backup 1241 run_tests $ns1 $ns2 10.0.1.1 2 1242 chk_join_nr "backup flow used, bidi, link failure" 2 2 2 1243 chk_add_nr 1 1 1244 chk_stale_nr $ns2 1 -1 2 1245 chk_link_usage $ns2 ns2eth3 $cinsent 50 1246} 1247 1248add_addr_timeout_tests() 1249{ 1250 # add_addr timeout 1251 reset_with_add_addr_timeout 1252 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1253 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1254 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1255 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 1256 chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1 1257 chk_add_nr 4 0 1258 1259 # add_addr timeout IPv6 1260 reset_with_add_addr_timeout 6 1261 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1262 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1263 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1264 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1265 chk_join_nr "signal address, ADD_ADDR6 timeout" 1 1 1 1266 chk_add_nr 4 0 1267 1268 # signal addresses timeout 1269 reset_with_add_addr_timeout 1270 ip netns exec $ns1 ./pm_nl_ctl limits 2 2 1271 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1272 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 1273 ip netns exec $ns2 ./pm_nl_ctl limits 2 2 1274 run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 1275 chk_join_nr "signal addresses, ADD_ADDR timeout" 2 2 2 1276 chk_add_nr 8 0 1277 1278 # signal invalid addresses timeout 1279 reset_with_add_addr_timeout 1280 ip netns exec $ns1 ./pm_nl_ctl limits 2 2 1281 ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal 1282 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 1283 ip netns exec $ns2 ./pm_nl_ctl limits 2 2 1284 run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 1285 chk_join_nr "invalid address, ADD_ADDR timeout" 1 1 1 1286 chk_add_nr 8 0 1287} 1288 1289remove_tests() 1290{ 1291 # single subflow, remove 1292 reset 1293 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1294 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1295 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1296 run_tests $ns1 $ns2 10.0.1.1 0 0 -1 slow 1297 chk_join_nr "remove single subflow" 1 1 1 1298 chk_rm_nr 1 1 1299 1300 # multiple subflows, remove 1301 reset 1302 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1303 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1304 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 1305 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1306 run_tests $ns1 $ns2 10.0.1.1 0 0 -2 slow 1307 chk_join_nr "remove multiple subflows" 2 2 2 1308 chk_rm_nr 2 2 1309 1310 # single address, remove 1311 reset 1312 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1313 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1314 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1315 run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 1316 chk_join_nr "remove single address" 1 1 1 1317 chk_add_nr 1 1 1318 chk_rm_nr 1 1 invert 1319 1320 # subflow and signal, remove 1321 reset 1322 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1323 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1324 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1325 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1326 run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 1327 chk_join_nr "remove subflow and signal" 2 2 2 1328 chk_add_nr 1 1 1329 chk_rm_nr 1 1 1330 1331 # subflows and signal, remove 1332 reset 1333 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 1334 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1335 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 1336 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1337 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 1338 run_tests $ns1 $ns2 10.0.1.1 0 -1 -2 slow 1339 chk_join_nr "remove subflows and signal" 3 3 3 1340 chk_add_nr 1 1 1341 chk_rm_nr 2 2 1342 1343 # addresses remove 1344 reset 1345 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 1346 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal id 250 1347 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 1348 ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal 1349 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 1350 run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 1351 chk_join_nr "remove addresses" 3 3 3 1352 chk_add_nr 3 3 1353 chk_rm_nr 3 3 invert 1354 1355 # invalid addresses remove 1356 reset 1357 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 1358 ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal 1359 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 1360 ip netns exec $ns1 ./pm_nl_ctl add 10.0.14.1 flags signal 1361 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 1362 run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 1363 chk_join_nr "remove invalid addresses" 1 1 1 1364 chk_add_nr 3 3 1365 chk_rm_nr 3 1 invert 1366 1367 # subflows and signal, flush 1368 reset 1369 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 1370 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1371 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 1372 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1373 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 1374 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1375 chk_join_nr "flush subflows and signal" 3 3 3 1376 chk_add_nr 1 1 1377 chk_rm_nr 2 2 1378 1379 # subflows flush 1380 reset 1381 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 1382 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 1383 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow id 150 1384 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1385 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 1386 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1387 chk_join_nr "flush subflows" 3 3 3 1388 chk_rm_nr 3 3 1389 1390 # addresses flush 1391 reset 1392 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 1393 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal id 250 1394 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 1395 ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal 1396 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 1397 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1398 chk_join_nr "flush addresses" 3 3 3 1399 chk_add_nr 3 3 1400 chk_rm_nr 3 3 invert 1401 1402 # invalid addresses flush 1403 reset 1404 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 1405 ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal 1406 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 1407 ip netns exec $ns1 ./pm_nl_ctl add 10.0.14.1 flags signal 1408 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 1409 run_tests $ns1 $ns2 10.0.1.1 0 -8 0 slow 1410 chk_join_nr "flush invalid addresses" 1 1 1 1411 chk_add_nr 3 3 1412 chk_rm_nr 3 1 invert 1413 1414 # remove id 0 subflow 1415 reset 1416 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1417 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1418 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1419 run_tests $ns1 $ns2 10.0.1.1 0 0 -9 slow 1420 chk_join_nr "remove id 0 subflow" 1 1 1 1421 chk_rm_nr 1 1 1422 1423 # remove id 0 address 1424 reset 1425 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1426 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1427 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1428 run_tests $ns1 $ns2 10.0.1.1 0 -9 0 slow 1429 chk_join_nr "remove id 0 address" 1 1 1 1430 chk_add_nr 1 1 1431 chk_rm_nr 1 1 invert 1432} 1433 1434add_tests() 1435{ 1436 # add single subflow 1437 reset 1438 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1439 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1440 run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow 1441 chk_join_nr "add single subflow" 1 1 1 1442 1443 # add signal address 1444 reset 1445 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1446 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1447 run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 1448 chk_join_nr "add signal address" 1 1 1 1449 chk_add_nr 1 1 1450 1451 # add multiple subflows 1452 reset 1453 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1454 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1455 run_tests $ns1 $ns2 10.0.1.1 0 0 2 slow 1456 chk_join_nr "add multiple subflows" 2 2 2 1457 1458 # add multiple subflows IPv6 1459 reset 1460 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1461 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1462 run_tests $ns1 $ns2 dead:beef:1::1 0 0 2 slow 1463 chk_join_nr "add multiple subflows IPv6" 2 2 2 1464 1465 # add multiple addresses IPv6 1466 reset 1467 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1468 ip netns exec $ns2 ./pm_nl_ctl limits 2 2 1469 run_tests $ns1 $ns2 dead:beef:1::1 0 2 0 slow 1470 chk_join_nr "add multiple addresses IPv6" 2 2 2 1471 chk_add_nr 2 2 1472} 1473 1474ipv6_tests() 1475{ 1476 # subflow IPv6 1477 reset 1478 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1479 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1480 ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 dev ns2eth3 flags subflow 1481 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1482 chk_join_nr "single subflow IPv6" 1 1 1 1483 1484 # add_address, unused IPv6 1485 reset 1486 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1487 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1488 chk_join_nr "unused signal address IPv6" 0 0 0 1489 chk_add_nr 1 1 1490 1491 # signal address IPv6 1492 reset 1493 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1494 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1495 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1496 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1497 chk_join_nr "single address IPv6" 1 1 1 1498 chk_add_nr 1 1 1499 1500 # single address IPv6, remove 1501 reset 1502 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1503 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1504 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1505 run_tests $ns1 $ns2 dead:beef:1::1 0 -1 0 slow 1506 chk_join_nr "remove single address IPv6" 1 1 1 1507 chk_add_nr 1 1 1508 chk_rm_nr 1 1 invert 1509 1510 # subflow and signal IPv6, remove 1511 reset 1512 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1513 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1514 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1515 ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 dev ns2eth3 flags subflow 1516 run_tests $ns1 $ns2 dead:beef:1::1 0 -1 -1 slow 1517 chk_join_nr "remove subflow and signal IPv6" 2 2 2 1518 chk_add_nr 1 1 1519 chk_rm_nr 1 1 1520} 1521 1522v4mapped_tests() 1523{ 1524 # subflow IPv4-mapped to IPv4-mapped 1525 reset 1526 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1527 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1528 ip netns exec $ns2 ./pm_nl_ctl add "::ffff:10.0.3.2" flags subflow 1529 run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1530 chk_join_nr "single subflow IPv4-mapped" 1 1 1 1531 1532 # signal address IPv4-mapped with IPv4-mapped sk 1533 reset 1534 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1535 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1536 ip netns exec $ns1 ./pm_nl_ctl add "::ffff:10.0.2.1" flags signal 1537 run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1538 chk_join_nr "signal address IPv4-mapped" 1 1 1 1539 chk_add_nr 1 1 1540 1541 # subflow v4-map-v6 1542 reset 1543 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1544 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1545 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1546 run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1547 chk_join_nr "single subflow v4-map-v6" 1 1 1 1548 1549 # signal address v4-map-v6 1550 reset 1551 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1552 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1553 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1554 run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1555 chk_join_nr "signal address v4-map-v6" 1 1 1 1556 chk_add_nr 1 1 1557 1558 # subflow v6-map-v4 1559 reset 1560 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1561 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1562 ip netns exec $ns2 ./pm_nl_ctl add "::ffff:10.0.3.2" flags subflow 1563 run_tests $ns1 $ns2 10.0.1.1 1564 chk_join_nr "single subflow v6-map-v4" 1 1 1 1565 1566 # signal address v6-map-v4 1567 reset 1568 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1569 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1570 ip netns exec $ns1 ./pm_nl_ctl add "::ffff:10.0.2.1" flags signal 1571 run_tests $ns1 $ns2 10.0.1.1 1572 chk_join_nr "signal address v6-map-v4" 1 1 1 1573 chk_add_nr 1 1 1574 1575 # no subflow IPv6 to v4 address 1576 reset 1577 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1578 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1579 ip netns exec $ns2 ./pm_nl_ctl add dead:beef:2::2 flags subflow 1580 run_tests $ns1 $ns2 10.0.1.1 1581 chk_join_nr "no JOIN with diff families v4-v6" 0 0 0 1582 1583 # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end 1584 reset 1585 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1586 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1587 ip netns exec $ns2 ./pm_nl_ctl add dead:beef:2::10.0.3.2 flags subflow 1588 run_tests $ns1 $ns2 10.0.1.1 1589 chk_join_nr "no JOIN with diff families v4-v6-2" 0 0 0 1590 1591 # no subflow IPv4 to v6 address, no need to slow down too then 1592 reset 1593 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1594 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1595 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1596 run_tests $ns1 $ns2 dead:beef:1::1 1597 chk_join_nr "no JOIN with diff families v6-v4" 0 0 0 1598} 1599 1600backup_tests() 1601{ 1602 # single subflow, backup 1603 reset 1604 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1605 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1606 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow,backup 1607 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup 1608 chk_join_nr "single subflow, backup" 1 1 1 1609 chk_prio_nr 0 1 1610 1611 # single address, backup 1612 reset 1613 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1614 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1615 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1616 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup 1617 chk_join_nr "single address, backup" 1 1 1 1618 chk_add_nr 1 1 1619 chk_prio_nr 1 0 1620} 1621 1622add_addr_ports_tests() 1623{ 1624 # signal address with port 1625 reset 1626 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1627 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1628 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1629 run_tests $ns1 $ns2 10.0.1.1 1630 chk_join_nr "signal address with port" 1 1 1 1631 chk_add_nr 1 1 1 1632 1633 # subflow and signal with port 1634 reset 1635 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1636 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1637 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1638 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1639 run_tests $ns1 $ns2 10.0.1.1 1640 chk_join_nr "subflow and signal with port" 2 2 2 1641 chk_add_nr 1 1 1 1642 1643 # single address with port, remove 1644 reset 1645 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1646 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1647 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1648 run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 1649 chk_join_nr "remove single address with port" 1 1 1 1650 chk_add_nr 1 1 1 1651 chk_rm_nr 1 1 invert 1652 1653 # subflow and signal with port, remove 1654 reset 1655 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1656 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1657 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1658 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1659 run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 1660 chk_join_nr "remove subflow and signal with port" 2 2 2 1661 chk_add_nr 1 1 1 1662 chk_rm_nr 1 1 1663 1664 # subflows and signal with port, flush 1665 reset 1666 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 1667 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1668 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 1669 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1670 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 1671 run_tests $ns1 $ns2 10.0.1.1 0 -8 -2 slow 1672 chk_join_nr "flush subflows and signal with port" 3 3 3 1673 chk_add_nr 1 1 1674 chk_rm_nr 2 2 1675 1676 # multiple addresses with port 1677 reset 1678 ip netns exec $ns1 ./pm_nl_ctl limits 2 2 1679 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1680 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal port 10100 1681 ip netns exec $ns2 ./pm_nl_ctl limits 2 2 1682 run_tests $ns1 $ns2 10.0.1.1 1683 chk_join_nr "multiple addresses with port" 2 2 2 1684 chk_add_nr 2 2 2 1685 1686 # multiple addresses with ports 1687 reset 1688 ip netns exec $ns1 ./pm_nl_ctl limits 2 2 1689 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1690 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal port 10101 1691 ip netns exec $ns2 ./pm_nl_ctl limits 2 2 1692 run_tests $ns1 $ns2 10.0.1.1 1693 chk_join_nr "multiple addresses with ports" 2 2 2 1694 chk_add_nr 2 2 2 1695} 1696 1697syncookies_tests() 1698{ 1699 # single subflow, syncookies 1700 reset_with_cookies 1701 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1702 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1703 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1704 run_tests $ns1 $ns2 10.0.1.1 1705 chk_join_nr "single subflow with syn cookies" 1 1 1 1706 1707 # multiple subflows with syn cookies 1708 reset_with_cookies 1709 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1710 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1711 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1712 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 1713 run_tests $ns1 $ns2 10.0.1.1 1714 chk_join_nr "multiple subflows with syn cookies" 2 2 2 1715 1716 # multiple subflows limited by server 1717 reset_with_cookies 1718 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1719 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1720 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1721 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 1722 run_tests $ns1 $ns2 10.0.1.1 1723 chk_join_nr "subflows limited by server w cookies" 2 1 1 1724 1725 # test signal address with cookies 1726 reset_with_cookies 1727 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1728 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1729 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1730 run_tests $ns1 $ns2 10.0.1.1 1731 chk_join_nr "signal address with syn cookies" 1 1 1 1732 chk_add_nr 1 1 1733 1734 # test cookie with subflow and signal 1735 reset_with_cookies 1736 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1737 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1738 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1739 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1740 run_tests $ns1 $ns2 10.0.1.1 1741 chk_join_nr "subflow and signal w cookies" 2 2 2 1742 chk_add_nr 1 1 1743 1744 # accept and use add_addr with additional subflows 1745 reset_with_cookies 1746 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 1747 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1748 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 1749 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1750 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 1751 run_tests $ns1 $ns2 10.0.1.1 1752 chk_join_nr "subflows and signal w. cookies" 3 3 3 1753 chk_add_nr 1 1 1754} 1755 1756checksum_tests() 1757{ 1758 # checksum test 0 0 1759 reset_with_checksum 0 0 1760 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1761 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1762 run_tests $ns1 $ns2 10.0.1.1 1763 chk_csum_nr "checksum test 0 0" 1764 1765 # checksum test 1 1 1766 reset_with_checksum 1 1 1767 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1768 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1769 run_tests $ns1 $ns2 10.0.1.1 1770 chk_csum_nr "checksum test 1 1" 1771 1772 # checksum test 0 1 1773 reset_with_checksum 0 1 1774 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1775 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1776 run_tests $ns1 $ns2 10.0.1.1 1777 chk_csum_nr "checksum test 0 1" 1778 1779 # checksum test 1 0 1780 reset_with_checksum 1 0 1781 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1782 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1783 run_tests $ns1 $ns2 10.0.1.1 1784 chk_csum_nr "checksum test 1 0" 1785} 1786 1787deny_join_id0_tests() 1788{ 1789 # subflow allow join id0 ns1 1790 reset_with_allow_join_id0 1 0 1791 ip netns exec $ns1 ./pm_nl_ctl limits 1 1 1792 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1793 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1794 run_tests $ns1 $ns2 10.0.1.1 1795 chk_join_nr "single subflow allow join id0 ns1" 1 1 1 1796 1797 # subflow allow join id0 ns2 1798 reset_with_allow_join_id0 0 1 1799 ip netns exec $ns1 ./pm_nl_ctl limits 1 1 1800 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1801 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1802 run_tests $ns1 $ns2 10.0.1.1 1803 chk_join_nr "single subflow allow join id0 ns2" 0 0 0 1804 1805 # signal address allow join id0 ns1 1806 # ADD_ADDRs are not affected by allow_join_id0 value. 1807 reset_with_allow_join_id0 1 0 1808 ip netns exec $ns1 ./pm_nl_ctl limits 1 1 1809 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1810 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1811 run_tests $ns1 $ns2 10.0.1.1 1812 chk_join_nr "signal address allow join id0 ns1" 1 1 1 1813 chk_add_nr 1 1 1814 1815 # signal address allow join id0 ns2 1816 # ADD_ADDRs are not affected by allow_join_id0 value. 1817 reset_with_allow_join_id0 0 1 1818 ip netns exec $ns1 ./pm_nl_ctl limits 1 1 1819 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1820 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1821 run_tests $ns1 $ns2 10.0.1.1 1822 chk_join_nr "signal address allow join id0 ns2" 1 1 1 1823 chk_add_nr 1 1 1824 1825 # subflow and address allow join id0 ns1 1826 reset_with_allow_join_id0 1 0 1827 ip netns exec $ns1 ./pm_nl_ctl limits 2 2 1828 ip netns exec $ns2 ./pm_nl_ctl limits 2 2 1829 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1830 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1831 run_tests $ns1 $ns2 10.0.1.1 1832 chk_join_nr "subflow and address allow join id0 1" 2 2 2 1833 1834 # subflow and address allow join id0 ns2 1835 reset_with_allow_join_id0 0 1 1836 ip netns exec $ns1 ./pm_nl_ctl limits 2 2 1837 ip netns exec $ns2 ./pm_nl_ctl limits 2 2 1838 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1839 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1840 run_tests $ns1 $ns2 10.0.1.1 1841 chk_join_nr "subflow and address allow join id0 2" 1 1 1 1842} 1843 1844fullmesh_tests() 1845{ 1846 # fullmesh 1 1847 # 2 fullmesh addrs in ns2, added before the connection, 1848 # 1 non-fullmesh addr in ns1, added during the connection. 1849 reset 1850 ip netns exec $ns1 ./pm_nl_ctl limits 0 4 1851 ip netns exec $ns2 ./pm_nl_ctl limits 1 4 1852 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow,fullmesh 1853 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow,fullmesh 1854 run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 1855 chk_join_nr "fullmesh test 2x1" 4 4 4 1856 chk_add_nr 1 1 1857 1858 # fullmesh 2 1859 # 1 non-fullmesh addr in ns1, added before the connection, 1860 # 1 fullmesh addr in ns2, added during the connection. 1861 reset 1862 ip netns exec $ns1 ./pm_nl_ctl limits 1 3 1863 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 1864 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1865 run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_1 slow 1866 chk_join_nr "fullmesh test 1x1" 3 3 3 1867 chk_add_nr 1 1 1868 1869 # fullmesh 3 1870 # 1 non-fullmesh addr in ns1, added before the connection, 1871 # 2 fullmesh addrs in ns2, added during the connection. 1872 reset 1873 ip netns exec $ns1 ./pm_nl_ctl limits 2 5 1874 ip netns exec $ns2 ./pm_nl_ctl limits 1 5 1875 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1876 run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow 1877 chk_join_nr "fullmesh test 1x2" 5 5 5 1878 chk_add_nr 1 1 1879 1880 # fullmesh 4 1881 # 1 non-fullmesh addr in ns1, added before the connection, 1882 # 2 fullmesh addrs in ns2, added during the connection, 1883 # limit max_subflows to 4. 1884 reset 1885 ip netns exec $ns1 ./pm_nl_ctl limits 2 4 1886 ip netns exec $ns2 ./pm_nl_ctl limits 1 4 1887 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1888 run_tests $ns1 $ns2 10.0.1.1 0 0 fullmesh_2 slow 1889 chk_join_nr "fullmesh test 1x2, limited" 4 4 4 1890 chk_add_nr 1 1 1891} 1892 1893all_tests() 1894{ 1895 subflows_tests 1896 subflows_error_tests 1897 signal_address_tests 1898 link_failure_tests 1899 add_addr_timeout_tests 1900 remove_tests 1901 add_tests 1902 ipv6_tests 1903 v4mapped_tests 1904 backup_tests 1905 add_addr_ports_tests 1906 syncookies_tests 1907 checksum_tests 1908 deny_join_id0_tests 1909 fullmesh_tests 1910} 1911 1912usage() 1913{ 1914 echo "mptcp_join usage:" 1915 echo " -f subflows_tests" 1916 echo " -e subflows_error_tests" 1917 echo " -s signal_address_tests" 1918 echo " -l link_failure_tests" 1919 echo " -t add_addr_timeout_tests" 1920 echo " -r remove_tests" 1921 echo " -a add_tests" 1922 echo " -6 ipv6_tests" 1923 echo " -4 v4mapped_tests" 1924 echo " -b backup_tests" 1925 echo " -p add_addr_ports_tests" 1926 echo " -k syncookies_tests" 1927 echo " -S checksum_tests" 1928 echo " -d deny_join_id0_tests" 1929 echo " -m fullmesh_tests" 1930 echo " -c capture pcap files" 1931 echo " -C enable data checksum" 1932 echo " -h help" 1933} 1934 1935sin=$(mktemp) 1936sout=$(mktemp) 1937cin=$(mktemp) 1938cinsent=$(mktemp) 1939cout=$(mktemp) 1940init 1941make_file "$cin" "client" 1 1942make_file "$sin" "server" 1 1943trap cleanup EXIT 1944 1945for arg in "$@"; do 1946 # check for "capture/checksum" args before launching tests 1947 if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"c"[0-9a-zA-Z]*$ ]]; then 1948 capture=1 1949 fi 1950 if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"C"[0-9a-zA-Z]*$ ]]; then 1951 checksum=1 1952 fi 1953 1954 # exception for the capture/checksum options, the rest means: a part of the tests 1955 if [ "${arg}" != "-c" ] && [ "${arg}" != "-C" ]; then 1956 do_all_tests=0 1957 fi 1958done 1959 1960if [ $do_all_tests -eq 1 ]; then 1961 all_tests 1962 exit $ret 1963fi 1964 1965while getopts 'fesltra64bpkdmchCS' opt; do 1966 case $opt in 1967 f) 1968 subflows_tests 1969 ;; 1970 e) 1971 subflows_error_tests 1972 ;; 1973 s) 1974 signal_address_tests 1975 ;; 1976 l) 1977 link_failure_tests 1978 ;; 1979 t) 1980 add_addr_timeout_tests 1981 ;; 1982 r) 1983 remove_tests 1984 ;; 1985 a) 1986 add_tests 1987 ;; 1988 6) 1989 ipv6_tests 1990 ;; 1991 4) 1992 v4mapped_tests 1993 ;; 1994 b) 1995 backup_tests 1996 ;; 1997 p) 1998 add_addr_ports_tests 1999 ;; 2000 k) 2001 syncookies_tests 2002 ;; 2003 S) 2004 checksum_tests 2005 ;; 2006 d) 2007 deny_join_id0_tests 2008 ;; 2009 m) 2010 fullmesh_tests 2011 ;; 2012 c) 2013 ;; 2014 C) 2015 ;; 2016 h | *) 2017 usage 2018 ;; 2019 esac 2020done 2021 2022exit $ret 2023