1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4ret=0 5sin="" 6sout="" 7cin="" 8cinsent="" 9cout="" 10ksft_skip=4 11timeout_poll=30 12timeout_test=$((timeout_poll * 2 + 1)) 13mptcp_connect="" 14capture=0 15do_all_tests=1 16 17TEST_COUNT=0 18 19# generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) || 20# (ip6 && (ip6[74] & 0xf0) == 0x30)'" 21CBPF_MPTCP_SUBOPTION_ADD_ADDR="14, 22 48 0 0 0, 23 84 0 0 240, 24 21 0 3 64, 25 48 0 0 54, 26 84 0 0 240, 27 21 6 7 48, 28 48 0 0 0, 29 84 0 0 240, 30 21 0 4 96, 31 48 0 0 74, 32 84 0 0 240, 33 21 0 1 48, 34 6 0 0 65535, 35 6 0 0 0" 36 37init() 38{ 39 capout=$(mktemp) 40 41 rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) 42 43 ns1="ns1-$rndh" 44 ns2="ns2-$rndh" 45 46 for netns in "$ns1" "$ns2";do 47 ip netns add $netns || exit $ksft_skip 48 ip -net $netns link set lo up 49 ip netns exec $netns sysctl -q net.mptcp.enabled=1 50 ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 51 ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 52 done 53 54 # ns1 ns2 55 # ns1eth1 ns2eth1 56 # ns1eth2 ns2eth2 57 # ns1eth3 ns2eth3 58 # ns1eth4 ns2eth4 59 60 for i in `seq 1 4`; do 61 ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2" 62 ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i 63 ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad 64 ip -net "$ns1" link set ns1eth$i up 65 66 ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i 67 ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad 68 ip -net "$ns2" link set ns2eth$i up 69 70 # let $ns2 reach any $ns1 address from any interface 71 ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i 72 done 73} 74 75cleanup_partial() 76{ 77 rm -f "$capout" 78 79 for netns in "$ns1" "$ns2"; do 80 ip netns del $netns 81 rm -f /tmp/$netns.{nstat,out} 82 done 83} 84 85cleanup() 86{ 87 rm -f "$cin" "$cout" 88 rm -f "$sin" "$sout" "$cinsent" 89 cleanup_partial 90} 91 92reset() 93{ 94 cleanup_partial 95 init 96} 97 98reset_with_cookies() 99{ 100 reset 101 102 for netns in "$ns1" "$ns2";do 103 ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2 104 done 105} 106 107reset_with_add_addr_timeout() 108{ 109 local ip="${1:-4}" 110 local tables 111 112 tables="iptables" 113 if [ $ip -eq 6 ]; then 114 tables="ip6tables" 115 fi 116 117 reset 118 119 ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 120 ip netns exec $ns2 $tables -A OUTPUT -p tcp \ 121 -m tcp --tcp-option 30 \ 122 -m bpf --bytecode \ 123 "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \ 124 -j DROP 125} 126 127ip -Version > /dev/null 2>&1 128if [ $? -ne 0 ];then 129 echo "SKIP: Could not run test without ip tool" 130 exit $ksft_skip 131fi 132 133iptables -V > /dev/null 2>&1 134if [ $? -ne 0 ];then 135 echo "SKIP: Could not run all tests without iptables tool" 136 exit $ksft_skip 137fi 138 139ip6tables -V > /dev/null 2>&1 140if [ $? -ne 0 ];then 141 echo "SKIP: Could not run all tests without ip6tables tool" 142 exit $ksft_skip 143fi 144 145print_file_err() 146{ 147 ls -l "$1" 1>&2 148 echo "Trailing bytes are: " 149 tail -c 27 "$1" 150} 151 152check_transfer() 153{ 154 in=$1 155 out=$2 156 what=$3 157 158 cmp "$in" "$out" > /dev/null 2>&1 159 if [ $? -ne 0 ] ;then 160 echo "[ FAIL ] $what does not match (in, out):" 161 print_file_err "$in" 162 print_file_err "$out" 163 ret=1 164 165 return 1 166 fi 167 168 return 0 169} 170 171do_ping() 172{ 173 listener_ns="$1" 174 connector_ns="$2" 175 connect_addr="$3" 176 177 ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null 178 if [ $? -ne 0 ] ; then 179 echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2 180 ret=1 181 fi 182} 183 184link_failure() 185{ 186 ns="$1" 187 188 l=$((RANDOM%4)) 189 l=$((l+1)) 190 191 veth="ns1eth$l" 192 ip -net "$ns" link set "$veth" down 193} 194 195# $1: IP address 196is_v6() 197{ 198 [ -z "${1##*:*}" ] 199} 200 201do_transfer() 202{ 203 listener_ns="$1" 204 connector_ns="$2" 205 cl_proto="$3" 206 srv_proto="$4" 207 connect_addr="$5" 208 test_link_fail="$6" 209 addr_nr_ns1="$7" 210 addr_nr_ns2="$8" 211 speed="$9" 212 bkup="${10}" 213 214 port=$((10000+$TEST_COUNT)) 215 TEST_COUNT=$((TEST_COUNT+1)) 216 217 :> "$cout" 218 :> "$sout" 219 :> "$capout" 220 221 if [ $capture -eq 1 ]; then 222 if [ -z $SUDO_USER ] ; then 223 capuser="" 224 else 225 capuser="-Z $SUDO_USER" 226 fi 227 228 capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}") 229 230 echo "Capturing traffic for test $TEST_COUNT into $capfile" 231 ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & 232 cappid=$! 233 234 sleep 1 235 fi 236 237 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 238 nstat -n 239 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 240 nstat -n 241 242 if [ $speed = "fast" ]; then 243 mptcp_connect="./mptcp_connect -j" 244 elif [ $speed = "slow" ]; then 245 mptcp_connect="./mptcp_connect -r 50" 246 elif [ $speed = "least" ]; then 247 mptcp_connect="./mptcp_connect -r 10" 248 fi 249 250 local local_addr 251 if is_v6 "${connect_addr}"; then 252 local_addr="::" 253 else 254 local_addr="0.0.0.0" 255 fi 256 257 timeout ${timeout_test} \ 258 ip netns exec ${listener_ns} \ 259 $mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 260 ${local_addr} < "$sin" > "$sout" & 261 spid=$! 262 263 sleep 1 264 265 if [ "$test_link_fail" -eq 0 ];then 266 timeout ${timeout_test} \ 267 ip netns exec ${connector_ns} \ 268 $mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 269 $connect_addr < "$cin" > "$cout" & 270 else 271 ( cat "$cin" ; sleep 2; link_failure $listener_ns ; cat "$cin" ) | \ 272 tee "$cinsent" | \ 273 timeout ${timeout_test} \ 274 ip netns exec ${connector_ns} \ 275 $mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 276 $connect_addr > "$cout" & 277 fi 278 cpid=$! 279 280 if [ $addr_nr_ns1 -gt 0 ]; then 281 let add_nr_ns1=addr_nr_ns1 282 counter=2 283 sleep 1 284 while [ $add_nr_ns1 -gt 0 ]; do 285 local addr 286 if is_v6 "${connect_addr}"; then 287 addr="dead:beef:$counter::1" 288 else 289 addr="10.0.$counter.1" 290 fi 291 ip netns exec $ns1 ./pm_nl_ctl add $addr flags signal 292 let counter+=1 293 let add_nr_ns1-=1 294 done 295 sleep 1 296 elif [ $addr_nr_ns1 -lt 0 ]; then 297 let rm_nr_ns1=-addr_nr_ns1 298 if [ $rm_nr_ns1 -lt 8 ]; then 299 counter=1 300 dump=(`ip netns exec ${listener_ns} ./pm_nl_ctl dump`) 301 if [ ${#dump[@]} -gt 0 ]; then 302 id=${dump[1]} 303 sleep 1 304 305 while [ $counter -le $rm_nr_ns1 ] 306 do 307 ip netns exec ${listener_ns} ./pm_nl_ctl del $id 308 sleep 1 309 let counter+=1 310 let id+=1 311 done 312 fi 313 elif [ $rm_nr_ns1 -eq 8 ]; then 314 sleep 1 315 ip netns exec ${listener_ns} ./pm_nl_ctl flush 316 elif [ $rm_nr_ns1 -eq 9 ]; then 317 sleep 1 318 ip netns exec ${listener_ns} ./pm_nl_ctl del 0 ${connect_addr} 319 fi 320 fi 321 322 if [ $addr_nr_ns2 -gt 0 ]; then 323 let add_nr_ns2=addr_nr_ns2 324 counter=3 325 sleep 1 326 while [ $add_nr_ns2 -gt 0 ]; do 327 local addr 328 if is_v6 "${connect_addr}"; then 329 addr="dead:beef:$counter::2" 330 else 331 addr="10.0.$counter.2" 332 fi 333 ip netns exec $ns2 ./pm_nl_ctl add $addr flags subflow 334 let counter+=1 335 let add_nr_ns2-=1 336 done 337 sleep 1 338 elif [ $addr_nr_ns2 -lt 0 ]; then 339 let rm_nr_ns2=-addr_nr_ns2 340 if [ $rm_nr_ns2 -lt 8 ]; then 341 counter=1 342 dump=(`ip netns exec ${connector_ns} ./pm_nl_ctl dump`) 343 if [ ${#dump[@]} -gt 0 ]; then 344 id=${dump[1]} 345 sleep 1 346 347 while [ $counter -le $rm_nr_ns2 ] 348 do 349 ip netns exec ${connector_ns} ./pm_nl_ctl del $id 350 sleep 1 351 let counter+=1 352 let id+=1 353 done 354 fi 355 elif [ $rm_nr_ns2 -eq 8 ]; then 356 sleep 1 357 ip netns exec ${connector_ns} ./pm_nl_ctl flush 358 elif [ $rm_nr_ns2 -eq 9 ]; then 359 local addr 360 if is_v6 "${connect_addr}"; then 361 addr="dead:beef:1::2" 362 else 363 addr="10.0.1.2" 364 fi 365 sleep 1 366 ip netns exec ${connector_ns} ./pm_nl_ctl del 0 $addr 367 fi 368 fi 369 370 if [ ! -z $bkup ]; then 371 sleep 1 372 for netns in "$ns1" "$ns2"; do 373 dump=(`ip netns exec $netns ./pm_nl_ctl dump`) 374 if [ ${#dump[@]} -gt 0 ]; then 375 addr=${dump[${#dump[@]} - 1]} 376 backup="ip netns exec $netns ./pm_nl_ctl set $addr flags $bkup" 377 $backup 378 fi 379 done 380 fi 381 382 wait $cpid 383 retc=$? 384 wait $spid 385 rets=$? 386 387 if [ $capture -eq 1 ]; then 388 sleep 1 389 kill $cappid 390 fi 391 392 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 393 nstat | grep Tcp > /tmp/${listener_ns}.out 394 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 395 nstat | grep Tcp > /tmp/${connector_ns}.out 396 397 if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then 398 echo " client exit code $retc, server $rets" 1>&2 399 echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 400 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port" 401 cat /tmp/${listener_ns}.out 402 echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2 403 ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port" 404 cat /tmp/${connector_ns}.out 405 406 cat "$capout" 407 ret=1 408 return 1 409 fi 410 411 check_transfer $sin $cout "file received by client" 412 retc=$? 413 if [ "$test_link_fail" -eq 0 ];then 414 check_transfer $cin $sout "file received by server" 415 else 416 check_transfer $cinsent $sout "file received by server" 417 fi 418 rets=$? 419 420 if [ $retc -eq 0 ] && [ $rets -eq 0 ];then 421 cat "$capout" 422 return 0 423 fi 424 425 cat "$capout" 426 return 1 427} 428 429make_file() 430{ 431 name=$1 432 who=$2 433 size=$3 434 435 dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null 436 echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" 437 438 echo "Created $name (size $size KB) containing data sent by $who" 439} 440 441run_tests() 442{ 443 listener_ns="$1" 444 connector_ns="$2" 445 connect_addr="$3" 446 test_linkfail="${4:-0}" 447 addr_nr_ns1="${5:-0}" 448 addr_nr_ns2="${6:-0}" 449 speed="${7:-fast}" 450 bkup="${8:-""}" 451 lret=0 452 oldin="" 453 454 if [ "$test_linkfail" -eq 1 ];then 455 size=$((RANDOM%1024)) 456 size=$((size+1)) 457 size=$((size*128)) 458 459 oldin=$(mktemp) 460 cp "$cin" "$oldin" 461 make_file "$cin" "client" $size 462 fi 463 464 do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \ 465 ${test_linkfail} ${addr_nr_ns1} ${addr_nr_ns2} ${speed} ${bkup} 466 lret=$? 467 468 if [ "$test_linkfail" -eq 1 ];then 469 cp "$oldin" "$cin" 470 rm -f "$oldin" 471 fi 472 473 if [ $lret -ne 0 ]; then 474 ret=$lret 475 return 476 fi 477} 478 479chk_join_nr() 480{ 481 local msg="$1" 482 local syn_nr=$2 483 local syn_ack_nr=$3 484 local ack_nr=$4 485 local count 486 local dump_stats 487 488 printf "%02u %-36s %s" "$TEST_COUNT" "$msg" "syn" 489 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'` 490 [ -z "$count" ] && count=0 491 if [ "$count" != "$syn_nr" ]; then 492 echo "[fail] got $count JOIN[s] syn expected $syn_nr" 493 ret=1 494 dump_stats=1 495 else 496 echo -n "[ ok ]" 497 fi 498 499 echo -n " - synack" 500 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'` 501 [ -z "$count" ] && count=0 502 if [ "$count" != "$syn_ack_nr" ]; then 503 echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr" 504 ret=1 505 dump_stats=1 506 else 507 echo -n "[ ok ]" 508 fi 509 510 echo -n " - ack" 511 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'` 512 [ -z "$count" ] && count=0 513 if [ "$count" != "$ack_nr" ]; then 514 echo "[fail] got $count JOIN[s] ack expected $ack_nr" 515 ret=1 516 dump_stats=1 517 else 518 echo "[ ok ]" 519 fi 520 if [ "${dump_stats}" = 1 ]; then 521 echo Server ns stats 522 ip netns exec $ns1 nstat -as | grep MPTcp 523 echo Client ns stats 524 ip netns exec $ns2 nstat -as | grep MPTcp 525 fi 526} 527 528chk_add_nr() 529{ 530 local add_nr=$1 531 local echo_nr=$2 532 local port_nr=${3:-0} 533 local syn_nr=${4:-$port_nr} 534 local syn_ack_nr=${5:-$port_nr} 535 local ack_nr=${6:-$port_nr} 536 local mis_syn_nr=${7:-0} 537 local mis_ack_nr=${8:-0} 538 local count 539 local dump_stats 540 541 printf "%-39s %s" " " "add" 542 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtAddAddr | awk '{print $2}'` 543 [ -z "$count" ] && count=0 544 if [ "$count" != "$add_nr" ]; then 545 echo "[fail] got $count ADD_ADDR[s] expected $add_nr" 546 ret=1 547 dump_stats=1 548 else 549 echo -n "[ ok ]" 550 fi 551 552 echo -n " - echo " 553 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtEchoAdd | awk '{print $2}'` 554 [ -z "$count" ] && count=0 555 if [ "$count" != "$echo_nr" ]; then 556 echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr" 557 ret=1 558 dump_stats=1 559 else 560 echo -n "[ ok ]" 561 fi 562 563 if [ $port_nr -gt 0 ]; then 564 echo -n " - pt " 565 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtPortAdd | awk '{print $2}'` 566 [ -z "$count" ] && count=0 567 if [ "$count" != "$port_nr" ]; then 568 echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr" 569 ret=1 570 dump_stats=1 571 else 572 echo "[ ok ]" 573 fi 574 575 printf "%-39s %s" " " "syn" 576 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortSynRx | 577 awk '{print $2}'` 578 [ -z "$count" ] && count=0 579 if [ "$count" != "$syn_nr" ]; then 580 echo "[fail] got $count JOIN[s] syn with a different \ 581 port-number expected $syn_nr" 582 ret=1 583 dump_stats=1 584 else 585 echo -n "[ ok ]" 586 fi 587 588 echo -n " - synack" 589 count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinPortSynAckRx | 590 awk '{print $2}'` 591 [ -z "$count" ] && count=0 592 if [ "$count" != "$syn_ack_nr" ]; then 593 echo "[fail] got $count JOIN[s] synack with a different \ 594 port-number expected $syn_ack_nr" 595 ret=1 596 dump_stats=1 597 else 598 echo -n "[ ok ]" 599 fi 600 601 echo -n " - ack" 602 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortAckRx | 603 awk '{print $2}'` 604 [ -z "$count" ] && count=0 605 if [ "$count" != "$ack_nr" ]; then 606 echo "[fail] got $count JOIN[s] ack with a different \ 607 port-number expected $ack_nr" 608 ret=1 609 dump_stats=1 610 else 611 echo "[ ok ]" 612 fi 613 614 printf "%-39s %s" " " "syn" 615 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortSynRx | 616 awk '{print $2}'` 617 [ -z "$count" ] && count=0 618 if [ "$count" != "$mis_syn_nr" ]; then 619 echo "[fail] got $count JOIN[s] syn with a mismatched \ 620 port-number expected $mis_syn_nr" 621 ret=1 622 dump_stats=1 623 else 624 echo -n "[ ok ]" 625 fi 626 627 echo -n " - ack " 628 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortAckRx | 629 awk '{print $2}'` 630 [ -z "$count" ] && count=0 631 if [ "$count" != "$mis_ack_nr" ]; then 632 echo "[fail] got $count JOIN[s] ack with a mismatched \ 633 port-number expected $mis_ack_nr" 634 ret=1 635 dump_stats=1 636 else 637 echo "[ ok ]" 638 fi 639 else 640 echo "" 641 fi 642 643 if [ "${dump_stats}" = 1 ]; then 644 echo Server ns stats 645 ip netns exec $ns1 nstat -as | grep MPTcp 646 echo Client ns stats 647 ip netns exec $ns2 nstat -as | grep MPTcp 648 fi 649} 650 651chk_rm_nr() 652{ 653 local rm_addr_nr=$1 654 local rm_subflow_nr=$2 655 local invert=${3:-""} 656 local count 657 local dump_stats 658 local addr_ns 659 local subflow_ns 660 661 if [ -z $invert ]; then 662 addr_ns=$ns1 663 subflow_ns=$ns2 664 elif [ $invert = "invert" ]; then 665 addr_ns=$ns2 666 subflow_ns=$ns1 667 fi 668 669 printf "%-39s %s" " " "rm " 670 count=`ip netns exec $addr_ns nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'` 671 [ -z "$count" ] && count=0 672 if [ "$count" != "$rm_addr_nr" ]; then 673 echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" 674 ret=1 675 dump_stats=1 676 else 677 echo -n "[ ok ]" 678 fi 679 680 echo -n " - sf " 681 count=`ip netns exec $subflow_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'` 682 [ -z "$count" ] && count=0 683 if [ "$count" != "$rm_subflow_nr" ]; then 684 echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr" 685 ret=1 686 dump_stats=1 687 else 688 echo "[ ok ]" 689 fi 690 691 if [ "${dump_stats}" = 1 ]; then 692 echo Server ns stats 693 ip netns exec $ns1 nstat -as | grep MPTcp 694 echo Client ns stats 695 ip netns exec $ns2 nstat -as | grep MPTcp 696 fi 697} 698 699chk_prio_nr() 700{ 701 local mp_prio_nr_tx=$1 702 local mp_prio_nr_rx=$2 703 local count 704 local dump_stats 705 706 printf "%-39s %s" " " "ptx" 707 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}'` 708 [ -z "$count" ] && count=0 709 if [ "$count" != "$mp_prio_nr_tx" ]; then 710 echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" 711 ret=1 712 dump_stats=1 713 else 714 echo -n "[ ok ]" 715 fi 716 717 echo -n " - prx " 718 count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}'` 719 [ -z "$count" ] && count=0 720 if [ "$count" != "$mp_prio_nr_rx" ]; then 721 echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" 722 ret=1 723 dump_stats=1 724 else 725 echo "[ ok ]" 726 fi 727 728 if [ "${dump_stats}" = 1 ]; then 729 echo Server ns stats 730 ip netns exec $ns1 nstat -as | grep MPTcp 731 echo Client ns stats 732 ip netns exec $ns2 nstat -as | grep MPTcp 733 fi 734} 735 736subflows_tests() 737{ 738 reset 739 run_tests $ns1 $ns2 10.0.1.1 740 chk_join_nr "no JOIN" "0" "0" "0" 741 742 # subflow limited by client 743 reset 744 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 745 run_tests $ns1 $ns2 10.0.1.1 746 chk_join_nr "single subflow, limited by client" 0 0 0 747 748 # subflow limited by server 749 reset 750 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 751 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 752 run_tests $ns1 $ns2 10.0.1.1 753 chk_join_nr "single subflow, limited by server" 1 1 0 754 755 # subflow 756 reset 757 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 758 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 759 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 760 run_tests $ns1 $ns2 10.0.1.1 761 chk_join_nr "single subflow" 1 1 1 762 763 # multiple subflows 764 reset 765 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 766 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 767 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 768 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 769 run_tests $ns1 $ns2 10.0.1.1 770 chk_join_nr "multiple subflows" 2 2 2 771 772 # multiple subflows limited by serverf 773 reset 774 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 775 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 776 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 777 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 778 run_tests $ns1 $ns2 10.0.1.1 779 chk_join_nr "multiple subflows, limited by server" 2 2 1 780 781 # single subflow, dev 782 reset 783 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 784 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 785 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow dev ns2eth3 786 run_tests $ns1 $ns2 10.0.1.1 787 chk_join_nr "single subflow, dev" 1 1 1 788} 789 790signal_address_tests() 791{ 792 # add_address, unused 793 reset 794 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 795 run_tests $ns1 $ns2 10.0.1.1 796 chk_join_nr "unused signal address" 0 0 0 797 chk_add_nr 1 1 798 799 # accept and use add_addr 800 reset 801 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 802 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 803 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 804 run_tests $ns1 $ns2 10.0.1.1 805 chk_join_nr "signal address" 1 1 1 806 chk_add_nr 1 1 807 808 # accept and use add_addr with an additional subflow 809 # note: signal address in server ns and local addresses in client ns must 810 # belong to different subnets or one of the listed local address could be 811 # used for 'add_addr' subflow 812 reset 813 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 814 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 815 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 816 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 817 run_tests $ns1 $ns2 10.0.1.1 818 chk_join_nr "subflow and signal" 2 2 2 819 chk_add_nr 1 1 820 821 # accept and use add_addr with additional subflows 822 reset 823 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 824 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 825 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 826 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 827 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 828 run_tests $ns1 $ns2 10.0.1.1 829 chk_join_nr "multiple subflows and signal" 3 3 3 830 chk_add_nr 1 1 831 832 # signal addresses 833 reset 834 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 835 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 836 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 837 ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal 838 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 839 run_tests $ns1 $ns2 10.0.1.1 840 chk_join_nr "signal addresses" 3 3 3 841 chk_add_nr 3 3 842 843 # signal invalid addresses 844 reset 845 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 846 ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal 847 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 848 ip netns exec $ns1 ./pm_nl_ctl add 10.0.14.1 flags signal 849 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 850 run_tests $ns1 $ns2 10.0.1.1 851 chk_join_nr "signal invalid addresses" 1 1 1 852 chk_add_nr 3 3 853} 854 855link_failure_tests() 856{ 857 # accept and use add_addr with additional subflows and link loss 858 reset 859 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 860 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 861 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 862 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 863 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 864 run_tests $ns1 $ns2 10.0.1.1 1 865 chk_join_nr "multiple flows, signal, link failure" 3 3 3 866 chk_add_nr 1 1 867} 868 869add_addr_timeout_tests() 870{ 871 # add_addr timeout 872 reset_with_add_addr_timeout 873 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 874 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 875 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 876 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 877 chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1 878 chk_add_nr 4 0 879 880 # add_addr timeout IPv6 881 reset_with_add_addr_timeout 6 882 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 883 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 884 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 885 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 886 chk_join_nr "signal address, ADD_ADDR6 timeout" 1 1 1 887 chk_add_nr 4 0 888 889 # signal addresses timeout 890 reset_with_add_addr_timeout 891 ip netns exec $ns1 ./pm_nl_ctl limits 2 2 892 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 893 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 894 ip netns exec $ns2 ./pm_nl_ctl limits 2 2 895 run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 896 chk_join_nr "signal addresses, ADD_ADDR timeout" 2 2 2 897 chk_add_nr 8 0 898 899 # signal invalid addresses timeout 900 reset_with_add_addr_timeout 901 ip netns exec $ns1 ./pm_nl_ctl limits 2 2 902 ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal 903 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 904 ip netns exec $ns2 ./pm_nl_ctl limits 2 2 905 run_tests $ns1 $ns2 10.0.1.1 0 0 0 least 906 chk_join_nr "invalid address, ADD_ADDR timeout" 1 1 1 907 chk_add_nr 8 0 908} 909 910remove_tests() 911{ 912 # single subflow, remove 913 reset 914 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 915 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 916 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 917 run_tests $ns1 $ns2 10.0.1.1 0 0 -1 slow 918 chk_join_nr "remove single subflow" 1 1 1 919 chk_rm_nr 1 1 920 921 # multiple subflows, remove 922 reset 923 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 924 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 925 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 926 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 927 run_tests $ns1 $ns2 10.0.1.1 0 0 -2 slow 928 chk_join_nr "remove multiple subflows" 2 2 2 929 chk_rm_nr 2 2 930 931 # single address, remove 932 reset 933 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 934 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 935 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 936 run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 937 chk_join_nr "remove single address" 1 1 1 938 chk_add_nr 1 1 939 chk_rm_nr 1 1 invert 940 941 # subflow and signal, remove 942 reset 943 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 944 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 945 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 946 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 947 run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 948 chk_join_nr "remove subflow and signal" 2 2 2 949 chk_add_nr 1 1 950 chk_rm_nr 1 1 951 952 # subflows and signal, remove 953 reset 954 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 955 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 956 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 957 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 958 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 959 run_tests $ns1 $ns2 10.0.1.1 0 -1 -2 slow 960 chk_join_nr "remove subflows and signal" 3 3 3 961 chk_add_nr 1 1 962 chk_rm_nr 2 2 963 964 # addresses remove 965 reset 966 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 967 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal id 250 968 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 969 ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal 970 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 971 run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 972 chk_join_nr "remove addresses" 3 3 3 973 chk_add_nr 3 3 974 chk_rm_nr 3 3 invert 975 976 # invalid addresses remove 977 reset 978 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 979 ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal 980 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 981 ip netns exec $ns1 ./pm_nl_ctl add 10.0.14.1 flags signal 982 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 983 run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow 984 chk_join_nr "remove invalid addresses" 1 1 1 985 chk_add_nr 3 3 986 chk_rm_nr 3 1 invert 987 988 # subflows and signal, flush 989 reset 990 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 991 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 992 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 993 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 994 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 995 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 996 chk_join_nr "flush subflows and signal" 3 3 3 997 chk_add_nr 1 1 998 chk_rm_nr 2 2 999 1000 # subflows flush 1001 reset 1002 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 1003 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 1004 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow id 150 1005 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1006 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 1007 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1008 chk_join_nr "flush subflows" 3 3 3 1009 chk_rm_nr 3 3 1010 1011 # addresses flush 1012 reset 1013 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 1014 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal id 250 1015 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 1016 ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal 1017 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 1018 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1019 chk_join_nr "flush addresses" 3 3 3 1020 chk_add_nr 3 3 1021 chk_rm_nr 3 3 invert 1022 1023 # invalid addresses flush 1024 reset 1025 ip netns exec $ns1 ./pm_nl_ctl limits 3 3 1026 ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal 1027 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal 1028 ip netns exec $ns1 ./pm_nl_ctl add 10.0.14.1 flags signal 1029 ip netns exec $ns2 ./pm_nl_ctl limits 3 3 1030 run_tests $ns1 $ns2 10.0.1.1 0 -8 0 slow 1031 chk_join_nr "flush invalid addresses" 1 1 1 1032 chk_add_nr 3 3 1033 chk_rm_nr 3 1 invert 1034 1035 # remove id 0 subflow 1036 reset 1037 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1038 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1039 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1040 run_tests $ns1 $ns2 10.0.1.1 0 0 -9 slow 1041 chk_join_nr "remove id 0 subflow" 1 1 1 1042 chk_rm_nr 1 1 1043 1044 # remove id 0 address 1045 reset 1046 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1047 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1048 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1049 run_tests $ns1 $ns2 10.0.1.1 0 -9 0 slow 1050 chk_join_nr "remove id 0 address" 1 1 1 1051 chk_add_nr 1 1 1052 chk_rm_nr 1 1 invert 1053} 1054 1055add_tests() 1056{ 1057 # add single subflow 1058 reset 1059 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1060 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1061 run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow 1062 chk_join_nr "add single subflow" 1 1 1 1063 1064 # add signal address 1065 reset 1066 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1067 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1068 run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 1069 chk_join_nr "add signal address" 1 1 1 1070 chk_add_nr 1 1 1071 1072 # add multiple subflows 1073 reset 1074 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1075 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1076 run_tests $ns1 $ns2 10.0.1.1 0 0 2 slow 1077 chk_join_nr "add multiple subflows" 2 2 2 1078 1079 # add multiple subflows IPv6 1080 reset 1081 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1082 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1083 run_tests $ns1 $ns2 dead:beef:1::1 0 0 2 slow 1084 chk_join_nr "add multiple subflows IPv6" 2 2 2 1085 1086 # add multiple addresses IPv6 1087 reset 1088 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1089 ip netns exec $ns2 ./pm_nl_ctl limits 2 2 1090 run_tests $ns1 $ns2 dead:beef:1::1 0 2 0 slow 1091 chk_join_nr "add multiple addresses IPv6" 2 2 2 1092 chk_add_nr 2 2 1093} 1094 1095ipv6_tests() 1096{ 1097 # subflow IPv6 1098 reset 1099 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1100 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1101 ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 flags subflow 1102 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1103 chk_join_nr "single subflow IPv6" 1 1 1 1104 1105 # add_address, unused IPv6 1106 reset 1107 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1108 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1109 chk_join_nr "unused signal address IPv6" 0 0 0 1110 chk_add_nr 1 1 1111 1112 # signal address IPv6 1113 reset 1114 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1115 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1116 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1117 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1118 chk_join_nr "single address IPv6" 1 1 1 1119 chk_add_nr 1 1 1120 1121 # single address IPv6, remove 1122 reset 1123 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1124 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1125 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1126 run_tests $ns1 $ns2 dead:beef:1::1 0 -1 0 slow 1127 chk_join_nr "remove single address IPv6" 1 1 1 1128 chk_add_nr 1 1 1129 chk_rm_nr 1 1 invert 1130 1131 # subflow and signal IPv6, remove 1132 reset 1133 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1134 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1135 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1136 ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 flags subflow 1137 run_tests $ns1 $ns2 dead:beef:1::1 0 -1 -1 slow 1138 chk_join_nr "remove subflow and signal IPv6" 2 2 2 1139 chk_add_nr 1 1 1140 chk_rm_nr 1 1 1141} 1142 1143v4mapped_tests() 1144{ 1145 # subflow IPv4-mapped to IPv4-mapped 1146 reset 1147 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1148 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1149 ip netns exec $ns2 ./pm_nl_ctl add "::ffff:10.0.3.2" flags subflow 1150 run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1151 chk_join_nr "single subflow IPv4-mapped" 1 1 1 1152 1153 # signal address IPv4-mapped with IPv4-mapped sk 1154 reset 1155 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1156 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1157 ip netns exec $ns1 ./pm_nl_ctl add "::ffff:10.0.2.1" flags signal 1158 run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1159 chk_join_nr "signal address IPv4-mapped" 1 1 1 1160 chk_add_nr 1 1 1161 1162 # subflow v4-map-v6 1163 reset 1164 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1165 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1166 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1167 run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1168 chk_join_nr "single subflow v4-map-v6" 1 1 1 1169 1170 # signal address v4-map-v6 1171 reset 1172 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1173 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1174 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1175 run_tests $ns1 $ns2 "::ffff:10.0.1.1" 1176 chk_join_nr "signal address v4-map-v6" 1 1 1 1177 chk_add_nr 1 1 1178 1179 # subflow v6-map-v4 1180 reset 1181 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1182 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1183 ip netns exec $ns2 ./pm_nl_ctl add "::ffff:10.0.3.2" flags subflow 1184 run_tests $ns1 $ns2 10.0.1.1 1185 chk_join_nr "single subflow v6-map-v4" 1 1 1 1186 1187 # signal address v6-map-v4 1188 reset 1189 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1190 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1191 ip netns exec $ns1 ./pm_nl_ctl add "::ffff:10.0.2.1" flags signal 1192 run_tests $ns1 $ns2 10.0.1.1 1193 chk_join_nr "signal address v6-map-v4" 1 1 1 1194 chk_add_nr 1 1 1195 1196 # no subflow IPv6 to v4 address 1197 reset 1198 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1199 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1200 ip netns exec $ns2 ./pm_nl_ctl add dead:beef:2::2 flags subflow 1201 run_tests $ns1 $ns2 10.0.1.1 1202 chk_join_nr "no JOIN with diff families v4-v6" 0 0 0 1203 1204 # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end 1205 reset 1206 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1207 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1208 ip netns exec $ns2 ./pm_nl_ctl add dead:beef:2::10.0.3.2 flags subflow 1209 run_tests $ns1 $ns2 10.0.1.1 1210 chk_join_nr "no JOIN with diff families v4-v6-2" 0 0 0 1211 1212 # no subflow IPv4 to v6 address, no need to slow down too then 1213 reset 1214 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1215 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1216 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1217 run_tests $ns1 $ns2 dead:beef:1::1 1218 chk_join_nr "no JOIN with diff families v6-v4" 0 0 0 1219} 1220 1221backup_tests() 1222{ 1223 # single subflow, backup 1224 reset 1225 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1226 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1227 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow,backup 1228 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup 1229 chk_join_nr "single subflow, backup" 1 1 1 1230 chk_prio_nr 0 1 1231 1232 # single address, backup 1233 reset 1234 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1235 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1236 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1237 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup 1238 chk_join_nr "single address, backup" 1 1 1 1239 chk_add_nr 1 1 1240 chk_prio_nr 1 0 1241} 1242 1243add_addr_ports_tests() 1244{ 1245 # signal address with port 1246 reset 1247 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1248 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1249 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1250 run_tests $ns1 $ns2 10.0.1.1 1251 chk_join_nr "signal address with port" 1 1 1 1252 chk_add_nr 1 1 1 1253 1254 # subflow and signal with port 1255 reset 1256 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1257 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1258 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1259 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1260 run_tests $ns1 $ns2 10.0.1.1 1261 chk_join_nr "subflow and signal with port" 2 2 2 1262 chk_add_nr 1 1 1 1263 1264 # single address with port, remove 1265 reset 1266 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1267 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1268 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1269 run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow 1270 chk_join_nr "remove single address with port" 1 1 1 1271 chk_add_nr 1 1 1 1272 chk_rm_nr 1 1 invert 1273 1274 # subflow and signal with port, remove 1275 reset 1276 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1277 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1278 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1279 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1280 run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow 1281 chk_join_nr "remove subflow and signal with port" 2 2 2 1282 chk_add_nr 1 1 1 1283 chk_rm_nr 1 1 1284 1285 # subflows and signal with port, flush 1286 reset 1287 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 1288 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1289 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 1290 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1291 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 1292 run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow 1293 chk_join_nr "flush subflows and signal with port" 3 3 3 1294 chk_add_nr 1 1 1295 chk_rm_nr 2 2 1296 1297 # multiple addresses with port 1298 reset 1299 ip netns exec $ns1 ./pm_nl_ctl limits 2 2 1300 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1301 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal port 10100 1302 ip netns exec $ns2 ./pm_nl_ctl limits 2 2 1303 run_tests $ns1 $ns2 10.0.1.1 1304 chk_join_nr "multiple addresses with port" 2 2 2 1305 chk_add_nr 2 2 2 1306 1307 # multiple addresses with ports 1308 reset 1309 ip netns exec $ns1 ./pm_nl_ctl limits 2 2 1310 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 1311 ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal port 10101 1312 ip netns exec $ns2 ./pm_nl_ctl limits 2 2 1313 run_tests $ns1 $ns2 10.0.1.1 1314 chk_join_nr "multiple addresses with ports" 2 2 2 1315 chk_add_nr 2 2 2 1316} 1317 1318syncookies_tests() 1319{ 1320 # single subflow, syncookies 1321 reset_with_cookies 1322 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1323 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1324 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1325 run_tests $ns1 $ns2 10.0.1.1 1326 chk_join_nr "single subflow with syn cookies" 1 1 1 1327 1328 # multiple subflows with syn cookies 1329 reset_with_cookies 1330 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1331 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1332 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1333 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 1334 run_tests $ns1 $ns2 10.0.1.1 1335 chk_join_nr "multiple subflows with syn cookies" 2 2 2 1336 1337 # multiple subflows limited by server 1338 reset_with_cookies 1339 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1340 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 1341 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1342 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow 1343 run_tests $ns1 $ns2 10.0.1.1 1344 chk_join_nr "subflows limited by server w cookies" 2 2 1 1345 1346 # test signal address with cookies 1347 reset_with_cookies 1348 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1349 ip netns exec $ns2 ./pm_nl_ctl limits 1 1 1350 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1351 run_tests $ns1 $ns2 10.0.1.1 1352 chk_join_nr "signal address with syn cookies" 1 1 1 1353 chk_add_nr 1 1 1354 1355 # test cookie with subflow and signal 1356 reset_with_cookies 1357 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1358 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1359 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1360 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1361 run_tests $ns1 $ns2 10.0.1.1 1362 chk_join_nr "subflow and signal w cookies" 2 2 2 1363 chk_add_nr 1 1 1364 1365 # accept and use add_addr with additional subflows 1366 reset_with_cookies 1367 ip netns exec $ns1 ./pm_nl_ctl limits 0 3 1368 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal 1369 ip netns exec $ns2 ./pm_nl_ctl limits 1 3 1370 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow 1371 ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow 1372 run_tests $ns1 $ns2 10.0.1.1 1373 chk_join_nr "subflows and signal w. cookies" 3 3 3 1374 chk_add_nr 1 1 1375} 1376 1377all_tests() 1378{ 1379 subflows_tests 1380 signal_address_tests 1381 link_failure_tests 1382 add_addr_timeout_tests 1383 remove_tests 1384 add_tests 1385 ipv6_tests 1386 v4mapped_tests 1387 backup_tests 1388 add_addr_ports_tests 1389 syncookies_tests 1390} 1391 1392usage() 1393{ 1394 echo "mptcp_join usage:" 1395 echo " -f subflows_tests" 1396 echo " -s signal_address_tests" 1397 echo " -l link_failure_tests" 1398 echo " -t add_addr_timeout_tests" 1399 echo " -r remove_tests" 1400 echo " -a add_tests" 1401 echo " -6 ipv6_tests" 1402 echo " -4 v4mapped_tests" 1403 echo " -b backup_tests" 1404 echo " -p add_addr_ports_tests" 1405 echo " -k syncookies_tests" 1406 echo " -c capture pcap files" 1407 echo " -h help" 1408} 1409 1410sin=$(mktemp) 1411sout=$(mktemp) 1412cin=$(mktemp) 1413cinsent=$(mktemp) 1414cout=$(mktemp) 1415init 1416make_file "$cin" "client" 1 1417make_file "$sin" "server" 1 1418trap cleanup EXIT 1419 1420for arg in "$@"; do 1421 # check for "capture" arg before launching tests 1422 if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"c"[0-9a-zA-Z]*$ ]]; then 1423 capture=1 1424 fi 1425 1426 # exception for the capture option, the rest means: a part of the tests 1427 if [ "${arg}" != "-c" ]; then 1428 do_all_tests=0 1429 fi 1430done 1431 1432if [ $do_all_tests -eq 1 ]; then 1433 all_tests 1434 exit $ret 1435fi 1436 1437while getopts 'fsltra64bpkch' opt; do 1438 case $opt in 1439 f) 1440 subflows_tests 1441 ;; 1442 s) 1443 signal_address_tests 1444 ;; 1445 l) 1446 link_failure_tests 1447 ;; 1448 t) 1449 add_addr_timeout_tests 1450 ;; 1451 r) 1452 remove_tests 1453 ;; 1454 a) 1455 add_tests 1456 ;; 1457 6) 1458 ipv6_tests 1459 ;; 1460 4) 1461 v4mapped_tests 1462 ;; 1463 b) 1464 backup_tests 1465 ;; 1466 p) 1467 add_addr_ports_tests 1468 ;; 1469 k) 1470 syncookies_tests 1471 ;; 1472 c) 1473 ;; 1474 h | *) 1475 usage 1476 ;; 1477 esac 1478done 1479 1480exit $ret 1481