1b08fbf24SPaolo Abeni#!/bin/bash 2b08fbf24SPaolo Abeni# SPDX-License-Identifier: GPL-2.0 3b08fbf24SPaolo Abeni 4d8d08302SMatthieu Baerts# Double quotes to prevent globbing and word splitting is recommended in new 5d8d08302SMatthieu Baerts# code but we accept it, especially because there were too many before having 6d8d08302SMatthieu Baerts# address all other issues detected by shellcheck. 7d8d08302SMatthieu Baerts#shellcheck disable=SC2086 8d8d08302SMatthieu Baerts 90fcd72dfSMatthieu Baerts# ShellCheck incorrectly believes that most of the code here is unreachable 100fcd72dfSMatthieu Baerts# because it's invoked by variable name, see how the "tests" array is used 110fcd72dfSMatthieu Baerts#shellcheck disable=SC2317 120fcd72dfSMatthieu Baerts 13715c78a8SMatthieu Baerts. "$(dirname "${0}")/mptcp_lib.sh" 14715c78a8SMatthieu Baerts 15b08fbf24SPaolo Abeniret=0 16b08fbf24SPaolo Abenisin="" 177d1e6f16SPaolo Abenisinfail="" 18b08fbf24SPaolo Abenisout="" 19b08fbf24SPaolo Abenicin="" 207d1e6f16SPaolo Abenicinfail="" 218b819a84SFlorian Westphalcinsent="" 22d328fe87SMatthieu Baertstmpfile="" 23b08fbf24SPaolo Abenicout="" 241b8af4baSGeliang Tangerr="" 251e777bd8SMatthieu Baertscapout="" 261e777bd8SMatthieu Baertsns1="" 271e777bd8SMatthieu Baertsns2="" 28b08fbf24SPaolo Abeniksft_skip=4 290c4cd3f8SMatthieu Baertsiptables="iptables" 300c4cd3f8SMatthieu Baertsip6tables="ip6tables" 315888a61cSMatthieu Baertstimeout_poll=30 325888a61cSMatthieu Baertstimeout_test=$((timeout_poll * 2 + 1)) 33b08fbf24SPaolo Abenicapture=0 34af66d3e1SGeliang Tangchecksum=0 3534aa6e3bSGeliang Tangip_mptcp=0 368117dac3SGeliang Tangcheck_invert=0 373c082695SGeliang Tangvalidate_checksum=0 3893827ad5SMatthieu Baertsinit=0 39a3735625SGeliang Tangevts_ns1="" 40a3735625SGeliang Tangevts_ns2="" 41a3735625SGeliang Tangevts_ns1_pid=0 42a3735625SGeliang Tangevts_ns2_pid=0 437f117cd3SMatthieu Baertslast_test_failed=0 447f117cd3SMatthieu Baertslast_test_skipped=0 457f117cd3SMatthieu Baertslast_test_ignored=1 46b08fbf24SPaolo Abeni 473afd0280SMatthieu Baertsdeclare -A all_tests 48c7d49c03SMatthieu Baertsdeclare -a only_tests_ids 49c7d49c03SMatthieu Baertsdeclare -a only_tests_names 5039aab882SMatthieu Baertsdeclare -A failed_tests 51b08fbf24SPaolo AbeniTEST_COUNT=0 52c7d49c03SMatthieu BaertsTEST_NAME="" 5303668c65SMatthieu Baertsnr_blank=6 54b08fbf24SPaolo Abeni 55662aa22dSGeliang Tang# These var are used only in some tests, make sure they are not already set 56662aa22dSGeliang Tangunset FAILING_LINKS 57662aa22dSGeliang Tangunset test_linkfail 58662aa22dSGeliang Tangunset addr_nr_ns1 59662aa22dSGeliang Tangunset addr_nr_ns2 60662aa22dSGeliang Tangunset sflags 61080b7f57SGeliang Tangunset fastclose 624aadde08SGeliang Tangunset fullmesh 63e571fb09SGeliang Tangunset speed 64e59300ceSMatthieu Baerts 658d014eaaSGeliang Tang# generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) || 668d014eaaSGeliang Tang# (ip6 && (ip6[74] & 0xf0) == 0x30)'" 678d014eaaSGeliang TangCBPF_MPTCP_SUBOPTION_ADD_ADDR="14, 688d014eaaSGeliang Tang 48 0 0 0, 698d014eaaSGeliang Tang 84 0 0 240, 708d014eaaSGeliang Tang 21 0 3 64, 718d014eaaSGeliang Tang 48 0 0 54, 728d014eaaSGeliang Tang 84 0 0 240, 738d014eaaSGeliang Tang 21 6 7 48, 748d014eaaSGeliang Tang 48 0 0 0, 758d014eaaSGeliang Tang 84 0 0 240, 768d014eaaSGeliang Tang 21 0 4 96, 778d014eaaSGeliang Tang 48 0 0 74, 788d014eaaSGeliang Tang 84 0 0 240, 798d014eaaSGeliang Tang 21 0 1 48, 808d014eaaSGeliang Tang 6 0 0 65535, 818d014eaaSGeliang Tang 6 0 0 0" 828d014eaaSGeliang Tang 8393827ad5SMatthieu Baertsinit_partial() 84b08fbf24SPaolo Abeni{ 85b08fbf24SPaolo Abeni capout=$(mktemp) 86b08fbf24SPaolo Abeni 87787eb1e4SMatthieu Baerts local sec rndh 88787eb1e4SMatthieu Baerts sec=$(date +%s) 89787eb1e4SMatthieu Baerts rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) 90b08fbf24SPaolo Abeni 91b08fbf24SPaolo Abeni ns1="ns1-$rndh" 92b08fbf24SPaolo Abeni ns2="ns2-$rndh" 93b08fbf24SPaolo Abeni 941e777bd8SMatthieu Baerts local netns 95b08fbf24SPaolo Abeni for netns in "$ns1" "$ns2"; do 96b08fbf24SPaolo Abeni ip netns add $netns || exit $ksft_skip 97b08fbf24SPaolo Abeni ip -net $netns link set lo up 98b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.mptcp.enabled=1 99f2b492b0SMatthieu Baerts ip netns exec $netns sysctl -q net.mptcp.pm_type=0 2>/dev/null || true 100b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 101b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 102af66d3e1SGeliang Tang if [ $checksum -eq 1 ]; then 103af66d3e1SGeliang Tang ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1 104af66d3e1SGeliang Tang fi 105b08fbf24SPaolo Abeni done 106b08fbf24SPaolo Abeni 1078117dac3SGeliang Tang check_invert=0 1083c082695SGeliang Tang validate_checksum=$checksum 1098117dac3SGeliang Tang 110b08fbf24SPaolo Abeni # ns1 ns2 111b08fbf24SPaolo Abeni # ns1eth1 ns2eth1 112b08fbf24SPaolo Abeni # ns1eth2 ns2eth2 113b08fbf24SPaolo Abeni # ns1eth3 ns2eth3 114b08fbf24SPaolo Abeni # ns1eth4 ns2eth4 115b08fbf24SPaolo Abeni 1161e777bd8SMatthieu Baerts local i 1174bfadd71SMatthieu Baerts for i in $(seq 1 4); do 118b08fbf24SPaolo Abeni ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2" 119b08fbf24SPaolo Abeni ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i 120b08fbf24SPaolo Abeni ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad 121b08fbf24SPaolo Abeni ip -net "$ns1" link set ns1eth$i up 122b08fbf24SPaolo Abeni 123b08fbf24SPaolo Abeni ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i 124b08fbf24SPaolo Abeni ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad 125b08fbf24SPaolo Abeni ip -net "$ns2" link set ns2eth$i up 126b08fbf24SPaolo Abeni 127b08fbf24SPaolo Abeni # let $ns2 reach any $ns1 address from any interface 128b08fbf24SPaolo Abeni ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i 1299846921dSPaolo Abeni ip -net "$ns2" route add default via dead:beef:$i::1 dev ns2eth$i metric 10$i 130b08fbf24SPaolo Abeni done 131b08fbf24SPaolo Abeni} 132b08fbf24SPaolo Abeni 1337d1e6f16SPaolo Abeniinit_shapers() 1347d1e6f16SPaolo Abeni{ 1351e777bd8SMatthieu Baerts local i 1364bfadd71SMatthieu Baerts for i in $(seq 1 4); do 13799ac814eSGeliang Tang tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1ms 13899ac814eSGeliang Tang tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1ms 1397d1e6f16SPaolo Abeni done 1407d1e6f16SPaolo Abeni} 1417d1e6f16SPaolo Abeni 142b08fbf24SPaolo Abenicleanup_partial() 143b08fbf24SPaolo Abeni{ 144b08fbf24SPaolo Abeni rm -f "$capout" 145b08fbf24SPaolo Abeni 1461e777bd8SMatthieu Baerts local netns 147b08fbf24SPaolo Abeni for netns in "$ns1" "$ns2"; do 148b08fbf24SPaolo Abeni ip netns del $netns 149c2a55e8fSMatthieu Baerts rm -f /tmp/$netns.{nstat,out} 150b08fbf24SPaolo Abeni done 151b08fbf24SPaolo Abeni} 152b08fbf24SPaolo Abeni 15387154755SMatthieu Baertscheck_tools() 15487154755SMatthieu Baerts{ 155715c78a8SMatthieu Baerts mptcp_lib_check_mptcp 156cdb50525SMatthieu Baerts mptcp_lib_check_kallsyms 157715c78a8SMatthieu Baerts 15887154755SMatthieu Baerts if ! ip -Version &> /dev/null; then 15987154755SMatthieu Baerts echo "SKIP: Could not run test without ip tool" 16087154755SMatthieu Baerts exit $ksft_skip 16187154755SMatthieu Baerts fi 16287154755SMatthieu Baerts 163536a661bSGeliang Tang if ! ss -h | grep -q MPTCP; then 164536a661bSGeliang Tang echo "SKIP: ss tool does not support MPTCP" 165536a661bSGeliang Tang exit $ksft_skip 166536a661bSGeliang Tang fi 167536a661bSGeliang Tang 1680c4cd3f8SMatthieu Baerts # Use the legacy version if available to support old kernel versions 1690c4cd3f8SMatthieu Baerts if iptables-legacy -V &> /dev/null; then 1700c4cd3f8SMatthieu Baerts iptables="iptables-legacy" 1710c4cd3f8SMatthieu Baerts ip6tables="ip6tables-legacy" 1720c4cd3f8SMatthieu Baerts elif ! iptables -V &> /dev/null; then 17387154755SMatthieu Baerts echo "SKIP: Could not run all tests without iptables tool" 17487154755SMatthieu Baerts exit $ksft_skip 175016e7ba4SMatthieu Baerts elif ! ip6tables -V &> /dev/null; then 17687154755SMatthieu Baerts echo "SKIP: Could not run all tests without ip6tables tool" 17787154755SMatthieu Baerts exit $ksft_skip 17887154755SMatthieu Baerts fi 17987154755SMatthieu Baerts} 18087154755SMatthieu Baerts 18193827ad5SMatthieu Baertsinit() { 18293827ad5SMatthieu Baerts init=1 18393827ad5SMatthieu Baerts 18487154755SMatthieu Baerts check_tools 18587154755SMatthieu Baerts 18693827ad5SMatthieu Baerts sin=$(mktemp) 18793827ad5SMatthieu Baerts sout=$(mktemp) 18893827ad5SMatthieu Baerts cin=$(mktemp) 18993827ad5SMatthieu Baerts cinsent=$(mktemp) 19093827ad5SMatthieu Baerts cout=$(mktemp) 1911b8af4baSGeliang Tang err=$(mktemp) 192a3735625SGeliang Tang evts_ns1=$(mktemp) 193a3735625SGeliang Tang evts_ns2=$(mktemp) 19493827ad5SMatthieu Baerts 19593827ad5SMatthieu Baerts trap cleanup EXIT 19693827ad5SMatthieu Baerts 19703668c65SMatthieu Baerts make_file "$cin" "client" 1 >/dev/null 19803668c65SMatthieu Baerts make_file "$sin" "server" 1 >/dev/null 19993827ad5SMatthieu Baerts} 20093827ad5SMatthieu Baerts 201b08fbf24SPaolo Abenicleanup() 202b08fbf24SPaolo Abeni{ 2037d1e6f16SPaolo Abeni rm -f "$cin" "$cout" "$sinfail" 2047d1e6f16SPaolo Abeni rm -f "$sin" "$sout" "$cinsent" "$cinfail" 205d328fe87SMatthieu Baerts rm -f "$tmpfile" 206a3735625SGeliang Tang rm -rf $evts_ns1 $evts_ns2 2071b8af4baSGeliang Tang rm -f "$err" 208b08fbf24SPaolo Abeni cleanup_partial 209b08fbf24SPaolo Abeni} 210b08fbf24SPaolo Abeni 211cdb50525SMatthieu Baertsprint_title() 212cdb50525SMatthieu Baerts{ 21303668c65SMatthieu Baerts printf "%03u %s\n" "${TEST_COUNT}" "${TEST_NAME}" 21403668c65SMatthieu Baerts} 21503668c65SMatthieu Baerts 21603668c65SMatthieu Baertsprint_check() 21703668c65SMatthieu Baerts{ 21803668c65SMatthieu Baerts printf "%-${nr_blank}s%-36s" " " "${*}" 21903668c65SMatthieu Baerts} 22003668c65SMatthieu Baerts 22103668c65SMatthieu Baertsprint_info() 22203668c65SMatthieu Baerts{ 22303668c65SMatthieu Baerts # It can be empty, no need to print anything then 22403668c65SMatthieu Baerts [ -z "${1}" ] && return 22503668c65SMatthieu Baerts 2269466df1aSMatthieu Baerts mptcp_lib_print_info " Info: ${*}" 22703668c65SMatthieu Baerts} 22803668c65SMatthieu Baerts 22903668c65SMatthieu Baertsprint_ok() 23003668c65SMatthieu Baerts{ 2319466df1aSMatthieu Baerts mptcp_lib_print_ok "[ ok ]${1:+ ${*}}" 23203668c65SMatthieu Baerts} 23303668c65SMatthieu Baerts 23403668c65SMatthieu Baertsprint_fail() 23503668c65SMatthieu Baerts{ 2369466df1aSMatthieu Baerts mptcp_lib_print_err "[fail]${1:+ ${*}}" 23703668c65SMatthieu Baerts} 23803668c65SMatthieu Baerts 23903668c65SMatthieu Baertsprint_skip() 24003668c65SMatthieu Baerts{ 2419466df1aSMatthieu Baerts mptcp_lib_print_warn "[skip]${1:+ ${*}}" 242cdb50525SMatthieu Baerts} 243cdb50525SMatthieu Baerts 244cdb50525SMatthieu Baerts# [ $1: fail msg ] 245cdb50525SMatthieu Baertsmark_as_skipped() 246cdb50525SMatthieu Baerts{ 247cdb50525SMatthieu Baerts local msg="${1:-"Feature not supported"}" 248cdb50525SMatthieu Baerts 249cdb50525SMatthieu Baerts mptcp_lib_fail_if_expected_feature "${msg}" 250cdb50525SMatthieu Baerts 25103668c65SMatthieu Baerts print_check "${msg}" 25203668c65SMatthieu Baerts print_skip 2537f117cd3SMatthieu Baerts 2547f117cd3SMatthieu Baerts last_test_skipped=1 255cdb50525SMatthieu Baerts} 256cdb50525SMatthieu Baerts 257cdb50525SMatthieu Baerts# $@: condition 258cdb50525SMatthieu Baertscontinue_if() 259cdb50525SMatthieu Baerts{ 260cdb50525SMatthieu Baerts if ! "${@}"; then 261cdb50525SMatthieu Baerts mark_as_skipped 262cdb50525SMatthieu Baerts return 1 263cdb50525SMatthieu Baerts fi 264cdb50525SMatthieu Baerts} 265cdb50525SMatthieu Baerts 266ae7bd9ccSMatthieu Baertsskip_test() 267ae7bd9ccSMatthieu Baerts{ 268c7d49c03SMatthieu Baerts if [ "${#only_tests_ids[@]}" -eq 0 ] && [ "${#only_tests_names[@]}" -eq 0 ]; then 269ae7bd9ccSMatthieu Baerts return 1 270ae7bd9ccSMatthieu Baerts fi 271ae7bd9ccSMatthieu Baerts 272ae7bd9ccSMatthieu Baerts local i 273c7d49c03SMatthieu Baerts for i in "${only_tests_ids[@]}"; do 274ae7bd9ccSMatthieu Baerts if [ "${TEST_COUNT}" -eq "${i}" ]; then 275ae7bd9ccSMatthieu Baerts return 1 276ae7bd9ccSMatthieu Baerts fi 277ae7bd9ccSMatthieu Baerts done 278c7d49c03SMatthieu Baerts for i in "${only_tests_names[@]}"; do 279c7d49c03SMatthieu Baerts if [ "${TEST_NAME}" = "${i}" ]; then 280c7d49c03SMatthieu Baerts return 1 281c7d49c03SMatthieu Baerts fi 282c7d49c03SMatthieu Baerts done 283ae7bd9ccSMatthieu Baerts 284ae7bd9ccSMatthieu Baerts return 0 285ae7bd9ccSMatthieu Baerts} 286ae7bd9ccSMatthieu Baerts 2877f117cd3SMatthieu Baertsappend_prev_results() 2887f117cd3SMatthieu Baerts{ 2897f117cd3SMatthieu Baerts if [ ${last_test_failed} -eq 1 ]; then 2907f117cd3SMatthieu Baerts mptcp_lib_result_fail "${TEST_NAME}" 2917f117cd3SMatthieu Baerts elif [ ${last_test_skipped} -eq 1 ]; then 2927f117cd3SMatthieu Baerts mptcp_lib_result_skip "${TEST_NAME}" 2937f117cd3SMatthieu Baerts elif [ ${last_test_ignored} -ne 1 ]; then 2947f117cd3SMatthieu Baerts mptcp_lib_result_pass "${TEST_NAME}" 2957f117cd3SMatthieu Baerts fi 2967f117cd3SMatthieu Baerts 2977f117cd3SMatthieu Baerts last_test_failed=0 2987f117cd3SMatthieu Baerts last_test_skipped=0 2997f117cd3SMatthieu Baerts last_test_ignored=0 3007f117cd3SMatthieu Baerts} 3017f117cd3SMatthieu Baerts 302c7d49c03SMatthieu Baerts# $1: test name 303b08fbf24SPaolo Abenireset() 304b08fbf24SPaolo Abeni{ 3057f117cd3SMatthieu Baerts append_prev_results 3067f117cd3SMatthieu Baerts 307c7d49c03SMatthieu Baerts TEST_NAME="${1}" 308c7d49c03SMatthieu Baerts 309ae7bd9ccSMatthieu Baerts TEST_COUNT=$((TEST_COUNT+1)) 310ae7bd9ccSMatthieu Baerts 311ae7bd9ccSMatthieu Baerts if skip_test; then 3127f117cd3SMatthieu Baerts last_test_ignored=1 313ae7bd9ccSMatthieu Baerts return 1 314ae7bd9ccSMatthieu Baerts fi 315ae7bd9ccSMatthieu Baerts 31603668c65SMatthieu Baerts print_title 31703668c65SMatthieu Baerts 31893827ad5SMatthieu Baerts if [ "${init}" != "1" ]; then 319b08fbf24SPaolo Abeni init 32093827ad5SMatthieu Baerts else 32193827ad5SMatthieu Baerts cleanup_partial 32293827ad5SMatthieu Baerts fi 32393827ad5SMatthieu Baerts 32493827ad5SMatthieu Baerts init_partial 325ae7bd9ccSMatthieu Baerts 326ae7bd9ccSMatthieu Baerts return 0 327b08fbf24SPaolo Abeni} 328b08fbf24SPaolo Abeni 329ae947bb2SMatthieu Baerts# $1: test name ; $2: counter to check 330ae947bb2SMatthieu Baertsreset_check_counter() 331ae947bb2SMatthieu Baerts{ 332ae947bb2SMatthieu Baerts reset "${1}" || return 1 333ae947bb2SMatthieu Baerts 334ae947bb2SMatthieu Baerts local counter="${2}" 335ae947bb2SMatthieu Baerts 336ae947bb2SMatthieu Baerts if ! nstat -asz "${counter}" | grep -wq "${counter}"; then 337ae947bb2SMatthieu Baerts mark_as_skipped "counter '${counter}' is not available" 338ae947bb2SMatthieu Baerts return 1 339ae947bb2SMatthieu Baerts fi 340ae947bb2SMatthieu Baerts} 341ae947bb2SMatthieu Baerts 342c7d49c03SMatthieu Baerts# $1: test name 34300587187SFlorian Westphalreset_with_cookies() 34400587187SFlorian Westphal{ 345c7d49c03SMatthieu Baerts reset "${1}" || return 1 34600587187SFlorian Westphal 3471e777bd8SMatthieu Baerts local netns 34800587187SFlorian Westphal for netns in "$ns1" "$ns2"; do 34900587187SFlorian Westphal ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2 35000587187SFlorian Westphal done 35100587187SFlorian Westphal} 35200587187SFlorian Westphal 353c7d49c03SMatthieu Baerts# $1: test name 3548d014eaaSGeliang Tangreset_with_add_addr_timeout() 3558d014eaaSGeliang Tang{ 356c7d49c03SMatthieu Baerts local ip="${2:-4}" 3578d014eaaSGeliang Tang local tables 3588d014eaaSGeliang Tang 359c7d49c03SMatthieu Baerts reset "${1}" || return 1 360c7d49c03SMatthieu Baerts 3610c4cd3f8SMatthieu Baerts tables="${iptables}" 3628d014eaaSGeliang Tang if [ $ip -eq 6 ]; then 3630c4cd3f8SMatthieu Baerts tables="${ip6tables}" 3648d014eaaSGeliang Tang fi 3658d014eaaSGeliang Tang 3668d014eaaSGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 3674a0b866aSMatthieu Baerts 3684a0b866aSMatthieu Baerts if ! ip netns exec $ns2 $tables -A OUTPUT -p tcp \ 3698d014eaaSGeliang Tang -m tcp --tcp-option 30 \ 3708d014eaaSGeliang Tang -m bpf --bytecode \ 3718d014eaaSGeliang Tang "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \ 3724a0b866aSMatthieu Baerts -j DROP; then 3734a0b866aSMatthieu Baerts mark_as_skipped "unable to set the 'add addr' rule" 3744a0b866aSMatthieu Baerts return 1 3754a0b866aSMatthieu Baerts fi 3768d014eaaSGeliang Tang} 3778d014eaaSGeliang Tang 378c7d49c03SMatthieu Baerts# $1: test name 379af66d3e1SGeliang Tangreset_with_checksum() 380af66d3e1SGeliang Tang{ 381af66d3e1SGeliang Tang local ns1_enable=$1 382af66d3e1SGeliang Tang local ns2_enable=$2 383af66d3e1SGeliang Tang 384c7d49c03SMatthieu Baerts reset "checksum test ${1} ${2}" || return 1 385af66d3e1SGeliang Tang 386af66d3e1SGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=$ns1_enable 387af66d3e1SGeliang Tang ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=$ns2_enable 3883c082695SGeliang Tang 3893c082695SGeliang Tang validate_checksum=1 390af66d3e1SGeliang Tang} 391af66d3e1SGeliang Tang 3920cddb4a6SGeliang Tangreset_with_allow_join_id0() 3930cddb4a6SGeliang Tang{ 394c7d49c03SMatthieu Baerts local ns1_enable=$2 395c7d49c03SMatthieu Baerts local ns2_enable=$3 3960cddb4a6SGeliang Tang 397c7d49c03SMatthieu Baerts reset "${1}" || return 1 3980cddb4a6SGeliang Tang 3990cddb4a6SGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns1_enable 4000cddb4a6SGeliang Tang ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable 4010cddb4a6SGeliang Tang} 4020cddb4a6SGeliang Tang 403b6e074e1SGeliang Tang# Modify TCP payload without corrupting the TCP packet 404b6e074e1SGeliang Tang# 405b6e074e1SGeliang Tang# This rule inverts a 8-bit word at byte offset 148 for the 2nd TCP ACK packets 406b6e074e1SGeliang Tang# carrying enough data. 407b6e074e1SGeliang Tang# Once it is done, the TCP Checksum field is updated so the packet is still 408b6e074e1SGeliang Tang# considered as valid at the TCP level. 409b6e074e1SGeliang Tang# Because the MPTCP checksum, covering the TCP options and data, has not been 410b6e074e1SGeliang Tang# updated, the modification will be detected and an MP_FAIL will be emitted: 411b6e074e1SGeliang Tang# what we want to validate here without corrupting "random" MPTCP options. 412b6e074e1SGeliang Tang# 413b6e074e1SGeliang Tang# To avoid having tc producing this pr_info() message for each TCP ACK packets 414b6e074e1SGeliang Tang# not carrying enough data: 415b6e074e1SGeliang Tang# 416b6e074e1SGeliang Tang# tc action pedit offset 162 out of bounds 417b6e074e1SGeliang Tang# 418b6e074e1SGeliang Tang# Netfilter is used to mark packets with enough data. 4194a0b866aSMatthieu Baertssetup_fail_rules() 420b6e074e1SGeliang Tang{ 421b6e074e1SGeliang Tang check_invert=1 422b6e074e1SGeliang Tang validate_checksum=1 4234a0b866aSMatthieu Baerts local i="$1" 4244a0b866aSMatthieu Baerts local ip="${2:-4}" 425b6e074e1SGeliang Tang local tables 426b6e074e1SGeliang Tang 4270c4cd3f8SMatthieu Baerts tables="${iptables}" 428b6e074e1SGeliang Tang if [ $ip -eq 6 ]; then 4290c4cd3f8SMatthieu Baerts tables="${ip6tables}" 430b6e074e1SGeliang Tang fi 431b6e074e1SGeliang Tang 432b6e074e1SGeliang Tang ip netns exec $ns2 $tables \ 433b6e074e1SGeliang Tang -t mangle \ 434b6e074e1SGeliang Tang -A OUTPUT \ 435b6e074e1SGeliang Tang -o ns2eth$i \ 436b6e074e1SGeliang Tang -p tcp \ 437b6e074e1SGeliang Tang -m length --length 150:9999 \ 438b6e074e1SGeliang Tang -m statistic --mode nth --packet 1 --every 99999 \ 4394a0b866aSMatthieu Baerts -j MARK --set-mark 42 || return ${ksft_skip} 440b6e074e1SGeliang Tang 4414a0b866aSMatthieu Baerts tc -n $ns2 qdisc add dev ns2eth$i clsact || return ${ksft_skip} 442b6e074e1SGeliang Tang tc -n $ns2 filter add dev ns2eth$i egress \ 443b6e074e1SGeliang Tang protocol ip prio 1000 \ 444b6e074e1SGeliang Tang handle 42 fw \ 445b6e074e1SGeliang Tang action pedit munge offset 148 u8 invert \ 446b6e074e1SGeliang Tang pipe csum tcp \ 4474a0b866aSMatthieu Baerts index 100 || return ${ksft_skip} 4484a0b866aSMatthieu Baerts} 4494a0b866aSMatthieu Baerts 4504a0b866aSMatthieu Baertsreset_with_fail() 4514a0b866aSMatthieu Baerts{ 452ff8897b5SMatthieu Baerts reset_check_counter "${1}" "MPTcpExtInfiniteMapTx" || return 1 4534a0b866aSMatthieu Baerts shift 4544a0b866aSMatthieu Baerts 4554a0b866aSMatthieu Baerts ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=1 4564a0b866aSMatthieu Baerts ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=1 4574a0b866aSMatthieu Baerts 4584a0b866aSMatthieu Baerts local rc=0 4594a0b866aSMatthieu Baerts setup_fail_rules "${@}" || rc=$? 4604a0b866aSMatthieu Baerts 4614a0b866aSMatthieu Baerts if [ ${rc} -eq ${ksft_skip} ]; then 4624a0b866aSMatthieu Baerts mark_as_skipped "unable to set the 'fail' rules" 4634a0b866aSMatthieu Baerts return 1 4644a0b866aSMatthieu Baerts fi 465b6e074e1SGeliang Tang} 466b6e074e1SGeliang Tang 467a3735625SGeliang Tangreset_with_events() 468a3735625SGeliang Tang{ 469a3735625SGeliang Tang reset "${1}" || return 1 470a3735625SGeliang Tang 471a3735625SGeliang Tang :> "$evts_ns1" 472a3735625SGeliang Tang :> "$evts_ns2" 473a3735625SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl events >> "$evts_ns1" 2>&1 & 474a3735625SGeliang Tang evts_ns1_pid=$! 475a3735625SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl events >> "$evts_ns2" 2>&1 & 476a3735625SGeliang Tang evts_ns2_pid=$! 477a3735625SGeliang Tang} 478a3735625SGeliang Tang 4794a0b866aSMatthieu Baertsreset_with_tcp_filter() 4804a0b866aSMatthieu Baerts{ 4814a0b866aSMatthieu Baerts reset "${1}" || return 1 4824a0b866aSMatthieu Baerts shift 4834a0b866aSMatthieu Baerts 4844a0b866aSMatthieu Baerts local ns="${!1}" 4854a0b866aSMatthieu Baerts local src="${2}" 4864a0b866aSMatthieu Baerts local target="${3}" 487ce2f28a5SMatthieu Baerts (NGI0) local chain="${4:-INPUT}" 4884a0b866aSMatthieu Baerts 4894a0b866aSMatthieu Baerts if ! ip netns exec "${ns}" ${iptables} \ 490ce2f28a5SMatthieu Baerts (NGI0) -A "${chain}" \ 4914a0b866aSMatthieu Baerts -s "${src}" \ 4924a0b866aSMatthieu Baerts -p tcp \ 4934a0b866aSMatthieu Baerts -j "${target}"; then 4944a0b866aSMatthieu Baerts mark_as_skipped "unable to set the filter rules" 4954a0b866aSMatthieu Baerts return 1 4964a0b866aSMatthieu Baerts fi 4974a0b866aSMatthieu Baerts} 4984a0b866aSMatthieu Baerts 49903668c65SMatthieu Baerts# $1: err msg 50039aab882SMatthieu Baertsfail_test() 50139aab882SMatthieu Baerts{ 50239aab882SMatthieu Baerts ret=1 503985de459SPaolo Abeni 50403668c65SMatthieu Baerts print_fail "${@}" 50503668c65SMatthieu Baerts 5067f117cd3SMatthieu Baerts # just in case a test is marked twice as failed 5077f117cd3SMatthieu Baerts if [ ${last_test_failed} -eq 0 ]; then 5087f117cd3SMatthieu Baerts failed_tests[${TEST_COUNT}]="${TEST_NAME}" 5097f117cd3SMatthieu Baerts dump_stats 5107f117cd3SMatthieu Baerts last_test_failed=1 5117f117cd3SMatthieu Baerts fi 51239aab882SMatthieu Baerts} 51339aab882SMatthieu Baerts 51439aab882SMatthieu Baertsget_failed_tests_ids() 51539aab882SMatthieu Baerts{ 51639aab882SMatthieu Baerts # sorted 51739aab882SMatthieu Baerts local i 51839aab882SMatthieu Baerts for i in "${!failed_tests[@]}"; do 51939aab882SMatthieu Baerts echo "${i}" 52039aab882SMatthieu Baerts done | sort -n 52139aab882SMatthieu Baerts} 52239aab882SMatthieu Baerts 5238b819a84SFlorian Westphalprint_file_err() 5248b819a84SFlorian Westphal{ 5258b819a84SFlorian Westphal ls -l "$1" 1>&2 52603668c65SMatthieu Baerts echo -n "Trailing bytes are: " 5278b819a84SFlorian Westphal tail -c 27 "$1" 5288b819a84SFlorian Westphal} 5298b819a84SFlorian Westphal 530b08fbf24SPaolo Abenicheck_transfer() 531b08fbf24SPaolo Abeni{ 5321e777bd8SMatthieu Baerts local in=$1 5331e777bd8SMatthieu Baerts local out=$2 5341e777bd8SMatthieu Baerts local what=$3 5356bf41020SPaolo Abeni local bytes=$4 536d8d08302SMatthieu Baerts local i a b 537b08fbf24SPaolo Abeni 5381e777bd8SMatthieu Baerts local line 5396bf41020SPaolo Abeni if [ -n "$bytes" ]; then 5400fcd72dfSMatthieu Baerts local out_size 5416bf41020SPaolo Abeni # when truncating we must check the size explicitly 5420fcd72dfSMatthieu Baerts out_size=$(wc -c $out | awk '{print $1}') 5436bf41020SPaolo Abeni if [ $out_size -ne $bytes ]; then 54403668c65SMatthieu Baerts fail_test "$what output file has wrong size ($out_size, $bytes)" 5456bf41020SPaolo Abeni return 1 5466bf41020SPaolo Abeni fi 547d328fe87SMatthieu Baerts 548d328fe87SMatthieu Baerts # note: BusyBox's "cmp" command doesn't support --bytes 549d328fe87SMatthieu Baerts tmpfile=$(mktemp) 550d328fe87SMatthieu Baerts head --bytes="$bytes" "$in" > "$tmpfile" 551d328fe87SMatthieu Baerts mv "$tmpfile" "$in" 552d328fe87SMatthieu Baerts head --bytes="$bytes" "$out" > "$tmpfile" 553d328fe87SMatthieu Baerts mv "$tmpfile" "$out" 554d328fe87SMatthieu Baerts tmpfile="" 5556bf41020SPaolo Abeni fi 556d328fe87SMatthieu Baerts cmp -l "$in" "$out" | while read -r i a b; do 557d8d08302SMatthieu Baerts local sum=$((0${a} + 0${b})) 5588117dac3SGeliang Tang if [ $check_invert -eq 0 ] || [ $sum -ne $((0xff)) ]; then 55903668c65SMatthieu Baerts fail_test "$what does not match (in, out):" 560b08fbf24SPaolo Abeni print_file_err "$in" 561b08fbf24SPaolo Abeni print_file_err "$out" 562b08fbf24SPaolo Abeni 563b08fbf24SPaolo Abeni return 1 5648117dac3SGeliang Tang else 56503668c65SMatthieu Baerts print_info "$what has inverted byte at ${i}" 566b08fbf24SPaolo Abeni fi 5678117dac3SGeliang Tang done 568b08fbf24SPaolo Abeni 569b08fbf24SPaolo Abeni return 0 570b08fbf24SPaolo Abeni} 571b08fbf24SPaolo Abeni 572b08fbf24SPaolo Abenido_ping() 573b08fbf24SPaolo Abeni{ 5741e777bd8SMatthieu Baerts local listener_ns="$1" 5751e777bd8SMatthieu Baerts local connector_ns="$2" 5761e777bd8SMatthieu Baerts local connect_addr="$3" 577b08fbf24SPaolo Abeni 578d8d08302SMatthieu Baerts if ! ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null; then 57903668c65SMatthieu Baerts fail_test "$listener_ns -> $connect_addr connectivity" 580b08fbf24SPaolo Abeni fi 581b08fbf24SPaolo Abeni} 582b08fbf24SPaolo Abeni 5838b819a84SFlorian Westphallink_failure() 5848b819a84SFlorian Westphal{ 5851e777bd8SMatthieu Baerts local ns="$1" 5868b819a84SFlorian Westphal 5877d1e6f16SPaolo Abeni if [ -z "$FAILING_LINKS" ]; then 5888b819a84SFlorian Westphal l=$((RANDOM%4)) 5897d1e6f16SPaolo Abeni FAILING_LINKS=$((l+1)) 5907d1e6f16SPaolo Abeni fi 5918b819a84SFlorian Westphal 5921e777bd8SMatthieu Baerts local l 5937d1e6f16SPaolo Abeni for l in $FAILING_LINKS; do 5941e777bd8SMatthieu Baerts local veth="ns1eth$l" 5958b819a84SFlorian Westphal ip -net "$ns" link set "$veth" down 5967d1e6f16SPaolo Abeni done 5978b819a84SFlorian Westphal} 5988b819a84SFlorian Westphal 599327b9a94SPaolo Abeni# $1: ns, $2: port 600327b9a94SPaolo Abeniwait_local_port_listen() 601327b9a94SPaolo Abeni{ 602327b9a94SPaolo Abeni local listener_ns="${1}" 603327b9a94SPaolo Abeni local port="${2}" 604327b9a94SPaolo Abeni 6051e777bd8SMatthieu Baerts local port_hex 606327b9a94SPaolo Abeni port_hex="$(printf "%04X" "${port}")" 6071e777bd8SMatthieu Baerts 6081e777bd8SMatthieu Baerts local i 609327b9a94SPaolo Abeni for i in $(seq 10); do 610327b9a94SPaolo Abeni ip netns exec "${listener_ns}" cat /proc/net/tcp* | \ 611327b9a94SPaolo Abeni awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" && 612327b9a94SPaolo Abeni break 613327b9a94SPaolo Abeni sleep 0.1 614327b9a94SPaolo Abeni done 615327b9a94SPaolo Abeni} 616327b9a94SPaolo Abeni 617327b9a94SPaolo Abenirm_addr_count() 618327b9a94SPaolo Abeni{ 619697128a3SGeliang Tang mptcp_lib_get_counter "${1}" "MPTcpExtRmAddr" 620327b9a94SPaolo Abeni} 621327b9a94SPaolo Abeni 622327b9a94SPaolo Abeni# $1: ns, $2: old rm_addr counter in $ns 623327b9a94SPaolo Abeniwait_rm_addr() 624327b9a94SPaolo Abeni{ 625327b9a94SPaolo Abeni local ns="${1}" 626327b9a94SPaolo Abeni local old_cnt="${2}" 627327b9a94SPaolo Abeni local cnt 628327b9a94SPaolo Abeni 6291e777bd8SMatthieu Baerts local i 630327b9a94SPaolo Abeni for i in $(seq 10); do 631327b9a94SPaolo Abeni cnt=$(rm_addr_count ${ns}) 632327b9a94SPaolo Abeni [ "$cnt" = "${old_cnt}" ] || break 633327b9a94SPaolo Abeni sleep 0.1 634327b9a94SPaolo Abeni done 635327b9a94SPaolo Abeni} 636327b9a94SPaolo Abeni 6374369c198SGeliang Tangrm_sf_count() 6384369c198SGeliang Tang{ 639697128a3SGeliang Tang mptcp_lib_get_counter "${1}" "MPTcpExtRmSubflow" 6404369c198SGeliang Tang} 6414369c198SGeliang Tang 6424369c198SGeliang Tang# $1: ns, $2: old rm_sf counter in $ns 6434369c198SGeliang Tangwait_rm_sf() 6444369c198SGeliang Tang{ 6454369c198SGeliang Tang local ns="${1}" 6464369c198SGeliang Tang local old_cnt="${2}" 6474369c198SGeliang Tang local cnt 6484369c198SGeliang Tang 6494369c198SGeliang Tang local i 6504369c198SGeliang Tang for i in $(seq 10); do 6514369c198SGeliang Tang cnt=$(rm_sf_count ${ns}) 6524369c198SGeliang Tang [ "$cnt" = "${old_cnt}" ] || break 6534369c198SGeliang Tang sleep 0.1 6544369c198SGeliang Tang done 6554369c198SGeliang Tang} 6564369c198SGeliang Tang 65769c6ce7bSPaolo Abeniwait_mpj() 65869c6ce7bSPaolo Abeni{ 65969c6ce7bSPaolo Abeni local ns="${1}" 66069c6ce7bSPaolo Abeni local cnt old_cnt 66169c6ce7bSPaolo Abeni 662697128a3SGeliang Tang old_cnt=$(mptcp_lib_get_counter ${ns} "MPTcpExtMPJoinAckRx") 66369c6ce7bSPaolo Abeni 66469c6ce7bSPaolo Abeni local i 66569c6ce7bSPaolo Abeni for i in $(seq 10); do 666697128a3SGeliang Tang cnt=$(mptcp_lib_get_counter ${ns} "MPTcpExtMPJoinAckRx") 66769c6ce7bSPaolo Abeni [ "$cnt" = "${old_cnt}" ] || break 66869c6ce7bSPaolo Abeni sleep 0.1 66969c6ce7bSPaolo Abeni done 67069c6ce7bSPaolo Abeni} 67169c6ce7bSPaolo Abeni 672a3735625SGeliang Tangkill_events_pids() 673a3735625SGeliang Tang{ 6741fdb37a6SGeliang Tang mptcp_lib_kill_wait $evts_ns1_pid 6751fdb37a6SGeliang Tang mptcp_lib_kill_wait $evts_ns2_pid 676a3735625SGeliang Tang} 677a3735625SGeliang Tang 67834aa6e3bSGeliang Tangpm_nl_set_limits() 67934aa6e3bSGeliang Tang{ 68034aa6e3bSGeliang Tang local ns=$1 68134aa6e3bSGeliang Tang local addrs=$2 68234aa6e3bSGeliang Tang local subflows=$3 68334aa6e3bSGeliang Tang 68434aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 68534aa6e3bSGeliang Tang ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows 68634aa6e3bSGeliang Tang else 68734aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows 68834aa6e3bSGeliang Tang fi 68934aa6e3bSGeliang Tang} 69034aa6e3bSGeliang Tang 69134aa6e3bSGeliang Tangpm_nl_add_endpoint() 69234aa6e3bSGeliang Tang{ 69334aa6e3bSGeliang Tang local ns=$1 69434aa6e3bSGeliang Tang local addr=$2 6951e777bd8SMatthieu Baerts local flags _flags 6961e777bd8SMatthieu Baerts local port _port 6971e777bd8SMatthieu Baerts local dev _dev 6981e777bd8SMatthieu Baerts local id _id 69934aa6e3bSGeliang Tang local nr=2 70034aa6e3bSGeliang Tang 7011e777bd8SMatthieu Baerts local p 702d8d08302SMatthieu Baerts for p in "${@}" 70334aa6e3bSGeliang Tang do 70434aa6e3bSGeliang Tang if [ $p = "flags" ]; then 70534aa6e3bSGeliang Tang eval _flags=\$"$nr" 706d8d08302SMatthieu Baerts [ -n "$_flags" ]; flags="flags $_flags" 70734aa6e3bSGeliang Tang fi 70834aa6e3bSGeliang Tang if [ $p = "dev" ]; then 70934aa6e3bSGeliang Tang eval _dev=\$"$nr" 710d8d08302SMatthieu Baerts [ -n "$_dev" ]; dev="dev $_dev" 71134aa6e3bSGeliang Tang fi 71234aa6e3bSGeliang Tang if [ $p = "id" ]; then 71334aa6e3bSGeliang Tang eval _id=\$"$nr" 714d8d08302SMatthieu Baerts [ -n "$_id" ]; id="id $_id" 71534aa6e3bSGeliang Tang fi 71634aa6e3bSGeliang Tang if [ $p = "port" ]; then 71734aa6e3bSGeliang Tang eval _port=\$"$nr" 718d8d08302SMatthieu Baerts [ -n "$_port" ]; port="port $_port" 71934aa6e3bSGeliang Tang fi 72034aa6e3bSGeliang Tang 721d8d08302SMatthieu Baerts nr=$((nr + 1)) 72234aa6e3bSGeliang Tang done 72334aa6e3bSGeliang Tang 72434aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 72534aa6e3bSGeliang Tang ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port 72634aa6e3bSGeliang Tang else 72734aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port 72834aa6e3bSGeliang Tang fi 72934aa6e3bSGeliang Tang} 73034aa6e3bSGeliang Tang 73134aa6e3bSGeliang Tangpm_nl_del_endpoint() 73234aa6e3bSGeliang Tang{ 73334aa6e3bSGeliang Tang local ns=$1 73434aa6e3bSGeliang Tang local id=$2 73534aa6e3bSGeliang Tang local addr=$3 73634aa6e3bSGeliang Tang 73734aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 738aaf2123aSAndrea Claudi [ $id -ne 0 ] && addr='' 73934aa6e3bSGeliang Tang ip -n $ns mptcp endpoint delete id $id $addr 74034aa6e3bSGeliang Tang else 74134aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl del $id $addr 74234aa6e3bSGeliang Tang fi 74334aa6e3bSGeliang Tang} 74434aa6e3bSGeliang Tang 74534aa6e3bSGeliang Tangpm_nl_flush_endpoint() 74634aa6e3bSGeliang Tang{ 74734aa6e3bSGeliang Tang local ns=$1 74834aa6e3bSGeliang Tang 74934aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 75034aa6e3bSGeliang Tang ip -n $ns mptcp endpoint flush 75134aa6e3bSGeliang Tang else 75234aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl flush 75334aa6e3bSGeliang Tang fi 75434aa6e3bSGeliang Tang} 75534aa6e3bSGeliang Tang 756dda61b3dSGeliang Tangpm_nl_show_endpoints() 757dda61b3dSGeliang Tang{ 758dda61b3dSGeliang Tang local ns=$1 759dda61b3dSGeliang Tang 760dda61b3dSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 761dda61b3dSGeliang Tang ip -n $ns mptcp endpoint show 762dda61b3dSGeliang Tang else 763dda61b3dSGeliang Tang ip netns exec $ns ./pm_nl_ctl dump 764dda61b3dSGeliang Tang fi 765dda61b3dSGeliang Tang} 766dda61b3dSGeliang Tang 767f0140386SGeliang Tangpm_nl_change_endpoint() 768f0140386SGeliang Tang{ 769f0140386SGeliang Tang local ns=$1 770bccefb76SGeliang Tang local id=$2 771bccefb76SGeliang Tang local flags=$3 772f0140386SGeliang Tang 773f0140386SGeliang Tang if [ $ip_mptcp -eq 1 ]; then 774f0140386SGeliang Tang ip -n $ns mptcp endpoint change id $id ${flags//","/" "} 775f0140386SGeliang Tang else 776bccefb76SGeliang Tang ip netns exec $ns ./pm_nl_ctl set id $id flags $flags 777f0140386SGeliang Tang fi 778f0140386SGeliang Tang} 779f0140386SGeliang Tang 78069c6ce7bSPaolo Abenipm_nl_check_endpoint() 78169c6ce7bSPaolo Abeni{ 78269c6ce7bSPaolo Abeni local line expected_line 78303668c65SMatthieu Baerts local msg="$1" 78403668c65SMatthieu Baerts local ns=$2 78503668c65SMatthieu Baerts local addr=$3 78669c6ce7bSPaolo Abeni local _flags="" 78769c6ce7bSPaolo Abeni local flags 78869c6ce7bSPaolo Abeni local _port 78969c6ce7bSPaolo Abeni local port 79069c6ce7bSPaolo Abeni local dev 79169c6ce7bSPaolo Abeni local _id 79269c6ce7bSPaolo Abeni local id 79369c6ce7bSPaolo Abeni 79403668c65SMatthieu Baerts print_check "${msg}" 79569c6ce7bSPaolo Abeni 79603668c65SMatthieu Baerts shift 3 79769c6ce7bSPaolo Abeni while [ -n "$1" ]; do 79869c6ce7bSPaolo Abeni if [ $1 = "flags" ]; then 79969c6ce7bSPaolo Abeni _flags=$2 800d8d08302SMatthieu Baerts [ -n "$_flags" ]; flags="flags $_flags" 80169c6ce7bSPaolo Abeni shift 80269c6ce7bSPaolo Abeni elif [ $1 = "dev" ]; then 803117eed29SGeliang Tang [ -n "$2" ]; dev="dev $2" 80469c6ce7bSPaolo Abeni shift 80569c6ce7bSPaolo Abeni elif [ $1 = "id" ]; then 80669c6ce7bSPaolo Abeni _id=$2 807d8d08302SMatthieu Baerts [ -n "$_id" ]; id="id $_id" 80869c6ce7bSPaolo Abeni shift 80969c6ce7bSPaolo Abeni elif [ $1 = "port" ]; then 81069c6ce7bSPaolo Abeni _port=$2 811d8d08302SMatthieu Baerts [ -n "$_port" ]; port=" port $_port" 81269c6ce7bSPaolo Abeni shift 81369c6ce7bSPaolo Abeni fi 81469c6ce7bSPaolo Abeni 81569c6ce7bSPaolo Abeni shift 81669c6ce7bSPaolo Abeni done 81769c6ce7bSPaolo Abeni 81869c6ce7bSPaolo Abeni if [ -z "$id" ]; then 8198165c844SPaolo Abeni fail_test "bad test - missing endpoint id" 82069c6ce7bSPaolo Abeni return 82169c6ce7bSPaolo Abeni fi 82269c6ce7bSPaolo Abeni 82369c6ce7bSPaolo Abeni if [ $ip_mptcp -eq 1 ]; then 824c8c101aeSAndrea Claudi # get line and trim trailing whitespace 82569c6ce7bSPaolo Abeni line=$(ip -n $ns mptcp endpoint show $id) 826c8c101aeSAndrea Claudi line="${line% }" 82769c6ce7bSPaolo Abeni # the dump order is: address id flags port dev 828c8c101aeSAndrea Claudi [ -n "$addr" ] && expected_line="$addr" 829732752baSGeliang Tang expected_line+=" $id" 830732752baSGeliang Tang [ -n "$_flags" ] && expected_line+=" ${_flags//","/" "}" 831732752baSGeliang Tang [ -n "$dev" ] && expected_line+=" $dev" 832732752baSGeliang Tang [ -n "$port" ] && expected_line+=" $port" 83369c6ce7bSPaolo Abeni else 83469c6ce7bSPaolo Abeni line=$(ip netns exec $ns ./pm_nl_ctl get $_id) 83569c6ce7bSPaolo Abeni # the dump order is: id flags dev address port 83669c6ce7bSPaolo Abeni expected_line="$id" 837732752baSGeliang Tang [ -n "$flags" ] && expected_line+=" $flags" 838732752baSGeliang Tang [ -n "$dev" ] && expected_line+=" $dev" 839732752baSGeliang Tang [ -n "$addr" ] && expected_line+=" $addr" 840732752baSGeliang Tang [ -n "$_port" ] && expected_line+=" $_port" 84169c6ce7bSPaolo Abeni fi 84269c6ce7bSPaolo Abeni if [ "$line" = "$expected_line" ]; then 84303668c65SMatthieu Baerts print_ok 84469c6ce7bSPaolo Abeni else 84503668c65SMatthieu Baerts fail_test "expected '$expected_line' found '$line'" 84669c6ce7bSPaolo Abeni fi 84769c6ce7bSPaolo Abeni} 84869c6ce7bSPaolo Abeni 8499e9d176dSGeliang Tangpm_nl_set_endpoint() 850b08fbf24SPaolo Abeni{ 8511e777bd8SMatthieu Baerts local listener_ns="$1" 8521e777bd8SMatthieu Baerts local connector_ns="$2" 8539e9d176dSGeliang Tang local connect_addr="$3" 854b08fbf24SPaolo Abeni 855662aa22dSGeliang Tang local addr_nr_ns1=${addr_nr_ns1:-0} 856662aa22dSGeliang Tang local addr_nr_ns2=${addr_nr_ns2:-0} 857662aa22dSGeliang Tang local sflags=${sflags:-""} 8584aadde08SGeliang Tang local fullmesh=${fullmesh:-""} 859662aa22dSGeliang Tang 860080b7f57SGeliang Tang local flags="subflow" 8614aadde08SGeliang Tang if [ -n "${fullmesh}" ]; then 862080b7f57SGeliang Tang flags="${flags},fullmesh" 8634aadde08SGeliang Tang addr_nr_ns2=${fullmesh} 864080b7f57SGeliang Tang fi 865080b7f57SGeliang Tang 866327b9a94SPaolo Abeni # let the mptcp subflow be established in background before 867327b9a94SPaolo Abeni # do endpoint manipulation 868d8d08302SMatthieu Baerts if [ $addr_nr_ns1 != "0" ] || [ $addr_nr_ns2 != "0" ]; then 869d8d08302SMatthieu Baerts sleep 1 870d8d08302SMatthieu Baerts fi 871327b9a94SPaolo Abeni 8726208fd82SGeliang Tang if [ $addr_nr_ns1 -gt 0 ]; then 8731e777bd8SMatthieu Baerts local counter=2 874d8d08302SMatthieu Baerts local add_nr_ns1=${addr_nr_ns1} 87597040cf9SGeliang Tang local id=10 8766208fd82SGeliang Tang while [ $add_nr_ns1 -gt 0 ]; do 8776208fd82SGeliang Tang local addr 8788e7f31bfSGeliang Tang if mptcp_lib_is_v6 "${connect_addr}"; then 8796208fd82SGeliang Tang addr="dead:beef:$counter::1" 8806208fd82SGeliang Tang else 8816208fd82SGeliang Tang addr="10.0.$counter.1" 8826208fd82SGeliang Tang fi 88334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 $addr flags signal 884d8d08302SMatthieu Baerts counter=$((counter + 1)) 885d8d08302SMatthieu Baerts add_nr_ns1=$((add_nr_ns1 - 1)) 88697040cf9SGeliang Tang id=$((id + 1)) 8876208fd82SGeliang Tang done 8886208fd82SGeliang Tang elif [ $addr_nr_ns1 -lt 0 ]; then 889d8d08302SMatthieu Baerts local rm_nr_ns1=$((-addr_nr_ns1)) 8906fe4ccdcSGeliang Tang if [ $rm_nr_ns1 -lt 8 ]; then 8911e777bd8SMatthieu Baerts local counter=0 8921e777bd8SMatthieu Baerts local line 893d8d08302SMatthieu Baerts pm_nl_show_endpoints ${listener_ns} | while read -r line; do 894d8d08302SMatthieu Baerts # shellcheck disable=SC2206 # we do want to split per word 895dda61b3dSGeliang Tang local arr=($line) 896dda61b3dSGeliang Tang local nr=0 897dda61b3dSGeliang Tang 8981e777bd8SMatthieu Baerts local i 899d8d08302SMatthieu Baerts for i in "${arr[@]}"; do 900dda61b3dSGeliang Tang if [ $i = "id" ]; then 901dda61b3dSGeliang Tang if [ $counter -eq $rm_nr_ns1 ]; then 902dda61b3dSGeliang Tang break 903dda61b3dSGeliang Tang fi 904dda61b3dSGeliang Tang id=${arr[$nr+1]} 905327b9a94SPaolo Abeni rm_addr=$(rm_addr_count ${connector_ns}) 90634aa6e3bSGeliang Tang pm_nl_del_endpoint ${listener_ns} $id 907327b9a94SPaolo Abeni wait_rm_addr ${connector_ns} ${rm_addr} 908d8d08302SMatthieu Baerts counter=$((counter + 1)) 909f87744adSGeliang Tang fi 910d8d08302SMatthieu Baerts nr=$((nr + 1)) 911dda61b3dSGeliang Tang done 912dda61b3dSGeliang Tang done 9135e287fe7SGeliang Tang elif [ $rm_nr_ns1 -eq 8 ]; then 91434aa6e3bSGeliang Tang pm_nl_flush_endpoint ${listener_ns} 9155e287fe7SGeliang Tang elif [ $rm_nr_ns1 -eq 9 ]; then 91634aa6e3bSGeliang Tang pm_nl_del_endpoint ${listener_ns} 0 ${connect_addr} 9176fe4ccdcSGeliang Tang fi 918dd72b0feSGeliang Tang fi 919dd72b0feSGeliang Tang 920327b9a94SPaolo Abeni # if newly added endpoints must be deleted, give the background msk 921327b9a94SPaolo Abeni # some time to created them 922d8d08302SMatthieu Baerts [ $addr_nr_ns1 -gt 0 ] && [ $addr_nr_ns2 -lt 0 ] && sleep 1 923327b9a94SPaolo Abeni 9246208fd82SGeliang Tang if [ $addr_nr_ns2 -gt 0 ]; then 925d8d08302SMatthieu Baerts local add_nr_ns2=${addr_nr_ns2} 9261e777bd8SMatthieu Baerts local counter=3 9275e986ec4SGeliang Tang local id=20 9286208fd82SGeliang Tang while [ $add_nr_ns2 -gt 0 ]; do 9296208fd82SGeliang Tang local addr 9308e7f31bfSGeliang Tang if mptcp_lib_is_v6 "${connect_addr}"; then 9316208fd82SGeliang Tang addr="dead:beef:$counter::2" 9326208fd82SGeliang Tang else 9336208fd82SGeliang Tang addr="10.0.$counter.2" 9346208fd82SGeliang Tang fi 93534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 $addr flags $flags 936d8d08302SMatthieu Baerts counter=$((counter + 1)) 937d8d08302SMatthieu Baerts add_nr_ns2=$((add_nr_ns2 - 1)) 9385e986ec4SGeliang Tang id=$((id + 1)) 9396208fd82SGeliang Tang done 9406208fd82SGeliang Tang elif [ $addr_nr_ns2 -lt 0 ]; then 941d8d08302SMatthieu Baerts local rm_nr_ns2=$((-addr_nr_ns2)) 9426fe4ccdcSGeliang Tang if [ $rm_nr_ns2 -lt 8 ]; then 9431e777bd8SMatthieu Baerts local counter=0 9441e777bd8SMatthieu Baerts local line 945d8d08302SMatthieu Baerts pm_nl_show_endpoints ${connector_ns} | while read -r line; do 946d8d08302SMatthieu Baerts # shellcheck disable=SC2206 # we do want to split per word 947dda61b3dSGeliang Tang local arr=($line) 948dda61b3dSGeliang Tang local nr=0 949dda61b3dSGeliang Tang 9501e777bd8SMatthieu Baerts local i 951d8d08302SMatthieu Baerts for i in "${arr[@]}"; do 952dda61b3dSGeliang Tang if [ $i = "id" ]; then 953dda61b3dSGeliang Tang if [ $counter -eq $rm_nr_ns2 ]; then 954dda61b3dSGeliang Tang break 955dda61b3dSGeliang Tang fi 9561e777bd8SMatthieu Baerts local id rm_addr 957dda61b3dSGeliang Tang # rm_addr are serialized, allow the previous one to 958dda61b3dSGeliang Tang # complete 959dda61b3dSGeliang Tang id=${arr[$nr+1]} 960327b9a94SPaolo Abeni rm_addr=$(rm_addr_count ${listener_ns}) 96134aa6e3bSGeliang Tang pm_nl_del_endpoint ${connector_ns} $id 962327b9a94SPaolo Abeni wait_rm_addr ${listener_ns} ${rm_addr} 963d8d08302SMatthieu Baerts counter=$((counter + 1)) 964f87744adSGeliang Tang fi 965d8d08302SMatthieu Baerts nr=$((nr + 1)) 966dda61b3dSGeliang Tang done 967dda61b3dSGeliang Tang done 9685e287fe7SGeliang Tang elif [ $rm_nr_ns2 -eq 8 ]; then 96934aa6e3bSGeliang Tang pm_nl_flush_endpoint ${connector_ns} 9705e287fe7SGeliang Tang elif [ $rm_nr_ns2 -eq 9 ]; then 9715e287fe7SGeliang Tang local addr 9728e7f31bfSGeliang Tang if mptcp_lib_is_v6 "${connect_addr}"; then 9735e287fe7SGeliang Tang addr="dead:beef:1::2" 9745e287fe7SGeliang Tang else 9755e287fe7SGeliang Tang addr="10.0.1.2" 9765e287fe7SGeliang Tang fi 97734aa6e3bSGeliang Tang pm_nl_del_endpoint ${connector_ns} 0 $addr 9786fe4ccdcSGeliang Tang fi 979dd72b0feSGeliang Tang fi 980dd72b0feSGeliang Tang 981d8d08302SMatthieu Baerts if [ -n "${sflags}" ]; then 982718eb44eSGeliang Tang sleep 1 9831e777bd8SMatthieu Baerts 9841e777bd8SMatthieu Baerts local netns 985718eb44eSGeliang Tang for netns in "$ns1" "$ns2"; do 9861e777bd8SMatthieu Baerts local line 987d8d08302SMatthieu Baerts pm_nl_show_endpoints $netns | while read -r line; do 988d8d08302SMatthieu Baerts # shellcheck disable=SC2206 # we do want to split per word 98933397b83SGeliang Tang local arr=($line) 990bccefb76SGeliang Tang local nr=0 991f0140386SGeliang Tang local id 99233397b83SGeliang Tang 9931e777bd8SMatthieu Baerts local i 994d8d08302SMatthieu Baerts for i in "${arr[@]}"; do 995bccefb76SGeliang Tang if [ $i = "id" ]; then 996bccefb76SGeliang Tang id=${arr[$nr+1]} 997718eb44eSGeliang Tang fi 998d8d08302SMatthieu Baerts nr=$((nr + 1)) 99933397b83SGeliang Tang done 1000bccefb76SGeliang Tang pm_nl_change_endpoint $netns $id $sflags 100133397b83SGeliang Tang done 1002718eb44eSGeliang Tang done 1003718eb44eSGeliang Tang fi 10049e9d176dSGeliang Tang} 10059e9d176dSGeliang Tang 10069e9d176dSGeliang Tangdo_transfer() 10079e9d176dSGeliang Tang{ 10089e9d176dSGeliang Tang local listener_ns="$1" 10099e9d176dSGeliang Tang local connector_ns="$2" 10109e9d176dSGeliang Tang local cl_proto="$3" 10119e9d176dSGeliang Tang local srv_proto="$4" 10129e9d176dSGeliang Tang local connect_addr="$5" 10139e9d176dSGeliang Tang 10149e9d176dSGeliang Tang local port=$((10000 + TEST_COUNT - 1)) 10159e9d176dSGeliang Tang local cappid 1016662aa22dSGeliang Tang local FAILING_LINKS=${FAILING_LINKS:-""} 1017080b7f57SGeliang Tang local fastclose=${fastclose:-""} 1018e571fb09SGeliang Tang local speed=${speed:-"fast"} 10199e9d176dSGeliang Tang 10209e9d176dSGeliang Tang :> "$cout" 10219e9d176dSGeliang Tang :> "$sout" 10229e9d176dSGeliang Tang :> "$capout" 10239e9d176dSGeliang Tang 10249e9d176dSGeliang Tang if [ $capture -eq 1 ]; then 10259e9d176dSGeliang Tang local capuser 10269e9d176dSGeliang Tang if [ -z $SUDO_USER ] ; then 10279e9d176dSGeliang Tang capuser="" 10289e9d176dSGeliang Tang else 10299e9d176dSGeliang Tang capuser="-Z $SUDO_USER" 10309e9d176dSGeliang Tang fi 10319e9d176dSGeliang Tang 10329e9d176dSGeliang Tang capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}") 10339e9d176dSGeliang Tang 10349e9d176dSGeliang Tang echo "Capturing traffic for test $TEST_COUNT into $capfile" 10359e9d176dSGeliang Tang ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & 10369e9d176dSGeliang Tang cappid=$! 10379e9d176dSGeliang Tang 10389e9d176dSGeliang Tang sleep 1 10399e9d176dSGeliang Tang fi 10409e9d176dSGeliang Tang 10419e9d176dSGeliang Tang NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 10429e9d176dSGeliang Tang nstat -n 10439e9d176dSGeliang Tang NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 10449e9d176dSGeliang Tang nstat -n 10459e9d176dSGeliang Tang 10469e9d176dSGeliang Tang local extra_args 10479e9d176dSGeliang Tang if [ $speed = "fast" ]; then 10489e9d176dSGeliang Tang extra_args="-j" 10499e9d176dSGeliang Tang elif [ $speed = "slow" ]; then 10509e9d176dSGeliang Tang extra_args="-r 50" 1051e571fb09SGeliang Tang elif [ $speed -gt 0 ]; then 1052e571fb09SGeliang Tang extra_args="-r ${speed}" 10539e9d176dSGeliang Tang fi 10549e9d176dSGeliang Tang 10559e9d176dSGeliang Tang local extra_cl_args="" 10569e9d176dSGeliang Tang local extra_srv_args="" 10579e9d176dSGeliang Tang local trunc_size="" 1058080b7f57SGeliang Tang if [ -n "${fastclose}" ]; then 10599e9d176dSGeliang Tang if [ ${test_linkfail} -le 1 ]; then 106003668c65SMatthieu Baerts fail_test "fastclose tests need test_linkfail argument" 10619e9d176dSGeliang Tang return 1 10629e9d176dSGeliang Tang fi 10639e9d176dSGeliang Tang 10649e9d176dSGeliang Tang # disconnect 10659e9d176dSGeliang Tang trunc_size=${test_linkfail} 1066080b7f57SGeliang Tang local side=${fastclose} 10679e9d176dSGeliang Tang 10689e9d176dSGeliang Tang if [ ${side} = "client" ]; then 10699e9d176dSGeliang Tang extra_cl_args="-f ${test_linkfail}" 10709e9d176dSGeliang Tang extra_srv_args="-f -1" 10719e9d176dSGeliang Tang elif [ ${side} = "server" ]; then 10729e9d176dSGeliang Tang extra_srv_args="-f ${test_linkfail}" 10739e9d176dSGeliang Tang extra_cl_args="-f -1" 10749e9d176dSGeliang Tang else 107503668c65SMatthieu Baerts fail_test "wrong/unknown fastclose spec ${side}" 10769e9d176dSGeliang Tang return 1 10779e9d176dSGeliang Tang fi 10789e9d176dSGeliang Tang fi 10799e9d176dSGeliang Tang 10809e9d176dSGeliang Tang extra_srv_args="$extra_args $extra_srv_args" 10819e9d176dSGeliang Tang if [ "$test_linkfail" -gt 1 ];then 10829e9d176dSGeliang Tang timeout ${timeout_test} \ 10839e9d176dSGeliang Tang ip netns exec ${listener_ns} \ 10849e9d176dSGeliang Tang ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 10859e9d176dSGeliang Tang $extra_srv_args "::" < "$sinfail" > "$sout" & 10869e9d176dSGeliang Tang else 10879e9d176dSGeliang Tang timeout ${timeout_test} \ 10889e9d176dSGeliang Tang ip netns exec ${listener_ns} \ 10899e9d176dSGeliang Tang ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 10909e9d176dSGeliang Tang $extra_srv_args "::" < "$sin" > "$sout" & 10919e9d176dSGeliang Tang fi 10929e9d176dSGeliang Tang local spid=$! 10939e9d176dSGeliang Tang 10949e9d176dSGeliang Tang wait_local_port_listen "${listener_ns}" "${port}" 10959e9d176dSGeliang Tang 10969e9d176dSGeliang Tang extra_cl_args="$extra_args $extra_cl_args" 10979e9d176dSGeliang Tang if [ "$test_linkfail" -eq 0 ];then 10989e9d176dSGeliang Tang timeout ${timeout_test} \ 10999e9d176dSGeliang Tang ip netns exec ${connector_ns} \ 11009e9d176dSGeliang Tang ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 11019e9d176dSGeliang Tang $extra_cl_args $connect_addr < "$cin" > "$cout" & 11029e9d176dSGeliang Tang elif [ "$test_linkfail" -eq 1 ] || [ "$test_linkfail" -eq 2 ];then 11039e9d176dSGeliang Tang ( cat "$cinfail" ; sleep 2; link_failure $listener_ns ; cat "$cinfail" ) | \ 11049e9d176dSGeliang Tang tee "$cinsent" | \ 11059e9d176dSGeliang Tang timeout ${timeout_test} \ 11069e9d176dSGeliang Tang ip netns exec ${connector_ns} \ 11079e9d176dSGeliang Tang ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 11089e9d176dSGeliang Tang $extra_cl_args $connect_addr > "$cout" & 11099e9d176dSGeliang Tang else 11109e9d176dSGeliang Tang tee "$cinsent" < "$cinfail" | \ 11119e9d176dSGeliang Tang timeout ${timeout_test} \ 11129e9d176dSGeliang Tang ip netns exec ${connector_ns} \ 11139e9d176dSGeliang Tang ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 11149e9d176dSGeliang Tang $extra_cl_args $connect_addr > "$cout" & 11159e9d176dSGeliang Tang fi 11169e9d176dSGeliang Tang local cpid=$! 11179e9d176dSGeliang Tang 11189e9d176dSGeliang Tang pm_nl_set_endpoint $listener_ns $connector_ns $connect_addr 1119718eb44eSGeliang Tang 1120b08fbf24SPaolo Abeni wait $cpid 11211e777bd8SMatthieu Baerts local retc=$? 1122b08fbf24SPaolo Abeni wait $spid 11231e777bd8SMatthieu Baerts local rets=$? 1124b08fbf24SPaolo Abeni 1125b08fbf24SPaolo Abeni if [ $capture -eq 1 ]; then 1126b08fbf24SPaolo Abeni sleep 1 1127b08fbf24SPaolo Abeni kill $cappid 1128b08fbf24SPaolo Abeni fi 1129b08fbf24SPaolo Abeni 1130c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 1131c2a55e8fSMatthieu Baerts nstat | grep Tcp > /tmp/${listener_ns}.out 1132c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 1133c2a55e8fSMatthieu Baerts nstat | grep Tcp > /tmp/${connector_ns}.out 1134c2a55e8fSMatthieu Baerts 1135b08fbf24SPaolo Abeni if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then 113603668c65SMatthieu Baerts fail_test "client exit code $retc, server $rets" 11378b974778SMatthieu Baerts echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 1138c2a55e8fSMatthieu Baerts ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port" 1139c2a55e8fSMatthieu Baerts cat /tmp/${listener_ns}.out 11408b974778SMatthieu Baerts echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2 1141c2a55e8fSMatthieu Baerts ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port" 1142c2a55e8fSMatthieu Baerts cat /tmp/${connector_ns}.out 1143b08fbf24SPaolo Abeni 1144b08fbf24SPaolo Abeni cat "$capout" 1145b08fbf24SPaolo Abeni return 1 1146b08fbf24SPaolo Abeni fi 1147b08fbf24SPaolo Abeni 11480c93af1fSGeliang Tang if [ "$test_linkfail" -gt 1 ];then 11496bf41020SPaolo Abeni check_transfer $sinfail $cout "file received by client" $trunc_size 11507d1e6f16SPaolo Abeni else 11516bf41020SPaolo Abeni check_transfer $sin $cout "file received by client" $trunc_size 11527d1e6f16SPaolo Abeni fi 1153b08fbf24SPaolo Abeni retc=$? 11540c93af1fSGeliang Tang if [ "$test_linkfail" -eq 0 ];then 11556bf41020SPaolo Abeni check_transfer $cin $sout "file received by server" $trunc_size 11568b819a84SFlorian Westphal else 11576bf41020SPaolo Abeni check_transfer $cinsent $sout "file received by server" $trunc_size 11588b819a84SFlorian Westphal fi 1159b08fbf24SPaolo Abeni rets=$? 1160b08fbf24SPaolo Abeni 1161b08fbf24SPaolo Abeni if [ $retc -eq 0 ] && [ $rets -eq 0 ];then 1162b08fbf24SPaolo Abeni cat "$capout" 1163b08fbf24SPaolo Abeni return 0 1164b08fbf24SPaolo Abeni fi 1165b08fbf24SPaolo Abeni 1166b08fbf24SPaolo Abeni cat "$capout" 1167b08fbf24SPaolo Abeni return 1 1168b08fbf24SPaolo Abeni} 1169b08fbf24SPaolo Abeni 1170b08fbf24SPaolo Abenimake_file() 1171b08fbf24SPaolo Abeni{ 11721e777bd8SMatthieu Baerts local name=$1 11731e777bd8SMatthieu Baerts local who=$2 11741e777bd8SMatthieu Baerts local size=$3 1175b08fbf24SPaolo Abeni 11768b819a84SFlorian Westphal dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null 1177b08fbf24SPaolo Abeni echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" 1178b08fbf24SPaolo Abeni 117903668c65SMatthieu Baerts print_info "Test file (size $size KB) for $who" 1180b08fbf24SPaolo Abeni} 1181b08fbf24SPaolo Abeni 1182b08fbf24SPaolo Abenirun_tests() 1183b08fbf24SPaolo Abeni{ 11841e777bd8SMatthieu Baerts local listener_ns="$1" 11851e777bd8SMatthieu Baerts local connector_ns="$2" 11861e777bd8SMatthieu Baerts local connect_addr="$3" 11871e777bd8SMatthieu Baerts 11881e777bd8SMatthieu Baerts local size 1189662aa22dSGeliang Tang local test_linkfail=${test_linkfail:-0} 11908b819a84SFlorian Westphal 119134b572b7SGeliang Tang # The values above 2 are reused to make test files 119234b572b7SGeliang Tang # with the given sizes (KB) 119334b572b7SGeliang Tang if [ "$test_linkfail" -gt 2 ]; then 119434b572b7SGeliang Tang size=$test_linkfail 119534b572b7SGeliang Tang 119634b572b7SGeliang Tang if [ -z "$cinfail" ]; then 119734b572b7SGeliang Tang cinfail=$(mktemp) 119834b572b7SGeliang Tang fi 119934b572b7SGeliang Tang make_file "$cinfail" "client" $size 12007d1e6f16SPaolo Abeni # create the input file for the failure test when 12017d1e6f16SPaolo Abeni # the first failure test run 1202d8d08302SMatthieu Baerts elif [ "$test_linkfail" -ne 0 ] && [ -z "$cinfail" ]; then 12037d1e6f16SPaolo Abeni # the client file must be considerably larger 12047d1e6f16SPaolo Abeni # of the maximum expected cwin value, or the 12057d1e6f16SPaolo Abeni # link utilization will be not predicable 12067d1e6f16SPaolo Abeni size=$((RANDOM%2)) 12078b819a84SFlorian Westphal size=$((size+1)) 12087d1e6f16SPaolo Abeni size=$((size*8192)) 1209d8d08302SMatthieu Baerts size=$((size + ( RANDOM % 8192) )) 12108b819a84SFlorian Westphal 12117d1e6f16SPaolo Abeni cinfail=$(mktemp) 12127d1e6f16SPaolo Abeni make_file "$cinfail" "client" $size 12137d1e6f16SPaolo Abeni fi 12147d1e6f16SPaolo Abeni 121534b572b7SGeliang Tang if [ "$test_linkfail" -gt 2 ]; then 121634b572b7SGeliang Tang size=$test_linkfail 121734b572b7SGeliang Tang 121834b572b7SGeliang Tang if [ -z "$sinfail" ]; then 121934b572b7SGeliang Tang sinfail=$(mktemp) 122034b572b7SGeliang Tang fi 122134b572b7SGeliang Tang make_file "$sinfail" "server" $size 1222d8d08302SMatthieu Baerts elif [ "$test_linkfail" -eq 2 ] && [ -z "$sinfail" ]; then 12237d1e6f16SPaolo Abeni size=$((RANDOM%16)) 12247d1e6f16SPaolo Abeni size=$((size+1)) 12257d1e6f16SPaolo Abeni size=$((size*2048)) 12267d1e6f16SPaolo Abeni 12277d1e6f16SPaolo Abeni sinfail=$(mktemp) 12287d1e6f16SPaolo Abeni make_file "$sinfail" "server" $size 12298b819a84SFlorian Westphal fi 1230b08fbf24SPaolo Abeni 1231e571fb09SGeliang Tang do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} 1232b08fbf24SPaolo Abeni} 1233b08fbf24SPaolo Abeni 1234327b9a94SPaolo Abenidump_stats() 1235327b9a94SPaolo Abeni{ 1236327b9a94SPaolo Abeni echo Server ns stats 1237327b9a94SPaolo Abeni ip netns exec $ns1 nstat -as | grep Tcp 1238327b9a94SPaolo Abeni echo Client ns stats 1239327b9a94SPaolo Abeni ip netns exec $ns2 nstat -as | grep Tcp 1240327b9a94SPaolo Abeni} 1241327b9a94SPaolo Abeni 1242af66d3e1SGeliang Tangchk_csum_nr() 1243af66d3e1SGeliang Tang{ 12443c082695SGeliang Tang local csum_ns1=${1:-0} 12453c082695SGeliang Tang local csum_ns2=${2:-0} 1246af66d3e1SGeliang Tang local count 124753f368bfSGeliang Tang local extra_msg="" 124826516e10SGeliang Tang local allow_multi_errors_ns1=0 124926516e10SGeliang Tang local allow_multi_errors_ns2=0 125026516e10SGeliang Tang 125126516e10SGeliang Tang if [[ "${csum_ns1}" = "+"* ]]; then 125226516e10SGeliang Tang allow_multi_errors_ns1=1 125326516e10SGeliang Tang csum_ns1=${csum_ns1:1} 125426516e10SGeliang Tang fi 125526516e10SGeliang Tang if [[ "${csum_ns2}" = "+"* ]]; then 125626516e10SGeliang Tang allow_multi_errors_ns2=1 125726516e10SGeliang Tang csum_ns2=${csum_ns2:1} 125826516e10SGeliang Tang fi 1259af66d3e1SGeliang Tang 126003668c65SMatthieu Baerts print_check "sum" 1261697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtDataCsumErr") 126299c17b3bSMatthieu Baerts (NGI0) if [ -n "$count" ] && [ "$count" != "$csum_ns1" ]; then 1263732752baSGeliang Tang extra_msg+=" ns1=$count" 126453f368bfSGeliang Tang fi 126547867f0aSMatthieu Baerts if [ -z "$count" ]; then 126603668c65SMatthieu Baerts print_skip 126747867f0aSMatthieu Baerts elif { [ "$count" != $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 0 ]; } || 1268d8d08302SMatthieu Baerts { [ "$count" -lt $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 1 ]; }; then 126903668c65SMatthieu Baerts fail_test "got $count data checksum error[s] expected $csum_ns1" 1270af66d3e1SGeliang Tang else 127103668c65SMatthieu Baerts print_ok 1272af66d3e1SGeliang Tang fi 127303668c65SMatthieu Baerts print_check "csum" 1274697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtDataCsumErr") 127599c17b3bSMatthieu Baerts (NGI0) if [ -n "$count" ] && [ "$count" != "$csum_ns2" ]; then 1276732752baSGeliang Tang extra_msg+=" ns2=$count" 127753f368bfSGeliang Tang fi 127847867f0aSMatthieu Baerts if [ -z "$count" ]; then 127903668c65SMatthieu Baerts print_skip 128047867f0aSMatthieu Baerts elif { [ "$count" != $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 0 ]; } || 1281d8d08302SMatthieu Baerts { [ "$count" -lt $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 1 ]; }; then 128203668c65SMatthieu Baerts fail_test "got $count data checksum error[s] expected $csum_ns2" 1283af66d3e1SGeliang Tang else 128403668c65SMatthieu Baerts print_ok 1285af66d3e1SGeliang Tang fi 128653f368bfSGeliang Tang 128703668c65SMatthieu Baerts print_info "$extra_msg" 1288af66d3e1SGeliang Tang} 1289af66d3e1SGeliang Tang 12906bb3ab49SGeliang Tangchk_fail_nr() 12916bb3ab49SGeliang Tang{ 129226516e10SGeliang Tang local fail_tx=$1 129326516e10SGeliang Tang local fail_rx=$2 12941f7d325fSGeliang Tang local ns_invert=${3:-""} 12956bb3ab49SGeliang Tang local count 12961f7d325fSGeliang Tang local ns_tx=$ns1 12971f7d325fSGeliang Tang local ns_rx=$ns2 12981f7d325fSGeliang Tang local extra_msg="" 12991f7d325fSGeliang Tang local allow_tx_lost=0 13001f7d325fSGeliang Tang local allow_rx_lost=0 13011f7d325fSGeliang Tang 13021f7d325fSGeliang Tang if [[ $ns_invert = "invert" ]]; then 13031f7d325fSGeliang Tang ns_tx=$ns2 13041f7d325fSGeliang Tang ns_rx=$ns1 13051f7d325fSGeliang Tang extra_msg="invert" 13061f7d325fSGeliang Tang fi 13071f7d325fSGeliang Tang 13081f7d325fSGeliang Tang if [[ "${fail_tx}" = "-"* ]]; then 13091f7d325fSGeliang Tang allow_tx_lost=1 13101f7d325fSGeliang Tang fail_tx=${fail_tx:1} 13111f7d325fSGeliang Tang fi 13121f7d325fSGeliang Tang if [[ "${fail_rx}" = "-"* ]]; then 13131f7d325fSGeliang Tang allow_rx_lost=1 13141f7d325fSGeliang Tang fail_rx=${fail_rx:1} 13151f7d325fSGeliang Tang fi 13166bb3ab49SGeliang Tang 131703668c65SMatthieu Baerts print_check "ftx" 1318697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPFailTx") 131999c17b3bSMatthieu Baerts (NGI0) if [ -n "$count" ] && [ "$count" != "$fail_tx" ]; then 1320732752baSGeliang Tang extra_msg+=",tx=$count" 13211f7d325fSGeliang Tang fi 132247867f0aSMatthieu Baerts if [ -z "$count" ]; then 132303668c65SMatthieu Baerts print_skip 132447867f0aSMatthieu Baerts elif { [ "$count" != "$fail_tx" ] && [ $allow_tx_lost -eq 0 ]; } || 13251f7d325fSGeliang Tang { [ "$count" -gt "$fail_tx" ] && [ $allow_tx_lost -eq 1 ]; }; then 132603668c65SMatthieu Baerts fail_test "got $count MP_FAIL[s] TX expected $fail_tx" 13276bb3ab49SGeliang Tang else 132803668c65SMatthieu Baerts print_ok 13296bb3ab49SGeliang Tang fi 13306bb3ab49SGeliang Tang 133103668c65SMatthieu Baerts print_check "failrx" 1332697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPFailRx") 133399c17b3bSMatthieu Baerts (NGI0) if [ -n "$count" ] && [ "$count" != "$fail_rx" ]; then 1334732752baSGeliang Tang extra_msg+=",rx=$count" 13351f7d325fSGeliang Tang fi 133647867f0aSMatthieu Baerts if [ -z "$count" ]; then 133703668c65SMatthieu Baerts print_skip 133847867f0aSMatthieu Baerts elif { [ "$count" != "$fail_rx" ] && [ $allow_rx_lost -eq 0 ]; } || 13391f7d325fSGeliang Tang { [ "$count" -gt "$fail_rx" ] && [ $allow_rx_lost -eq 1 ]; }; then 134003668c65SMatthieu Baerts fail_test "got $count MP_FAIL[s] RX expected $fail_rx" 13416bb3ab49SGeliang Tang else 134203668c65SMatthieu Baerts print_ok 13436bb3ab49SGeliang Tang fi 13446bb3ab49SGeliang Tang 134503668c65SMatthieu Baerts print_info "$extra_msg" 13466bb3ab49SGeliang Tang} 13476bb3ab49SGeliang Tang 1348e8e947efSGeliang Tangchk_fclose_nr() 1349e8e947efSGeliang Tang{ 1350e8e947efSGeliang Tang local fclose_tx=$1 1351e8e947efSGeliang Tang local fclose_rx=$2 13526bf41020SPaolo Abeni local ns_invert=$3 1353e8e947efSGeliang Tang local count 13546bf41020SPaolo Abeni local ns_tx=$ns2 13556bf41020SPaolo Abeni local ns_rx=$ns1 13566bf41020SPaolo Abeni local extra_msg="" 13576bf41020SPaolo Abeni 13586bf41020SPaolo Abeni if [[ $ns_invert = "invert" ]]; then 13596bf41020SPaolo Abeni ns_tx=$ns1 13606bf41020SPaolo Abeni ns_rx=$ns2 136103668c65SMatthieu Baerts extra_msg="invert" 13626bf41020SPaolo Abeni fi 1363e8e947efSGeliang Tang 136403668c65SMatthieu Baerts print_check "ctx" 1365697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPFastcloseTx") 136647867f0aSMatthieu Baerts if [ -z "$count" ]; then 136703668c65SMatthieu Baerts print_skip 136847867f0aSMatthieu Baerts elif [ "$count" != "$fclose_tx" ]; then 1369732752baSGeliang Tang extra_msg+=",tx=$count" 137003668c65SMatthieu Baerts fail_test "got $count MP_FASTCLOSE[s] TX expected $fclose_tx" 1371e8e947efSGeliang Tang else 137203668c65SMatthieu Baerts print_ok 1373e8e947efSGeliang Tang fi 1374e8e947efSGeliang Tang 137503668c65SMatthieu Baerts print_check "fclzrx" 1376697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPFastcloseRx") 137747867f0aSMatthieu Baerts if [ -z "$count" ]; then 137803668c65SMatthieu Baerts print_skip 137947867f0aSMatthieu Baerts elif [ "$count" != "$fclose_rx" ]; then 1380732752baSGeliang Tang extra_msg+=",rx=$count" 138103668c65SMatthieu Baerts fail_test "got $count MP_FASTCLOSE[s] RX expected $fclose_rx" 1382e8e947efSGeliang Tang else 138303668c65SMatthieu Baerts print_ok 1384e8e947efSGeliang Tang fi 1385e8e947efSGeliang Tang 138603668c65SMatthieu Baerts print_info "$extra_msg" 1387e8e947efSGeliang Tang} 1388e8e947efSGeliang Tang 1389922fd2b3SGeliang Tangchk_rst_nr() 1390922fd2b3SGeliang Tang{ 1391922fd2b3SGeliang Tang local rst_tx=$1 1392922fd2b3SGeliang Tang local rst_rx=$2 1393922fd2b3SGeliang Tang local ns_invert=${3:-""} 1394922fd2b3SGeliang Tang local count 1395922fd2b3SGeliang Tang local ns_tx=$ns1 1396922fd2b3SGeliang Tang local ns_rx=$ns2 1397922fd2b3SGeliang Tang local extra_msg="" 1398922fd2b3SGeliang Tang 1399922fd2b3SGeliang Tang if [[ $ns_invert = "invert" ]]; then 1400922fd2b3SGeliang Tang ns_tx=$ns2 1401922fd2b3SGeliang Tang ns_rx=$ns1 1402922fd2b3SGeliang Tang extra_msg="invert" 1403922fd2b3SGeliang Tang fi 1404922fd2b3SGeliang Tang 140503668c65SMatthieu Baerts print_check "rtx" 1406697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPRstTx") 140747867f0aSMatthieu Baerts if [ -z "$count" ]; then 140803668c65SMatthieu Baerts print_skip 1409b134a580SMatthieu Baerts # accept more rst than expected except if we don't expect any 1410b134a580SMatthieu Baerts elif { [ $rst_tx -ne 0 ] && [ $count -lt $rst_tx ]; } || 1411b134a580SMatthieu Baerts { [ $rst_tx -eq 0 ] && [ $count -ne 0 ]; }; then 141203668c65SMatthieu Baerts fail_test "got $count MP_RST[s] TX expected $rst_tx" 1413922fd2b3SGeliang Tang else 141403668c65SMatthieu Baerts print_ok 1415922fd2b3SGeliang Tang fi 1416922fd2b3SGeliang Tang 141703668c65SMatthieu Baerts print_check "rstrx" 1418697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPRstRx") 141947867f0aSMatthieu Baerts if [ -z "$count" ]; then 142003668c65SMatthieu Baerts print_skip 1421b134a580SMatthieu Baerts # accept more rst than expected except if we don't expect any 1422b134a580SMatthieu Baerts elif { [ $rst_rx -ne 0 ] && [ $count -lt $rst_rx ]; } || 1423b134a580SMatthieu Baerts { [ $rst_rx -eq 0 ] && [ $count -ne 0 ]; }; then 142403668c65SMatthieu Baerts fail_test "got $count MP_RST[s] RX expected $rst_rx" 1425922fd2b3SGeliang Tang else 142603668c65SMatthieu Baerts print_ok 1427922fd2b3SGeliang Tang fi 1428922fd2b3SGeliang Tang 142903668c65SMatthieu Baerts print_info "$extra_msg" 1430922fd2b3SGeliang Tang} 1431922fd2b3SGeliang Tang 14328bd03be3SGeliang Tangchk_infi_nr() 14338bd03be3SGeliang Tang{ 14348bd03be3SGeliang Tang local infi_tx=$1 14358bd03be3SGeliang Tang local infi_rx=$2 14368bd03be3SGeliang Tang local count 14378bd03be3SGeliang Tang 143803668c65SMatthieu Baerts print_check "itx" 1439697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtInfiniteMapTx") 144047867f0aSMatthieu Baerts if [ -z "$count" ]; then 144103668c65SMatthieu Baerts print_skip 144247867f0aSMatthieu Baerts elif [ "$count" != "$infi_tx" ]; then 144303668c65SMatthieu Baerts fail_test "got $count infinite map[s] TX expected $infi_tx" 14448bd03be3SGeliang Tang else 144503668c65SMatthieu Baerts print_ok 14468bd03be3SGeliang Tang fi 14478bd03be3SGeliang Tang 144803668c65SMatthieu Baerts print_check "infirx" 1449697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtInfiniteMapRx") 145047867f0aSMatthieu Baerts if [ -z "$count" ]; then 145103668c65SMatthieu Baerts print_skip 145247867f0aSMatthieu Baerts elif [ "$count" != "$infi_rx" ]; then 145303668c65SMatthieu Baerts fail_test "got $count infinite map[s] RX expected $infi_rx" 14548bd03be3SGeliang Tang else 145503668c65SMatthieu Baerts print_ok 14568bd03be3SGeliang Tang fi 14578bd03be3SGeliang Tang} 14588bd03be3SGeliang Tang 1459b08fbf24SPaolo Abenichk_join_nr() 1460b08fbf24SPaolo Abeni{ 1461c7d49c03SMatthieu Baerts local syn_nr=$1 1462c7d49c03SMatthieu Baerts local syn_ack_nr=$2 1463c7d49c03SMatthieu Baerts local ack_nr=$3 1464c7d49c03SMatthieu Baerts local csum_ns1=${4:-0} 1465c7d49c03SMatthieu Baerts local csum_ns2=${5:-0} 1466c7d49c03SMatthieu Baerts local fail_nr=${6:-0} 1467c7d49c03SMatthieu Baerts local rst_nr=${7:-0} 14688bd03be3SGeliang Tang local infi_nr=${8:-0} 14698bd03be3SGeliang Tang local corrupted_pkts=${9:-0} 1470b08fbf24SPaolo Abeni local count 1471e35f885bSPaolo Abeni local with_cookie 1472b08fbf24SPaolo Abeni 1473c7d49c03SMatthieu Baerts if [ "${corrupted_pkts}" -gt 0 ]; then 147403668c65SMatthieu Baerts print_info "${corrupted_pkts} corrupted pkts" 1475c7d49c03SMatthieu Baerts fi 1476c7d49c03SMatthieu Baerts 147703668c65SMatthieu Baerts print_check "syn" 1478697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinSynRx") 147947867f0aSMatthieu Baerts if [ -z "$count" ]; then 148003668c65SMatthieu Baerts print_skip 148147867f0aSMatthieu Baerts elif [ "$count" != "$syn_nr" ]; then 148203668c65SMatthieu Baerts fail_test "got $count JOIN[s] syn expected $syn_nr" 1483b08fbf24SPaolo Abeni else 148403668c65SMatthieu Baerts print_ok 1485b08fbf24SPaolo Abeni fi 1486b08fbf24SPaolo Abeni 148703668c65SMatthieu Baerts print_check "synack" 14884bfadd71SMatthieu Baerts with_cookie=$(ip netns exec $ns2 sysctl -n net.ipv4.tcp_syncookies) 1489697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinSynAckRx") 149047867f0aSMatthieu Baerts if [ -z "$count" ]; then 149103668c65SMatthieu Baerts print_skip 149247867f0aSMatthieu Baerts elif [ "$count" != "$syn_ack_nr" ]; then 1493e35f885bSPaolo Abeni # simult connections exceeding the limit with cookie enabled could go up to 1494e35f885bSPaolo Abeni # synack validation as the conn limit can be enforced reliably only after 1495e35f885bSPaolo Abeni # the subflow creation 1496e35f885bSPaolo Abeni if [ "$with_cookie" = 2 ] && [ "$count" -gt "$syn_ack_nr" ] && [ "$count" -le "$syn_nr" ]; then 149703668c65SMatthieu Baerts print_ok 1498e35f885bSPaolo Abeni else 149903668c65SMatthieu Baerts fail_test "got $count JOIN[s] synack expected $syn_ack_nr" 1500e35f885bSPaolo Abeni fi 1501b08fbf24SPaolo Abeni else 150203668c65SMatthieu Baerts print_ok 1503b08fbf24SPaolo Abeni fi 1504b08fbf24SPaolo Abeni 150503668c65SMatthieu Baerts print_check "ack" 1506697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinAckRx") 150747867f0aSMatthieu Baerts if [ -z "$count" ]; then 150803668c65SMatthieu Baerts print_skip 150947867f0aSMatthieu Baerts elif [ "$count" != "$ack_nr" ]; then 151003668c65SMatthieu Baerts fail_test "got $count JOIN[s] ack expected $ack_nr" 1511b08fbf24SPaolo Abeni else 151203668c65SMatthieu Baerts print_ok 1513b08fbf24SPaolo Abeni fi 1514b6e074e1SGeliang Tang if [ $validate_checksum -eq 1 ]; then 15153c082695SGeliang Tang chk_csum_nr $csum_ns1 $csum_ns2 151626516e10SGeliang Tang chk_fail_nr $fail_nr $fail_nr 151726516e10SGeliang Tang chk_rst_nr $rst_nr $rst_nr 15188bd03be3SGeliang Tang chk_infi_nr $infi_nr $infi_nr 1519af66d3e1SGeliang Tang fi 1520b08fbf24SPaolo Abeni} 1521b08fbf24SPaolo Abeni 15227d1e6f16SPaolo Abeni# a negative value for 'stale_max' means no upper bound: 15237d1e6f16SPaolo Abeni# for bidirectional transfer, if one peer sleep for a while 15247d1e6f16SPaolo Abeni# - as these tests do - we can have a quite high number of 15257d1e6f16SPaolo Abeni# stale/recover conversions, proportional to 15267d1e6f16SPaolo Abeni# sleep duration/ MPTCP-level RTX interval. 15277d1e6f16SPaolo Abenichk_stale_nr() 15287d1e6f16SPaolo Abeni{ 15297d1e6f16SPaolo Abeni local ns=$1 15307d1e6f16SPaolo Abeni local stale_min=$2 15317d1e6f16SPaolo Abeni local stale_max=$3 15327d1e6f16SPaolo Abeni local stale_delta=$4 15337d1e6f16SPaolo Abeni local dump_stats 15347d1e6f16SPaolo Abeni local stale_nr 15357d1e6f16SPaolo Abeni local recover_nr 15367d1e6f16SPaolo Abeni 153703668c65SMatthieu Baerts print_check "stale" 15387d1e6f16SPaolo Abeni 1539697128a3SGeliang Tang stale_nr=$(mptcp_lib_get_counter ${ns} "MPTcpExtSubflowStale") 1540697128a3SGeliang Tang recover_nr=$(mptcp_lib_get_counter ${ns} "MPTcpExtSubflowRecover") 154147867f0aSMatthieu Baerts if [ -z "$stale_nr" ] || [ -z "$recover_nr" ]; then 154203668c65SMatthieu Baerts print_skip 154347867f0aSMatthieu Baerts elif [ $stale_nr -lt $stale_min ] || 1544d8d08302SMatthieu Baerts { [ $stale_max -gt 0 ] && [ $stale_nr -gt $stale_max ]; } || 1545d8d08302SMatthieu Baerts [ $((stale_nr - recover_nr)) -ne $stale_delta ]; then 154603668c65SMatthieu Baerts fail_test "got $stale_nr stale[s] $recover_nr recover[s], " \ 15477d1e6f16SPaolo Abeni " expected stale in range [$stale_min..$stale_max]," \ 15487d1e6f16SPaolo Abeni " stale-recover delta $stale_delta" 15497d1e6f16SPaolo Abeni dump_stats=1 15507d1e6f16SPaolo Abeni else 155103668c65SMatthieu Baerts print_ok 15527d1e6f16SPaolo Abeni fi 15537d1e6f16SPaolo Abeni 15547d1e6f16SPaolo Abeni if [ "${dump_stats}" = 1 ]; then 15557d1e6f16SPaolo Abeni echo $ns stats 15567d1e6f16SPaolo Abeni ip netns exec $ns ip -s link show 15577d1e6f16SPaolo Abeni ip netns exec $ns nstat -as | grep MPTcp 15587d1e6f16SPaolo Abeni fi 15597d1e6f16SPaolo Abeni} 15607d1e6f16SPaolo Abeni 1561be613160SGeliang Tangchk_add_nr() 1562be613160SGeliang Tang{ 1563be613160SGeliang Tang local add_nr=$1 1564be613160SGeliang Tang local echo_nr=$2 15658a127bf6SGeliang Tang local port_nr=${3:-0} 1566e80cf3fcSMatthieu Baerts (NGI0) local ns_invert=${4:-""} 1567e80cf3fcSMatthieu Baerts (NGI0) local syn_nr=$port_nr 1568e80cf3fcSMatthieu Baerts (NGI0) local syn_ack_nr=$port_nr 1569e80cf3fcSMatthieu Baerts (NGI0) local ack_nr=$port_nr 1570e80cf3fcSMatthieu Baerts (NGI0) local mis_syn_nr=0 1571e80cf3fcSMatthieu Baerts (NGI0) local mis_ack_nr=0 1572e80cf3fcSMatthieu Baerts (NGI0) local ns_tx=$ns1 1573e80cf3fcSMatthieu Baerts (NGI0) local ns_rx=$ns2 1574e80cf3fcSMatthieu Baerts (NGI0) local extra_msg="" 1575be613160SGeliang Tang local count 15766ef84b15SPaolo Abeni local timeout 15776ef84b15SPaolo Abeni 1578e80cf3fcSMatthieu Baerts (NGI0) if [[ $ns_invert = "invert" ]]; then 1579e80cf3fcSMatthieu Baerts (NGI0) ns_tx=$ns2 1580e80cf3fcSMatthieu Baerts (NGI0) ns_rx=$ns1 1581e80cf3fcSMatthieu Baerts (NGI0) extra_msg="invert" 1582e80cf3fcSMatthieu Baerts (NGI0) fi 1583e80cf3fcSMatthieu Baerts (NGI0) 1584e80cf3fcSMatthieu Baerts (NGI0) timeout=$(ip netns exec ${ns_tx} sysctl -n net.mptcp.add_addr_timeout) 1585be613160SGeliang Tang 158603668c65SMatthieu Baerts print_check "add" 1587e80cf3fcSMatthieu Baerts (NGI0) count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtAddAddr") 158847867f0aSMatthieu Baerts if [ -z "$count" ]; then 158903668c65SMatthieu Baerts print_skip 15906ef84b15SPaolo Abeni # if the test configured a short timeout tolerate greater then expected 15916ef84b15SPaolo Abeni # add addrs options, due to retransmissions 159247867f0aSMatthieu Baerts elif [ "$count" != "$add_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_nr" ]; }; then 159303668c65SMatthieu Baerts fail_test "got $count ADD_ADDR[s] expected $add_nr" 1594be613160SGeliang Tang else 159503668c65SMatthieu Baerts print_ok 1596be613160SGeliang Tang fi 1597be613160SGeliang Tang 159803668c65SMatthieu Baerts print_check "echo" 1599e80cf3fcSMatthieu Baerts (NGI0) count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtEchoAdd") 160047867f0aSMatthieu Baerts if [ -z "$count" ]; then 160103668c65SMatthieu Baerts print_skip 160247867f0aSMatthieu Baerts elif [ "$count" != "$echo_nr" ]; then 160303668c65SMatthieu Baerts fail_test "got $count ADD_ADDR echo[s] expected $echo_nr" 1604be613160SGeliang Tang else 160503668c65SMatthieu Baerts print_ok 16068a127bf6SGeliang Tang fi 16078a127bf6SGeliang Tang 16088a127bf6SGeliang Tang if [ $port_nr -gt 0 ]; then 160903668c65SMatthieu Baerts print_check "pt" 1610e80cf3fcSMatthieu Baerts (NGI0) count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtPortAdd") 161147867f0aSMatthieu Baerts if [ -z "$count" ]; then 161203668c65SMatthieu Baerts print_skip 161347867f0aSMatthieu Baerts elif [ "$count" != "$port_nr" ]; then 161403668c65SMatthieu Baerts fail_test "got $count ADD_ADDR[s] with a port-number expected $port_nr" 16158a127bf6SGeliang Tang else 161603668c65SMatthieu Baerts print_ok 1617be613160SGeliang Tang fi 1618be613160SGeliang Tang 161903668c65SMatthieu Baerts print_check "syn" 1620e80cf3fcSMatthieu Baerts (NGI0) count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPJoinPortSynRx") 162147867f0aSMatthieu Baerts if [ -z "$count" ]; then 162203668c65SMatthieu Baerts print_skip 162347867f0aSMatthieu Baerts elif [ "$count" != "$syn_nr" ]; then 162403668c65SMatthieu Baerts fail_test "got $count JOIN[s] syn with a different \ 16258a127bf6SGeliang Tang port-number expected $syn_nr" 16268a127bf6SGeliang Tang else 162703668c65SMatthieu Baerts print_ok 16288a127bf6SGeliang Tang fi 16298a127bf6SGeliang Tang 163003668c65SMatthieu Baerts print_check "synack" 1631e80cf3fcSMatthieu Baerts (NGI0) count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPJoinPortSynAckRx") 163247867f0aSMatthieu Baerts if [ -z "$count" ]; then 163303668c65SMatthieu Baerts print_skip 163447867f0aSMatthieu Baerts elif [ "$count" != "$syn_ack_nr" ]; then 163503668c65SMatthieu Baerts fail_test "got $count JOIN[s] synack with a different \ 16368a127bf6SGeliang Tang port-number expected $syn_ack_nr" 16378a127bf6SGeliang Tang else 163803668c65SMatthieu Baerts print_ok 16398a127bf6SGeliang Tang fi 16408a127bf6SGeliang Tang 164103668c65SMatthieu Baerts print_check "ack" 1642e80cf3fcSMatthieu Baerts (NGI0) count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPJoinPortAckRx") 164347867f0aSMatthieu Baerts if [ -z "$count" ]; then 164403668c65SMatthieu Baerts print_skip 164547867f0aSMatthieu Baerts elif [ "$count" != "$ack_nr" ]; then 164603668c65SMatthieu Baerts fail_test "got $count JOIN[s] ack with a different \ 16478a127bf6SGeliang Tang port-number expected $ack_nr" 16488a127bf6SGeliang Tang else 164903668c65SMatthieu Baerts print_ok 16508a127bf6SGeliang Tang fi 16518a127bf6SGeliang Tang 165203668c65SMatthieu Baerts print_check "syn" 1653e80cf3fcSMatthieu Baerts (NGI0) count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMismatchPortSynRx") 165447867f0aSMatthieu Baerts if [ -z "$count" ]; then 165503668c65SMatthieu Baerts print_skip 165647867f0aSMatthieu Baerts elif [ "$count" != "$mis_syn_nr" ]; then 165703668c65SMatthieu Baerts fail_test "got $count JOIN[s] syn with a mismatched \ 16588a127bf6SGeliang Tang port-number expected $mis_syn_nr" 16598a127bf6SGeliang Tang else 166003668c65SMatthieu Baerts print_ok 16618a127bf6SGeliang Tang fi 16628a127bf6SGeliang Tang 166303668c65SMatthieu Baerts print_check "ack" 1664e80cf3fcSMatthieu Baerts (NGI0) count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMismatchPortAckRx") 166547867f0aSMatthieu Baerts if [ -z "$count" ]; then 166603668c65SMatthieu Baerts print_skip 166747867f0aSMatthieu Baerts elif [ "$count" != "$mis_ack_nr" ]; then 166803668c65SMatthieu Baerts fail_test "got $count JOIN[s] ack with a mismatched \ 16698a127bf6SGeliang Tang port-number expected $mis_ack_nr" 16708a127bf6SGeliang Tang else 167103668c65SMatthieu Baerts print_ok 16728a127bf6SGeliang Tang fi 16738a127bf6SGeliang Tang fi 1674e80cf3fcSMatthieu Baerts (NGI0) 1675e80cf3fcSMatthieu Baerts (NGI0) print_info "$extra_msg" 1676be613160SGeliang Tang} 1677be613160SGeliang Tang 16780639fa23SPaolo Abenichk_add_tx_nr() 16790639fa23SPaolo Abeni{ 16800639fa23SPaolo Abeni local add_tx_nr=$1 16810639fa23SPaolo Abeni local echo_tx_nr=$2 16820639fa23SPaolo Abeni local timeout 16830639fa23SPaolo Abeni local count 16840639fa23SPaolo Abeni 16850639fa23SPaolo Abeni timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout) 16860639fa23SPaolo Abeni 168703668c65SMatthieu Baerts print_check "add TX" 1688697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtAddAddrTx") 168900079f18SMatthieu Baerts if [ -z "$count" ]; then 169003668c65SMatthieu Baerts print_skip 16910639fa23SPaolo Abeni # if the test configured a short timeout tolerate greater then expected 16920639fa23SPaolo Abeni # add addrs options, due to retransmissions 169300079f18SMatthieu Baerts elif [ "$count" != "$add_tx_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_tx_nr" ]; }; then 169403668c65SMatthieu Baerts fail_test "got $count ADD_ADDR[s] TX, expected $add_tx_nr" 16950639fa23SPaolo Abeni else 169603668c65SMatthieu Baerts print_ok 16970639fa23SPaolo Abeni fi 16980639fa23SPaolo Abeni 169903668c65SMatthieu Baerts print_check "echo TX" 1700697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtEchoAddTx") 170100079f18SMatthieu Baerts if [ -z "$count" ]; then 170203668c65SMatthieu Baerts print_skip 170300079f18SMatthieu Baerts elif [ "$count" != "$echo_tx_nr" ]; then 170403668c65SMatthieu Baerts fail_test "got $count ADD_ADDR echo[s] TX, expected $echo_tx_nr" 17050639fa23SPaolo Abeni else 170603668c65SMatthieu Baerts print_ok 17070639fa23SPaolo Abeni fi 17080639fa23SPaolo Abeni} 17090639fa23SPaolo Abeni 1710dd72b0feSGeliang Tangchk_rm_nr() 1711dd72b0feSGeliang Tang{ 1712dd72b0feSGeliang Tang local rm_addr_nr=$1 1713dd72b0feSGeliang Tang local rm_subflow_nr=$2 17146fa0174aSPaolo Abeni local invert 17156fa0174aSPaolo Abeni local simult 1716dd72b0feSGeliang Tang local count 17177d9bf018SGeliang Tang local addr_ns=$ns1 17187d9bf018SGeliang Tang local subflow_ns=$ns2 17197d9bf018SGeliang Tang local extra_msg="" 17207028ba8aSGeliang Tang 17216fa0174aSPaolo Abeni shift 2 17226fa0174aSPaolo Abeni while [ -n "$1" ]; do 17236fa0174aSPaolo Abeni [ "$1" = "invert" ] && invert=true 17246fa0174aSPaolo Abeni [ "$1" = "simult" ] && simult=true 17256fa0174aSPaolo Abeni shift 17266fa0174aSPaolo Abeni done 17276fa0174aSPaolo Abeni 17286fa0174aSPaolo Abeni if [ -z $invert ]; then 17296fa0174aSPaolo Abeni addr_ns=$ns1 17306fa0174aSPaolo Abeni subflow_ns=$ns2 17316fa0174aSPaolo Abeni elif [ $invert = "true" ]; then 17327028ba8aSGeliang Tang addr_ns=$ns2 17337028ba8aSGeliang Tang subflow_ns=$ns1 17347d9bf018SGeliang Tang extra_msg="invert" 17357028ba8aSGeliang Tang fi 1736dd72b0feSGeliang Tang 173703668c65SMatthieu Baerts print_check "rm" 1738697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${addr_ns} "MPTcpExtRmAddr") 173900079f18SMatthieu Baerts if [ -z "$count" ]; then 174003668c65SMatthieu Baerts print_skip 174100079f18SMatthieu Baerts elif [ "$count" != "$rm_addr_nr" ]; then 174203668c65SMatthieu Baerts fail_test "got $count RM_ADDR[s] expected $rm_addr_nr" 1743dd72b0feSGeliang Tang else 174403668c65SMatthieu Baerts print_ok 1745dd72b0feSGeliang Tang fi 1746dd72b0feSGeliang Tang 174703668c65SMatthieu Baerts print_check "rmsf" 1748697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${subflow_ns} "MPTcpExtRmSubflow") 174947867f0aSMatthieu Baerts if [ -z "$count" ]; then 175003668c65SMatthieu Baerts print_skip 175147867f0aSMatthieu Baerts elif [ -n "$simult" ]; then 1752d8d08302SMatthieu Baerts local cnt suffix 1753d8d08302SMatthieu Baerts 1754697128a3SGeliang Tang cnt=$(mptcp_lib_get_counter ${addr_ns} "MPTcpExtRmSubflow") 17556fa0174aSPaolo Abeni 17566fa0174aSPaolo Abeni # in case of simult flush, the subflow removal count on each side is 17576fa0174aSPaolo Abeni # unreliable 17586fa0174aSPaolo Abeni count=$((count + cnt)) 1759a445eb1fSGeliang Tang if [ "$count" != "$rm_subflow_nr" ]; then 1760a445eb1fSGeliang Tang suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]" 1761732752baSGeliang Tang extra_msg+=" simult" 1762a445eb1fSGeliang Tang fi 17636fa0174aSPaolo Abeni if [ $count -ge "$rm_subflow_nr" ] && \ 17646fa0174aSPaolo Abeni [ "$count" -le "$((rm_subflow_nr *2 ))" ]; then 176503668c65SMatthieu Baerts print_ok "$suffix" 17666fa0174aSPaolo Abeni else 176703668c65SMatthieu Baerts fail_test "got $count RM_SUBFLOW[s] expected in range [$rm_subflow_nr:$((rm_subflow_nr*2))]" 17686fa0174aSPaolo Abeni fi 176947867f0aSMatthieu Baerts elif [ "$count" != "$rm_subflow_nr" ]; then 177003668c65SMatthieu Baerts fail_test "got $count RM_SUBFLOW[s] expected $rm_subflow_nr" 1771dd72b0feSGeliang Tang else 177203668c65SMatthieu Baerts print_ok 1773dd72b0feSGeliang Tang fi 1774dd72b0feSGeliang Tang 177503668c65SMatthieu Baerts print_info "$extra_msg" 1776dd72b0feSGeliang Tang} 1777dd72b0feSGeliang Tang 17780639fa23SPaolo Abenichk_rm_tx_nr() 17790639fa23SPaolo Abeni{ 17800639fa23SPaolo Abeni local rm_addr_tx_nr=$1 17810639fa23SPaolo Abeni 178203668c65SMatthieu Baerts print_check "rm TX" 1783697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtRmAddrTx") 178400079f18SMatthieu Baerts if [ -z "$count" ]; then 178503668c65SMatthieu Baerts print_skip 178600079f18SMatthieu Baerts elif [ "$count" != "$rm_addr_tx_nr" ]; then 178703668c65SMatthieu Baerts fail_test "got $count RM_ADDR[s] expected $rm_addr_tx_nr" 17880639fa23SPaolo Abeni else 178903668c65SMatthieu Baerts print_ok 17900639fa23SPaolo Abeni fi 17910639fa23SPaolo Abeni} 17920639fa23SPaolo Abeni 1793718eb44eSGeliang Tangchk_prio_nr() 1794718eb44eSGeliang Tang{ 1795718eb44eSGeliang Tang local mp_prio_nr_tx=$1 1796718eb44eSGeliang Tang local mp_prio_nr_rx=$2 17978213b98eSMatthieu Baerts (NGI0) local mpj_syn=$3 17988213b98eSMatthieu Baerts (NGI0) local mpj_syn_ack=$4 1799718eb44eSGeliang Tang local count 1800718eb44eSGeliang Tang 180103668c65SMatthieu Baerts print_check "ptx" 1802697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPPrioTx") 180347867f0aSMatthieu Baerts if [ -z "$count" ]; then 180403668c65SMatthieu Baerts print_skip 180547867f0aSMatthieu Baerts elif [ "$count" != "$mp_prio_nr_tx" ]; then 180603668c65SMatthieu Baerts fail_test "got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" 1807718eb44eSGeliang Tang else 180803668c65SMatthieu Baerts print_ok 1809718eb44eSGeliang Tang fi 1810718eb44eSGeliang Tang 181103668c65SMatthieu Baerts print_check "prx" 1812697128a3SGeliang Tang count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPPrioRx") 181347867f0aSMatthieu Baerts if [ -z "$count" ]; then 181403668c65SMatthieu Baerts print_skip 181547867f0aSMatthieu Baerts elif [ "$count" != "$mp_prio_nr_rx" ]; then 181603668c65SMatthieu Baerts fail_test "got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" 1817718eb44eSGeliang Tang else 181803668c65SMatthieu Baerts print_ok 1819718eb44eSGeliang Tang fi 18208213b98eSMatthieu Baerts (NGI0) 18218213b98eSMatthieu Baerts (NGI0) print_check "syn backup" 18228213b98eSMatthieu Baerts (NGI0) count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinSynBackupRx") 18238213b98eSMatthieu Baerts (NGI0) if [ -z "$count" ]; then 18248213b98eSMatthieu Baerts (NGI0) print_skip 18258213b98eSMatthieu Baerts (NGI0) elif [ "$count" != "$mpj_syn" ]; then 18268213b98eSMatthieu Baerts (NGI0) fail_test "got $count JOIN[s] syn with Backup expected $mpj_syn" 18278213b98eSMatthieu Baerts (NGI0) else 18288213b98eSMatthieu Baerts (NGI0) print_ok 18298213b98eSMatthieu Baerts (NGI0) fi 18308213b98eSMatthieu Baerts (NGI0) 18318213b98eSMatthieu Baerts (NGI0) print_check "synack backup" 18328213b98eSMatthieu Baerts (NGI0) count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinSynAckBackupRx") 18338213b98eSMatthieu Baerts (NGI0) if [ -z "$count" ]; then 18348213b98eSMatthieu Baerts (NGI0) print_skip 18358213b98eSMatthieu Baerts (NGI0) elif [ "$count" != "$mpj_syn_ack" ]; then 18368213b98eSMatthieu Baerts (NGI0) fail_test "got $count JOIN[s] synack with Backup expected $mpj_syn_ack" 18378213b98eSMatthieu Baerts (NGI0) else 18388213b98eSMatthieu Baerts (NGI0) print_ok 18398213b98eSMatthieu Baerts (NGI0) fi 1840718eb44eSGeliang Tang} 1841718eb44eSGeliang Tang 1842e274f715SPaolo Abenichk_subflow_nr() 1843e274f715SPaolo Abeni{ 184403668c65SMatthieu Baerts local msg="$1" 184503668c65SMatthieu Baerts local subflow_nr=$2 1846e274f715SPaolo Abeni local cnt1 1847e274f715SPaolo Abeni local cnt2 1848a635a8c3SPaolo Abeni local dump_stats 1849e274f715SPaolo Abeni 185003668c65SMatthieu Baerts print_check "${msg}" 1851e274f715SPaolo Abeni 1852e274f715SPaolo Abeni cnt1=$(ss -N $ns1 -tOni | grep -c token) 1853e274f715SPaolo Abeni cnt2=$(ss -N $ns2 -tOni | grep -c token) 18540fcd72dfSMatthieu Baerts if [ "$cnt1" != "$subflow_nr" ] || [ "$cnt2" != "$subflow_nr" ]; then 185503668c65SMatthieu Baerts fail_test "got $cnt1:$cnt2 subflows expected $subflow_nr" 1856e274f715SPaolo Abeni dump_stats=1 1857e274f715SPaolo Abeni else 185803668c65SMatthieu Baerts print_ok 1859e274f715SPaolo Abeni fi 1860e274f715SPaolo Abeni 1861a635a8c3SPaolo Abeni if [ "${dump_stats}" = 1 ]; then 1862a635a8c3SPaolo Abeni ss -N $ns1 -tOni 1863a635a8c3SPaolo Abeni ss -N $ns1 -tOni | grep token 1864a635a8c3SPaolo Abeni ip -n $ns1 mptcp endpoint 1865a635a8c3SPaolo Abeni fi 1866e274f715SPaolo Abeni} 1867e274f715SPaolo Abeni 18689095ce97SGeliang Tangchk_mptcp_info() 18699095ce97SGeliang Tang{ 1870d7ced753SGeliang Tang local info1=$1 1871d7ced753SGeliang Tang local exp1=$2 1872d7ced753SGeliang Tang local info2=$3 1873d7ced753SGeliang Tang local exp2=$4 18749095ce97SGeliang Tang local cnt1 18759095ce97SGeliang Tang local cnt2 18769095ce97SGeliang Tang local dump_stats 18779095ce97SGeliang Tang 1878f9190d79SGeliang Tang print_check "mptcp_info ${info1:0:15}=$exp1:$exp2" 18799095ce97SGeliang Tang 1880ae1fa39dSGeliang Tang cnt1=$(ss -N $ns1 -inmHM | mptcp_lib_get_info_value "$info1" "$info1") 1881ae1fa39dSGeliang Tang cnt2=$(ss -N $ns2 -inmHM | mptcp_lib_get_info_value "$info2" "$info2") 1882d7ced753SGeliang Tang # 'ss' only display active connections and counters that are not 0. 18839095ce97SGeliang Tang [ -z "$cnt1" ] && cnt1=0 18849095ce97SGeliang Tang [ -z "$cnt2" ] && cnt2=0 1885d7ced753SGeliang Tang 1886d7ced753SGeliang Tang if [ "$cnt1" != "$exp1" ] || [ "$cnt2" != "$exp2" ]; then 188703668c65SMatthieu Baerts fail_test "got $cnt1:$cnt2 $info1:$info2 expected $exp1:$exp2" 18889095ce97SGeliang Tang dump_stats=1 18899095ce97SGeliang Tang else 189003668c65SMatthieu Baerts print_ok 18919095ce97SGeliang Tang fi 18929095ce97SGeliang Tang 18939095ce97SGeliang Tang if [ "$dump_stats" = 1 ]; then 18949095ce97SGeliang Tang ss -N $ns1 -inmHM 18959095ce97SGeliang Tang ss -N $ns2 -inmHM 18969095ce97SGeliang Tang fi 18979095ce97SGeliang Tang} 18989095ce97SGeliang Tang 1899f9190d79SGeliang Tang# $1: subflows in ns1 ; $2: subflows in ns2 1900f9190d79SGeliang Tang# number of all subflows, including the initial subflow. 1901f9190d79SGeliang Tangchk_subflows_total() 1902f9190d79SGeliang Tang{ 1903f9190d79SGeliang Tang local cnt1 1904f9190d79SGeliang Tang local cnt2 1905f9190d79SGeliang Tang local info="subflows_total" 1906f9190d79SGeliang Tang local dump_stats 1907f9190d79SGeliang Tang 1908f9190d79SGeliang Tang # if subflows_total counter is supported, use it: 1909f9190d79SGeliang Tang if [ -n "$(ss -N $ns1 -inmHM | mptcp_lib_get_info_value $info $info)" ]; then 1910f9190d79SGeliang Tang chk_mptcp_info $info $1 $info $2 1911f9190d79SGeliang Tang return 1912f9190d79SGeliang Tang fi 1913f9190d79SGeliang Tang 1914f9190d79SGeliang Tang print_check "$info $1:$2" 1915f9190d79SGeliang Tang 1916f9190d79SGeliang Tang # if not, count the TCP connections that are in fact MPTCP subflows 1917f9190d79SGeliang Tang cnt1=$(ss -N $ns1 -ti state established state syn-sent state syn-recv | 1918f9190d79SGeliang Tang grep -c tcp-ulp-mptcp) 1919f9190d79SGeliang Tang cnt2=$(ss -N $ns2 -ti state established state syn-sent state syn-recv | 1920f9190d79SGeliang Tang grep -c tcp-ulp-mptcp) 1921f9190d79SGeliang Tang 1922f9190d79SGeliang Tang if [ "$1" != "$cnt1" ] || [ "$2" != "$cnt2" ]; then 1923f9190d79SGeliang Tang fail_test "got subflows $cnt1:$cnt2 expected $1:$2" 1924f9190d79SGeliang Tang dump_stats=1 1925f9190d79SGeliang Tang else 1926f9190d79SGeliang Tang print_ok 1927f9190d79SGeliang Tang fi 1928f9190d79SGeliang Tang 1929f9190d79SGeliang Tang if [ "$dump_stats" = 1 ]; then 1930f9190d79SGeliang Tang ss -N $ns1 -ti 1931f9190d79SGeliang Tang ss -N $ns2 -ti 1932f9190d79SGeliang Tang fi 1933f9190d79SGeliang Tang} 1934f9190d79SGeliang Tang 19357d1e6f16SPaolo Abenichk_link_usage() 19367d1e6f16SPaolo Abeni{ 19377d1e6f16SPaolo Abeni local ns=$1 19387d1e6f16SPaolo Abeni local link=$2 19397d1e6f16SPaolo Abeni local out=$3 19407d1e6f16SPaolo Abeni local expected_rate=$4 19414bfadd71SMatthieu Baerts 19424bfadd71SMatthieu Baerts local tx_link tx_total 19434bfadd71SMatthieu Baerts tx_link=$(ip netns exec $ns cat /sys/class/net/$link/statistics/tx_bytes) 1944d8d08302SMatthieu Baerts tx_total=$(stat --format=%s $out) 1945d8d08302SMatthieu Baerts local tx_rate=$((tx_link * 100 / tx_total)) 19467d1e6f16SPaolo Abeni local tolerance=5 19477d1e6f16SPaolo Abeni 194803668c65SMatthieu Baerts print_check "link usage" 1949d8d08302SMatthieu Baerts if [ $tx_rate -lt $((expected_rate - tolerance)) ] || \ 1950d8d08302SMatthieu Baerts [ $tx_rate -gt $((expected_rate + tolerance)) ]; then 195103668c65SMatthieu Baerts fail_test "got $tx_rate% usage, expected $expected_rate%" 19527d1e6f16SPaolo Abeni else 195303668c65SMatthieu Baerts print_ok 19547d1e6f16SPaolo Abeni fi 19557d1e6f16SPaolo Abeni} 19567d1e6f16SPaolo Abeni 1957f98c2bcaSMat Martineauwait_attempt_fail() 195846e967d1SPaolo Abeni{ 195946e967d1SPaolo Abeni local timeout_ms=$((timeout_poll * 1000)) 196046e967d1SPaolo Abeni local time=0 196146e967d1SPaolo Abeni local ns=$1 196246e967d1SPaolo Abeni 196346e967d1SPaolo Abeni while [ $time -lt $timeout_ms ]; do 19641e777bd8SMatthieu Baerts local cnt 19651e777bd8SMatthieu Baerts 1966697128a3SGeliang Tang cnt=$(mptcp_lib_get_counter ${ns} "TcpAttemptFails") 196746e967d1SPaolo Abeni 196846e967d1SPaolo Abeni [ "$cnt" = 1 ] && return 1 196946e967d1SPaolo Abeni time=$((time + 100)) 197046e967d1SPaolo Abeni sleep 0.1 197146e967d1SPaolo Abeni done 197246e967d1SPaolo Abeni return 1 197346e967d1SPaolo Abeni} 197446e967d1SPaolo Abeni 19755ac1d2d6SMat Martineauset_userspace_pm() 19765ac1d2d6SMat Martineau{ 19775ac1d2d6SMat Martineau local ns=$1 19785ac1d2d6SMat Martineau 19795ac1d2d6SMat Martineau ip netns exec $ns sysctl -q net.mptcp.pm_type=1 19805ac1d2d6SMat Martineau} 19815ac1d2d6SMat Martineau 19821002b89fSGeliang Tangsubflows_tests() 19831002b89fSGeliang Tang{ 1984c7d49c03SMatthieu Baerts if reset "no JOIN"; then 1985b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1986c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 1987ae7bd9ccSMatthieu Baerts fi 1988b08fbf24SPaolo Abeni 19891002b89fSGeliang Tang # subflow limited by client 1990c7d49c03SMatthieu Baerts if reset "single subflow, limited by client"; then 199134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 0 199234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 0 199334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1994b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1995c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 1996ae7bd9ccSMatthieu Baerts fi 1997b08fbf24SPaolo Abeni 19981002b89fSGeliang Tang # subflow limited by server 1999c7d49c03SMatthieu Baerts if reset "single subflow, limited by server"; then 200034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 0 200134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 200234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2003b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2004c7d49c03SMatthieu Baerts chk_join_nr 1 1 0 2005ae7bd9ccSMatthieu Baerts fi 2006b08fbf24SPaolo Abeni 2007b08fbf24SPaolo Abeni # subflow 2008c7d49c03SMatthieu Baerts if reset "single subflow"; then 200934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 201034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 201134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2012b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2013c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2014ae7bd9ccSMatthieu Baerts fi 2015b08fbf24SPaolo Abeni 2016b08fbf24SPaolo Abeni # multiple subflows 2017c7d49c03SMatthieu Baerts if reset "multiple subflows"; then 201834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 201934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 202034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 202134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 2022b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2023c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2024ae7bd9ccSMatthieu Baerts fi 2025b08fbf24SPaolo Abeni 202672bcbc46SPaolo Abeni # multiple subflows limited by server 2027c7d49c03SMatthieu Baerts if reset "multiple subflows, limited by server"; then 202834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 202934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 203034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 203134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 2032b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2033c7d49c03SMatthieu Baerts chk_join_nr 2 2 1 2034ae7bd9ccSMatthieu Baerts fi 2035c3eaa5f6SGeliang Tang 2036c3eaa5f6SGeliang Tang # single subflow, dev 2037c7d49c03SMatthieu Baerts if reset "single subflow, dev"; then 203834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 203934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 204034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow dev ns2eth3 2041c3eaa5f6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2042c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2043ae7bd9ccSMatthieu Baerts fi 20441002b89fSGeliang Tang} 2045b08fbf24SPaolo Abeni 204646e967d1SPaolo Abenisubflows_error_tests() 204746e967d1SPaolo Abeni{ 204846e967d1SPaolo Abeni # If a single subflow is configured, and matches the MPC src 204946e967d1SPaolo Abeni # address, no additional subflow should be created 2050c7d49c03SMatthieu Baerts if reset "no MPC reuse with single endpoint"; then 205134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 205234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 205334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow 2054e571fb09SGeliang Tang speed=slow \ 2055e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2056c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 2057ae7bd9ccSMatthieu Baerts fi 205846e967d1SPaolo Abeni 205946e967d1SPaolo Abeni # multiple subflows, with subflow creation error 20604a0b866aSMatthieu Baerts if reset_with_tcp_filter "multi subflows, with failing subflow" ns1 10.0.3.2 REJECT && 20614a0b866aSMatthieu Baerts continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then 206234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 206334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 206434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 206534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 2066e571fb09SGeliang Tang speed=slow \ 2067e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2068c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2069ae7bd9ccSMatthieu Baerts fi 207046e967d1SPaolo Abeni 207146e967d1SPaolo Abeni # multiple subflows, with subflow timeout on MPJ 20724a0b866aSMatthieu Baerts if reset_with_tcp_filter "multi subflows, with subflow timeout" ns1 10.0.3.2 DROP && 20734a0b866aSMatthieu Baerts continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then 207434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 207534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 207634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 207734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 2078e571fb09SGeliang Tang speed=slow \ 2079e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2080c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2081ae7bd9ccSMatthieu Baerts fi 208246e967d1SPaolo Abeni 208346e967d1SPaolo Abeni # multiple subflows, check that the endpoint corresponding to 208446e967d1SPaolo Abeni # closed subflow (due to reset) is not reused if additional 208546e967d1SPaolo Abeni # subflows are added later 20864a0b866aSMatthieu Baerts if reset_with_tcp_filter "multi subflows, fair usage on close" ns1 10.0.3.2 REJECT && 20874a0b866aSMatthieu Baerts continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then 208834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 208934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 209034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2091e571fb09SGeliang Tang speed=slow \ 2092e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 & 209346e967d1SPaolo Abeni 209446e967d1SPaolo Abeni # mpj subflow will be in TW after the reset 2095f98c2bcaSMat Martineau wait_attempt_fail $ns2 209634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 209746e967d1SPaolo Abeni wait 209846e967d1SPaolo Abeni 209946e967d1SPaolo Abeni # additional subflow could be created only if the PM select 210046e967d1SPaolo Abeni # the later endpoint, skipping the already used one 2101c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2102ae7bd9ccSMatthieu Baerts fi 210346e967d1SPaolo Abeni} 210446e967d1SPaolo Abeni 21051002b89fSGeliang Tangsignal_address_tests() 21061002b89fSGeliang Tang{ 2107b08fbf24SPaolo Abeni # add_address, unused 2108c7d49c03SMatthieu Baerts if reset "unused signal address"; then 210934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2110b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2111c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 21120639fa23SPaolo Abeni chk_add_tx_nr 1 1 2113be613160SGeliang Tang chk_add_nr 1 1 2114ae7bd9ccSMatthieu Baerts fi 2115b08fbf24SPaolo Abeni 2116b08fbf24SPaolo Abeni # accept and use add_addr 2117c7d49c03SMatthieu Baerts if reset "signal address"; then 211834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 211934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 212034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2121b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2122c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2123be613160SGeliang Tang chk_add_nr 1 1 2124ae7bd9ccSMatthieu Baerts fi 2125b08fbf24SPaolo Abeni 2126b08fbf24SPaolo Abeni # accept and use add_addr with an additional subflow 2127b08fbf24SPaolo Abeni # note: signal address in server ns and local addresses in client ns must 2128b08fbf24SPaolo Abeni # belong to different subnets or one of the listed local address could be 2129b08fbf24SPaolo Abeni # used for 'add_addr' subflow 2130c7d49c03SMatthieu Baerts if reset "subflow and signal"; then 213134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 213234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 213334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 213434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2135b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2136c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2137be613160SGeliang Tang chk_add_nr 1 1 2138ae7bd9ccSMatthieu Baerts fi 2139b08fbf24SPaolo Abeni 21409d97114fSMatthieu Baerts (NGI0) # uncommon: subflow and signal flags on the same endpoint 21419d97114fSMatthieu Baerts (NGI0) # or because the user wrongly picked both, but still expects the client 21429d97114fSMatthieu Baerts (NGI0) # to create additional subflows 21439d97114fSMatthieu Baerts (NGI0) if reset "subflow and signal together"; then 21449d97114fSMatthieu Baerts (NGI0) pm_nl_set_limits $ns1 0 2 21459d97114fSMatthieu Baerts (NGI0) pm_nl_set_limits $ns2 0 2 21469d97114fSMatthieu Baerts (NGI0) pm_nl_add_endpoint $ns2 10.0.3.2 flags signal,subflow 21479d97114fSMatthieu Baerts (NGI0) run_tests $ns1 $ns2 10.0.1.1 21489d97114fSMatthieu Baerts (NGI0) chk_join_nr 1 1 1 21499d97114fSMatthieu Baerts (NGI0) chk_add_nr 1 1 0 invert # only initiated by ns2 21509d97114fSMatthieu Baerts (NGI0) chk_add_nr 0 0 0 # none initiated by ns1 21519d97114fSMatthieu Baerts (NGI0) chk_rst_nr 0 0 invert # no RST sent by the client 21529d97114fSMatthieu Baerts (NGI0) chk_rst_nr 0 0 # no RST sent by the server 21539d97114fSMatthieu Baerts (NGI0) fi 21549d97114fSMatthieu Baerts (NGI0) 2155b08fbf24SPaolo Abeni # accept and use add_addr with additional subflows 2156c7d49c03SMatthieu Baerts if reset "multiple subflows and signal"; then 215734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 215834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 215934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 216034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 216134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 2162b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2163c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2164be613160SGeliang Tang chk_add_nr 1 1 2165ae7bd9ccSMatthieu Baerts fi 2166ef360019SGeliang Tang 2167ef360019SGeliang Tang # signal addresses 2168c7d49c03SMatthieu Baerts if reset "signal addresses"; then 216934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 217034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 217134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 217234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 217334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 2174ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2175c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2176ef360019SGeliang Tang chk_add_nr 3 3 2177ae7bd9ccSMatthieu Baerts fi 2178ef360019SGeliang Tang 2179ef360019SGeliang Tang # signal invalid addresses 2180c7d49c03SMatthieu Baerts if reset "signal invalid addresses"; then 218134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 218234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 218334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 218434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 218534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 2186ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2187c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2188ef360019SGeliang Tang chk_add_nr 3 3 2189ae7bd9ccSMatthieu Baerts fi 219033c563adSYonglong Li 219133c563adSYonglong Li # signal addresses race test 2192c7d49c03SMatthieu Baerts if reset "signal addresses race test"; then 219334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 219434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 219534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.1.1 flags signal 219634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 219734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 219834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 219934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.1.2 flags signal 220034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags signal 220134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags signal 220234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags signal 22036ef84b15SPaolo Abeni 22046ef84b15SPaolo Abeni # the peer could possibly miss some addr notification, allow retransmission 22056ef84b15SPaolo Abeni ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 2206e571fb09SGeliang Tang speed=slow \ 2207e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 220886e39e04SPaolo Abeni 2209d4c81bbbSMatthieu Baerts # It is not directly linked to the commit introducing this 2210d4c81bbbSMatthieu Baerts # symbol but for the parent one which is linked anyway. 2211d4c81bbbSMatthieu Baerts if ! mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then 2212d4c81bbbSMatthieu Baerts chk_join_nr 3 3 2 2213d4c81bbbSMatthieu Baerts chk_add_nr 4 4 2214d4c81bbbSMatthieu Baerts else 2215d4c81bbbSMatthieu Baerts chk_join_nr 3 3 3 221686e39e04SPaolo Abeni # the server will not signal the address terminating 221786e39e04SPaolo Abeni # the MPC subflow 221886e39e04SPaolo Abeni chk_add_nr 3 3 2219ae7bd9ccSMatthieu Baerts fi 2220d4c81bbbSMatthieu Baerts fi 22211002b89fSGeliang Tang} 2222b08fbf24SPaolo Abeni 22231002b89fSGeliang Tanglink_failure_tests() 22241002b89fSGeliang Tang{ 22258b819a84SFlorian Westphal # accept and use add_addr with additional subflows and link loss 2226c7d49c03SMatthieu Baerts if reset "multiple flows, signal, link failure"; then 22277d1e6f16SPaolo Abeni # without any b/w limit each veth could spool the packets and get 22287d1e6f16SPaolo Abeni # them acked at xmit time, so that the corresponding subflow will 22297d1e6f16SPaolo Abeni # have almost always no outstanding pkts, the scheduler will pick 22307d1e6f16SPaolo Abeni # always the first subflow and we will have hard time testing 22317d1e6f16SPaolo Abeni # active backup and link switch-over. 22327d1e6f16SPaolo Abeni # Let's set some arbitrary (low) virtual link limits. 22337d1e6f16SPaolo Abeni init_shapers 223434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 223534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 223634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 223734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow 223834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow 22390c93af1fSGeliang Tang test_linkfail=1 \ 22400c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2241c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 22428b819a84SFlorian Westphal chk_add_nr 1 1 22437d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 5 1 2244ae7bd9ccSMatthieu Baerts fi 22457d1e6f16SPaolo Abeni 22467d1e6f16SPaolo Abeni # accept and use add_addr with additional subflows and link loss 22477d1e6f16SPaolo Abeni # for bidirectional transfer 2248c7d49c03SMatthieu Baerts if reset "multi flows, signal, bidi, link fail"; then 22497d1e6f16SPaolo Abeni init_shapers 225034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 225134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 225234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 225334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow 225434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow 22550c93af1fSGeliang Tang test_linkfail=2 \ 22560c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2257c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 22587d1e6f16SPaolo Abeni chk_add_nr 1 1 22597d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 -1 1 2260ae7bd9ccSMatthieu Baerts fi 22617d1e6f16SPaolo Abeni 22627d1e6f16SPaolo Abeni # 2 subflows plus 1 backup subflow with a lossy link, backup 22637d1e6f16SPaolo Abeni # will never be used 2264c7d49c03SMatthieu Baerts if reset "backup subflow unused, link failure"; then 22657d1e6f16SPaolo Abeni init_shapers 226634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 226734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 226834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 226934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 22700c93af1fSGeliang Tang FAILING_LINKS="1" test_linkfail=1 \ 22710c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2272c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 22737d1e6f16SPaolo Abeni chk_add_nr 1 1 22747d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 0 2275ae7bd9ccSMatthieu Baerts fi 22767d1e6f16SPaolo Abeni 22777d1e6f16SPaolo Abeni # 2 lossy links after half transfer, backup will get half of 22787d1e6f16SPaolo Abeni # the traffic 2279c7d49c03SMatthieu Baerts if reset "backup flow used, multi links fail"; then 22807d1e6f16SPaolo Abeni init_shapers 228134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 228234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 228334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 228434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 22850c93af1fSGeliang Tang FAILING_LINKS="1 2" test_linkfail=1 \ 22860c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2287c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 22887d1e6f16SPaolo Abeni chk_add_nr 1 1 22897d1e6f16SPaolo Abeni chk_stale_nr $ns2 2 4 2 22907d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 50 2291ae7bd9ccSMatthieu Baerts fi 22927d1e6f16SPaolo Abeni 22937d1e6f16SPaolo Abeni # use a backup subflow with the first subflow on a lossy link 22947d1e6f16SPaolo Abeni # for bidirectional transfer 2295c7d49c03SMatthieu Baerts if reset "backup flow used, bidi, link failure"; then 22967d1e6f16SPaolo Abeni init_shapers 229734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 229834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 229934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 230034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 23010c93af1fSGeliang Tang FAILING_LINKS="1 2" test_linkfail=2 \ 23020c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2303c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 23047d1e6f16SPaolo Abeni chk_add_nr 1 1 23057d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 -1 2 23067d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 50 2307ae7bd9ccSMatthieu Baerts fi 23081002b89fSGeliang Tang} 23098b819a84SFlorian Westphal 23101002b89fSGeliang Tangadd_addr_timeout_tests() 23111002b89fSGeliang Tang{ 23128d014eaaSGeliang Tang # add_addr timeout 2313c7d49c03SMatthieu Baerts if reset_with_add_addr_timeout "signal address, ADD_ADDR timeout"; then 231434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 231534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 231634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2317e571fb09SGeliang Tang speed=slow \ 2318e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2319c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 23200639fa23SPaolo Abeni chk_add_tx_nr 4 4 23218d014eaaSGeliang Tang chk_add_nr 4 0 2322ae7bd9ccSMatthieu Baerts fi 23238d014eaaSGeliang Tang 23241002b89fSGeliang Tang # add_addr timeout IPv6 2325c7d49c03SMatthieu Baerts if reset_with_add_addr_timeout "signal address, ADD_ADDR6 timeout" 6; then 232634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 232734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 232834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 2329e571fb09SGeliang Tang speed=slow \ 2330e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2331c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 23321002b89fSGeliang Tang chk_add_nr 4 0 2333ae7bd9ccSMatthieu Baerts fi 23348da6229bSGeliang Tang 23358da6229bSGeliang Tang # signal addresses timeout 2336c7d49c03SMatthieu Baerts if reset_with_add_addr_timeout "signal addresses, ADD_ADDR timeout"; then 233734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 233834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 233934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 234034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 2341e571fb09SGeliang Tang speed=10 \ 2342e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2343c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 23448da6229bSGeliang Tang chk_add_nr 8 0 2345ae7bd9ccSMatthieu Baerts fi 23468da6229bSGeliang Tang 23478da6229bSGeliang Tang # signal invalid addresses timeout 2348c7d49c03SMatthieu Baerts if reset_with_add_addr_timeout "invalid address, ADD_ADDR timeout"; then 234934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 235034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 235134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 235234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 2353e571fb09SGeliang Tang speed=10 \ 2354e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2355c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 23568da6229bSGeliang Tang chk_add_nr 8 0 2357ae7bd9ccSMatthieu Baerts fi 23581002b89fSGeliang Tang} 23591002b89fSGeliang Tang 23601002b89fSGeliang Tangremove_tests() 23611002b89fSGeliang Tang{ 2362dd72b0feSGeliang Tang # single subflow, remove 2363c7d49c03SMatthieu Baerts if reset "remove single subflow"; then 236434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 236534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 236634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2367e571fb09SGeliang Tang addr_nr_ns2=-1 speed=slow \ 2368e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2369c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 23700639fa23SPaolo Abeni chk_rm_tx_nr 1 2371dd72b0feSGeliang Tang chk_rm_nr 1 1 23722cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 2373ae7bd9ccSMatthieu Baerts fi 2374dd72b0feSGeliang Tang 2375dd72b0feSGeliang Tang # multiple subflows, remove 2376c7d49c03SMatthieu Baerts if reset "remove multiple subflows"; then 237734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 237834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 237934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 238034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2381e571fb09SGeliang Tang addr_nr_ns2=-2 speed=slow \ 2382e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2383c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2384dd72b0feSGeliang Tang chk_rm_nr 2 2 23852cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 2386ae7bd9ccSMatthieu Baerts fi 2387dd72b0feSGeliang Tang 2388dd72b0feSGeliang Tang # single address, remove 2389c7d49c03SMatthieu Baerts if reset "remove single address"; then 239034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 239134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 239234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2393e571fb09SGeliang Tang addr_nr_ns1=-1 speed=slow \ 2394e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2395c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2396dd72b0feSGeliang Tang chk_add_nr 1 1 23977028ba8aSGeliang Tang chk_rm_nr 1 1 invert 23982cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 2399ae7bd9ccSMatthieu Baerts fi 2400dd72b0feSGeliang Tang 2401dd72b0feSGeliang Tang # subflow and signal, remove 2402c7d49c03SMatthieu Baerts if reset "remove subflow and signal"; then 240334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 240434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 240534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 240634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2407e571fb09SGeliang Tang addr_nr_ns1=-1 addr_nr_ns2=-1 speed=slow \ 2408e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2409c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2410dd72b0feSGeliang Tang chk_add_nr 1 1 2411dd72b0feSGeliang Tang chk_rm_nr 1 1 24122cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 2413ae7bd9ccSMatthieu Baerts fi 2414dd72b0feSGeliang Tang 2415dd72b0feSGeliang Tang # subflows and signal, remove 2416c7d49c03SMatthieu Baerts if reset "remove subflows and signal"; then 241734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 241834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 241934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 242034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 242134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 2422e571fb09SGeliang Tang addr_nr_ns1=-1 addr_nr_ns2=-2 speed=10 \ 2423e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2424c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2425dd72b0feSGeliang Tang chk_add_nr 1 1 2426dd72b0feSGeliang Tang chk_rm_nr 2 2 24272cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 2428ae7bd9ccSMatthieu Baerts fi 2429dd72b0feSGeliang Tang 2430ef360019SGeliang Tang # addresses remove 2431c7d49c03SMatthieu Baerts if reset "remove addresses"; then 243234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 243334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 243434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 243534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 243634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 2437e571fb09SGeliang Tang addr_nr_ns1=-3 speed=10 \ 2438e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2439c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2440ef360019SGeliang Tang chk_add_nr 3 3 2441ef360019SGeliang Tang chk_rm_nr 3 3 invert 24422cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 2443ae7bd9ccSMatthieu Baerts fi 2444ef360019SGeliang Tang 2445ef360019SGeliang Tang # invalid addresses remove 2446c7d49c03SMatthieu Baerts if reset "remove invalid addresses"; then 244734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 244834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 244909469a08SYonglongLi # broadcast IP: no packet for this address will be received on ns1 245009469a08SYonglongLi pm_nl_add_endpoint $ns1 224.0.0.1 flags signal 2451dbf0787cSYonglongLi pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 2452dbf0787cSYonglongLi pm_nl_set_limits $ns2 2 2 2453e571fb09SGeliang Tang addr_nr_ns1=-3 speed=10 \ 2454e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2455c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2456ef360019SGeliang Tang chk_add_nr 3 3 2457ef360019SGeliang Tang chk_rm_nr 3 1 invert 24582cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 2459ae7bd9ccSMatthieu Baerts fi 2460ef360019SGeliang Tang 24616fe4ccdcSGeliang Tang # subflows and signal, flush 2462c7d49c03SMatthieu Baerts if reset "flush subflows and signal"; then 246334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 246434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 246534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 246634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 246734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 2468e571fb09SGeliang Tang addr_nr_ns1=-8 addr_nr_ns2=-8 speed=slow \ 2469e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2470c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 24716fe4ccdcSGeliang Tang chk_add_nr 1 1 24726fa0174aSPaolo Abeni chk_rm_nr 1 3 invert simult 24732cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 2474ae7bd9ccSMatthieu Baerts fi 2475d2c4333aSGeliang Tang 2476d2c4333aSGeliang Tang # subflows flush 2477c7d49c03SMatthieu Baerts if reset "flush subflows"; then 247834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 247934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 248034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow id 150 248134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 248234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 2483e571fb09SGeliang Tang addr_nr_ns1=-8 addr_nr_ns2=-8 speed=slow \ 2484e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2485c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2486425ba803SMatthieu Baerts 2487425ba803SMatthieu Baerts if mptcp_lib_kversion_ge 5.18; then 24880639fa23SPaolo Abeni chk_rm_tx_nr 0 24896fa0174aSPaolo Abeni chk_rm_nr 0 3 simult 2490425ba803SMatthieu Baerts else 2491425ba803SMatthieu Baerts chk_rm_nr 3 3 2492425ba803SMatthieu Baerts fi 24932cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 2494ae7bd9ccSMatthieu Baerts fi 2495d2c4333aSGeliang Tang 2496d2c4333aSGeliang Tang # addresses flush 2497c7d49c03SMatthieu Baerts if reset "flush addresses"; then 249834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 249934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 250034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 250134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 250234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 2503e571fb09SGeliang Tang addr_nr_ns1=-8 addr_nr_ns2=-8 speed=slow \ 2504e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2505c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2506d2c4333aSGeliang Tang chk_add_nr 3 3 25076fa0174aSPaolo Abeni chk_rm_nr 3 3 invert simult 25082cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 2509ae7bd9ccSMatthieu Baerts fi 2510ef360019SGeliang Tang 2511ef360019SGeliang Tang # invalid addresses flush 2512c7d49c03SMatthieu Baerts if reset "flush invalid addresses"; then 251334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 251434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 251534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 251634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 251734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 2518e571fb09SGeliang Tang addr_nr_ns1=-8 speed=slow \ 2519e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2520c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2521ef360019SGeliang Tang chk_add_nr 3 3 2522ef360019SGeliang Tang chk_rm_nr 3 1 invert 25232cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 2524ae7bd9ccSMatthieu Baerts fi 25255e287fe7SGeliang Tang 25265e287fe7SGeliang Tang # remove id 0 subflow 2527c7d49c03SMatthieu Baerts if reset "remove id 0 subflow"; then 252834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 252934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 253034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2531e571fb09SGeliang Tang addr_nr_ns2=-9 speed=slow \ 2532e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2533c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 25345e287fe7SGeliang Tang chk_rm_nr 1 1 25352cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 2536ae7bd9ccSMatthieu Baerts fi 25375e287fe7SGeliang Tang 25385e287fe7SGeliang Tang # remove id 0 address 2539c7d49c03SMatthieu Baerts if reset "remove id 0 address"; then 254034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 254134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 254234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2543e571fb09SGeliang Tang addr_nr_ns1=-9 speed=slow \ 2544e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2545c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 25465e287fe7SGeliang Tang chk_add_nr 1 1 25475e287fe7SGeliang Tang chk_rm_nr 1 1 invert 25482cfaa8b3SMatthieu Baerts chk_rst_nr 0 0 invert 2549ae7bd9ccSMatthieu Baerts fi 25501002b89fSGeliang Tang} 25516fe4ccdcSGeliang Tang 25521002b89fSGeliang Tangadd_tests() 25531002b89fSGeliang Tang{ 25546208fd82SGeliang Tang # add single subflow 2555c7d49c03SMatthieu Baerts if reset "add single subflow"; then 255634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 255734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 2558e571fb09SGeliang Tang addr_nr_ns2=1 speed=slow \ 2559e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2560c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2561ae7bd9ccSMatthieu Baerts fi 25626208fd82SGeliang Tang 25636208fd82SGeliang Tang # add signal address 2564c7d49c03SMatthieu Baerts if reset "add signal address"; then 256534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 256634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2567e571fb09SGeliang Tang addr_nr_ns1=1 speed=slow \ 2568e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2569c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 25706208fd82SGeliang Tang chk_add_nr 1 1 2571ae7bd9ccSMatthieu Baerts fi 25726208fd82SGeliang Tang 25736208fd82SGeliang Tang # add multiple subflows 2574c7d49c03SMatthieu Baerts if reset "add multiple subflows"; then 257534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 257634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 2577e571fb09SGeliang Tang addr_nr_ns2=2 speed=slow \ 2578e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2579c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2580ae7bd9ccSMatthieu Baerts fi 25816208fd82SGeliang Tang 25826208fd82SGeliang Tang # add multiple subflows IPv6 2583c7d49c03SMatthieu Baerts if reset "add multiple subflows IPv6"; then 258434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 258534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 2586e571fb09SGeliang Tang addr_nr_ns2=2 speed=slow \ 2587e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2588c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2589ae7bd9ccSMatthieu Baerts fi 25906208fd82SGeliang Tang 25916208fd82SGeliang Tang # add multiple addresses IPv6 2592c7d49c03SMatthieu Baerts if reset "add multiple addresses IPv6"; then 259334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 259434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 2595e571fb09SGeliang Tang addr_nr_ns1=2 speed=slow \ 2596e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2597c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 25986208fd82SGeliang Tang chk_add_nr 2 2 2599ae7bd9ccSMatthieu Baerts fi 26001002b89fSGeliang Tang} 26016208fd82SGeliang Tang 26021002b89fSGeliang Tangipv6_tests() 26031002b89fSGeliang Tang{ 2604523514edSGeliang Tang # subflow IPv6 2605c7d49c03SMatthieu Baerts if reset "single subflow IPv6"; then 260634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 260734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 260834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow 2609e571fb09SGeliang Tang speed=slow \ 2610e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2611c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2612ae7bd9ccSMatthieu Baerts fi 2613523514edSGeliang Tang 2614523514edSGeliang Tang # add_address, unused IPv6 2615c7d49c03SMatthieu Baerts if reset "unused signal address IPv6"; then 261634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 2617e571fb09SGeliang Tang speed=slow \ 2618e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2619c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 2620523514edSGeliang Tang chk_add_nr 1 1 2621ae7bd9ccSMatthieu Baerts fi 2622523514edSGeliang Tang 2623523514edSGeliang Tang # signal address IPv6 2624c7d49c03SMatthieu Baerts if reset "single address IPv6"; then 262534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 262634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 262734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2628e571fb09SGeliang Tang speed=slow \ 2629e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2630c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2631523514edSGeliang Tang chk_add_nr 1 1 2632ae7bd9ccSMatthieu Baerts fi 2633523514edSGeliang Tang 2634523514edSGeliang Tang # single address IPv6, remove 2635c7d49c03SMatthieu Baerts if reset "remove single address IPv6"; then 263634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 263734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 263834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2639e571fb09SGeliang Tang addr_nr_ns1=-1 speed=slow \ 2640e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2641c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2642523514edSGeliang Tang chk_add_nr 1 1 26437028ba8aSGeliang Tang chk_rm_nr 1 1 invert 2644ae7bd9ccSMatthieu Baerts fi 2645523514edSGeliang Tang 2646523514edSGeliang Tang # subflow and signal IPv6, remove 2647c7d49c03SMatthieu Baerts if reset "remove subflow and signal IPv6"; then 264834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 264934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 265034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 265134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow 2652e571fb09SGeliang Tang addr_nr_ns1=-1 addr_nr_ns2=-1 speed=slow \ 2653e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2654c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2655523514edSGeliang Tang chk_add_nr 1 1 2656523514edSGeliang Tang chk_rm_nr 1 1 2657ae7bd9ccSMatthieu Baerts fi 26581002b89fSGeliang Tang} 2659523514edSGeliang Tang 26601002b89fSGeliang Tangv4mapped_tests() 26611002b89fSGeliang Tang{ 2662a6094788SGeliang Tang # subflow IPv4-mapped to IPv4-mapped 2663c7d49c03SMatthieu Baerts if reset "single subflow IPv4-mapped"; then 266434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 266534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 266634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow 2667a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 2668c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2669ae7bd9ccSMatthieu Baerts fi 2670a6094788SGeliang Tang 2671a6094788SGeliang Tang # signal address IPv4-mapped with IPv4-mapped sk 2672c7d49c03SMatthieu Baerts if reset "signal address IPv4-mapped"; then 267334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 267434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 267534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal 2676a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 2677c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2678a6094788SGeliang Tang chk_add_nr 1 1 2679ae7bd9ccSMatthieu Baerts fi 2680a6094788SGeliang Tang 2681a6094788SGeliang Tang # subflow v4-map-v6 2682c7d49c03SMatthieu Baerts if reset "single subflow v4-map-v6"; then 268334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 268434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 268534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2686a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 2687c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2688ae7bd9ccSMatthieu Baerts fi 2689a6094788SGeliang Tang 2690a6094788SGeliang Tang # signal address v4-map-v6 2691c7d49c03SMatthieu Baerts if reset "signal address v4-map-v6"; then 269234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 269334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 269434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2695a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 2696c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2697a6094788SGeliang Tang chk_add_nr 1 1 2698ae7bd9ccSMatthieu Baerts fi 2699a6094788SGeliang Tang 2700a6094788SGeliang Tang # subflow v6-map-v4 2701c7d49c03SMatthieu Baerts if reset "single subflow v6-map-v4"; then 270234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 270334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 270434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow 2705a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2706c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2707ae7bd9ccSMatthieu Baerts fi 2708a6094788SGeliang Tang 2709a6094788SGeliang Tang # signal address v6-map-v4 2710c7d49c03SMatthieu Baerts if reset "signal address v6-map-v4"; then 271134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 271234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 271334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal 2714a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2715c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2716a6094788SGeliang Tang chk_add_nr 1 1 2717ae7bd9ccSMatthieu Baerts fi 2718a6094788SGeliang Tang 2719a6094788SGeliang Tang # no subflow IPv6 to v4 address 2720c7d49c03SMatthieu Baerts if reset "no JOIN with diff families v4-v6"; then 272134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 272234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 272334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow 2724a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2725c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 2726ae7bd9ccSMatthieu Baerts fi 2727a6094788SGeliang Tang 2728a6094788SGeliang Tang # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end 2729c7d49c03SMatthieu Baerts if reset "no JOIN with diff families v4-v6-2"; then 273034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 273134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 273234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:2::10.0.3.2 flags subflow 2733a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2734c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 2735ae7bd9ccSMatthieu Baerts fi 2736a6094788SGeliang Tang 2737a6094788SGeliang Tang # no subflow IPv4 to v6 address, no need to slow down too then 2738c7d49c03SMatthieu Baerts if reset "no JOIN with diff families v6-v4"; then 273934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 274034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 274134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2742a6094788SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2743c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 2744ae7bd9ccSMatthieu Baerts fi 27451002b89fSGeliang Tang} 2746a6094788SGeliang Tang 2747ad349374SPaolo Abenimixed_tests() 2748ad349374SPaolo Abeni{ 27496673851bSMatthieu Baerts if reset "IPv4 sockets do not use IPv6 addresses" && 27506673851bSMatthieu Baerts continue_if mptcp_lib_kversion_ge 6.3; then 2751ad349374SPaolo Abeni pm_nl_set_limits $ns1 0 1 2752ad349374SPaolo Abeni pm_nl_set_limits $ns2 1 1 2753ad349374SPaolo Abeni pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 2754e571fb09SGeliang Tang speed=slow \ 2755e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2756ad349374SPaolo Abeni chk_join_nr 0 0 0 2757ad349374SPaolo Abeni fi 2758ad349374SPaolo Abeni 2759ad349374SPaolo Abeni # Need an IPv6 mptcp socket to allow subflows of both families 27606673851bSMatthieu Baerts if reset "simult IPv4 and IPv6 subflows" && 27616673851bSMatthieu Baerts continue_if mptcp_lib_kversion_ge 6.3; then 2762ad349374SPaolo Abeni pm_nl_set_limits $ns1 0 1 2763ad349374SPaolo Abeni pm_nl_set_limits $ns2 1 1 2764ad349374SPaolo Abeni pm_nl_add_endpoint $ns1 10.0.1.1 flags signal 2765e571fb09SGeliang Tang speed=slow \ 2766e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:2::1 2767ad349374SPaolo Abeni chk_join_nr 1 1 1 2768ad349374SPaolo Abeni fi 2769ad349374SPaolo Abeni 2770ad349374SPaolo Abeni # cross families subflows will not be created even in fullmesh mode 27716673851bSMatthieu Baerts if reset "simult IPv4 and IPv6 subflows, fullmesh 1x1" && 27726673851bSMatthieu Baerts continue_if mptcp_lib_kversion_ge 6.3; then 2773ad349374SPaolo Abeni pm_nl_set_limits $ns1 0 4 2774ad349374SPaolo Abeni pm_nl_set_limits $ns2 1 4 2775ad349374SPaolo Abeni pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow,fullmesh 2776ad349374SPaolo Abeni pm_nl_add_endpoint $ns1 10.0.1.1 flags signal 2777e571fb09SGeliang Tang speed=slow \ 2778e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:2::1 2779ad349374SPaolo Abeni chk_join_nr 1 1 1 2780ad349374SPaolo Abeni fi 2781ad349374SPaolo Abeni 2782ad349374SPaolo Abeni # fullmesh still tries to create all the possibly subflows with 2783ad349374SPaolo Abeni # matching family 27846673851bSMatthieu Baerts if reset "simult IPv4 and IPv6 subflows, fullmesh 2x2" && 27856673851bSMatthieu Baerts continue_if mptcp_lib_kversion_ge 6.3; then 2786ad349374SPaolo Abeni pm_nl_set_limits $ns1 0 4 2787ad349374SPaolo Abeni pm_nl_set_limits $ns2 2 4 2788ad349374SPaolo Abeni pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2789ad349374SPaolo Abeni pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 2790e571fb09SGeliang Tang fullmesh=1 speed=slow \ 2791e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2792ad349374SPaolo Abeni chk_join_nr 4 4 4 2793ad349374SPaolo Abeni fi 2794ad349374SPaolo Abeni} 2795ad349374SPaolo Abeni 27961002b89fSGeliang Tangbackup_tests() 27971002b89fSGeliang Tang{ 2798718eb44eSGeliang Tang # single subflow, backup 279907216a3cSMatthieu Baerts if reset "single subflow, backup" && 280007216a3cSMatthieu Baerts continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then 280134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 280234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 280334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup 2804e571fb09SGeliang Tang sflags=nobackup speed=slow \ 2805e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2806c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 28078213b98eSMatthieu Baerts (NGI0) chk_prio_nr 0 1 1 0 2808ae7bd9ccSMatthieu Baerts fi 2809718eb44eSGeliang Tang 2810718eb44eSGeliang Tang # single address, backup 281107216a3cSMatthieu Baerts if reset "single address, backup" && 281207216a3cSMatthieu Baerts continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then 281334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 28146f2b2180SMatthieu Baerts (NGI0) pm_nl_add_endpoint $ns1 10.0.2.1 flags signal,backup 28156f2b2180SMatthieu Baerts (NGI0) pm_nl_set_limits $ns2 1 1 28166f2b2180SMatthieu Baerts (NGI0) sflags=nobackup speed=slow \ 28176f2b2180SMatthieu Baerts (NGI0) run_tests $ns1 $ns2 10.0.1.1 28186f2b2180SMatthieu Baerts (NGI0) chk_join_nr 1 1 1 28196f2b2180SMatthieu Baerts (NGI0) chk_add_nr 1 1 28206f2b2180SMatthieu Baerts (NGI0) chk_prio_nr 1 0 0 1 28216f2b2180SMatthieu Baerts (NGI0) fi 28226f2b2180SMatthieu Baerts (NGI0) 28236f2b2180SMatthieu Baerts (NGI0) # single address, switch to backup 28246f2b2180SMatthieu Baerts (NGI0) if reset "single address, switch to backup" && 28256f2b2180SMatthieu Baerts (NGI0) continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then 28266f2b2180SMatthieu Baerts (NGI0) pm_nl_set_limits $ns1 0 1 282734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 282834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2829e571fb09SGeliang Tang sflags=backup speed=slow \ 2830e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2831c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2832718eb44eSGeliang Tang chk_add_nr 1 1 28338213b98eSMatthieu Baerts (NGI0) chk_prio_nr 1 1 0 0 2834ae7bd9ccSMatthieu Baerts fi 283533397b83SGeliang Tang 283633397b83SGeliang Tang # single address with port, backup 283707216a3cSMatthieu Baerts if reset "single address with port, backup" && 283807216a3cSMatthieu Baerts continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then 283934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 28406f2b2180SMatthieu Baerts (NGI0) pm_nl_add_endpoint $ns1 10.0.2.1 flags signal,backup port 10100 284134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 28426f2b2180SMatthieu Baerts (NGI0) sflags=nobackup speed=slow \ 2843e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2844c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 284533397b83SGeliang Tang chk_add_nr 1 1 28466f2b2180SMatthieu Baerts (NGI0) chk_prio_nr 1 0 0 1 2847ae7bd9ccSMatthieu Baerts fi 2848914f6a59SPaolo Abeni 2849632978f0SMatthieu Baerts if reset "mpc backup" && 2850c18cf955SGeliang Tang continue_if mptcp_lib_kallsyms_doesnt_have "T mptcp_subflow_send_ack$"; then 2851914f6a59SPaolo Abeni pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,backup 2852e571fb09SGeliang Tang speed=slow \ 2853e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2854914f6a59SPaolo Abeni chk_join_nr 0 0 0 28558213b98eSMatthieu Baerts (NGI0) chk_prio_nr 0 1 0 0 2856914f6a59SPaolo Abeni fi 2857914f6a59SPaolo Abeni 2858632978f0SMatthieu Baerts if reset "mpc backup both sides" && 2859c18cf955SGeliang Tang continue_if mptcp_lib_kallsyms_doesnt_have "T mptcp_subflow_send_ack$"; then 28606f2b2180SMatthieu Baerts (NGI0) pm_nl_set_limits $ns1 0 2 28616f2b2180SMatthieu Baerts (NGI0) pm_nl_set_limits $ns2 1 2 28626f2b2180SMatthieu Baerts (NGI0) pm_nl_add_endpoint $ns1 10.0.1.1 flags signal,backup 2863914f6a59SPaolo Abeni pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,backup 28646f2b2180SMatthieu Baerts (NGI0) 28656f2b2180SMatthieu Baerts (NGI0) # 10.0.2.2 (non-backup) -> 10.0.1.1 (backup) 28666f2b2180SMatthieu Baerts (NGI0) pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 28676f2b2180SMatthieu Baerts (NGI0) # 10.0.1.2 (backup) -> 10.0.2.1 (non-backup) 28686f2b2180SMatthieu Baerts (NGI0) pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 28696f2b2180SMatthieu Baerts (NGI0) ip -net "$ns2" route add 10.0.2.1 via 10.0.1.1 dev ns2eth1 # force this path 28706f2b2180SMatthieu Baerts (NGI0) 2871e571fb09SGeliang Tang speed=slow \ 2872e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 28736f2b2180SMatthieu Baerts (NGI0) chk_join_nr 2 2 2 28746f2b2180SMatthieu Baerts (NGI0) chk_prio_nr 1 1 1 1 2875914f6a59SPaolo Abeni fi 2876914f6a59SPaolo Abeni 2877632978f0SMatthieu Baerts if reset "mpc switch to backup" && 2878c18cf955SGeliang Tang continue_if mptcp_lib_kallsyms_doesnt_have "T mptcp_subflow_send_ack$"; then 2879914f6a59SPaolo Abeni pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow 2880e571fb09SGeliang Tang sflags=backup speed=slow \ 2881e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2882914f6a59SPaolo Abeni chk_join_nr 0 0 0 28838213b98eSMatthieu Baerts (NGI0) chk_prio_nr 0 1 0 0 2884914f6a59SPaolo Abeni fi 2885914f6a59SPaolo Abeni 2886632978f0SMatthieu Baerts if reset "mpc switch to backup both sides" && 2887c18cf955SGeliang Tang continue_if mptcp_lib_kallsyms_doesnt_have "T mptcp_subflow_send_ack$"; then 2888914f6a59SPaolo Abeni pm_nl_add_endpoint $ns1 10.0.1.1 flags subflow 2889914f6a59SPaolo Abeni pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow 2890e571fb09SGeliang Tang sflags=backup speed=slow \ 2891e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2892914f6a59SPaolo Abeni chk_join_nr 0 0 0 28938213b98eSMatthieu Baerts (NGI0) chk_prio_nr 1 1 0 0 2894914f6a59SPaolo Abeni fi 28951002b89fSGeliang Tang} 2896718eb44eSGeliang Tang 2897178d0232SGeliang Tangverify_listener_events() 2898178d0232SGeliang Tang{ 2899178d0232SGeliang Tang local evt=$1 2900178d0232SGeliang Tang local e_type=$2 2901178d0232SGeliang Tang local e_family=$3 2902178d0232SGeliang Tang local e_saddr=$4 2903178d0232SGeliang Tang local e_sport=$5 2904178d0232SGeliang Tang local type 2905178d0232SGeliang Tang local family 2906178d0232SGeliang Tang local saddr 2907178d0232SGeliang Tang local sport 290896b84195SMatthieu Baerts local name 2909178d0232SGeliang Tang 2910a17d1419SGeliang Tang if [ $e_type = $MPTCP_LIB_EVENT_LISTENER_CREATED ]; then 291196b84195SMatthieu Baerts name="LISTENER_CREATED" 2912a17d1419SGeliang Tang elif [ $e_type = $MPTCP_LIB_EVENT_LISTENER_CLOSED ]; then 291396b84195SMatthieu Baerts name="LISTENER_CLOSED " 291496b84195SMatthieu Baerts else 291596b84195SMatthieu Baerts name="$e_type" 2916178d0232SGeliang Tang fi 2917178d0232SGeliang Tang 291803668c65SMatthieu Baerts print_check "$name $e_saddr:$e_sport" 291996b84195SMatthieu Baerts 29200471bb47SMatthieu Baerts if ! mptcp_lib_kallsyms_has "mptcp_event_pm_listener$"; then 292103668c65SMatthieu Baerts print_skip "event not supported" 29220471bb47SMatthieu Baerts return 29230471bb47SMatthieu Baerts fi 29240471bb47SMatthieu Baerts 2925ae1fa39dSGeliang Tang type=$(mptcp_lib_evts_get_info type "$evt" "$e_type") 2926ae1fa39dSGeliang Tang family=$(mptcp_lib_evts_get_info family "$evt" "$e_type") 2927ae1fa39dSGeliang Tang sport=$(mptcp_lib_evts_get_info sport "$evt" "$e_type") 2928178d0232SGeliang Tang if [ $family ] && [ $family = $AF_INET6 ]; then 2929ae1fa39dSGeliang Tang saddr=$(mptcp_lib_evts_get_info saddr6 "$evt" "$e_type") 2930178d0232SGeliang Tang else 2931ae1fa39dSGeliang Tang saddr=$(mptcp_lib_evts_get_info saddr4 "$evt" "$e_type") 2932178d0232SGeliang Tang fi 2933178d0232SGeliang Tang 2934178d0232SGeliang Tang if [ $type ] && [ $type = $e_type ] && 2935178d0232SGeliang Tang [ $family ] && [ $family = $e_family ] && 2936178d0232SGeliang Tang [ $saddr ] && [ $saddr = $e_saddr ] && 2937178d0232SGeliang Tang [ $sport ] && [ $sport = $e_sport ]; then 293803668c65SMatthieu Baerts print_ok 2939178d0232SGeliang Tang return 0 2940178d0232SGeliang Tang fi 294103668c65SMatthieu Baerts fail_test "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport" 2942178d0232SGeliang Tang} 2943178d0232SGeliang Tang 29441002b89fSGeliang Tangadd_addr_ports_tests() 29451002b89fSGeliang Tang{ 29468a127bf6SGeliang Tang # signal address with port 2947c7d49c03SMatthieu Baerts if reset "signal address with port"; then 294834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 294934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 295034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 29518a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2952c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 29538a127bf6SGeliang Tang chk_add_nr 1 1 1 2954ae7bd9ccSMatthieu Baerts fi 29558a127bf6SGeliang Tang 29568a127bf6SGeliang Tang # subflow and signal with port 2957c7d49c03SMatthieu Baerts if reset "subflow and signal with port"; then 295834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 295934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 296034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 296134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 29628a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2963c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 29648a127bf6SGeliang Tang chk_add_nr 1 1 1 2965ae7bd9ccSMatthieu Baerts fi 29668a127bf6SGeliang Tang 29678a127bf6SGeliang Tang # single address with port, remove 2968178d0232SGeliang Tang # pm listener events 2969178d0232SGeliang Tang if reset_with_events "remove single address with port"; then 297034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 297134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 297234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2973e571fb09SGeliang Tang addr_nr_ns1=-1 speed=slow \ 2974e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2975c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 29768a127bf6SGeliang Tang chk_add_nr 1 1 1 29777028ba8aSGeliang Tang chk_rm_nr 1 1 invert 2978178d0232SGeliang Tang 2979a17d1419SGeliang Tang verify_listener_events $evts_ns1 $MPTCP_LIB_EVENT_LISTENER_CREATED \ 2980a17d1419SGeliang Tang $MPTCP_LIB_AF_INET 10.0.2.1 10100 2981a17d1419SGeliang Tang verify_listener_events $evts_ns1 $MPTCP_LIB_EVENT_LISTENER_CLOSED \ 2982a17d1419SGeliang Tang $MPTCP_LIB_AF_INET 10.0.2.1 10100 2983178d0232SGeliang Tang kill_events_pids 2984ae7bd9ccSMatthieu Baerts fi 29858a127bf6SGeliang Tang 29868a127bf6SGeliang Tang # subflow and signal with port, remove 2987c7d49c03SMatthieu Baerts if reset "remove subflow and signal with port"; then 298834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 298934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 299034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 299134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2992e571fb09SGeliang Tang addr_nr_ns1=-1 addr_nr_ns2=-1 speed=slow \ 2993e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2994c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 29958a127bf6SGeliang Tang chk_add_nr 1 1 1 29968a127bf6SGeliang Tang chk_rm_nr 1 1 2997ae7bd9ccSMatthieu Baerts fi 29988a127bf6SGeliang Tang 29998a127bf6SGeliang Tang # subflows and signal with port, flush 3000c7d49c03SMatthieu Baerts if reset "flush subflows and signal with port"; then 300134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 300234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 300334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 300434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 300534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 3006e571fb09SGeliang Tang addr_nr_ns1=-8 addr_nr_ns2=-2 speed=slow \ 3007e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3008c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 30098a127bf6SGeliang Tang chk_add_nr 1 1 30106fa0174aSPaolo Abeni chk_rm_nr 1 3 invert simult 3011ae7bd9ccSMatthieu Baerts fi 30128a127bf6SGeliang Tang 30138a127bf6SGeliang Tang # multiple addresses with port 3014c7d49c03SMatthieu Baerts if reset "multiple addresses with port"; then 301534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 301634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 301734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10100 301834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 30198a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3020c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 30218a127bf6SGeliang Tang chk_add_nr 2 2 2 3022ae7bd9ccSMatthieu Baerts fi 30238a127bf6SGeliang Tang 30248a127bf6SGeliang Tang # multiple addresses with ports 3025c7d49c03SMatthieu Baerts if reset "multiple addresses with ports"; then 302634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 302734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 302834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10101 302934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 30308a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3031c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 30328a127bf6SGeliang Tang chk_add_nr 2 2 2 3033ae7bd9ccSMatthieu Baerts fi 30341002b89fSGeliang Tang} 30358a127bf6SGeliang Tang 30361002b89fSGeliang Tangsyncookies_tests() 30371002b89fSGeliang Tang{ 303800587187SFlorian Westphal # single subflow, syncookies 3039c7d49c03SMatthieu Baerts if reset_with_cookies "single subflow with syn cookies"; then 304034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 304134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 304234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 304300587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 3044c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 3045ae7bd9ccSMatthieu Baerts fi 304600587187SFlorian Westphal 304700587187SFlorian Westphal # multiple subflows with syn cookies 3048c7d49c03SMatthieu Baerts if reset_with_cookies "multiple subflows with syn cookies"; then 304934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 305034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 305134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 305234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 305300587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 3054c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 3055ae7bd9ccSMatthieu Baerts fi 305600587187SFlorian Westphal 305700587187SFlorian Westphal # multiple subflows limited by server 3058c7d49c03SMatthieu Baerts if reset_with_cookies "subflows limited by server w cookies"; then 305934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 306034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 306134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 306234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 306300587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 3064c7d49c03SMatthieu Baerts chk_join_nr 2 1 1 3065ae7bd9ccSMatthieu Baerts fi 306600587187SFlorian Westphal 306700587187SFlorian Westphal # test signal address with cookies 3068c7d49c03SMatthieu Baerts if reset_with_cookies "signal address with syn cookies"; then 306934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 307034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 307134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 307200587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 3073c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 3074be613160SGeliang Tang chk_add_nr 1 1 3075ae7bd9ccSMatthieu Baerts fi 307600587187SFlorian Westphal 307700587187SFlorian Westphal # test cookie with subflow and signal 3078c7d49c03SMatthieu Baerts if reset_with_cookies "subflow and signal w cookies"; then 307934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 308034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 308134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 308234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 308300587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 3084c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 3085be613160SGeliang Tang chk_add_nr 1 1 3086ae7bd9ccSMatthieu Baerts fi 308700587187SFlorian Westphal 308800587187SFlorian Westphal # accept and use add_addr with additional subflows 3089c7d49c03SMatthieu Baerts if reset_with_cookies "subflows and signal w. cookies"; then 309034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 309134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 309234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 309334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 309434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 309500587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 3096c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 3097be613160SGeliang Tang chk_add_nr 1 1 3098ae7bd9ccSMatthieu Baerts fi 30991002b89fSGeliang Tang} 31001002b89fSGeliang Tang 3101af66d3e1SGeliang Tangchecksum_tests() 3102af66d3e1SGeliang Tang{ 3103af66d3e1SGeliang Tang # checksum test 0 0 3104ae7bd9ccSMatthieu Baerts if reset_with_checksum 0 0; then 310534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 310634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 3107af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3108c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 3109ae7bd9ccSMatthieu Baerts fi 3110af66d3e1SGeliang Tang 3111af66d3e1SGeliang Tang # checksum test 1 1 3112ae7bd9ccSMatthieu Baerts if reset_with_checksum 1 1; then 311334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 311434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 3115af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3116c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 3117ae7bd9ccSMatthieu Baerts fi 3118af66d3e1SGeliang Tang 3119af66d3e1SGeliang Tang # checksum test 0 1 3120ae7bd9ccSMatthieu Baerts if reset_with_checksum 0 1; then 312134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 312234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 3123af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3124c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 3125ae7bd9ccSMatthieu Baerts fi 3126af66d3e1SGeliang Tang 3127af66d3e1SGeliang Tang # checksum test 1 0 3128ae7bd9ccSMatthieu Baerts if reset_with_checksum 1 0; then 312934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 313034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 3131af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3132c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 3133ae7bd9ccSMatthieu Baerts fi 3134af66d3e1SGeliang Tang} 3135af66d3e1SGeliang Tang 31360cddb4a6SGeliang Tangdeny_join_id0_tests() 31370cddb4a6SGeliang Tang{ 31380cddb4a6SGeliang Tang # subflow allow join id0 ns1 3139c7d49c03SMatthieu Baerts if reset_with_allow_join_id0 "single subflow allow join id0 ns1" 1 0; then 314034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 314134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 314234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 31430cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3144c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 3145ae7bd9ccSMatthieu Baerts fi 31460cddb4a6SGeliang Tang 31470cddb4a6SGeliang Tang # subflow allow join id0 ns2 3148c7d49c03SMatthieu Baerts if reset_with_allow_join_id0 "single subflow allow join id0 ns2" 0 1; then 314934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 315034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 315134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 31520cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3153c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 3154ae7bd9ccSMatthieu Baerts fi 31550cddb4a6SGeliang Tang 31560cddb4a6SGeliang Tang # signal address allow join id0 ns1 31570cddb4a6SGeliang Tang # ADD_ADDRs are not affected by allow_join_id0 value. 3158c7d49c03SMatthieu Baerts if reset_with_allow_join_id0 "signal address allow join id0 ns1" 1 0; then 315934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 316034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 316134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 31620cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3163c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 31640cddb4a6SGeliang Tang chk_add_nr 1 1 3165ae7bd9ccSMatthieu Baerts fi 31660cddb4a6SGeliang Tang 31670cddb4a6SGeliang Tang # signal address allow join id0 ns2 31680cddb4a6SGeliang Tang # ADD_ADDRs are not affected by allow_join_id0 value. 3169c7d49c03SMatthieu Baerts if reset_with_allow_join_id0 "signal address allow join id0 ns2" 0 1; then 317034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 317134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 317234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 31730cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3174c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 31750cddb4a6SGeliang Tang chk_add_nr 1 1 3176ae7bd9ccSMatthieu Baerts fi 31770cddb4a6SGeliang Tang 31780cddb4a6SGeliang Tang # subflow and address allow join id0 ns1 3179c7d49c03SMatthieu Baerts if reset_with_allow_join_id0 "subflow and address allow join id0 1" 1 0; then 318034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 318134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 318234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 318334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 31840cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3185c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 3186ae7bd9ccSMatthieu Baerts fi 31870cddb4a6SGeliang Tang 31880cddb4a6SGeliang Tang # subflow and address allow join id0 ns2 3189c7d49c03SMatthieu Baerts if reset_with_allow_join_id0 "subflow and address allow join id0 2" 0 1; then 319034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 319134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 319234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 319334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 31940cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3195c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 3196ae7bd9ccSMatthieu Baerts fi 31970cddb4a6SGeliang Tang} 31980cddb4a6SGeliang Tang 31994f49d633SGeliang Tangfullmesh_tests() 32004f49d633SGeliang Tang{ 32014f49d633SGeliang Tang # fullmesh 1 32024f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added before the connection, 32034f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added during the connection. 3204c7d49c03SMatthieu Baerts if reset "fullmesh test 2x1"; then 320534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 4 320634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 4 320734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,fullmesh 320834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,fullmesh 3209e571fb09SGeliang Tang addr_nr_ns1=1 speed=slow \ 3210e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3211c7d49c03SMatthieu Baerts chk_join_nr 4 4 4 32124f49d633SGeliang Tang chk_add_nr 1 1 3213ae7bd9ccSMatthieu Baerts fi 32144f49d633SGeliang Tang 32154f49d633SGeliang Tang # fullmesh 2 32164f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 32174f49d633SGeliang Tang # 1 fullmesh addr in ns2, added during the connection. 3218c7d49c03SMatthieu Baerts if reset "fullmesh test 1x1"; then 321934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 3 322034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 322134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 3222f845af67SMatthieu Baerts (NGI0) pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,fullmesh 3223e571fb09SGeliang Tang fullmesh=1 speed=slow \ 3224e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3225c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 32264f49d633SGeliang Tang chk_add_nr 1 1 3227ae7bd9ccSMatthieu Baerts fi 32284f49d633SGeliang Tang 32294f49d633SGeliang Tang # fullmesh 3 32304f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 32314f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added during the connection. 3232c7d49c03SMatthieu Baerts if reset "fullmesh test 1x2"; then 323334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 5 323434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 5 323534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 3236e571fb09SGeliang Tang fullmesh=2 speed=slow \ 3237e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3238c7d49c03SMatthieu Baerts chk_join_nr 5 5 5 32394f49d633SGeliang Tang chk_add_nr 1 1 3240ae7bd9ccSMatthieu Baerts fi 32414f49d633SGeliang Tang 32424f49d633SGeliang Tang # fullmesh 4 32434f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 32444f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added during the connection, 32454f49d633SGeliang Tang # limit max_subflows to 4. 3246c7d49c03SMatthieu Baerts if reset "fullmesh test 1x2, limited"; then 324734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 4 324834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 4 324934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 3250e571fb09SGeliang Tang fullmesh=2 speed=slow \ 3251e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3252c7d49c03SMatthieu Baerts chk_join_nr 4 4 4 32534f49d633SGeliang Tang chk_add_nr 1 1 3254ae7bd9ccSMatthieu Baerts fi 32556a0653b9SGeliang Tang 32566a0653b9SGeliang Tang # set fullmesh flag 32579db34c42SMatthieu Baerts if reset "set fullmesh flag test" && 32589db34c42SMatthieu Baerts continue_if mptcp_lib_kversion_ge 5.18; then 325934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 326034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow 326134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 3262e571fb09SGeliang Tang addr_nr_ns2=1 sflags=fullmesh speed=slow \ 3263e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3264c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 32656a0653b9SGeliang Tang chk_rm_nr 0 1 3266ae7bd9ccSMatthieu Baerts fi 32676a0653b9SGeliang Tang 32686a0653b9SGeliang Tang # set nofullmesh flag 32699db34c42SMatthieu Baerts if reset "set nofullmesh flag test" && 32709db34c42SMatthieu Baerts continue_if mptcp_lib_kversion_ge 5.18; then 327134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 327234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow,fullmesh 327334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 3274e571fb09SGeliang Tang fullmesh=1 sflags=nofullmesh speed=slow \ 3275e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3276c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 32776a0653b9SGeliang Tang chk_rm_nr 0 1 3278ae7bd9ccSMatthieu Baerts fi 32796a0653b9SGeliang Tang 32806a0653b9SGeliang Tang # set backup,fullmesh flags 32819db34c42SMatthieu Baerts if reset "set backup,fullmesh flags test" && 32829db34c42SMatthieu Baerts continue_if mptcp_lib_kversion_ge 5.18; then 328334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 328434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow 328534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 3286e571fb09SGeliang Tang addr_nr_ns2=1 sflags=backup,fullmesh speed=slow \ 3287e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3288c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 32898213b98eSMatthieu Baerts (NGI0) chk_prio_nr 0 1 1 0 32906a0653b9SGeliang Tang chk_rm_nr 0 1 3291ae7bd9ccSMatthieu Baerts fi 32926a0653b9SGeliang Tang 32936a0653b9SGeliang Tang # set nobackup,nofullmesh flags 32949db34c42SMatthieu Baerts if reset "set nobackup,nofullmesh flags test" && 32959db34c42SMatthieu Baerts continue_if mptcp_lib_kversion_ge 5.18; then 329634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 329734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 329834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,backup,fullmesh 3299e571fb09SGeliang Tang sflags=nobackup,nofullmesh speed=slow \ 3300e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3301c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 33028213b98eSMatthieu Baerts (NGI0) chk_prio_nr 0 1 1 0 33036a0653b9SGeliang Tang chk_rm_nr 0 1 3304ae7bd9ccSMatthieu Baerts fi 33054f49d633SGeliang Tang} 33064f49d633SGeliang Tang 330701542c9bSGeliang Tangfastclose_tests() 330801542c9bSGeliang Tang{ 3309ae947bb2SMatthieu Baerts if reset_check_counter "fastclose test" "MPTcpExtMPFastcloseTx"; then 3310080b7f57SGeliang Tang test_linkfail=1024 fastclose=client \ 3311595ef566SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3312c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 331301542c9bSGeliang Tang chk_fclose_nr 1 1 331401542c9bSGeliang Tang chk_rst_nr 1 1 invert 3315ae7bd9ccSMatthieu Baerts fi 33166bf41020SPaolo Abeni 3317ae947bb2SMatthieu Baerts if reset_check_counter "fastclose server test" "MPTcpExtMPFastcloseRx"; then 3318080b7f57SGeliang Tang test_linkfail=1024 fastclose=server \ 3319595ef566SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 332055dd3816SPaolo Abeni chk_join_nr 0 0 0 0 0 0 1 33216bf41020SPaolo Abeni chk_fclose_nr 1 1 invert 33226bf41020SPaolo Abeni chk_rst_nr 1 1 33236bf41020SPaolo Abeni fi 332401542c9bSGeliang Tang} 332501542c9bSGeliang Tang 3326b6e074e1SGeliang Tangpedit_action_pkts() 3327b6e074e1SGeliang Tang{ 3328b6e074e1SGeliang Tang tc -n $ns2 -j -s action show action pedit index 100 | \ 3329ae1fa39dSGeliang Tang mptcp_lib_get_info_value \"packets\" packets 3330b6e074e1SGeliang Tang} 3331b6e074e1SGeliang Tang 3332b6e074e1SGeliang Tangfail_tests() 3333b6e074e1SGeliang Tang{ 3334b6e074e1SGeliang Tang # single subflow 3335b6e074e1SGeliang Tang if reset_with_fail "Infinite map" 1; then 3336562f8862SMatthieu Baerts (NGI0) MPTCP_LIB_SUBTEST_FLAKY=1 33370c93af1fSGeliang Tang test_linkfail=128 \ 33380c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3339b6e074e1SGeliang Tang chk_join_nr 0 0 0 +1 +0 1 0 1 "$(pedit_action_pkts)" 33401f7d325fSGeliang Tang chk_fail_nr 1 -1 invert 3341b6e074e1SGeliang Tang fi 33422ba18161SGeliang Tang 33432ba18161SGeliang Tang # multiple subflows 33442ba18161SGeliang Tang if reset_with_fail "MP_FAIL MP_RST" 2; then 3345562f8862SMatthieu Baerts (NGI0) MPTCP_LIB_SUBTEST_FLAKY=1 334699ac814eSGeliang Tang tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit delay 5ms 33472ba18161SGeliang Tang pm_nl_set_limits $ns1 0 1 33482ba18161SGeliang Tang pm_nl_set_limits $ns2 0 1 33492ba18161SGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow 33500c93af1fSGeliang Tang test_linkfail=1024 \ 33510c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 33522ba18161SGeliang Tang chk_join_nr 1 1 1 1 0 1 1 0 "$(pedit_action_pkts)" 33532ba18161SGeliang Tang fi 3354b6e074e1SGeliang Tang} 3355b6e074e1SGeliang Tang 33569d71f43aSGeliang Tang# $1: ns ; $2: addr ; $3: id 33574369c198SGeliang Tanguserspace_pm_add_addr() 33584369c198SGeliang Tang{ 33599d71f43aSGeliang Tang local evts=$evts_ns1 33604369c198SGeliang Tang local tk 33614369c198SGeliang Tang 33629d71f43aSGeliang Tang [ "$1" == "$ns2" ] && evts=$evts_ns2 33639d71f43aSGeliang Tang tk=$(mptcp_lib_evts_get_info token "$evts") 33649d71f43aSGeliang Tang 33659d71f43aSGeliang Tang ip netns exec $1 ./pm_nl_ctl ann $2 token $tk id $3 33664369c198SGeliang Tang sleep 1 33674369c198SGeliang Tang} 33684369c198SGeliang Tang 33699d71f43aSGeliang Tang# $1: ns ; $2: id 33709d71f43aSGeliang Tanguserspace_pm_rm_addr() 33714369c198SGeliang Tang{ 33729d71f43aSGeliang Tang local evts=$evts_ns1 33739d71f43aSGeliang Tang local tk 33749d71f43aSGeliang Tang local cnt 33754369c198SGeliang Tang 33769d71f43aSGeliang Tang [ "$1" == "$ns2" ] && evts=$evts_ns2 33779d71f43aSGeliang Tang tk=$(mptcp_lib_evts_get_info token "$evts") 33789d71f43aSGeliang Tang 33799d71f43aSGeliang Tang cnt=$(rm_addr_count ${1}) 33809d71f43aSGeliang Tang ip netns exec $1 ./pm_nl_ctl rem token $tk id $2 33819d71f43aSGeliang Tang wait_rm_addr $1 "${cnt}" 33824369c198SGeliang Tang} 33834369c198SGeliang Tang 33849d71f43aSGeliang Tang# $1: ns ; $2: addr ; $3: id 33854369c198SGeliang Tanguserspace_pm_add_sf() 33864369c198SGeliang Tang{ 33879d71f43aSGeliang Tang local evts=$evts_ns1 33884369c198SGeliang Tang local tk da dp 33894369c198SGeliang Tang 33909d71f43aSGeliang Tang [ "$1" == "$ns2" ] && evts=$evts_ns2 33919d71f43aSGeliang Tang tk=$(mptcp_lib_evts_get_info token "$evts") 33929d71f43aSGeliang Tang da=$(mptcp_lib_evts_get_info daddr4 "$evts") 33939d71f43aSGeliang Tang dp=$(mptcp_lib_evts_get_info dport "$evts") 33949d71f43aSGeliang Tang 33959d71f43aSGeliang Tang ip netns exec $1 ./pm_nl_ctl csf lip $2 lid $3 \ 33964369c198SGeliang Tang rip $da rport $dp token $tk 33974369c198SGeliang Tang sleep 1 33984369c198SGeliang Tang} 33994369c198SGeliang Tang 34009d71f43aSGeliang Tang# $1: ns ; $2: addr $3: event type 34019d71f43aSGeliang Tanguserspace_pm_rm_sf() 34024369c198SGeliang Tang{ 34039d71f43aSGeliang Tang local evts=$evts_ns1 34049d71f43aSGeliang Tang local t=${3:-1} 3405ece1aaecSGeliang Tang local ip 34064369c198SGeliang Tang local tk da dp sp 34079d71f43aSGeliang Tang local cnt 34084369c198SGeliang Tang 34099d71f43aSGeliang Tang [ "$1" == "$ns2" ] && evts=$evts_ns2 3410ece1aaecSGeliang Tang [ -n "$(mptcp_lib_evts_get_info "saddr4" "$evts" $t)" ] && ip=4 3411ece1aaecSGeliang Tang [ -n "$(mptcp_lib_evts_get_info "saddr6" "$evts" $t)" ] && ip=6 34129d71f43aSGeliang Tang tk=$(mptcp_lib_evts_get_info token "$evts") 3413ece1aaecSGeliang Tang da=$(mptcp_lib_evts_get_info "daddr$ip" "$evts" $t $2) 3414ece1aaecSGeliang Tang dp=$(mptcp_lib_evts_get_info dport "$evts" $t $2) 3415ece1aaecSGeliang Tang sp=$(mptcp_lib_evts_get_info sport "$evts" $t $2) 34169d71f43aSGeliang Tang 34179d71f43aSGeliang Tang cnt=$(rm_sf_count ${1}) 34189d71f43aSGeliang Tang ip netns exec $1 ./pm_nl_ctl dsf lip $2 lport $sp \ 34194369c198SGeliang Tang rip $da rport $dp token $tk 34209d71f43aSGeliang Tang wait_rm_sf $1 "${cnt}" 34214369c198SGeliang Tang} 34224369c198SGeliang Tang 34231b8af4baSGeliang Tangcheck_output() 34241b8af4baSGeliang Tang{ 34251b8af4baSGeliang Tang local cmd="$1" 34261b8af4baSGeliang Tang local expected="$2" 34271b8af4baSGeliang Tang local msg="$3" 34281b8af4baSGeliang Tang local rc=0 34291b8af4baSGeliang Tang 34301b8af4baSGeliang Tang mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=${?} 34311b8af4baSGeliang Tang if [ ${rc} -eq 2 ]; then 34321b8af4baSGeliang Tang fail_test "fail to check output # error ${rc}" 34331b8af4baSGeliang Tang elif [ ${rc} -eq 0 ]; then 34341b8af4baSGeliang Tang print_ok 34351b8af4baSGeliang Tang elif [ ${rc} -eq 1 ]; then 34361b8af4baSGeliang Tang fail_test "fail to check output # different output" 34371b8af4baSGeliang Tang fi 34381b8af4baSGeliang Tang} 34391b8af4baSGeliang Tang 34401b8af4baSGeliang Tang# $1: ns 34411b8af4baSGeliang Tanguserspace_pm_dump() 34421b8af4baSGeliang Tang{ 34431b8af4baSGeliang Tang local evts=$evts_ns1 34441b8af4baSGeliang Tang local tk 34451b8af4baSGeliang Tang 34461b8af4baSGeliang Tang [ "$1" == "$ns2" ] && evts=$evts_ns2 34471b8af4baSGeliang Tang tk=$(mptcp_lib_evts_get_info token "$evts") 34481b8af4baSGeliang Tang 34491b8af4baSGeliang Tang ip netns exec $1 ./pm_nl_ctl dump token $tk 34501b8af4baSGeliang Tang} 34511b8af4baSGeliang Tang 3452485bb198SGeliang Tang# $1: ns ; $2: id 3453485bb198SGeliang Tanguserspace_pm_get_addr() 3454485bb198SGeliang Tang{ 3455485bb198SGeliang Tang local evts=$evts_ns1 3456485bb198SGeliang Tang local tk 3457485bb198SGeliang Tang 3458485bb198SGeliang Tang [ "$1" == "$ns2" ] && evts=$evts_ns2 3459485bb198SGeliang Tang tk=$(mptcp_lib_evts_get_info token "$evts") 3460485bb198SGeliang Tang 3461485bb198SGeliang Tang ip netns exec $1 ./pm_nl_ctl get $2 token $tk 3462485bb198SGeliang Tang} 3463485bb198SGeliang Tang 34641b8af4baSGeliang Tanguserspace_pm_chk_dump_addr() 34651b8af4baSGeliang Tang{ 34661b8af4baSGeliang Tang local ns="${1}" 34671b8af4baSGeliang Tang local exp="${2}" 34681b8af4baSGeliang Tang local check="${3}" 34691b8af4baSGeliang Tang 34701b8af4baSGeliang Tang print_check "dump addrs ${check}" 34711b8af4baSGeliang Tang 34721b8af4baSGeliang Tang if mptcp_lib_kallsyms_has "mptcp_userspace_pm_dump_addr$"; then 34731b8af4baSGeliang Tang check_output "userspace_pm_dump ${ns}" "${exp}" 34741b8af4baSGeliang Tang else 34751b8af4baSGeliang Tang print_skip 34761b8af4baSGeliang Tang fi 34771b8af4baSGeliang Tang} 34781b8af4baSGeliang Tang 3479485bb198SGeliang Tanguserspace_pm_chk_get_addr() 3480485bb198SGeliang Tang{ 3481485bb198SGeliang Tang local ns="${1}" 3482485bb198SGeliang Tang local id="${2}" 3483485bb198SGeliang Tang local exp="${3}" 3484485bb198SGeliang Tang 3485485bb198SGeliang Tang print_check "get id ${id} addr" 3486485bb198SGeliang Tang 3487485bb198SGeliang Tang if mptcp_lib_kallsyms_has "mptcp_userspace_pm_get_addr$"; then 3488485bb198SGeliang Tang check_output "userspace_pm_get_addr ${ns} ${id}" "${exp}" 3489485bb198SGeliang Tang else 3490485bb198SGeliang Tang print_skip 3491485bb198SGeliang Tang fi 3492485bb198SGeliang Tang} 3493485bb198SGeliang Tang 34945ac1d2d6SMat Martineauuserspace_tests() 34955ac1d2d6SMat Martineau{ 34965ac1d2d6SMat Martineau # userspace pm type prevents add_addr 3497f2b492b0SMatthieu Baerts if reset "userspace pm type prevents add_addr" && 3498f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 34995ac1d2d6SMat Martineau set_userspace_pm $ns1 35005ac1d2d6SMat Martineau pm_nl_set_limits $ns1 0 2 35015ac1d2d6SMat Martineau pm_nl_set_limits $ns2 0 2 35025ac1d2d6SMat Martineau pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 35035ac1d2d6SMat Martineau run_tests $ns1 $ns2 10.0.1.1 35045ac1d2d6SMat Martineau chk_join_nr 0 0 0 35055ac1d2d6SMat Martineau chk_add_nr 0 0 35065ac1d2d6SMat Martineau fi 35075ac1d2d6SMat Martineau 3508b3b71bf9SMat Martineau # userspace pm type does not echo add_addr without daemon 3509f2b492b0SMatthieu Baerts if reset "userspace pm no echo w/o daemon" && 3510f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 3511b3b71bf9SMat Martineau set_userspace_pm $ns2 3512b3b71bf9SMat Martineau pm_nl_set_limits $ns1 0 2 3513b3b71bf9SMat Martineau pm_nl_set_limits $ns2 0 2 3514b3b71bf9SMat Martineau pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 3515b3b71bf9SMat Martineau run_tests $ns1 $ns2 10.0.1.1 3516b3b71bf9SMat Martineau chk_join_nr 0 0 0 3517b3b71bf9SMat Martineau chk_add_nr 1 0 3518b3b71bf9SMat Martineau fi 3519b3b71bf9SMat Martineau 35205ac1d2d6SMat Martineau # userspace pm type rejects join 3521f2b492b0SMatthieu Baerts if reset "userspace pm type rejects join" && 3522f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 35235ac1d2d6SMat Martineau set_userspace_pm $ns1 35245ac1d2d6SMat Martineau pm_nl_set_limits $ns1 1 1 35255ac1d2d6SMat Martineau pm_nl_set_limits $ns2 1 1 35265ac1d2d6SMat Martineau pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 35275ac1d2d6SMat Martineau run_tests $ns1 $ns2 10.0.1.1 35285ac1d2d6SMat Martineau chk_join_nr 1 1 0 35295ac1d2d6SMat Martineau fi 35305ac1d2d6SMat Martineau 35315ac1d2d6SMat Martineau # userspace pm type does not send join 3532f2b492b0SMatthieu Baerts if reset "userspace pm type does not send join" && 3533f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 35345ac1d2d6SMat Martineau set_userspace_pm $ns2 35355ac1d2d6SMat Martineau pm_nl_set_limits $ns1 1 1 35365ac1d2d6SMat Martineau pm_nl_set_limits $ns2 1 1 35375ac1d2d6SMat Martineau pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 35385ac1d2d6SMat Martineau run_tests $ns1 $ns2 10.0.1.1 35395ac1d2d6SMat Martineau chk_join_nr 0 0 0 35405ac1d2d6SMat Martineau fi 35415ac1d2d6SMat Martineau 35425ac1d2d6SMat Martineau # userspace pm type prevents mp_prio 3543f2b492b0SMatthieu Baerts if reset "userspace pm type prevents mp_prio" && 3544f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 35455ac1d2d6SMat Martineau set_userspace_pm $ns1 35465ac1d2d6SMat Martineau pm_nl_set_limits $ns1 1 1 35475ac1d2d6SMat Martineau pm_nl_set_limits $ns2 1 1 35485ac1d2d6SMat Martineau pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 3549e571fb09SGeliang Tang sflags=backup speed=slow \ 3550e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 35515ac1d2d6SMat Martineau chk_join_nr 1 1 0 35528213b98eSMatthieu Baerts (NGI0) chk_prio_nr 0 0 0 0 35535ac1d2d6SMat Martineau fi 35545ac1d2d6SMat Martineau 35555ac1d2d6SMat Martineau # userspace pm type prevents rm_addr 3556f2b492b0SMatthieu Baerts if reset "userspace pm type prevents rm_addr" && 3557f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 35585ac1d2d6SMat Martineau set_userspace_pm $ns1 35595ac1d2d6SMat Martineau set_userspace_pm $ns2 35605ac1d2d6SMat Martineau pm_nl_set_limits $ns1 0 1 35615ac1d2d6SMat Martineau pm_nl_set_limits $ns2 0 1 35625ac1d2d6SMat Martineau pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 3563e571fb09SGeliang Tang addr_nr_ns2=-1 speed=slow \ 3564e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 35655ac1d2d6SMat Martineau chk_join_nr 0 0 0 35665ac1d2d6SMat Martineau chk_rm_nr 0 0 35675ac1d2d6SMat Martineau fi 356897040cf9SGeliang Tang 356997040cf9SGeliang Tang # userspace pm add & remove address 3570f2b492b0SMatthieu Baerts if reset_with_events "userspace pm add & remove address" && 3571f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 357297040cf9SGeliang Tang set_userspace_pm $ns1 3573ece1aaecSGeliang Tang pm_nl_set_limits $ns2 2 2 35741c6d07ddSGeliang Tang speed=5 \ 3575e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 & 35764369c198SGeliang Tang local tests_pid=$! 35774369c198SGeliang Tang wait_mpj $ns1 35789d71f43aSGeliang Tang userspace_pm_add_addr $ns1 10.0.2.1 10 3579ece1aaecSGeliang Tang userspace_pm_add_addr $ns1 10.0.3.1 20 3580ece1aaecSGeliang Tang chk_join_nr 2 2 2 3581ece1aaecSGeliang Tang chk_add_nr 2 2 3582ece1aaecSGeliang Tang chk_mptcp_info subflows 2 subflows 2 3583ece1aaecSGeliang Tang chk_subflows_total 3 3 3584ece1aaecSGeliang Tang chk_mptcp_info add_addr_signal 2 add_addr_accepted 2 35851b8af4baSGeliang Tang userspace_pm_chk_dump_addr "${ns1}" \ 35861b8af4baSGeliang Tang $'id 10 flags signal 10.0.2.1\nid 20 flags signal 10.0.3.1' \ 35871b8af4baSGeliang Tang "signal" 3588485bb198SGeliang Tang userspace_pm_chk_get_addr "${ns1}" "10" "id 10 flags signal 10.0.2.1" 3589485bb198SGeliang Tang userspace_pm_chk_get_addr "${ns1}" "20" "id 20 flags signal 10.0.3.1" 3590a17d1419SGeliang Tang userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $MPTCP_LIB_EVENT_SUB_ESTABLISHED 35911b8af4baSGeliang Tang userspace_pm_chk_dump_addr "${ns1}" \ 3592*8863e430SMatthieu Baerts (NGI0) "id 20 flags signal 10.0.3.1" "after rm_sf 10" 3593ece1aaecSGeliang Tang userspace_pm_rm_addr $ns1 20 35941b8af4baSGeliang Tang userspace_pm_chk_dump_addr "${ns1}" "" "after rm_addr 20" 3595*8863e430SMatthieu Baerts (NGI0) chk_rm_nr 1 1 invert 3596d7ced753SGeliang Tang chk_mptcp_info subflows 0 subflows 0 3597f9190d79SGeliang Tang chk_subflows_total 1 1 3598a3735625SGeliang Tang kill_events_pids 3599a259173bSMatthieu Baerts (NGI0) mptcp_lib_kill_wait $tests_pid 360097040cf9SGeliang Tang fi 36015e986ec4SGeliang Tang 36025e986ec4SGeliang Tang # userspace pm create destroy subflow 3603f2b492b0SMatthieu Baerts if reset_with_events "userspace pm create destroy subflow" && 3604f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 36055e986ec4SGeliang Tang set_userspace_pm $ns2 36065e986ec4SGeliang Tang pm_nl_set_limits $ns1 0 1 36071c6d07ddSGeliang Tang speed=5 \ 3608e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 & 36094369c198SGeliang Tang local tests_pid=$! 36104369c198SGeliang Tang wait_mpj $ns2 36119d71f43aSGeliang Tang userspace_pm_add_sf $ns2 10.0.3.2 20 36125e986ec4SGeliang Tang chk_join_nr 1 1 1 3613d7ced753SGeliang Tang chk_mptcp_info subflows 1 subflows 1 3614f9190d79SGeliang Tang chk_subflows_total 2 2 36151b8af4baSGeliang Tang userspace_pm_chk_dump_addr "${ns2}" \ 36161b8af4baSGeliang Tang "id 20 flags subflow 10.0.3.2" \ 36171b8af4baSGeliang Tang "subflow" 3618485bb198SGeliang Tang userspace_pm_chk_get_addr "${ns2}" "20" "id 20 flags subflow 10.0.3.2" 3619a17d1419SGeliang Tang userspace_pm_rm_sf $ns2 10.0.3.2 $MPTCP_LIB_EVENT_SUB_ESTABLISHED 36201b8af4baSGeliang Tang userspace_pm_chk_dump_addr "${ns2}" \ 36211b8af4baSGeliang Tang "" \ 3622*8863e430SMatthieu Baerts (NGI0) "after rm_sf 20" 3623*8863e430SMatthieu Baerts (NGI0) chk_rm_nr 0 1 3624d7ced753SGeliang Tang chk_mptcp_info subflows 0 subflows 0 3625f9190d79SGeliang Tang chk_subflows_total 1 1 3626a3735625SGeliang Tang kill_events_pids 3627a259173bSMatthieu Baerts (NGI0) mptcp_lib_kill_wait $tests_pid 36285e986ec4SGeliang Tang fi 362905867195SGeliang Tang 363005867195SGeliang Tang # userspace pm create id 0 subflow 363105867195SGeliang Tang if reset_with_events "userspace pm create id 0 subflow" && 363205867195SGeliang Tang continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 363305867195SGeliang Tang set_userspace_pm $ns2 363405867195SGeliang Tang pm_nl_set_limits $ns1 0 1 363505867195SGeliang Tang speed=5 \ 363605867195SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 & 363705867195SGeliang Tang local tests_pid=$! 363805867195SGeliang Tang wait_mpj $ns2 363905867195SGeliang Tang chk_mptcp_info subflows 0 subflows 0 364005867195SGeliang Tang chk_subflows_total 1 1 364105867195SGeliang Tang userspace_pm_add_sf $ns2 10.0.3.2 0 36421b8af4baSGeliang Tang userspace_pm_chk_dump_addr "${ns2}" \ 36431b8af4baSGeliang Tang "id 0 flags subflow 10.0.3.2" "id 0 subflow" 364405867195SGeliang Tang chk_join_nr 1 1 1 364505867195SGeliang Tang chk_mptcp_info subflows 1 subflows 1 364605867195SGeliang Tang chk_subflows_total 2 2 364705867195SGeliang Tang kill_events_pids 364805867195SGeliang Tang wait $tests_pid 364905867195SGeliang Tang fi 36505ac1d2d6SMat Martineau} 36515ac1d2d6SMat Martineau 3652e274f715SPaolo Abeniendpoint_tests() 365369c6ce7bSPaolo Abeni{ 365436c4127aSMatthieu Baerts # subflow_rebuild_header is needed to support the implicit flag 365569c6ce7bSPaolo Abeni # userspace pm type prevents add_addr 365636c4127aSMatthieu Baerts if reset "implicit EP" && 365736c4127aSMatthieu Baerts mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then 365869c6ce7bSPaolo Abeni pm_nl_set_limits $ns1 2 2 365969c6ce7bSPaolo Abeni pm_nl_set_limits $ns2 2 2 366069c6ce7bSPaolo Abeni pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 3661e571fb09SGeliang Tang speed=slow \ 3662358f02b8SMatthieu Baerts (NGI0) run_tests $ns1 $ns2 10.0.1.1 & 3663358f02b8SMatthieu Baerts (NGI0) local tests_pid=$! 366469c6ce7bSPaolo Abeni 366569c6ce7bSPaolo Abeni wait_mpj $ns1 366603668c65SMatthieu Baerts pm_nl_check_endpoint "creation" \ 366769c6ce7bSPaolo Abeni $ns2 10.0.2.2 id 1 flags implicit 3668d7ced753SGeliang Tang chk_mptcp_info subflows 1 subflows 1 3669d7ced753SGeliang Tang chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 367069c6ce7bSPaolo Abeni 36711dc88d24SMatthieu Baerts pm_nl_add_endpoint $ns2 10.0.2.2 id 33 2>/dev/null 367203668c65SMatthieu Baerts pm_nl_check_endpoint "ID change is prevented" \ 367369c6ce7bSPaolo Abeni $ns2 10.0.2.2 id 1 flags implicit 367469c6ce7bSPaolo Abeni 367569c6ce7bSPaolo Abeni pm_nl_add_endpoint $ns2 10.0.2.2 flags signal 367603668c65SMatthieu Baerts pm_nl_check_endpoint "modif is allowed" \ 367769c6ce7bSPaolo Abeni $ns2 10.0.2.2 id 1 flags signal 3678358f02b8SMatthieu Baerts (NGI0) mptcp_lib_kill_wait $tests_pid 3679ae7bd9ccSMatthieu Baerts fi 3680e274f715SPaolo Abeni 3681ce2f28a5SMatthieu Baerts (NGI0) if reset_with_tcp_filter "delete and re-add" ns2 10.0.3.2 REJECT OUTPUT && 368236c4127aSMatthieu Baerts mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then 3683a81c87acSMatthieu Baerts (NGI0) pm_nl_set_limits $ns1 0 3 3684a81c87acSMatthieu Baerts (NGI0) pm_nl_set_limits $ns2 0 3 3685a81c87acSMatthieu Baerts (NGI0) pm_nl_add_endpoint $ns2 10.0.1.2 id 1 dev ns2eth1 flags subflow 3686e274f715SPaolo Abeni pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow 368709c423d6SMatthieu Baerts (NGI0) test_linkfail=4 speed=5 \ 3688358f02b8SMatthieu Baerts (NGI0) run_tests $ns1 $ns2 10.0.1.1 & 3689358f02b8SMatthieu Baerts (NGI0) local tests_pid=$! 3690e274f715SPaolo Abeni 3691e274f715SPaolo Abeni wait_mpj $ns2 3692117eed29SGeliang Tang pm_nl_check_endpoint "creation" \ 3693117eed29SGeliang Tang $ns2 10.0.2.2 id 2 flags subflow dev ns2eth2 3694a81c87acSMatthieu Baerts (NGI0) chk_subflow_nr "before delete id 2" 2 3695d7ced753SGeliang Tang chk_mptcp_info subflows 1 subflows 1 36969095ce97SGeliang Tang 3697e274f715SPaolo Abeni pm_nl_del_endpoint $ns2 2 10.0.2.2 3698e274f715SPaolo Abeni sleep 0.5 3699a81c87acSMatthieu Baerts (NGI0) chk_subflow_nr "after delete id 2" 1 3700d7ced753SGeliang Tang chk_mptcp_info subflows 0 subflows 0 3701e274f715SPaolo Abeni 3702ce2f28a5SMatthieu Baerts (NGI0) pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow 3703e274f715SPaolo Abeni wait_mpj $ns2 3704a81c87acSMatthieu Baerts (NGI0) chk_subflow_nr "after re-add id 2" 2 3705d7ced753SGeliang Tang chk_mptcp_info subflows 1 subflows 1 3706ce2f28a5SMatthieu Baerts (NGI0) 3707ce2f28a5SMatthieu Baerts (NGI0) pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow 3708ce2f28a5SMatthieu Baerts (NGI0) wait_attempt_fail $ns2 3709ce2f28a5SMatthieu Baerts (NGI0) chk_subflow_nr "after new reject" 2 3710ce2f28a5SMatthieu Baerts (NGI0) chk_mptcp_info subflows 1 subflows 1 3711ce2f28a5SMatthieu Baerts (NGI0) 3712ce2f28a5SMatthieu Baerts (NGI0) ip netns exec "${ns2}" ${iptables} -D OUTPUT -s "10.0.3.2" -p tcp -j REJECT 3713ce2f28a5SMatthieu Baerts (NGI0) pm_nl_del_endpoint $ns2 3 10.0.3.2 3714ce2f28a5SMatthieu Baerts (NGI0) pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow 3715ce2f28a5SMatthieu Baerts (NGI0) wait_mpj $ns2 3716ce2f28a5SMatthieu Baerts (NGI0) chk_subflow_nr "after no reject" 3 3717ce2f28a5SMatthieu Baerts (NGI0) chk_mptcp_info subflows 2 subflows 2 3718ce2f28a5SMatthieu Baerts (NGI0) 371909c423d6SMatthieu Baerts (NGI0) local i 372009c423d6SMatthieu Baerts (NGI0) for i in $(seq 3); do 3721a81c87acSMatthieu Baerts (NGI0) pm_nl_del_endpoint $ns2 1 10.0.1.2 3722a81c87acSMatthieu Baerts (NGI0) sleep 0.5 372309c423d6SMatthieu Baerts (NGI0) chk_subflow_nr "after delete id 0 ($i)" 2 3724a81c87acSMatthieu Baerts (NGI0) chk_mptcp_info subflows 2 subflows 2 # only decr for additional sf 3725a81c87acSMatthieu Baerts (NGI0) 3726a81c87acSMatthieu Baerts (NGI0) pm_nl_add_endpoint $ns2 10.0.1.2 id 1 dev ns2eth1 flags subflow 3727a81c87acSMatthieu Baerts (NGI0) wait_mpj $ns2 372809c423d6SMatthieu Baerts (NGI0) chk_subflow_nr "after re-add id 0 ($i)" 3 3729a81c87acSMatthieu Baerts (NGI0) chk_mptcp_info subflows 3 subflows 3 373009c423d6SMatthieu Baerts (NGI0) done 3731a81c87acSMatthieu Baerts (NGI0) 3732358f02b8SMatthieu Baerts (NGI0) mptcp_lib_kill_wait $tests_pid 3733ce2f28a5SMatthieu Baerts (NGI0) 373409c423d6SMatthieu Baerts (NGI0) chk_join_nr 6 6 6 373509c423d6SMatthieu Baerts (NGI0) chk_rm_nr 4 4 3736e274f715SPaolo Abeni fi 373769c6ce7bSPaolo Abeni} 373869c6ce7bSPaolo Abeni 373922514d52SMatthieu Baerts# [$1: error message] 37401002b89fSGeliang Tangusage() 37411002b89fSGeliang Tang{ 374222514d52SMatthieu Baerts if [ -n "${1}" ]; then 374322514d52SMatthieu Baerts echo "${1}" 374422514d52SMatthieu Baerts ret=1 374522514d52SMatthieu Baerts fi 374622514d52SMatthieu Baerts 37471002b89fSGeliang Tang echo "mptcp_join usage:" 37483afd0280SMatthieu Baerts 37493afd0280SMatthieu Baerts local key 37503afd0280SMatthieu Baerts for key in "${!all_tests[@]}"; do 37513afd0280SMatthieu Baerts echo " -${key} ${all_tests[${key}]}" 37523afd0280SMatthieu Baerts done 37533afd0280SMatthieu Baerts 3754a673321aSMat Martineau echo " -c capture pcap files" 3755af66d3e1SGeliang Tang echo " -C enable data checksum" 3756621bd393SGeliang Tang echo " -i use ip mptcp" 37571002b89fSGeliang Tang echo " -h help" 375822514d52SMatthieu Baerts 3759c7d49c03SMatthieu Baerts echo "[test ids|names]" 3760ae7bd9ccSMatthieu Baerts 376122514d52SMatthieu Baerts exit ${ret} 37621002b89fSGeliang Tang} 37631002b89fSGeliang Tang 3764a673321aSMat Martineau 37653afd0280SMatthieu Baerts# Use a "simple" array to force an specific order we cannot have with an associative one 37663afd0280SMatthieu Baertsall_tests_sorted=( 37673afd0280SMatthieu Baerts f@subflows_tests 37683afd0280SMatthieu Baerts e@subflows_error_tests 37693afd0280SMatthieu Baerts s@signal_address_tests 37703afd0280SMatthieu Baerts l@link_failure_tests 37713afd0280SMatthieu Baerts t@add_addr_timeout_tests 37723afd0280SMatthieu Baerts r@remove_tests 37733afd0280SMatthieu Baerts a@add_tests 37743afd0280SMatthieu Baerts 6@ipv6_tests 37753afd0280SMatthieu Baerts 4@v4mapped_tests 3776ad349374SPaolo Abeni M@mixed_tests 37773afd0280SMatthieu Baerts b@backup_tests 37783afd0280SMatthieu Baerts p@add_addr_ports_tests 37793afd0280SMatthieu Baerts k@syncookies_tests 37803afd0280SMatthieu Baerts S@checksum_tests 37813afd0280SMatthieu Baerts d@deny_join_id0_tests 37823afd0280SMatthieu Baerts m@fullmesh_tests 37833afd0280SMatthieu Baerts z@fastclose_tests 3784b6e074e1SGeliang Tang F@fail_tests 37855ac1d2d6SMat Martineau u@userspace_tests 3786e274f715SPaolo Abeni I@endpoint_tests 37873afd0280SMatthieu Baerts) 37883afd0280SMatthieu Baerts 37893afd0280SMatthieu Baertsall_tests_args="" 37903afd0280SMatthieu Baertsall_tests_names=() 37913afd0280SMatthieu Baertsfor subtests in "${all_tests_sorted[@]}"; do 37923afd0280SMatthieu Baerts key="${subtests%@*}" 37933afd0280SMatthieu Baerts value="${subtests#*@}" 37943afd0280SMatthieu Baerts 37953afd0280SMatthieu Baerts all_tests_args+="${key}" 37963afd0280SMatthieu Baerts all_tests_names+=("${value}") 37973afd0280SMatthieu Baerts all_tests[${key}]="${value}" 37983afd0280SMatthieu Baertsdone 37993afd0280SMatthieu Baerts 3800826d7bdcSMatthieu Baertstests=() 38013afd0280SMatthieu Baertswhile getopts "${all_tests_args}cCih" opt; do 38021002b89fSGeliang Tang case $opt in 38033afd0280SMatthieu Baerts ["${all_tests_args}"]) 38043afd0280SMatthieu Baerts tests+=("${all_tests[${opt}]}") 380569c6ce7bSPaolo Abeni ;; 3806a673321aSMat Martineau c) 3807826d7bdcSMatthieu Baerts capture=1 3808a673321aSMat Martineau ;; 3809af66d3e1SGeliang Tang C) 3810826d7bdcSMatthieu Baerts checksum=1 3811af66d3e1SGeliang Tang ;; 3812621bd393SGeliang Tang i) 3813826d7bdcSMatthieu Baerts ip_mptcp=1 3814621bd393SGeliang Tang ;; 381522514d52SMatthieu Baerts h) 38161002b89fSGeliang Tang usage 38171002b89fSGeliang Tang ;; 381822514d52SMatthieu Baerts *) 381922514d52SMatthieu Baerts usage "Unknown option: -${opt}" 382022514d52SMatthieu Baerts ;; 38211002b89fSGeliang Tang esac 38221002b89fSGeliang Tangdone 382300587187SFlorian Westphal 3824ae7bd9ccSMatthieu Baertsshift $((OPTIND - 1)) 3825ae7bd9ccSMatthieu Baerts 3826ae7bd9ccSMatthieu Baertsfor arg in "${@}"; do 3827ae7bd9ccSMatthieu Baerts if [[ "${arg}" =~ ^[0-9]+$ ]]; then 3828c7d49c03SMatthieu Baerts only_tests_ids+=("${arg}") 3829ae7bd9ccSMatthieu Baerts else 3830c7d49c03SMatthieu Baerts only_tests_names+=("${arg}") 3831ae7bd9ccSMatthieu Baerts fi 3832ae7bd9ccSMatthieu Baertsdone 3833ae7bd9ccSMatthieu Baerts 3834826d7bdcSMatthieu Baertsif [ ${#tests[@]} -eq 0 ]; then 38353afd0280SMatthieu Baerts tests=("${all_tests_names[@]}") 38363afd0280SMatthieu Baertsfi 38373afd0280SMatthieu Baerts 3838826d7bdcSMatthieu Baertsfor subtests in "${tests[@]}"; do 3839826d7bdcSMatthieu Baerts "${subtests}" 3840826d7bdcSMatthieu Baertsdone 3841826d7bdcSMatthieu Baerts 384239aab882SMatthieu Baertsif [ ${ret} -ne 0 ]; then 384339aab882SMatthieu Baerts echo 384439aab882SMatthieu Baerts echo "${#failed_tests[@]} failure(s) has(ve) been detected:" 384539aab882SMatthieu Baerts for i in $(get_failed_tests_ids); do 384639aab882SMatthieu Baerts echo -e "\t- ${i}: ${failed_tests[${i}]}" 384739aab882SMatthieu Baerts done 384839aab882SMatthieu Baerts echo 384939aab882SMatthieu Baertsfi 385039aab882SMatthieu Baerts 38517f117cd3SMatthieu Baertsappend_prev_results 38527f117cd3SMatthieu Baertsmptcp_lib_result_print_all_tap 38537f117cd3SMatthieu Baerts 3854b08fbf24SPaolo Abeniexit $ret 3855