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="" 241e777bd8SMatthieu Baertscapout="" 251e777bd8SMatthieu Baertsns1="" 261e777bd8SMatthieu Baertsns2="" 27b08fbf24SPaolo Abeniksft_skip=4 280c4cd3f8SMatthieu Baertsiptables="iptables" 290c4cd3f8SMatthieu Baertsip6tables="ip6tables" 305888a61cSMatthieu Baertstimeout_poll=30 315888a61cSMatthieu Baertstimeout_test=$((timeout_poll * 2 + 1)) 32b08fbf24SPaolo Abenicapture=0 33af66d3e1SGeliang Tangchecksum=0 3434aa6e3bSGeliang Tangip_mptcp=0 358117dac3SGeliang Tangcheck_invert=0 363c082695SGeliang Tangvalidate_checksum=0 3793827ad5SMatthieu Baertsinit=0 38a3735625SGeliang Tangevts_ns1="" 39a3735625SGeliang Tangevts_ns2="" 40a3735625SGeliang Tangevts_ns1_pid=0 41a3735625SGeliang Tangevts_ns2_pid=0 427f117cd3SMatthieu Baertslast_test_failed=0 437f117cd3SMatthieu Baertslast_test_skipped=0 447f117cd3SMatthieu Baertslast_test_ignored=1 45b08fbf24SPaolo Abeni 463afd0280SMatthieu Baertsdeclare -A all_tests 47c7d49c03SMatthieu Baertsdeclare -a only_tests_ids 48c7d49c03SMatthieu Baertsdeclare -a only_tests_names 4939aab882SMatthieu Baertsdeclare -A failed_tests 50b08fbf24SPaolo AbeniTEST_COUNT=0 51c7d49c03SMatthieu BaertsTEST_NAME="" 5203668c65SMatthieu Baertsnr_blank=6 53b08fbf24SPaolo Abeni 54662aa22dSGeliang Tang# These var are used only in some tests, make sure they are not already set 55662aa22dSGeliang Tangunset FAILING_LINKS 56662aa22dSGeliang Tangunset test_linkfail 57662aa22dSGeliang Tangunset addr_nr_ns1 58662aa22dSGeliang Tangunset addr_nr_ns2 59662aa22dSGeliang Tangunset sflags 60080b7f57SGeliang Tangunset fastclose 614aadde08SGeliang Tangunset fullmesh 62e571fb09SGeliang Tangunset speed 63e59300ceSMatthieu Baerts 648d014eaaSGeliang Tang# generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) || 658d014eaaSGeliang Tang# (ip6 && (ip6[74] & 0xf0) == 0x30)'" 668d014eaaSGeliang TangCBPF_MPTCP_SUBOPTION_ADD_ADDR="14, 678d014eaaSGeliang Tang 48 0 0 0, 688d014eaaSGeliang Tang 84 0 0 240, 698d014eaaSGeliang Tang 21 0 3 64, 708d014eaaSGeliang Tang 48 0 0 54, 718d014eaaSGeliang Tang 84 0 0 240, 728d014eaaSGeliang Tang 21 6 7 48, 738d014eaaSGeliang Tang 48 0 0 0, 748d014eaaSGeliang Tang 84 0 0 240, 758d014eaaSGeliang Tang 21 0 4 96, 768d014eaaSGeliang Tang 48 0 0 74, 778d014eaaSGeliang Tang 84 0 0 240, 788d014eaaSGeliang Tang 21 0 1 48, 798d014eaaSGeliang Tang 6 0 0 65535, 808d014eaaSGeliang Tang 6 0 0 0" 818d014eaaSGeliang Tang 8293827ad5SMatthieu Baertsinit_partial() 83b08fbf24SPaolo Abeni{ 84b08fbf24SPaolo Abeni capout=$(mktemp) 85b08fbf24SPaolo Abeni 86787eb1e4SMatthieu Baerts local sec rndh 87787eb1e4SMatthieu Baerts sec=$(date +%s) 88787eb1e4SMatthieu Baerts rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) 89b08fbf24SPaolo Abeni 90b08fbf24SPaolo Abeni ns1="ns1-$rndh" 91b08fbf24SPaolo Abeni ns2="ns2-$rndh" 92b08fbf24SPaolo Abeni 931e777bd8SMatthieu Baerts local netns 94b08fbf24SPaolo Abeni for netns in "$ns1" "$ns2"; do 95b08fbf24SPaolo Abeni ip netns add $netns || exit $ksft_skip 96b08fbf24SPaolo Abeni ip -net $netns link set lo up 97b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.mptcp.enabled=1 98f2b492b0SMatthieu Baerts ip netns exec $netns sysctl -q net.mptcp.pm_type=0 2>/dev/null || true 99b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 100b08fbf24SPaolo Abeni ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 101af66d3e1SGeliang Tang if [ $checksum -eq 1 ]; then 102af66d3e1SGeliang Tang ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1 103af66d3e1SGeliang Tang fi 104b08fbf24SPaolo Abeni done 105b08fbf24SPaolo Abeni 1068117dac3SGeliang Tang check_invert=0 1073c082695SGeliang Tang validate_checksum=$checksum 1088117dac3SGeliang Tang 109b08fbf24SPaolo Abeni # ns1 ns2 110b08fbf24SPaolo Abeni # ns1eth1 ns2eth1 111b08fbf24SPaolo Abeni # ns1eth2 ns2eth2 112b08fbf24SPaolo Abeni # ns1eth3 ns2eth3 113b08fbf24SPaolo Abeni # ns1eth4 ns2eth4 114b08fbf24SPaolo Abeni 1151e777bd8SMatthieu Baerts local i 1164bfadd71SMatthieu Baerts for i in $(seq 1 4); do 117b08fbf24SPaolo Abeni ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2" 118b08fbf24SPaolo Abeni ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i 119b08fbf24SPaolo Abeni ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad 120b08fbf24SPaolo Abeni ip -net "$ns1" link set ns1eth$i up 121b08fbf24SPaolo Abeni 122b08fbf24SPaolo Abeni ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i 123b08fbf24SPaolo Abeni ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad 124b08fbf24SPaolo Abeni ip -net "$ns2" link set ns2eth$i up 125b08fbf24SPaolo Abeni 126b08fbf24SPaolo Abeni # let $ns2 reach any $ns1 address from any interface 127b08fbf24SPaolo Abeni ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i 1289846921dSPaolo Abeni ip -net "$ns2" route add default via dead:beef:$i::1 dev ns2eth$i metric 10$i 129b08fbf24SPaolo Abeni done 130b08fbf24SPaolo Abeni} 131b08fbf24SPaolo Abeni 1327d1e6f16SPaolo Abeniinit_shapers() 1337d1e6f16SPaolo Abeni{ 1341e777bd8SMatthieu Baerts local i 1354bfadd71SMatthieu Baerts for i in $(seq 1 4); do 1367d1e6f16SPaolo Abeni tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1 1377d1e6f16SPaolo Abeni tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1 1387d1e6f16SPaolo Abeni done 1397d1e6f16SPaolo Abeni} 1407d1e6f16SPaolo Abeni 141b08fbf24SPaolo Abenicleanup_partial() 142b08fbf24SPaolo Abeni{ 143b08fbf24SPaolo Abeni rm -f "$capout" 144b08fbf24SPaolo Abeni 1451e777bd8SMatthieu Baerts local netns 146b08fbf24SPaolo Abeni for netns in "$ns1" "$ns2"; do 147b08fbf24SPaolo Abeni ip netns del $netns 148c2a55e8fSMatthieu Baerts rm -f /tmp/$netns.{nstat,out} 149b08fbf24SPaolo Abeni done 150b08fbf24SPaolo Abeni} 151b08fbf24SPaolo Abeni 15287154755SMatthieu Baertscheck_tools() 15387154755SMatthieu Baerts{ 154715c78a8SMatthieu Baerts mptcp_lib_check_mptcp 155cdb50525SMatthieu Baerts mptcp_lib_check_kallsyms 156715c78a8SMatthieu Baerts 15787154755SMatthieu Baerts if ! ip -Version &> /dev/null; then 15887154755SMatthieu Baerts echo "SKIP: Could not run test without ip tool" 15987154755SMatthieu Baerts exit $ksft_skip 16087154755SMatthieu Baerts fi 16187154755SMatthieu Baerts 1620c4cd3f8SMatthieu Baerts # Use the legacy version if available to support old kernel versions 1630c4cd3f8SMatthieu Baerts if iptables-legacy -V &> /dev/null; then 1640c4cd3f8SMatthieu Baerts iptables="iptables-legacy" 1650c4cd3f8SMatthieu Baerts ip6tables="ip6tables-legacy" 1660c4cd3f8SMatthieu Baerts elif ! iptables -V &> /dev/null; then 16787154755SMatthieu Baerts echo "SKIP: Could not run all tests without iptables tool" 16887154755SMatthieu Baerts exit $ksft_skip 169016e7ba4SMatthieu Baerts elif ! ip6tables -V &> /dev/null; then 17087154755SMatthieu Baerts echo "SKIP: Could not run all tests without ip6tables tool" 17187154755SMatthieu Baerts exit $ksft_skip 17287154755SMatthieu Baerts fi 17387154755SMatthieu Baerts} 17487154755SMatthieu Baerts 17593827ad5SMatthieu Baertsinit() { 17693827ad5SMatthieu Baerts init=1 17793827ad5SMatthieu Baerts 17887154755SMatthieu Baerts check_tools 17987154755SMatthieu Baerts 18093827ad5SMatthieu Baerts sin=$(mktemp) 18193827ad5SMatthieu Baerts sout=$(mktemp) 18293827ad5SMatthieu Baerts cin=$(mktemp) 18393827ad5SMatthieu Baerts cinsent=$(mktemp) 18493827ad5SMatthieu Baerts cout=$(mktemp) 185a3735625SGeliang Tang evts_ns1=$(mktemp) 186a3735625SGeliang Tang evts_ns2=$(mktemp) 18793827ad5SMatthieu Baerts 18893827ad5SMatthieu Baerts trap cleanup EXIT 18993827ad5SMatthieu Baerts 19003668c65SMatthieu Baerts make_file "$cin" "client" 1 >/dev/null 19103668c65SMatthieu Baerts make_file "$sin" "server" 1 >/dev/null 19293827ad5SMatthieu Baerts} 19393827ad5SMatthieu Baerts 194b08fbf24SPaolo Abenicleanup() 195b08fbf24SPaolo Abeni{ 1967d1e6f16SPaolo Abeni rm -f "$cin" "$cout" "$sinfail" 1977d1e6f16SPaolo Abeni rm -f "$sin" "$sout" "$cinsent" "$cinfail" 198d328fe87SMatthieu Baerts rm -f "$tmpfile" 199a3735625SGeliang Tang rm -rf $evts_ns1 $evts_ns2 200b08fbf24SPaolo Abeni cleanup_partial 201b08fbf24SPaolo Abeni} 202b08fbf24SPaolo Abeni 203cdb50525SMatthieu Baertsprint_title() 204cdb50525SMatthieu Baerts{ 20503668c65SMatthieu Baerts printf "%03u %s\n" "${TEST_COUNT}" "${TEST_NAME}" 20603668c65SMatthieu Baerts} 20703668c65SMatthieu Baerts 20803668c65SMatthieu Baertsprint_check() 20903668c65SMatthieu Baerts{ 21003668c65SMatthieu Baerts printf "%-${nr_blank}s%-36s" " " "${*}" 21103668c65SMatthieu Baerts} 21203668c65SMatthieu Baerts 21303668c65SMatthieu Baertsprint_info() 21403668c65SMatthieu Baerts{ 21503668c65SMatthieu Baerts # It can be empty, no need to print anything then 21603668c65SMatthieu Baerts [ -z "${1}" ] && return 21703668c65SMatthieu Baerts 218*9466df1aSMatthieu Baerts mptcp_lib_print_info " Info: ${*}" 21903668c65SMatthieu Baerts} 22003668c65SMatthieu Baerts 22103668c65SMatthieu Baertsprint_ok() 22203668c65SMatthieu Baerts{ 223*9466df1aSMatthieu Baerts mptcp_lib_print_ok "[ ok ]${1:+ ${*}}" 22403668c65SMatthieu Baerts} 22503668c65SMatthieu Baerts 22603668c65SMatthieu Baertsprint_fail() 22703668c65SMatthieu Baerts{ 228*9466df1aSMatthieu Baerts mptcp_lib_print_err "[fail]${1:+ ${*}}" 22903668c65SMatthieu Baerts} 23003668c65SMatthieu Baerts 23103668c65SMatthieu Baertsprint_skip() 23203668c65SMatthieu Baerts{ 233*9466df1aSMatthieu Baerts mptcp_lib_print_warn "[skip]${1:+ ${*}}" 234cdb50525SMatthieu Baerts} 235cdb50525SMatthieu Baerts 236cdb50525SMatthieu Baerts# [ $1: fail msg ] 237cdb50525SMatthieu Baertsmark_as_skipped() 238cdb50525SMatthieu Baerts{ 239cdb50525SMatthieu Baerts local msg="${1:-"Feature not supported"}" 240cdb50525SMatthieu Baerts 241cdb50525SMatthieu Baerts mptcp_lib_fail_if_expected_feature "${msg}" 242cdb50525SMatthieu Baerts 24303668c65SMatthieu Baerts print_check "${msg}" 24403668c65SMatthieu Baerts print_skip 2457f117cd3SMatthieu Baerts 2467f117cd3SMatthieu Baerts last_test_skipped=1 247cdb50525SMatthieu Baerts} 248cdb50525SMatthieu Baerts 249cdb50525SMatthieu Baerts# $@: condition 250cdb50525SMatthieu Baertscontinue_if() 251cdb50525SMatthieu Baerts{ 252cdb50525SMatthieu Baerts if ! "${@}"; then 253cdb50525SMatthieu Baerts mark_as_skipped 254cdb50525SMatthieu Baerts return 1 255cdb50525SMatthieu Baerts fi 256cdb50525SMatthieu Baerts} 257cdb50525SMatthieu Baerts 258ae7bd9ccSMatthieu Baertsskip_test() 259ae7bd9ccSMatthieu Baerts{ 260c7d49c03SMatthieu Baerts if [ "${#only_tests_ids[@]}" -eq 0 ] && [ "${#only_tests_names[@]}" -eq 0 ]; then 261ae7bd9ccSMatthieu Baerts return 1 262ae7bd9ccSMatthieu Baerts fi 263ae7bd9ccSMatthieu Baerts 264ae7bd9ccSMatthieu Baerts local i 265c7d49c03SMatthieu Baerts for i in "${only_tests_ids[@]}"; do 266ae7bd9ccSMatthieu Baerts if [ "${TEST_COUNT}" -eq "${i}" ]; then 267ae7bd9ccSMatthieu Baerts return 1 268ae7bd9ccSMatthieu Baerts fi 269ae7bd9ccSMatthieu Baerts done 270c7d49c03SMatthieu Baerts for i in "${only_tests_names[@]}"; do 271c7d49c03SMatthieu Baerts if [ "${TEST_NAME}" = "${i}" ]; then 272c7d49c03SMatthieu Baerts return 1 273c7d49c03SMatthieu Baerts fi 274c7d49c03SMatthieu Baerts done 275ae7bd9ccSMatthieu Baerts 276ae7bd9ccSMatthieu Baerts return 0 277ae7bd9ccSMatthieu Baerts} 278ae7bd9ccSMatthieu Baerts 2797f117cd3SMatthieu Baertsappend_prev_results() 2807f117cd3SMatthieu Baerts{ 2817f117cd3SMatthieu Baerts if [ ${last_test_failed} -eq 1 ]; then 2827f117cd3SMatthieu Baerts mptcp_lib_result_fail "${TEST_NAME}" 2837f117cd3SMatthieu Baerts elif [ ${last_test_skipped} -eq 1 ]; then 2847f117cd3SMatthieu Baerts mptcp_lib_result_skip "${TEST_NAME}" 2857f117cd3SMatthieu Baerts elif [ ${last_test_ignored} -ne 1 ]; then 2867f117cd3SMatthieu Baerts mptcp_lib_result_pass "${TEST_NAME}" 2877f117cd3SMatthieu Baerts fi 2887f117cd3SMatthieu Baerts 2897f117cd3SMatthieu Baerts last_test_failed=0 2907f117cd3SMatthieu Baerts last_test_skipped=0 2917f117cd3SMatthieu Baerts last_test_ignored=0 2927f117cd3SMatthieu Baerts} 2937f117cd3SMatthieu Baerts 294c7d49c03SMatthieu Baerts# $1: test name 295b08fbf24SPaolo Abenireset() 296b08fbf24SPaolo Abeni{ 2977f117cd3SMatthieu Baerts append_prev_results 2987f117cd3SMatthieu Baerts 299c7d49c03SMatthieu Baerts TEST_NAME="${1}" 300c7d49c03SMatthieu Baerts 301ae7bd9ccSMatthieu Baerts TEST_COUNT=$((TEST_COUNT+1)) 302ae7bd9ccSMatthieu Baerts 303ae7bd9ccSMatthieu Baerts if skip_test; then 3047f117cd3SMatthieu Baerts last_test_ignored=1 305ae7bd9ccSMatthieu Baerts return 1 306ae7bd9ccSMatthieu Baerts fi 307ae7bd9ccSMatthieu Baerts 30803668c65SMatthieu Baerts print_title 30903668c65SMatthieu Baerts 31093827ad5SMatthieu Baerts if [ "${init}" != "1" ]; then 311b08fbf24SPaolo Abeni init 31293827ad5SMatthieu Baerts else 31393827ad5SMatthieu Baerts cleanup_partial 31493827ad5SMatthieu Baerts fi 31593827ad5SMatthieu Baerts 31693827ad5SMatthieu Baerts init_partial 317ae7bd9ccSMatthieu Baerts 318ae7bd9ccSMatthieu Baerts return 0 319b08fbf24SPaolo Abeni} 320b08fbf24SPaolo Abeni 321ae947bb2SMatthieu Baerts# $1: test name ; $2: counter to check 322ae947bb2SMatthieu Baertsreset_check_counter() 323ae947bb2SMatthieu Baerts{ 324ae947bb2SMatthieu Baerts reset "${1}" || return 1 325ae947bb2SMatthieu Baerts 326ae947bb2SMatthieu Baerts local counter="${2}" 327ae947bb2SMatthieu Baerts 328ae947bb2SMatthieu Baerts if ! nstat -asz "${counter}" | grep -wq "${counter}"; then 329ae947bb2SMatthieu Baerts mark_as_skipped "counter '${counter}' is not available" 330ae947bb2SMatthieu Baerts return 1 331ae947bb2SMatthieu Baerts fi 332ae947bb2SMatthieu Baerts} 333ae947bb2SMatthieu Baerts 334c7d49c03SMatthieu Baerts# $1: test name 33500587187SFlorian Westphalreset_with_cookies() 33600587187SFlorian Westphal{ 337c7d49c03SMatthieu Baerts reset "${1}" || return 1 33800587187SFlorian Westphal 3391e777bd8SMatthieu Baerts local netns 34000587187SFlorian Westphal for netns in "$ns1" "$ns2"; do 34100587187SFlorian Westphal ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2 34200587187SFlorian Westphal done 34300587187SFlorian Westphal} 34400587187SFlorian Westphal 345c7d49c03SMatthieu Baerts# $1: test name 3468d014eaaSGeliang Tangreset_with_add_addr_timeout() 3478d014eaaSGeliang Tang{ 348c7d49c03SMatthieu Baerts local ip="${2:-4}" 3498d014eaaSGeliang Tang local tables 3508d014eaaSGeliang Tang 351c7d49c03SMatthieu Baerts reset "${1}" || return 1 352c7d49c03SMatthieu Baerts 3530c4cd3f8SMatthieu Baerts tables="${iptables}" 3548d014eaaSGeliang Tang if [ $ip -eq 6 ]; then 3550c4cd3f8SMatthieu Baerts tables="${ip6tables}" 3568d014eaaSGeliang Tang fi 3578d014eaaSGeliang Tang 3588d014eaaSGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 3594a0b866aSMatthieu Baerts 3604a0b866aSMatthieu Baerts if ! ip netns exec $ns2 $tables -A OUTPUT -p tcp \ 3618d014eaaSGeliang Tang -m tcp --tcp-option 30 \ 3628d014eaaSGeliang Tang -m bpf --bytecode \ 3638d014eaaSGeliang Tang "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \ 3644a0b866aSMatthieu Baerts -j DROP; then 3654a0b866aSMatthieu Baerts mark_as_skipped "unable to set the 'add addr' rule" 3664a0b866aSMatthieu Baerts return 1 3674a0b866aSMatthieu Baerts fi 3688d014eaaSGeliang Tang} 3698d014eaaSGeliang Tang 370c7d49c03SMatthieu Baerts# $1: test name 371af66d3e1SGeliang Tangreset_with_checksum() 372af66d3e1SGeliang Tang{ 373af66d3e1SGeliang Tang local ns1_enable=$1 374af66d3e1SGeliang Tang local ns2_enable=$2 375af66d3e1SGeliang Tang 376c7d49c03SMatthieu Baerts reset "checksum test ${1} ${2}" || return 1 377af66d3e1SGeliang Tang 378af66d3e1SGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=$ns1_enable 379af66d3e1SGeliang Tang ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=$ns2_enable 3803c082695SGeliang Tang 3813c082695SGeliang Tang validate_checksum=1 382af66d3e1SGeliang Tang} 383af66d3e1SGeliang Tang 3840cddb4a6SGeliang Tangreset_with_allow_join_id0() 3850cddb4a6SGeliang Tang{ 386c7d49c03SMatthieu Baerts local ns1_enable=$2 387c7d49c03SMatthieu Baerts local ns2_enable=$3 3880cddb4a6SGeliang Tang 389c7d49c03SMatthieu Baerts reset "${1}" || return 1 3900cddb4a6SGeliang Tang 3910cddb4a6SGeliang Tang ip netns exec $ns1 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns1_enable 3920cddb4a6SGeliang Tang ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable 3930cddb4a6SGeliang Tang} 3940cddb4a6SGeliang Tang 395b6e074e1SGeliang Tang# Modify TCP payload without corrupting the TCP packet 396b6e074e1SGeliang Tang# 397b6e074e1SGeliang Tang# This rule inverts a 8-bit word at byte offset 148 for the 2nd TCP ACK packets 398b6e074e1SGeliang Tang# carrying enough data. 399b6e074e1SGeliang Tang# Once it is done, the TCP Checksum field is updated so the packet is still 400b6e074e1SGeliang Tang# considered as valid at the TCP level. 401b6e074e1SGeliang Tang# Because the MPTCP checksum, covering the TCP options and data, has not been 402b6e074e1SGeliang Tang# updated, the modification will be detected and an MP_FAIL will be emitted: 403b6e074e1SGeliang Tang# what we want to validate here without corrupting "random" MPTCP options. 404b6e074e1SGeliang Tang# 405b6e074e1SGeliang Tang# To avoid having tc producing this pr_info() message for each TCP ACK packets 406b6e074e1SGeliang Tang# not carrying enough data: 407b6e074e1SGeliang Tang# 408b6e074e1SGeliang Tang# tc action pedit offset 162 out of bounds 409b6e074e1SGeliang Tang# 410b6e074e1SGeliang Tang# Netfilter is used to mark packets with enough data. 4114a0b866aSMatthieu Baertssetup_fail_rules() 412b6e074e1SGeliang Tang{ 413b6e074e1SGeliang Tang check_invert=1 414b6e074e1SGeliang Tang validate_checksum=1 4154a0b866aSMatthieu Baerts local i="$1" 4164a0b866aSMatthieu Baerts local ip="${2:-4}" 417b6e074e1SGeliang Tang local tables 418b6e074e1SGeliang Tang 4190c4cd3f8SMatthieu Baerts tables="${iptables}" 420b6e074e1SGeliang Tang if [ $ip -eq 6 ]; then 4210c4cd3f8SMatthieu Baerts tables="${ip6tables}" 422b6e074e1SGeliang Tang fi 423b6e074e1SGeliang Tang 424b6e074e1SGeliang Tang ip netns exec $ns2 $tables \ 425b6e074e1SGeliang Tang -t mangle \ 426b6e074e1SGeliang Tang -A OUTPUT \ 427b6e074e1SGeliang Tang -o ns2eth$i \ 428b6e074e1SGeliang Tang -p tcp \ 429b6e074e1SGeliang Tang -m length --length 150:9999 \ 430b6e074e1SGeliang Tang -m statistic --mode nth --packet 1 --every 99999 \ 4314a0b866aSMatthieu Baerts -j MARK --set-mark 42 || return ${ksft_skip} 432b6e074e1SGeliang Tang 4334a0b866aSMatthieu Baerts tc -n $ns2 qdisc add dev ns2eth$i clsact || return ${ksft_skip} 434b6e074e1SGeliang Tang tc -n $ns2 filter add dev ns2eth$i egress \ 435b6e074e1SGeliang Tang protocol ip prio 1000 \ 436b6e074e1SGeliang Tang handle 42 fw \ 437b6e074e1SGeliang Tang action pedit munge offset 148 u8 invert \ 438b6e074e1SGeliang Tang pipe csum tcp \ 4394a0b866aSMatthieu Baerts index 100 || return ${ksft_skip} 4404a0b866aSMatthieu Baerts} 4414a0b866aSMatthieu Baerts 4424a0b866aSMatthieu Baertsreset_with_fail() 4434a0b866aSMatthieu Baerts{ 444ff8897b5SMatthieu Baerts reset_check_counter "${1}" "MPTcpExtInfiniteMapTx" || return 1 4454a0b866aSMatthieu Baerts shift 4464a0b866aSMatthieu Baerts 4474a0b866aSMatthieu Baerts ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=1 4484a0b866aSMatthieu Baerts ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=1 4494a0b866aSMatthieu Baerts 4504a0b866aSMatthieu Baerts local rc=0 4514a0b866aSMatthieu Baerts setup_fail_rules "${@}" || rc=$? 4524a0b866aSMatthieu Baerts 4534a0b866aSMatthieu Baerts if [ ${rc} -eq ${ksft_skip} ]; then 4544a0b866aSMatthieu Baerts mark_as_skipped "unable to set the 'fail' rules" 4554a0b866aSMatthieu Baerts return 1 4564a0b866aSMatthieu Baerts fi 457b6e074e1SGeliang Tang} 458b6e074e1SGeliang Tang 459a3735625SGeliang Tangreset_with_events() 460a3735625SGeliang Tang{ 461a3735625SGeliang Tang reset "${1}" || return 1 462a3735625SGeliang Tang 463a3735625SGeliang Tang :> "$evts_ns1" 464a3735625SGeliang Tang :> "$evts_ns2" 465a3735625SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl events >> "$evts_ns1" 2>&1 & 466a3735625SGeliang Tang evts_ns1_pid=$! 467a3735625SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl events >> "$evts_ns2" 2>&1 & 468a3735625SGeliang Tang evts_ns2_pid=$! 469a3735625SGeliang Tang} 470a3735625SGeliang Tang 4714a0b866aSMatthieu Baertsreset_with_tcp_filter() 4724a0b866aSMatthieu Baerts{ 4734a0b866aSMatthieu Baerts reset "${1}" || return 1 4744a0b866aSMatthieu Baerts shift 4754a0b866aSMatthieu Baerts 4764a0b866aSMatthieu Baerts local ns="${!1}" 4774a0b866aSMatthieu Baerts local src="${2}" 4784a0b866aSMatthieu Baerts local target="${3}" 4794a0b866aSMatthieu Baerts 4804a0b866aSMatthieu Baerts if ! ip netns exec "${ns}" ${iptables} \ 4814a0b866aSMatthieu Baerts -A INPUT \ 4824a0b866aSMatthieu Baerts -s "${src}" \ 4834a0b866aSMatthieu Baerts -p tcp \ 4844a0b866aSMatthieu Baerts -j "${target}"; then 4854a0b866aSMatthieu Baerts mark_as_skipped "unable to set the filter rules" 4864a0b866aSMatthieu Baerts return 1 4874a0b866aSMatthieu Baerts fi 4884a0b866aSMatthieu Baerts} 4894a0b866aSMatthieu Baerts 49003668c65SMatthieu Baerts# $1: err msg 49139aab882SMatthieu Baertsfail_test() 49239aab882SMatthieu Baerts{ 49339aab882SMatthieu Baerts ret=1 494985de459SPaolo Abeni 49503668c65SMatthieu Baerts print_fail "${@}" 49603668c65SMatthieu Baerts 4977f117cd3SMatthieu Baerts # just in case a test is marked twice as failed 4987f117cd3SMatthieu Baerts if [ ${last_test_failed} -eq 0 ]; then 4997f117cd3SMatthieu Baerts failed_tests[${TEST_COUNT}]="${TEST_NAME}" 5007f117cd3SMatthieu Baerts dump_stats 5017f117cd3SMatthieu Baerts last_test_failed=1 5027f117cd3SMatthieu Baerts fi 50339aab882SMatthieu Baerts} 50439aab882SMatthieu Baerts 50539aab882SMatthieu Baertsget_failed_tests_ids() 50639aab882SMatthieu Baerts{ 50739aab882SMatthieu Baerts # sorted 50839aab882SMatthieu Baerts local i 50939aab882SMatthieu Baerts for i in "${!failed_tests[@]}"; do 51039aab882SMatthieu Baerts echo "${i}" 51139aab882SMatthieu Baerts done | sort -n 51239aab882SMatthieu Baerts} 51339aab882SMatthieu Baerts 5148b819a84SFlorian Westphalprint_file_err() 5158b819a84SFlorian Westphal{ 5168b819a84SFlorian Westphal ls -l "$1" 1>&2 51703668c65SMatthieu Baerts echo -n "Trailing bytes are: " 5188b819a84SFlorian Westphal tail -c 27 "$1" 5198b819a84SFlorian Westphal} 5208b819a84SFlorian Westphal 521b08fbf24SPaolo Abenicheck_transfer() 522b08fbf24SPaolo Abeni{ 5231e777bd8SMatthieu Baerts local in=$1 5241e777bd8SMatthieu Baerts local out=$2 5251e777bd8SMatthieu Baerts local what=$3 5266bf41020SPaolo Abeni local bytes=$4 527d8d08302SMatthieu Baerts local i a b 528b08fbf24SPaolo Abeni 5291e777bd8SMatthieu Baerts local line 5306bf41020SPaolo Abeni if [ -n "$bytes" ]; then 5310fcd72dfSMatthieu Baerts local out_size 5326bf41020SPaolo Abeni # when truncating we must check the size explicitly 5330fcd72dfSMatthieu Baerts out_size=$(wc -c $out | awk '{print $1}') 5346bf41020SPaolo Abeni if [ $out_size -ne $bytes ]; then 53503668c65SMatthieu Baerts fail_test "$what output file has wrong size ($out_size, $bytes)" 5366bf41020SPaolo Abeni return 1 5376bf41020SPaolo Abeni fi 538d328fe87SMatthieu Baerts 539d328fe87SMatthieu Baerts # note: BusyBox's "cmp" command doesn't support --bytes 540d328fe87SMatthieu Baerts tmpfile=$(mktemp) 541d328fe87SMatthieu Baerts head --bytes="$bytes" "$in" > "$tmpfile" 542d328fe87SMatthieu Baerts mv "$tmpfile" "$in" 543d328fe87SMatthieu Baerts head --bytes="$bytes" "$out" > "$tmpfile" 544d328fe87SMatthieu Baerts mv "$tmpfile" "$out" 545d328fe87SMatthieu Baerts tmpfile="" 5466bf41020SPaolo Abeni fi 547d328fe87SMatthieu Baerts cmp -l "$in" "$out" | while read -r i a b; do 548d8d08302SMatthieu Baerts local sum=$((0${a} + 0${b})) 5498117dac3SGeliang Tang if [ $check_invert -eq 0 ] || [ $sum -ne $((0xff)) ]; then 55003668c65SMatthieu Baerts fail_test "$what does not match (in, out):" 551b08fbf24SPaolo Abeni print_file_err "$in" 552b08fbf24SPaolo Abeni print_file_err "$out" 553b08fbf24SPaolo Abeni 554b08fbf24SPaolo Abeni return 1 5558117dac3SGeliang Tang else 55603668c65SMatthieu Baerts print_info "$what has inverted byte at ${i}" 557b08fbf24SPaolo Abeni fi 5588117dac3SGeliang Tang done 559b08fbf24SPaolo Abeni 560b08fbf24SPaolo Abeni return 0 561b08fbf24SPaolo Abeni} 562b08fbf24SPaolo Abeni 563b08fbf24SPaolo Abenido_ping() 564b08fbf24SPaolo Abeni{ 5651e777bd8SMatthieu Baerts local listener_ns="$1" 5661e777bd8SMatthieu Baerts local connector_ns="$2" 5671e777bd8SMatthieu Baerts local connect_addr="$3" 568b08fbf24SPaolo Abeni 569d8d08302SMatthieu Baerts if ! ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null; then 57003668c65SMatthieu Baerts fail_test "$listener_ns -> $connect_addr connectivity" 571b08fbf24SPaolo Abeni fi 572b08fbf24SPaolo Abeni} 573b08fbf24SPaolo Abeni 5748b819a84SFlorian Westphallink_failure() 5758b819a84SFlorian Westphal{ 5761e777bd8SMatthieu Baerts local ns="$1" 5778b819a84SFlorian Westphal 5787d1e6f16SPaolo Abeni if [ -z "$FAILING_LINKS" ]; then 5798b819a84SFlorian Westphal l=$((RANDOM%4)) 5807d1e6f16SPaolo Abeni FAILING_LINKS=$((l+1)) 5817d1e6f16SPaolo Abeni fi 5828b819a84SFlorian Westphal 5831e777bd8SMatthieu Baerts local l 5847d1e6f16SPaolo Abeni for l in $FAILING_LINKS; do 5851e777bd8SMatthieu Baerts local veth="ns1eth$l" 5868b819a84SFlorian Westphal ip -net "$ns" link set "$veth" down 5877d1e6f16SPaolo Abeni done 5888b819a84SFlorian Westphal} 5898b819a84SFlorian Westphal 590523514edSGeliang Tang# $1: IP address 591523514edSGeliang Tangis_v6() 592523514edSGeliang Tang{ 593523514edSGeliang Tang [ -z "${1##*:*}" ] 594523514edSGeliang Tang} 595523514edSGeliang Tang 596327b9a94SPaolo Abeni# $1: ns, $2: port 597327b9a94SPaolo Abeniwait_local_port_listen() 598327b9a94SPaolo Abeni{ 599327b9a94SPaolo Abeni local listener_ns="${1}" 600327b9a94SPaolo Abeni local port="${2}" 601327b9a94SPaolo Abeni 6021e777bd8SMatthieu Baerts local port_hex 603327b9a94SPaolo Abeni port_hex="$(printf "%04X" "${port}")" 6041e777bd8SMatthieu Baerts 6051e777bd8SMatthieu Baerts local i 606327b9a94SPaolo Abeni for i in $(seq 10); do 607327b9a94SPaolo Abeni ip netns exec "${listener_ns}" cat /proc/net/tcp* | \ 608327b9a94SPaolo Abeni awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" && 609327b9a94SPaolo Abeni break 610327b9a94SPaolo Abeni sleep 0.1 611327b9a94SPaolo Abeni done 612327b9a94SPaolo Abeni} 613327b9a94SPaolo Abeni 61447867f0aSMatthieu Baerts# $1: ns ; $2: counter 61547867f0aSMatthieu Baertsget_counter() 61647867f0aSMatthieu Baerts{ 61747867f0aSMatthieu Baerts local ns="${1}" 61847867f0aSMatthieu Baerts local counter="${2}" 61947867f0aSMatthieu Baerts local count 62047867f0aSMatthieu Baerts 62147867f0aSMatthieu Baerts count=$(ip netns exec ${ns} nstat -asz "${counter}" | awk 'NR==1 {next} {print $2}') 62247867f0aSMatthieu Baerts if [ -z "${count}" ]; then 62347867f0aSMatthieu Baerts mptcp_lib_fail_if_expected_feature "${counter} counter" 62447867f0aSMatthieu Baerts return 1 62547867f0aSMatthieu Baerts fi 62647867f0aSMatthieu Baerts 62747867f0aSMatthieu Baerts echo "${count}" 62847867f0aSMatthieu Baerts} 62947867f0aSMatthieu Baerts 630327b9a94SPaolo Abenirm_addr_count() 631327b9a94SPaolo Abeni{ 63247867f0aSMatthieu Baerts get_counter "${1}" "MPTcpExtRmAddr" 633327b9a94SPaolo Abeni} 634327b9a94SPaolo Abeni 635327b9a94SPaolo Abeni# $1: ns, $2: old rm_addr counter in $ns 636327b9a94SPaolo Abeniwait_rm_addr() 637327b9a94SPaolo Abeni{ 638327b9a94SPaolo Abeni local ns="${1}" 639327b9a94SPaolo Abeni local old_cnt="${2}" 640327b9a94SPaolo Abeni local cnt 641327b9a94SPaolo Abeni 6421e777bd8SMatthieu Baerts local i 643327b9a94SPaolo Abeni for i in $(seq 10); do 644327b9a94SPaolo Abeni cnt=$(rm_addr_count ${ns}) 645327b9a94SPaolo Abeni [ "$cnt" = "${old_cnt}" ] || break 646327b9a94SPaolo Abeni sleep 0.1 647327b9a94SPaolo Abeni done 648327b9a94SPaolo Abeni} 649327b9a94SPaolo Abeni 6504369c198SGeliang Tangrm_sf_count() 6514369c198SGeliang Tang{ 6524369c198SGeliang Tang get_counter "${1}" "MPTcpExtRmSubflow" 6534369c198SGeliang Tang} 6544369c198SGeliang Tang 6554369c198SGeliang Tang# $1: ns, $2: old rm_sf counter in $ns 6564369c198SGeliang Tangwait_rm_sf() 6574369c198SGeliang Tang{ 6584369c198SGeliang Tang local ns="${1}" 6594369c198SGeliang Tang local old_cnt="${2}" 6604369c198SGeliang Tang local cnt 6614369c198SGeliang Tang 6624369c198SGeliang Tang local i 6634369c198SGeliang Tang for i in $(seq 10); do 6644369c198SGeliang Tang cnt=$(rm_sf_count ${ns}) 6654369c198SGeliang Tang [ "$cnt" = "${old_cnt}" ] || break 6664369c198SGeliang Tang sleep 0.1 6674369c198SGeliang Tang done 6684369c198SGeliang Tang} 6694369c198SGeliang Tang 67069c6ce7bSPaolo Abeniwait_mpj() 67169c6ce7bSPaolo Abeni{ 67269c6ce7bSPaolo Abeni local ns="${1}" 67369c6ce7bSPaolo Abeni local cnt old_cnt 67469c6ce7bSPaolo Abeni 67547867f0aSMatthieu Baerts old_cnt=$(get_counter ${ns} "MPTcpExtMPJoinAckRx") 67669c6ce7bSPaolo Abeni 67769c6ce7bSPaolo Abeni local i 67869c6ce7bSPaolo Abeni for i in $(seq 10); do 67947867f0aSMatthieu Baerts cnt=$(get_counter ${ns} "MPTcpExtMPJoinAckRx") 68069c6ce7bSPaolo Abeni [ "$cnt" = "${old_cnt}" ] || break 68169c6ce7bSPaolo Abeni sleep 0.1 68269c6ce7bSPaolo Abeni done 68369c6ce7bSPaolo Abeni} 68469c6ce7bSPaolo Abeni 68597040cf9SGeliang Tangkill_wait() 68697040cf9SGeliang Tang{ 68797040cf9SGeliang Tang kill $1 > /dev/null 2>&1 68897040cf9SGeliang Tang wait $1 2>/dev/null 68997040cf9SGeliang Tang} 69097040cf9SGeliang Tang 691a3735625SGeliang Tangkill_events_pids() 692a3735625SGeliang Tang{ 693a3735625SGeliang Tang kill_wait $evts_ns1_pid 694a3735625SGeliang Tang kill_wait $evts_ns2_pid 695a3735625SGeliang Tang} 696a3735625SGeliang Tang 697070d6dafSMatthieu Baertskill_tests_wait() 698070d6dafSMatthieu Baerts{ 6990fcd72dfSMatthieu Baerts #shellcheck disable=SC2046 700070d6dafSMatthieu Baerts kill -SIGUSR1 $(ip netns pids $ns2) $(ip netns pids $ns1) 701070d6dafSMatthieu Baerts wait 702070d6dafSMatthieu Baerts} 703070d6dafSMatthieu Baerts 70434aa6e3bSGeliang Tangpm_nl_set_limits() 70534aa6e3bSGeliang Tang{ 70634aa6e3bSGeliang Tang local ns=$1 70734aa6e3bSGeliang Tang local addrs=$2 70834aa6e3bSGeliang Tang local subflows=$3 70934aa6e3bSGeliang Tang 71034aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 71134aa6e3bSGeliang Tang ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows 71234aa6e3bSGeliang Tang else 71334aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows 71434aa6e3bSGeliang Tang fi 71534aa6e3bSGeliang Tang} 71634aa6e3bSGeliang Tang 71734aa6e3bSGeliang Tangpm_nl_add_endpoint() 71834aa6e3bSGeliang Tang{ 71934aa6e3bSGeliang Tang local ns=$1 72034aa6e3bSGeliang Tang local addr=$2 7211e777bd8SMatthieu Baerts local flags _flags 7221e777bd8SMatthieu Baerts local port _port 7231e777bd8SMatthieu Baerts local dev _dev 7241e777bd8SMatthieu Baerts local id _id 72534aa6e3bSGeliang Tang local nr=2 72634aa6e3bSGeliang Tang 7271e777bd8SMatthieu Baerts local p 728d8d08302SMatthieu Baerts for p in "${@}" 72934aa6e3bSGeliang Tang do 73034aa6e3bSGeliang Tang if [ $p = "flags" ]; then 73134aa6e3bSGeliang Tang eval _flags=\$"$nr" 732d8d08302SMatthieu Baerts [ -n "$_flags" ]; flags="flags $_flags" 73334aa6e3bSGeliang Tang fi 73434aa6e3bSGeliang Tang if [ $p = "dev" ]; then 73534aa6e3bSGeliang Tang eval _dev=\$"$nr" 736d8d08302SMatthieu Baerts [ -n "$_dev" ]; dev="dev $_dev" 73734aa6e3bSGeliang Tang fi 73834aa6e3bSGeliang Tang if [ $p = "id" ]; then 73934aa6e3bSGeliang Tang eval _id=\$"$nr" 740d8d08302SMatthieu Baerts [ -n "$_id" ]; id="id $_id" 74134aa6e3bSGeliang Tang fi 74234aa6e3bSGeliang Tang if [ $p = "port" ]; then 74334aa6e3bSGeliang Tang eval _port=\$"$nr" 744d8d08302SMatthieu Baerts [ -n "$_port" ]; port="port $_port" 74534aa6e3bSGeliang Tang fi 74634aa6e3bSGeliang Tang 747d8d08302SMatthieu Baerts nr=$((nr + 1)) 74834aa6e3bSGeliang Tang done 74934aa6e3bSGeliang Tang 75034aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 75134aa6e3bSGeliang Tang ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port 75234aa6e3bSGeliang Tang else 75334aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port 75434aa6e3bSGeliang Tang fi 75534aa6e3bSGeliang Tang} 75634aa6e3bSGeliang Tang 75734aa6e3bSGeliang Tangpm_nl_del_endpoint() 75834aa6e3bSGeliang Tang{ 75934aa6e3bSGeliang Tang local ns=$1 76034aa6e3bSGeliang Tang local id=$2 76134aa6e3bSGeliang Tang local addr=$3 76234aa6e3bSGeliang Tang 76334aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 76434aa6e3bSGeliang Tang ip -n $ns mptcp endpoint delete id $id $addr 76534aa6e3bSGeliang Tang else 76634aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl del $id $addr 76734aa6e3bSGeliang Tang fi 76834aa6e3bSGeliang Tang} 76934aa6e3bSGeliang Tang 77034aa6e3bSGeliang Tangpm_nl_flush_endpoint() 77134aa6e3bSGeliang Tang{ 77234aa6e3bSGeliang Tang local ns=$1 77334aa6e3bSGeliang Tang 77434aa6e3bSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 77534aa6e3bSGeliang Tang ip -n $ns mptcp endpoint flush 77634aa6e3bSGeliang Tang else 77734aa6e3bSGeliang Tang ip netns exec $ns ./pm_nl_ctl flush 77834aa6e3bSGeliang Tang fi 77934aa6e3bSGeliang Tang} 78034aa6e3bSGeliang Tang 781dda61b3dSGeliang Tangpm_nl_show_endpoints() 782dda61b3dSGeliang Tang{ 783dda61b3dSGeliang Tang local ns=$1 784dda61b3dSGeliang Tang 785dda61b3dSGeliang Tang if [ $ip_mptcp -eq 1 ]; then 786dda61b3dSGeliang Tang ip -n $ns mptcp endpoint show 787dda61b3dSGeliang Tang else 788dda61b3dSGeliang Tang ip netns exec $ns ./pm_nl_ctl dump 789dda61b3dSGeliang Tang fi 790dda61b3dSGeliang Tang} 791dda61b3dSGeliang Tang 792f0140386SGeliang Tangpm_nl_change_endpoint() 793f0140386SGeliang Tang{ 794f0140386SGeliang Tang local ns=$1 795bccefb76SGeliang Tang local id=$2 796bccefb76SGeliang Tang local flags=$3 797f0140386SGeliang Tang 798f0140386SGeliang Tang if [ $ip_mptcp -eq 1 ]; then 799f0140386SGeliang Tang ip -n $ns mptcp endpoint change id $id ${flags//","/" "} 800f0140386SGeliang Tang else 801bccefb76SGeliang Tang ip netns exec $ns ./pm_nl_ctl set id $id flags $flags 802f0140386SGeliang Tang fi 803f0140386SGeliang Tang} 804f0140386SGeliang Tang 80569c6ce7bSPaolo Abenipm_nl_check_endpoint() 80669c6ce7bSPaolo Abeni{ 80769c6ce7bSPaolo Abeni local line expected_line 80803668c65SMatthieu Baerts local msg="$1" 80903668c65SMatthieu Baerts local ns=$2 81003668c65SMatthieu Baerts local addr=$3 81169c6ce7bSPaolo Abeni local _flags="" 81269c6ce7bSPaolo Abeni local flags 81369c6ce7bSPaolo Abeni local _port 81469c6ce7bSPaolo Abeni local port 81569c6ce7bSPaolo Abeni local dev 81669c6ce7bSPaolo Abeni local _id 81769c6ce7bSPaolo Abeni local id 81869c6ce7bSPaolo Abeni 81903668c65SMatthieu Baerts print_check "${msg}" 82069c6ce7bSPaolo Abeni 82103668c65SMatthieu Baerts shift 3 82269c6ce7bSPaolo Abeni while [ -n "$1" ]; do 82369c6ce7bSPaolo Abeni if [ $1 = "flags" ]; then 82469c6ce7bSPaolo Abeni _flags=$2 825d8d08302SMatthieu Baerts [ -n "$_flags" ]; flags="flags $_flags" 82669c6ce7bSPaolo Abeni shift 82769c6ce7bSPaolo Abeni elif [ $1 = "dev" ]; then 828d8d08302SMatthieu Baerts [ -n "$2" ]; dev="dev $1" 82969c6ce7bSPaolo Abeni shift 83069c6ce7bSPaolo Abeni elif [ $1 = "id" ]; then 83169c6ce7bSPaolo Abeni _id=$2 832d8d08302SMatthieu Baerts [ -n "$_id" ]; id="id $_id" 83369c6ce7bSPaolo Abeni shift 83469c6ce7bSPaolo Abeni elif [ $1 = "port" ]; then 83569c6ce7bSPaolo Abeni _port=$2 836d8d08302SMatthieu Baerts [ -n "$_port" ]; port=" port $_port" 83769c6ce7bSPaolo Abeni shift 83869c6ce7bSPaolo Abeni fi 83969c6ce7bSPaolo Abeni 84069c6ce7bSPaolo Abeni shift 84169c6ce7bSPaolo Abeni done 84269c6ce7bSPaolo Abeni 84369c6ce7bSPaolo Abeni if [ -z "$id" ]; then 84403668c65SMatthieu Baerts test_fail "bad test - missing endpoint id" 84569c6ce7bSPaolo Abeni return 84669c6ce7bSPaolo Abeni fi 84769c6ce7bSPaolo Abeni 84869c6ce7bSPaolo Abeni if [ $ip_mptcp -eq 1 ]; then 84969c6ce7bSPaolo Abeni line=$(ip -n $ns mptcp endpoint show $id) 85069c6ce7bSPaolo Abeni # the dump order is: address id flags port dev 85169c6ce7bSPaolo Abeni expected_line="$addr" 85269c6ce7bSPaolo Abeni [ -n "$addr" ] && expected_line="$expected_line $addr" 85369c6ce7bSPaolo Abeni expected_line="$expected_line $id" 85469c6ce7bSPaolo Abeni [ -n "$_flags" ] && expected_line="$expected_line ${_flags//","/" "}" 85569c6ce7bSPaolo Abeni [ -n "$dev" ] && expected_line="$expected_line $dev" 85669c6ce7bSPaolo Abeni [ -n "$port" ] && expected_line="$expected_line $port" 85769c6ce7bSPaolo Abeni else 85869c6ce7bSPaolo Abeni line=$(ip netns exec $ns ./pm_nl_ctl get $_id) 85969c6ce7bSPaolo Abeni # the dump order is: id flags dev address port 86069c6ce7bSPaolo Abeni expected_line="$id" 86169c6ce7bSPaolo Abeni [ -n "$flags" ] && expected_line="$expected_line $flags" 86269c6ce7bSPaolo Abeni [ -n "$dev" ] && expected_line="$expected_line $dev" 86369c6ce7bSPaolo Abeni [ -n "$addr" ] && expected_line="$expected_line $addr" 86469c6ce7bSPaolo Abeni [ -n "$_port" ] && expected_line="$expected_line $_port" 86569c6ce7bSPaolo Abeni fi 86669c6ce7bSPaolo Abeni if [ "$line" = "$expected_line" ]; then 86703668c65SMatthieu Baerts print_ok 86869c6ce7bSPaolo Abeni else 86903668c65SMatthieu Baerts fail_test "expected '$expected_line' found '$line'" 87069c6ce7bSPaolo Abeni fi 87169c6ce7bSPaolo Abeni} 87269c6ce7bSPaolo Abeni 8739e9d176dSGeliang Tangpm_nl_set_endpoint() 874b08fbf24SPaolo Abeni{ 8751e777bd8SMatthieu Baerts local listener_ns="$1" 8761e777bd8SMatthieu Baerts local connector_ns="$2" 8779e9d176dSGeliang Tang local connect_addr="$3" 878b08fbf24SPaolo Abeni 879662aa22dSGeliang Tang local addr_nr_ns1=${addr_nr_ns1:-0} 880662aa22dSGeliang Tang local addr_nr_ns2=${addr_nr_ns2:-0} 881662aa22dSGeliang Tang local sflags=${sflags:-""} 8824aadde08SGeliang Tang local fullmesh=${fullmesh:-""} 883662aa22dSGeliang Tang 884080b7f57SGeliang Tang local flags="subflow" 8854aadde08SGeliang Tang if [ -n "${fullmesh}" ]; then 886080b7f57SGeliang Tang flags="${flags},fullmesh" 8874aadde08SGeliang Tang addr_nr_ns2=${fullmesh} 888080b7f57SGeliang Tang fi 889080b7f57SGeliang Tang 890327b9a94SPaolo Abeni # let the mptcp subflow be established in background before 891327b9a94SPaolo Abeni # do endpoint manipulation 892d8d08302SMatthieu Baerts if [ $addr_nr_ns1 != "0" ] || [ $addr_nr_ns2 != "0" ]; then 893d8d08302SMatthieu Baerts sleep 1 894d8d08302SMatthieu Baerts fi 895327b9a94SPaolo Abeni 8966208fd82SGeliang Tang if [ $addr_nr_ns1 -gt 0 ]; then 8971e777bd8SMatthieu Baerts local counter=2 898d8d08302SMatthieu Baerts local add_nr_ns1=${addr_nr_ns1} 89997040cf9SGeliang Tang local id=10 9006208fd82SGeliang Tang while [ $add_nr_ns1 -gt 0 ]; do 9016208fd82SGeliang Tang local addr 9026208fd82SGeliang Tang if is_v6 "${connect_addr}"; then 9036208fd82SGeliang Tang addr="dead:beef:$counter::1" 9046208fd82SGeliang Tang else 9056208fd82SGeliang Tang addr="10.0.$counter.1" 9066208fd82SGeliang Tang fi 90734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 $addr flags signal 908d8d08302SMatthieu Baerts counter=$((counter + 1)) 909d8d08302SMatthieu Baerts add_nr_ns1=$((add_nr_ns1 - 1)) 91097040cf9SGeliang Tang id=$((id + 1)) 9116208fd82SGeliang Tang done 9126208fd82SGeliang Tang elif [ $addr_nr_ns1 -lt 0 ]; then 913d8d08302SMatthieu Baerts local rm_nr_ns1=$((-addr_nr_ns1)) 9146fe4ccdcSGeliang Tang if [ $rm_nr_ns1 -lt 8 ]; then 9151e777bd8SMatthieu Baerts local counter=0 9161e777bd8SMatthieu Baerts local line 917d8d08302SMatthieu Baerts pm_nl_show_endpoints ${listener_ns} | while read -r line; do 918d8d08302SMatthieu Baerts # shellcheck disable=SC2206 # we do want to split per word 919dda61b3dSGeliang Tang local arr=($line) 920dda61b3dSGeliang Tang local nr=0 921dda61b3dSGeliang Tang 9221e777bd8SMatthieu Baerts local i 923d8d08302SMatthieu Baerts for i in "${arr[@]}"; do 924dda61b3dSGeliang Tang if [ $i = "id" ]; then 925dda61b3dSGeliang Tang if [ $counter -eq $rm_nr_ns1 ]; then 926dda61b3dSGeliang Tang break 927dda61b3dSGeliang Tang fi 928dda61b3dSGeliang Tang id=${arr[$nr+1]} 929327b9a94SPaolo Abeni rm_addr=$(rm_addr_count ${connector_ns}) 93034aa6e3bSGeliang Tang pm_nl_del_endpoint ${listener_ns} $id 931327b9a94SPaolo Abeni wait_rm_addr ${connector_ns} ${rm_addr} 932d8d08302SMatthieu Baerts counter=$((counter + 1)) 933f87744adSGeliang Tang fi 934d8d08302SMatthieu Baerts nr=$((nr + 1)) 935dda61b3dSGeliang Tang done 936dda61b3dSGeliang Tang done 9375e287fe7SGeliang Tang elif [ $rm_nr_ns1 -eq 8 ]; then 93834aa6e3bSGeliang Tang pm_nl_flush_endpoint ${listener_ns} 9395e287fe7SGeliang Tang elif [ $rm_nr_ns1 -eq 9 ]; then 94034aa6e3bSGeliang Tang pm_nl_del_endpoint ${listener_ns} 0 ${connect_addr} 9416fe4ccdcSGeliang Tang fi 942dd72b0feSGeliang Tang fi 943dd72b0feSGeliang Tang 944327b9a94SPaolo Abeni # if newly added endpoints must be deleted, give the background msk 945327b9a94SPaolo Abeni # some time to created them 946d8d08302SMatthieu Baerts [ $addr_nr_ns1 -gt 0 ] && [ $addr_nr_ns2 -lt 0 ] && sleep 1 947327b9a94SPaolo Abeni 9486208fd82SGeliang Tang if [ $addr_nr_ns2 -gt 0 ]; then 949d8d08302SMatthieu Baerts local add_nr_ns2=${addr_nr_ns2} 9501e777bd8SMatthieu Baerts local counter=3 9515e986ec4SGeliang Tang local id=20 9526208fd82SGeliang Tang while [ $add_nr_ns2 -gt 0 ]; do 9536208fd82SGeliang Tang local addr 9546208fd82SGeliang Tang if is_v6 "${connect_addr}"; then 9556208fd82SGeliang Tang addr="dead:beef:$counter::2" 9566208fd82SGeliang Tang else 9576208fd82SGeliang Tang addr="10.0.$counter.2" 9586208fd82SGeliang Tang fi 95934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 $addr flags $flags 960d8d08302SMatthieu Baerts counter=$((counter + 1)) 961d8d08302SMatthieu Baerts add_nr_ns2=$((add_nr_ns2 - 1)) 9625e986ec4SGeliang Tang id=$((id + 1)) 9636208fd82SGeliang Tang done 9646208fd82SGeliang Tang elif [ $addr_nr_ns2 -lt 0 ]; then 965d8d08302SMatthieu Baerts local rm_nr_ns2=$((-addr_nr_ns2)) 9666fe4ccdcSGeliang Tang if [ $rm_nr_ns2 -lt 8 ]; then 9671e777bd8SMatthieu Baerts local counter=0 9681e777bd8SMatthieu Baerts local line 969d8d08302SMatthieu Baerts pm_nl_show_endpoints ${connector_ns} | while read -r line; do 970d8d08302SMatthieu Baerts # shellcheck disable=SC2206 # we do want to split per word 971dda61b3dSGeliang Tang local arr=($line) 972dda61b3dSGeliang Tang local nr=0 973dda61b3dSGeliang Tang 9741e777bd8SMatthieu Baerts local i 975d8d08302SMatthieu Baerts for i in "${arr[@]}"; do 976dda61b3dSGeliang Tang if [ $i = "id" ]; then 977dda61b3dSGeliang Tang if [ $counter -eq $rm_nr_ns2 ]; then 978dda61b3dSGeliang Tang break 979dda61b3dSGeliang Tang fi 9801e777bd8SMatthieu Baerts local id rm_addr 981dda61b3dSGeliang Tang # rm_addr are serialized, allow the previous one to 982dda61b3dSGeliang Tang # complete 983dda61b3dSGeliang Tang id=${arr[$nr+1]} 984327b9a94SPaolo Abeni rm_addr=$(rm_addr_count ${listener_ns}) 98534aa6e3bSGeliang Tang pm_nl_del_endpoint ${connector_ns} $id 986327b9a94SPaolo Abeni wait_rm_addr ${listener_ns} ${rm_addr} 987d8d08302SMatthieu Baerts counter=$((counter + 1)) 988f87744adSGeliang Tang fi 989d8d08302SMatthieu Baerts nr=$((nr + 1)) 990dda61b3dSGeliang Tang done 991dda61b3dSGeliang Tang done 9925e287fe7SGeliang Tang elif [ $rm_nr_ns2 -eq 8 ]; then 99334aa6e3bSGeliang Tang pm_nl_flush_endpoint ${connector_ns} 9945e287fe7SGeliang Tang elif [ $rm_nr_ns2 -eq 9 ]; then 9955e287fe7SGeliang Tang local addr 9965e287fe7SGeliang Tang if is_v6 "${connect_addr}"; then 9975e287fe7SGeliang Tang addr="dead:beef:1::2" 9985e287fe7SGeliang Tang else 9995e287fe7SGeliang Tang addr="10.0.1.2" 10005e287fe7SGeliang Tang fi 100134aa6e3bSGeliang Tang pm_nl_del_endpoint ${connector_ns} 0 $addr 10026fe4ccdcSGeliang Tang fi 1003dd72b0feSGeliang Tang fi 1004dd72b0feSGeliang Tang 1005d8d08302SMatthieu Baerts if [ -n "${sflags}" ]; then 1006718eb44eSGeliang Tang sleep 1 10071e777bd8SMatthieu Baerts 10081e777bd8SMatthieu Baerts local netns 1009718eb44eSGeliang Tang for netns in "$ns1" "$ns2"; do 10101e777bd8SMatthieu Baerts local line 1011d8d08302SMatthieu Baerts pm_nl_show_endpoints $netns | while read -r line; do 1012d8d08302SMatthieu Baerts # shellcheck disable=SC2206 # we do want to split per word 101333397b83SGeliang Tang local arr=($line) 1014bccefb76SGeliang Tang local nr=0 1015f0140386SGeliang Tang local id 101633397b83SGeliang Tang 10171e777bd8SMatthieu Baerts local i 1018d8d08302SMatthieu Baerts for i in "${arr[@]}"; do 1019bccefb76SGeliang Tang if [ $i = "id" ]; then 1020bccefb76SGeliang Tang id=${arr[$nr+1]} 1021718eb44eSGeliang Tang fi 1022d8d08302SMatthieu Baerts nr=$((nr + 1)) 102333397b83SGeliang Tang done 1024bccefb76SGeliang Tang pm_nl_change_endpoint $netns $id $sflags 102533397b83SGeliang Tang done 1026718eb44eSGeliang Tang done 1027718eb44eSGeliang Tang fi 10289e9d176dSGeliang Tang} 10299e9d176dSGeliang Tang 10309e9d176dSGeliang Tangdo_transfer() 10319e9d176dSGeliang Tang{ 10329e9d176dSGeliang Tang local listener_ns="$1" 10339e9d176dSGeliang Tang local connector_ns="$2" 10349e9d176dSGeliang Tang local cl_proto="$3" 10359e9d176dSGeliang Tang local srv_proto="$4" 10369e9d176dSGeliang Tang local connect_addr="$5" 10379e9d176dSGeliang Tang 10389e9d176dSGeliang Tang local port=$((10000 + TEST_COUNT - 1)) 10399e9d176dSGeliang Tang local cappid 1040662aa22dSGeliang Tang local FAILING_LINKS=${FAILING_LINKS:-""} 1041080b7f57SGeliang Tang local fastclose=${fastclose:-""} 1042e571fb09SGeliang Tang local speed=${speed:-"fast"} 10439e9d176dSGeliang Tang 10449e9d176dSGeliang Tang :> "$cout" 10459e9d176dSGeliang Tang :> "$sout" 10469e9d176dSGeliang Tang :> "$capout" 10479e9d176dSGeliang Tang 10489e9d176dSGeliang Tang if [ $capture -eq 1 ]; then 10499e9d176dSGeliang Tang local capuser 10509e9d176dSGeliang Tang if [ -z $SUDO_USER ] ; then 10519e9d176dSGeliang Tang capuser="" 10529e9d176dSGeliang Tang else 10539e9d176dSGeliang Tang capuser="-Z $SUDO_USER" 10549e9d176dSGeliang Tang fi 10559e9d176dSGeliang Tang 10569e9d176dSGeliang Tang capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}") 10579e9d176dSGeliang Tang 10589e9d176dSGeliang Tang echo "Capturing traffic for test $TEST_COUNT into $capfile" 10599e9d176dSGeliang Tang ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & 10609e9d176dSGeliang Tang cappid=$! 10619e9d176dSGeliang Tang 10629e9d176dSGeliang Tang sleep 1 10639e9d176dSGeliang Tang fi 10649e9d176dSGeliang Tang 10659e9d176dSGeliang Tang NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 10669e9d176dSGeliang Tang nstat -n 10679e9d176dSGeliang Tang NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 10689e9d176dSGeliang Tang nstat -n 10699e9d176dSGeliang Tang 10709e9d176dSGeliang Tang local extra_args 10719e9d176dSGeliang Tang if [ $speed = "fast" ]; then 10729e9d176dSGeliang Tang extra_args="-j" 10739e9d176dSGeliang Tang elif [ $speed = "slow" ]; then 10749e9d176dSGeliang Tang extra_args="-r 50" 1075e571fb09SGeliang Tang elif [ $speed -gt 0 ]; then 1076e571fb09SGeliang Tang extra_args="-r ${speed}" 10779e9d176dSGeliang Tang fi 10789e9d176dSGeliang Tang 10799e9d176dSGeliang Tang local extra_cl_args="" 10809e9d176dSGeliang Tang local extra_srv_args="" 10819e9d176dSGeliang Tang local trunc_size="" 1082080b7f57SGeliang Tang if [ -n "${fastclose}" ]; then 10839e9d176dSGeliang Tang if [ ${test_linkfail} -le 1 ]; then 108403668c65SMatthieu Baerts fail_test "fastclose tests need test_linkfail argument" 10859e9d176dSGeliang Tang return 1 10869e9d176dSGeliang Tang fi 10879e9d176dSGeliang Tang 10889e9d176dSGeliang Tang # disconnect 10899e9d176dSGeliang Tang trunc_size=${test_linkfail} 1090080b7f57SGeliang Tang local side=${fastclose} 10919e9d176dSGeliang Tang 10929e9d176dSGeliang Tang if [ ${side} = "client" ]; then 10939e9d176dSGeliang Tang extra_cl_args="-f ${test_linkfail}" 10949e9d176dSGeliang Tang extra_srv_args="-f -1" 10959e9d176dSGeliang Tang elif [ ${side} = "server" ]; then 10969e9d176dSGeliang Tang extra_srv_args="-f ${test_linkfail}" 10979e9d176dSGeliang Tang extra_cl_args="-f -1" 10989e9d176dSGeliang Tang else 109903668c65SMatthieu Baerts fail_test "wrong/unknown fastclose spec ${side}" 11009e9d176dSGeliang Tang return 1 11019e9d176dSGeliang Tang fi 11029e9d176dSGeliang Tang fi 11039e9d176dSGeliang Tang 11049e9d176dSGeliang Tang extra_srv_args="$extra_args $extra_srv_args" 11059e9d176dSGeliang Tang if [ "$test_linkfail" -gt 1 ];then 11069e9d176dSGeliang Tang timeout ${timeout_test} \ 11079e9d176dSGeliang Tang ip netns exec ${listener_ns} \ 11089e9d176dSGeliang Tang ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 11099e9d176dSGeliang Tang $extra_srv_args "::" < "$sinfail" > "$sout" & 11109e9d176dSGeliang Tang else 11119e9d176dSGeliang Tang timeout ${timeout_test} \ 11129e9d176dSGeliang Tang ip netns exec ${listener_ns} \ 11139e9d176dSGeliang Tang ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ 11149e9d176dSGeliang Tang $extra_srv_args "::" < "$sin" > "$sout" & 11159e9d176dSGeliang Tang fi 11169e9d176dSGeliang Tang local spid=$! 11179e9d176dSGeliang Tang 11189e9d176dSGeliang Tang wait_local_port_listen "${listener_ns}" "${port}" 11199e9d176dSGeliang Tang 11209e9d176dSGeliang Tang extra_cl_args="$extra_args $extra_cl_args" 11219e9d176dSGeliang Tang if [ "$test_linkfail" -eq 0 ];then 11229e9d176dSGeliang Tang timeout ${timeout_test} \ 11239e9d176dSGeliang Tang ip netns exec ${connector_ns} \ 11249e9d176dSGeliang Tang ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 11259e9d176dSGeliang Tang $extra_cl_args $connect_addr < "$cin" > "$cout" & 11269e9d176dSGeliang Tang elif [ "$test_linkfail" -eq 1 ] || [ "$test_linkfail" -eq 2 ];then 11279e9d176dSGeliang Tang ( cat "$cinfail" ; sleep 2; link_failure $listener_ns ; cat "$cinfail" ) | \ 11289e9d176dSGeliang Tang tee "$cinsent" | \ 11299e9d176dSGeliang Tang timeout ${timeout_test} \ 11309e9d176dSGeliang Tang ip netns exec ${connector_ns} \ 11319e9d176dSGeliang Tang ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 11329e9d176dSGeliang Tang $extra_cl_args $connect_addr > "$cout" & 11339e9d176dSGeliang Tang else 11349e9d176dSGeliang Tang tee "$cinsent" < "$cinfail" | \ 11359e9d176dSGeliang Tang timeout ${timeout_test} \ 11369e9d176dSGeliang Tang ip netns exec ${connector_ns} \ 11379e9d176dSGeliang Tang ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \ 11389e9d176dSGeliang Tang $extra_cl_args $connect_addr > "$cout" & 11399e9d176dSGeliang Tang fi 11409e9d176dSGeliang Tang local cpid=$! 11419e9d176dSGeliang Tang 11429e9d176dSGeliang Tang pm_nl_set_endpoint $listener_ns $connector_ns $connect_addr 1143718eb44eSGeliang Tang 1144b08fbf24SPaolo Abeni wait $cpid 11451e777bd8SMatthieu Baerts local retc=$? 1146b08fbf24SPaolo Abeni wait $spid 11471e777bd8SMatthieu Baerts local rets=$? 1148b08fbf24SPaolo Abeni 1149b08fbf24SPaolo Abeni if [ $capture -eq 1 ]; then 1150b08fbf24SPaolo Abeni sleep 1 1151b08fbf24SPaolo Abeni kill $cappid 1152b08fbf24SPaolo Abeni fi 1153b08fbf24SPaolo Abeni 1154c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 1155c2a55e8fSMatthieu Baerts nstat | grep Tcp > /tmp/${listener_ns}.out 1156c2a55e8fSMatthieu Baerts NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ 1157c2a55e8fSMatthieu Baerts nstat | grep Tcp > /tmp/${connector_ns}.out 1158c2a55e8fSMatthieu Baerts 1159b08fbf24SPaolo Abeni if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then 116003668c65SMatthieu Baerts fail_test "client exit code $retc, server $rets" 11618b974778SMatthieu Baerts echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 1162c2a55e8fSMatthieu Baerts ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port" 1163c2a55e8fSMatthieu Baerts cat /tmp/${listener_ns}.out 11648b974778SMatthieu Baerts echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2 1165c2a55e8fSMatthieu Baerts ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port" 1166c2a55e8fSMatthieu Baerts cat /tmp/${connector_ns}.out 1167b08fbf24SPaolo Abeni 1168b08fbf24SPaolo Abeni cat "$capout" 1169b08fbf24SPaolo Abeni return 1 1170b08fbf24SPaolo Abeni fi 1171b08fbf24SPaolo Abeni 11720c93af1fSGeliang Tang if [ "$test_linkfail" -gt 1 ];then 11736bf41020SPaolo Abeni check_transfer $sinfail $cout "file received by client" $trunc_size 11747d1e6f16SPaolo Abeni else 11756bf41020SPaolo Abeni check_transfer $sin $cout "file received by client" $trunc_size 11767d1e6f16SPaolo Abeni fi 1177b08fbf24SPaolo Abeni retc=$? 11780c93af1fSGeliang Tang if [ "$test_linkfail" -eq 0 ];then 11796bf41020SPaolo Abeni check_transfer $cin $sout "file received by server" $trunc_size 11808b819a84SFlorian Westphal else 11816bf41020SPaolo Abeni check_transfer $cinsent $sout "file received by server" $trunc_size 11828b819a84SFlorian Westphal fi 1183b08fbf24SPaolo Abeni rets=$? 1184b08fbf24SPaolo Abeni 1185b08fbf24SPaolo Abeni if [ $retc -eq 0 ] && [ $rets -eq 0 ];then 1186b08fbf24SPaolo Abeni cat "$capout" 1187b08fbf24SPaolo Abeni return 0 1188b08fbf24SPaolo Abeni fi 1189b08fbf24SPaolo Abeni 1190b08fbf24SPaolo Abeni cat "$capout" 1191b08fbf24SPaolo Abeni return 1 1192b08fbf24SPaolo Abeni} 1193b08fbf24SPaolo Abeni 1194b08fbf24SPaolo Abenimake_file() 1195b08fbf24SPaolo Abeni{ 11961e777bd8SMatthieu Baerts local name=$1 11971e777bd8SMatthieu Baerts local who=$2 11981e777bd8SMatthieu Baerts local size=$3 1199b08fbf24SPaolo Abeni 12008b819a84SFlorian Westphal dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null 1201b08fbf24SPaolo Abeni echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" 1202b08fbf24SPaolo Abeni 120303668c65SMatthieu Baerts print_info "Test file (size $size KB) for $who" 1204b08fbf24SPaolo Abeni} 1205b08fbf24SPaolo Abeni 1206b08fbf24SPaolo Abenirun_tests() 1207b08fbf24SPaolo Abeni{ 12081e777bd8SMatthieu Baerts local listener_ns="$1" 12091e777bd8SMatthieu Baerts local connector_ns="$2" 12101e777bd8SMatthieu Baerts local connect_addr="$3" 12111e777bd8SMatthieu Baerts 12121e777bd8SMatthieu Baerts local size 1213662aa22dSGeliang Tang local test_linkfail=${test_linkfail:-0} 12148b819a84SFlorian Westphal 121534b572b7SGeliang Tang # The values above 2 are reused to make test files 121634b572b7SGeliang Tang # with the given sizes (KB) 121734b572b7SGeliang Tang if [ "$test_linkfail" -gt 2 ]; then 121834b572b7SGeliang Tang size=$test_linkfail 121934b572b7SGeliang Tang 122034b572b7SGeliang Tang if [ -z "$cinfail" ]; then 122134b572b7SGeliang Tang cinfail=$(mktemp) 122234b572b7SGeliang Tang fi 122334b572b7SGeliang Tang make_file "$cinfail" "client" $size 12247d1e6f16SPaolo Abeni # create the input file for the failure test when 12257d1e6f16SPaolo Abeni # the first failure test run 1226d8d08302SMatthieu Baerts elif [ "$test_linkfail" -ne 0 ] && [ -z "$cinfail" ]; then 12277d1e6f16SPaolo Abeni # the client file must be considerably larger 12287d1e6f16SPaolo Abeni # of the maximum expected cwin value, or the 12297d1e6f16SPaolo Abeni # link utilization will be not predicable 12307d1e6f16SPaolo Abeni size=$((RANDOM%2)) 12318b819a84SFlorian Westphal size=$((size+1)) 12327d1e6f16SPaolo Abeni size=$((size*8192)) 1233d8d08302SMatthieu Baerts size=$((size + ( RANDOM % 8192) )) 12348b819a84SFlorian Westphal 12357d1e6f16SPaolo Abeni cinfail=$(mktemp) 12367d1e6f16SPaolo Abeni make_file "$cinfail" "client" $size 12377d1e6f16SPaolo Abeni fi 12387d1e6f16SPaolo Abeni 123934b572b7SGeliang Tang if [ "$test_linkfail" -gt 2 ]; then 124034b572b7SGeliang Tang size=$test_linkfail 124134b572b7SGeliang Tang 124234b572b7SGeliang Tang if [ -z "$sinfail" ]; then 124334b572b7SGeliang Tang sinfail=$(mktemp) 124434b572b7SGeliang Tang fi 124534b572b7SGeliang Tang make_file "$sinfail" "server" $size 1246d8d08302SMatthieu Baerts elif [ "$test_linkfail" -eq 2 ] && [ -z "$sinfail" ]; then 12477d1e6f16SPaolo Abeni size=$((RANDOM%16)) 12487d1e6f16SPaolo Abeni size=$((size+1)) 12497d1e6f16SPaolo Abeni size=$((size*2048)) 12507d1e6f16SPaolo Abeni 12517d1e6f16SPaolo Abeni sinfail=$(mktemp) 12527d1e6f16SPaolo Abeni make_file "$sinfail" "server" $size 12538b819a84SFlorian Westphal fi 1254b08fbf24SPaolo Abeni 1255e571fb09SGeliang Tang do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} 1256b08fbf24SPaolo Abeni} 1257b08fbf24SPaolo Abeni 1258327b9a94SPaolo Abenidump_stats() 1259327b9a94SPaolo Abeni{ 1260327b9a94SPaolo Abeni echo Server ns stats 1261327b9a94SPaolo Abeni ip netns exec $ns1 nstat -as | grep Tcp 1262327b9a94SPaolo Abeni echo Client ns stats 1263327b9a94SPaolo Abeni ip netns exec $ns2 nstat -as | grep Tcp 1264327b9a94SPaolo Abeni} 1265327b9a94SPaolo Abeni 1266af66d3e1SGeliang Tangchk_csum_nr() 1267af66d3e1SGeliang Tang{ 12683c082695SGeliang Tang local csum_ns1=${1:-0} 12693c082695SGeliang Tang local csum_ns2=${2:-0} 1270af66d3e1SGeliang Tang local count 127153f368bfSGeliang Tang local extra_msg="" 127226516e10SGeliang Tang local allow_multi_errors_ns1=0 127326516e10SGeliang Tang local allow_multi_errors_ns2=0 127426516e10SGeliang Tang 127526516e10SGeliang Tang if [[ "${csum_ns1}" = "+"* ]]; then 127626516e10SGeliang Tang allow_multi_errors_ns1=1 127726516e10SGeliang Tang csum_ns1=${csum_ns1:1} 127826516e10SGeliang Tang fi 127926516e10SGeliang Tang if [[ "${csum_ns2}" = "+"* ]]; then 128026516e10SGeliang Tang allow_multi_errors_ns2=1 128126516e10SGeliang Tang csum_ns2=${csum_ns2:1} 128226516e10SGeliang Tang fi 1283af66d3e1SGeliang Tang 128403668c65SMatthieu Baerts print_check "sum" 128547867f0aSMatthieu Baerts count=$(get_counter ${ns1} "MPTcpExtDataCsumErr") 128653f368bfSGeliang Tang if [ "$count" != "$csum_ns1" ]; then 128753f368bfSGeliang Tang extra_msg="$extra_msg ns1=$count" 128853f368bfSGeliang Tang fi 128947867f0aSMatthieu Baerts if [ -z "$count" ]; then 129003668c65SMatthieu Baerts print_skip 129147867f0aSMatthieu Baerts elif { [ "$count" != $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 0 ]; } || 1292d8d08302SMatthieu Baerts { [ "$count" -lt $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 1 ]; }; then 129303668c65SMatthieu Baerts fail_test "got $count data checksum error[s] expected $csum_ns1" 1294af66d3e1SGeliang Tang else 129503668c65SMatthieu Baerts print_ok 1296af66d3e1SGeliang Tang fi 129703668c65SMatthieu Baerts print_check "csum" 129847867f0aSMatthieu Baerts count=$(get_counter ${ns2} "MPTcpExtDataCsumErr") 129953f368bfSGeliang Tang if [ "$count" != "$csum_ns2" ]; then 130053f368bfSGeliang Tang extra_msg="$extra_msg ns2=$count" 130153f368bfSGeliang Tang fi 130247867f0aSMatthieu Baerts if [ -z "$count" ]; then 130303668c65SMatthieu Baerts print_skip 130447867f0aSMatthieu Baerts elif { [ "$count" != $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 0 ]; } || 1305d8d08302SMatthieu Baerts { [ "$count" -lt $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 1 ]; }; then 130603668c65SMatthieu Baerts fail_test "got $count data checksum error[s] expected $csum_ns2" 1307af66d3e1SGeliang Tang else 130803668c65SMatthieu Baerts print_ok 1309af66d3e1SGeliang Tang fi 131053f368bfSGeliang Tang 131103668c65SMatthieu Baerts print_info "$extra_msg" 1312af66d3e1SGeliang Tang} 1313af66d3e1SGeliang Tang 13146bb3ab49SGeliang Tangchk_fail_nr() 13156bb3ab49SGeliang Tang{ 131626516e10SGeliang Tang local fail_tx=$1 131726516e10SGeliang Tang local fail_rx=$2 13181f7d325fSGeliang Tang local ns_invert=${3:-""} 13196bb3ab49SGeliang Tang local count 13201f7d325fSGeliang Tang local ns_tx=$ns1 13211f7d325fSGeliang Tang local ns_rx=$ns2 13221f7d325fSGeliang Tang local extra_msg="" 13231f7d325fSGeliang Tang local allow_tx_lost=0 13241f7d325fSGeliang Tang local allow_rx_lost=0 13251f7d325fSGeliang Tang 13261f7d325fSGeliang Tang if [[ $ns_invert = "invert" ]]; then 13271f7d325fSGeliang Tang ns_tx=$ns2 13281f7d325fSGeliang Tang ns_rx=$ns1 13291f7d325fSGeliang Tang extra_msg="invert" 13301f7d325fSGeliang Tang fi 13311f7d325fSGeliang Tang 13321f7d325fSGeliang Tang if [[ "${fail_tx}" = "-"* ]]; then 13331f7d325fSGeliang Tang allow_tx_lost=1 13341f7d325fSGeliang Tang fail_tx=${fail_tx:1} 13351f7d325fSGeliang Tang fi 13361f7d325fSGeliang Tang if [[ "${fail_rx}" = "-"* ]]; then 13371f7d325fSGeliang Tang allow_rx_lost=1 13381f7d325fSGeliang Tang fail_rx=${fail_rx:1} 13391f7d325fSGeliang Tang fi 13406bb3ab49SGeliang Tang 134103668c65SMatthieu Baerts print_check "ftx" 134247867f0aSMatthieu Baerts count=$(get_counter ${ns_tx} "MPTcpExtMPFailTx") 134326516e10SGeliang Tang if [ "$count" != "$fail_tx" ]; then 13441f7d325fSGeliang Tang extra_msg="$extra_msg,tx=$count" 13451f7d325fSGeliang Tang fi 134647867f0aSMatthieu Baerts if [ -z "$count" ]; then 134703668c65SMatthieu Baerts print_skip 134847867f0aSMatthieu Baerts elif { [ "$count" != "$fail_tx" ] && [ $allow_tx_lost -eq 0 ]; } || 13491f7d325fSGeliang Tang { [ "$count" -gt "$fail_tx" ] && [ $allow_tx_lost -eq 1 ]; }; then 135003668c65SMatthieu Baerts fail_test "got $count MP_FAIL[s] TX expected $fail_tx" 13516bb3ab49SGeliang Tang else 135203668c65SMatthieu Baerts print_ok 13536bb3ab49SGeliang Tang fi 13546bb3ab49SGeliang Tang 135503668c65SMatthieu Baerts print_check "failrx" 135647867f0aSMatthieu Baerts count=$(get_counter ${ns_rx} "MPTcpExtMPFailRx") 135726516e10SGeliang Tang if [ "$count" != "$fail_rx" ]; then 13581f7d325fSGeliang Tang extra_msg="$extra_msg,rx=$count" 13591f7d325fSGeliang Tang fi 136047867f0aSMatthieu Baerts if [ -z "$count" ]; then 136103668c65SMatthieu Baerts print_skip 136247867f0aSMatthieu Baerts elif { [ "$count" != "$fail_rx" ] && [ $allow_rx_lost -eq 0 ]; } || 13631f7d325fSGeliang Tang { [ "$count" -gt "$fail_rx" ] && [ $allow_rx_lost -eq 1 ]; }; then 136403668c65SMatthieu Baerts fail_test "got $count MP_FAIL[s] RX expected $fail_rx" 13656bb3ab49SGeliang Tang else 136603668c65SMatthieu Baerts print_ok 13676bb3ab49SGeliang Tang fi 13686bb3ab49SGeliang Tang 136903668c65SMatthieu Baerts print_info "$extra_msg" 13706bb3ab49SGeliang Tang} 13716bb3ab49SGeliang Tang 1372e8e947efSGeliang Tangchk_fclose_nr() 1373e8e947efSGeliang Tang{ 1374e8e947efSGeliang Tang local fclose_tx=$1 1375e8e947efSGeliang Tang local fclose_rx=$2 13766bf41020SPaolo Abeni local ns_invert=$3 1377e8e947efSGeliang Tang local count 13786bf41020SPaolo Abeni local ns_tx=$ns2 13796bf41020SPaolo Abeni local ns_rx=$ns1 13806bf41020SPaolo Abeni local extra_msg="" 13816bf41020SPaolo Abeni 13826bf41020SPaolo Abeni if [[ $ns_invert = "invert" ]]; then 13836bf41020SPaolo Abeni ns_tx=$ns1 13846bf41020SPaolo Abeni ns_rx=$ns2 138503668c65SMatthieu Baerts extra_msg="invert" 13866bf41020SPaolo Abeni fi 1387e8e947efSGeliang Tang 138803668c65SMatthieu Baerts print_check "ctx" 138947867f0aSMatthieu Baerts count=$(get_counter ${ns_tx} "MPTcpExtMPFastcloseTx") 139047867f0aSMatthieu Baerts if [ -z "$count" ]; then 139103668c65SMatthieu Baerts print_skip 139247867f0aSMatthieu Baerts elif [ "$count" != "$fclose_tx" ]; then 139347867f0aSMatthieu Baerts extra_msg="$extra_msg,tx=$count" 139403668c65SMatthieu Baerts fail_test "got $count MP_FASTCLOSE[s] TX expected $fclose_tx" 1395e8e947efSGeliang Tang else 139603668c65SMatthieu Baerts print_ok 1397e8e947efSGeliang Tang fi 1398e8e947efSGeliang Tang 139903668c65SMatthieu Baerts print_check "fclzrx" 140047867f0aSMatthieu Baerts count=$(get_counter ${ns_rx} "MPTcpExtMPFastcloseRx") 140147867f0aSMatthieu Baerts if [ -z "$count" ]; then 140203668c65SMatthieu Baerts print_skip 140347867f0aSMatthieu Baerts elif [ "$count" != "$fclose_rx" ]; then 140447867f0aSMatthieu Baerts extra_msg="$extra_msg,rx=$count" 140503668c65SMatthieu Baerts fail_test "got $count MP_FASTCLOSE[s] RX expected $fclose_rx" 1406e8e947efSGeliang Tang else 140703668c65SMatthieu Baerts print_ok 1408e8e947efSGeliang Tang fi 1409e8e947efSGeliang Tang 141003668c65SMatthieu Baerts print_info "$extra_msg" 1411e8e947efSGeliang Tang} 1412e8e947efSGeliang Tang 1413922fd2b3SGeliang Tangchk_rst_nr() 1414922fd2b3SGeliang Tang{ 1415922fd2b3SGeliang Tang local rst_tx=$1 1416922fd2b3SGeliang Tang local rst_rx=$2 1417922fd2b3SGeliang Tang local ns_invert=${3:-""} 1418922fd2b3SGeliang Tang local count 1419922fd2b3SGeliang Tang local ns_tx=$ns1 1420922fd2b3SGeliang Tang local ns_rx=$ns2 1421922fd2b3SGeliang Tang local extra_msg="" 1422922fd2b3SGeliang Tang 1423922fd2b3SGeliang Tang if [[ $ns_invert = "invert" ]]; then 1424922fd2b3SGeliang Tang ns_tx=$ns2 1425922fd2b3SGeliang Tang ns_rx=$ns1 1426922fd2b3SGeliang Tang extra_msg="invert" 1427922fd2b3SGeliang Tang fi 1428922fd2b3SGeliang Tang 142903668c65SMatthieu Baerts print_check "rtx" 143047867f0aSMatthieu Baerts count=$(get_counter ${ns_tx} "MPTcpExtMPRstTx") 143147867f0aSMatthieu Baerts if [ -z "$count" ]; then 143203668c65SMatthieu Baerts print_skip 143347867f0aSMatthieu Baerts elif [ $count -lt $rst_tx ]; then 143403668c65SMatthieu Baerts fail_test "got $count MP_RST[s] TX expected $rst_tx" 1435922fd2b3SGeliang Tang else 143603668c65SMatthieu Baerts print_ok 1437922fd2b3SGeliang Tang fi 1438922fd2b3SGeliang Tang 143903668c65SMatthieu Baerts print_check "rstrx" 144047867f0aSMatthieu Baerts count=$(get_counter ${ns_rx} "MPTcpExtMPRstRx") 144147867f0aSMatthieu Baerts if [ -z "$count" ]; then 144203668c65SMatthieu Baerts print_skip 144347867f0aSMatthieu Baerts elif [ "$count" -lt "$rst_rx" ]; then 144403668c65SMatthieu Baerts fail_test "got $count MP_RST[s] RX expected $rst_rx" 1445922fd2b3SGeliang Tang else 144603668c65SMatthieu Baerts print_ok 1447922fd2b3SGeliang Tang fi 1448922fd2b3SGeliang Tang 144903668c65SMatthieu Baerts print_info "$extra_msg" 1450922fd2b3SGeliang Tang} 1451922fd2b3SGeliang Tang 14528bd03be3SGeliang Tangchk_infi_nr() 14538bd03be3SGeliang Tang{ 14548bd03be3SGeliang Tang local infi_tx=$1 14558bd03be3SGeliang Tang local infi_rx=$2 14568bd03be3SGeliang Tang local count 14578bd03be3SGeliang Tang 145803668c65SMatthieu Baerts print_check "itx" 145947867f0aSMatthieu Baerts count=$(get_counter ${ns2} "MPTcpExtInfiniteMapTx") 146047867f0aSMatthieu Baerts if [ -z "$count" ]; then 146103668c65SMatthieu Baerts print_skip 146247867f0aSMatthieu Baerts elif [ "$count" != "$infi_tx" ]; then 146303668c65SMatthieu Baerts fail_test "got $count infinite map[s] TX expected $infi_tx" 14648bd03be3SGeliang Tang else 146503668c65SMatthieu Baerts print_ok 14668bd03be3SGeliang Tang fi 14678bd03be3SGeliang Tang 146803668c65SMatthieu Baerts print_check "infirx" 146947867f0aSMatthieu Baerts count=$(get_counter ${ns1} "MPTcpExtInfiniteMapRx") 147047867f0aSMatthieu Baerts if [ -z "$count" ]; then 147103668c65SMatthieu Baerts print_skip 147247867f0aSMatthieu Baerts elif [ "$count" != "$infi_rx" ]; then 147303668c65SMatthieu Baerts fail_test "got $count infinite map[s] RX expected $infi_rx" 14748bd03be3SGeliang Tang else 147503668c65SMatthieu Baerts print_ok 14768bd03be3SGeliang Tang fi 14778bd03be3SGeliang Tang} 14788bd03be3SGeliang Tang 1479b08fbf24SPaolo Abenichk_join_nr() 1480b08fbf24SPaolo Abeni{ 1481c7d49c03SMatthieu Baerts local syn_nr=$1 1482c7d49c03SMatthieu Baerts local syn_ack_nr=$2 1483c7d49c03SMatthieu Baerts local ack_nr=$3 1484c7d49c03SMatthieu Baerts local csum_ns1=${4:-0} 1485c7d49c03SMatthieu Baerts local csum_ns2=${5:-0} 1486c7d49c03SMatthieu Baerts local fail_nr=${6:-0} 1487c7d49c03SMatthieu Baerts local rst_nr=${7:-0} 14888bd03be3SGeliang Tang local infi_nr=${8:-0} 14898bd03be3SGeliang Tang local corrupted_pkts=${9:-0} 1490b08fbf24SPaolo Abeni local count 1491e35f885bSPaolo Abeni local with_cookie 1492b08fbf24SPaolo Abeni 1493c7d49c03SMatthieu Baerts if [ "${corrupted_pkts}" -gt 0 ]; then 149403668c65SMatthieu Baerts print_info "${corrupted_pkts} corrupted pkts" 1495c7d49c03SMatthieu Baerts fi 1496c7d49c03SMatthieu Baerts 149703668c65SMatthieu Baerts print_check "syn" 149847867f0aSMatthieu Baerts count=$(get_counter ${ns1} "MPTcpExtMPJoinSynRx") 149947867f0aSMatthieu Baerts if [ -z "$count" ]; then 150003668c65SMatthieu Baerts print_skip 150147867f0aSMatthieu Baerts elif [ "$count" != "$syn_nr" ]; then 150203668c65SMatthieu Baerts fail_test "got $count JOIN[s] syn expected $syn_nr" 1503b08fbf24SPaolo Abeni else 150403668c65SMatthieu Baerts print_ok 1505b08fbf24SPaolo Abeni fi 1506b08fbf24SPaolo Abeni 150703668c65SMatthieu Baerts print_check "synack" 15084bfadd71SMatthieu Baerts with_cookie=$(ip netns exec $ns2 sysctl -n net.ipv4.tcp_syncookies) 150947867f0aSMatthieu Baerts count=$(get_counter ${ns2} "MPTcpExtMPJoinSynAckRx") 151047867f0aSMatthieu Baerts if [ -z "$count" ]; then 151103668c65SMatthieu Baerts print_skip 151247867f0aSMatthieu Baerts elif [ "$count" != "$syn_ack_nr" ]; then 1513e35f885bSPaolo Abeni # simult connections exceeding the limit with cookie enabled could go up to 1514e35f885bSPaolo Abeni # synack validation as the conn limit can be enforced reliably only after 1515e35f885bSPaolo Abeni # the subflow creation 1516e35f885bSPaolo Abeni if [ "$with_cookie" = 2 ] && [ "$count" -gt "$syn_ack_nr" ] && [ "$count" -le "$syn_nr" ]; then 151703668c65SMatthieu Baerts print_ok 1518e35f885bSPaolo Abeni else 151903668c65SMatthieu Baerts fail_test "got $count JOIN[s] synack expected $syn_ack_nr" 1520e35f885bSPaolo Abeni fi 1521b08fbf24SPaolo Abeni else 152203668c65SMatthieu Baerts print_ok 1523b08fbf24SPaolo Abeni fi 1524b08fbf24SPaolo Abeni 152503668c65SMatthieu Baerts print_check "ack" 152647867f0aSMatthieu Baerts count=$(get_counter ${ns1} "MPTcpExtMPJoinAckRx") 152747867f0aSMatthieu Baerts if [ -z "$count" ]; then 152803668c65SMatthieu Baerts print_skip 152947867f0aSMatthieu Baerts elif [ "$count" != "$ack_nr" ]; then 153003668c65SMatthieu Baerts fail_test "got $count JOIN[s] ack expected $ack_nr" 1531b08fbf24SPaolo Abeni else 153203668c65SMatthieu Baerts print_ok 1533b08fbf24SPaolo Abeni fi 1534b6e074e1SGeliang Tang if [ $validate_checksum -eq 1 ]; then 15353c082695SGeliang Tang chk_csum_nr $csum_ns1 $csum_ns2 153626516e10SGeliang Tang chk_fail_nr $fail_nr $fail_nr 153726516e10SGeliang Tang chk_rst_nr $rst_nr $rst_nr 15388bd03be3SGeliang Tang chk_infi_nr $infi_nr $infi_nr 1539af66d3e1SGeliang Tang fi 1540b08fbf24SPaolo Abeni} 1541b08fbf24SPaolo Abeni 15427d1e6f16SPaolo Abeni# a negative value for 'stale_max' means no upper bound: 15437d1e6f16SPaolo Abeni# for bidirectional transfer, if one peer sleep for a while 15447d1e6f16SPaolo Abeni# - as these tests do - we can have a quite high number of 15457d1e6f16SPaolo Abeni# stale/recover conversions, proportional to 15467d1e6f16SPaolo Abeni# sleep duration/ MPTCP-level RTX interval. 15477d1e6f16SPaolo Abenichk_stale_nr() 15487d1e6f16SPaolo Abeni{ 15497d1e6f16SPaolo Abeni local ns=$1 15507d1e6f16SPaolo Abeni local stale_min=$2 15517d1e6f16SPaolo Abeni local stale_max=$3 15527d1e6f16SPaolo Abeni local stale_delta=$4 15537d1e6f16SPaolo Abeni local dump_stats 15547d1e6f16SPaolo Abeni local stale_nr 15557d1e6f16SPaolo Abeni local recover_nr 15567d1e6f16SPaolo Abeni 155703668c65SMatthieu Baerts print_check "stale" 15587d1e6f16SPaolo Abeni 155947867f0aSMatthieu Baerts stale_nr=$(get_counter ${ns} "MPTcpExtSubflowStale") 156047867f0aSMatthieu Baerts recover_nr=$(get_counter ${ns} "MPTcpExtSubflowRecover") 156147867f0aSMatthieu Baerts if [ -z "$stale_nr" ] || [ -z "$recover_nr" ]; then 156203668c65SMatthieu Baerts print_skip 156347867f0aSMatthieu Baerts elif [ $stale_nr -lt $stale_min ] || 1564d8d08302SMatthieu Baerts { [ $stale_max -gt 0 ] && [ $stale_nr -gt $stale_max ]; } || 1565d8d08302SMatthieu Baerts [ $((stale_nr - recover_nr)) -ne $stale_delta ]; then 156603668c65SMatthieu Baerts fail_test "got $stale_nr stale[s] $recover_nr recover[s], " \ 15677d1e6f16SPaolo Abeni " expected stale in range [$stale_min..$stale_max]," \ 15687d1e6f16SPaolo Abeni " stale-recover delta $stale_delta" 15697d1e6f16SPaolo Abeni dump_stats=1 15707d1e6f16SPaolo Abeni else 157103668c65SMatthieu Baerts print_ok 15727d1e6f16SPaolo Abeni fi 15737d1e6f16SPaolo Abeni 15747d1e6f16SPaolo Abeni if [ "${dump_stats}" = 1 ]; then 15757d1e6f16SPaolo Abeni echo $ns stats 15767d1e6f16SPaolo Abeni ip netns exec $ns ip -s link show 15777d1e6f16SPaolo Abeni ip netns exec $ns nstat -as | grep MPTcp 15787d1e6f16SPaolo Abeni fi 15797d1e6f16SPaolo Abeni} 15807d1e6f16SPaolo Abeni 1581be613160SGeliang Tangchk_add_nr() 1582be613160SGeliang Tang{ 1583be613160SGeliang Tang local add_nr=$1 1584be613160SGeliang Tang local echo_nr=$2 15858a127bf6SGeliang Tang local port_nr=${3:-0} 15868a127bf6SGeliang Tang local syn_nr=${4:-$port_nr} 15878a127bf6SGeliang Tang local syn_ack_nr=${5:-$port_nr} 15888a127bf6SGeliang Tang local ack_nr=${6:-$port_nr} 15898a127bf6SGeliang Tang local mis_syn_nr=${7:-0} 15908a127bf6SGeliang Tang local mis_ack_nr=${8:-0} 1591be613160SGeliang Tang local count 15926ef84b15SPaolo Abeni local timeout 15936ef84b15SPaolo Abeni 15944bfadd71SMatthieu Baerts timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout) 1595be613160SGeliang Tang 159603668c65SMatthieu Baerts print_check "add" 159747867f0aSMatthieu Baerts count=$(get_counter ${ns2} "MPTcpExtAddAddr") 159847867f0aSMatthieu Baerts if [ -z "$count" ]; then 159903668c65SMatthieu Baerts print_skip 16006ef84b15SPaolo Abeni # if the test configured a short timeout tolerate greater then expected 16016ef84b15SPaolo Abeni # add addrs options, due to retransmissions 160247867f0aSMatthieu Baerts elif [ "$count" != "$add_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_nr" ]; }; then 160303668c65SMatthieu Baerts fail_test "got $count ADD_ADDR[s] expected $add_nr" 1604be613160SGeliang Tang else 160503668c65SMatthieu Baerts print_ok 1606be613160SGeliang Tang fi 1607be613160SGeliang Tang 160803668c65SMatthieu Baerts print_check "echo" 160947867f0aSMatthieu Baerts count=$(get_counter ${ns1} "MPTcpExtEchoAdd") 161047867f0aSMatthieu Baerts if [ -z "$count" ]; then 161103668c65SMatthieu Baerts print_skip 161247867f0aSMatthieu Baerts elif [ "$count" != "$echo_nr" ]; then 161303668c65SMatthieu Baerts fail_test "got $count ADD_ADDR echo[s] expected $echo_nr" 1614be613160SGeliang Tang else 161503668c65SMatthieu Baerts print_ok 16168a127bf6SGeliang Tang fi 16178a127bf6SGeliang Tang 16188a127bf6SGeliang Tang if [ $port_nr -gt 0 ]; then 161903668c65SMatthieu Baerts print_check "pt" 162047867f0aSMatthieu Baerts count=$(get_counter ${ns2} "MPTcpExtPortAdd") 162147867f0aSMatthieu Baerts if [ -z "$count" ]; then 162203668c65SMatthieu Baerts print_skip 162347867f0aSMatthieu Baerts elif [ "$count" != "$port_nr" ]; then 162403668c65SMatthieu Baerts fail_test "got $count ADD_ADDR[s] with a port-number expected $port_nr" 16258a127bf6SGeliang Tang else 162603668c65SMatthieu Baerts print_ok 1627be613160SGeliang Tang fi 1628be613160SGeliang Tang 162903668c65SMatthieu Baerts print_check "syn" 163047867f0aSMatthieu Baerts count=$(get_counter ${ns1} "MPTcpExtMPJoinPortSynRx") 163147867f0aSMatthieu Baerts if [ -z "$count" ]; then 163203668c65SMatthieu Baerts print_skip 163347867f0aSMatthieu Baerts elif [ "$count" != "$syn_nr" ]; then 163403668c65SMatthieu Baerts fail_test "got $count JOIN[s] syn with a different \ 16358a127bf6SGeliang Tang port-number expected $syn_nr" 16368a127bf6SGeliang Tang else 163703668c65SMatthieu Baerts print_ok 16388a127bf6SGeliang Tang fi 16398a127bf6SGeliang Tang 164003668c65SMatthieu Baerts print_check "synack" 164147867f0aSMatthieu Baerts count=$(get_counter ${ns2} "MPTcpExtMPJoinPortSynAckRx") 164247867f0aSMatthieu Baerts if [ -z "$count" ]; then 164303668c65SMatthieu Baerts print_skip 164447867f0aSMatthieu Baerts elif [ "$count" != "$syn_ack_nr" ]; then 164503668c65SMatthieu Baerts fail_test "got $count JOIN[s] synack with a different \ 16468a127bf6SGeliang Tang port-number expected $syn_ack_nr" 16478a127bf6SGeliang Tang else 164803668c65SMatthieu Baerts print_ok 16498a127bf6SGeliang Tang fi 16508a127bf6SGeliang Tang 165103668c65SMatthieu Baerts print_check "ack" 165247867f0aSMatthieu Baerts count=$(get_counter ${ns1} "MPTcpExtMPJoinPortAckRx") 165347867f0aSMatthieu Baerts if [ -z "$count" ]; then 165403668c65SMatthieu Baerts print_skip 165547867f0aSMatthieu Baerts elif [ "$count" != "$ack_nr" ]; then 165603668c65SMatthieu Baerts fail_test "got $count JOIN[s] ack with a different \ 16578a127bf6SGeliang Tang port-number expected $ack_nr" 16588a127bf6SGeliang Tang else 165903668c65SMatthieu Baerts print_ok 16608a127bf6SGeliang Tang fi 16618a127bf6SGeliang Tang 166203668c65SMatthieu Baerts print_check "syn" 166347867f0aSMatthieu Baerts count=$(get_counter ${ns1} "MPTcpExtMismatchPortSynRx") 166447867f0aSMatthieu Baerts if [ -z "$count" ]; then 166503668c65SMatthieu Baerts print_skip 166647867f0aSMatthieu Baerts elif [ "$count" != "$mis_syn_nr" ]; then 166703668c65SMatthieu Baerts fail_test "got $count JOIN[s] syn with a mismatched \ 16688a127bf6SGeliang Tang port-number expected $mis_syn_nr" 16698a127bf6SGeliang Tang else 167003668c65SMatthieu Baerts print_ok 16718a127bf6SGeliang Tang fi 16728a127bf6SGeliang Tang 167303668c65SMatthieu Baerts print_check "ack" 167447867f0aSMatthieu Baerts count=$(get_counter ${ns1} "MPTcpExtMismatchPortAckRx") 167547867f0aSMatthieu Baerts if [ -z "$count" ]; then 167603668c65SMatthieu Baerts print_skip 167747867f0aSMatthieu Baerts elif [ "$count" != "$mis_ack_nr" ]; then 167803668c65SMatthieu Baerts fail_test "got $count JOIN[s] ack with a mismatched \ 16798a127bf6SGeliang Tang port-number expected $mis_ack_nr" 16808a127bf6SGeliang Tang else 168103668c65SMatthieu Baerts print_ok 16828a127bf6SGeliang Tang fi 16838a127bf6SGeliang Tang fi 1684be613160SGeliang Tang} 1685be613160SGeliang Tang 16860639fa23SPaolo Abenichk_add_tx_nr() 16870639fa23SPaolo Abeni{ 16880639fa23SPaolo Abeni local add_tx_nr=$1 16890639fa23SPaolo Abeni local echo_tx_nr=$2 16900639fa23SPaolo Abeni local timeout 16910639fa23SPaolo Abeni local count 16920639fa23SPaolo Abeni 16930639fa23SPaolo Abeni timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout) 16940639fa23SPaolo Abeni 169503668c65SMatthieu Baerts print_check "add TX" 169600079f18SMatthieu Baerts count=$(get_counter ${ns1} "MPTcpExtAddAddrTx") 169700079f18SMatthieu Baerts if [ -z "$count" ]; then 169803668c65SMatthieu Baerts print_skip 16990639fa23SPaolo Abeni # if the test configured a short timeout tolerate greater then expected 17000639fa23SPaolo Abeni # add addrs options, due to retransmissions 170100079f18SMatthieu Baerts elif [ "$count" != "$add_tx_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_tx_nr" ]; }; then 170203668c65SMatthieu Baerts fail_test "got $count ADD_ADDR[s] TX, expected $add_tx_nr" 17030639fa23SPaolo Abeni else 170403668c65SMatthieu Baerts print_ok 17050639fa23SPaolo Abeni fi 17060639fa23SPaolo Abeni 170703668c65SMatthieu Baerts print_check "echo TX" 170800079f18SMatthieu Baerts count=$(get_counter ${ns2} "MPTcpExtEchoAddTx") 170900079f18SMatthieu Baerts if [ -z "$count" ]; then 171003668c65SMatthieu Baerts print_skip 171100079f18SMatthieu Baerts elif [ "$count" != "$echo_tx_nr" ]; then 171203668c65SMatthieu Baerts fail_test "got $count ADD_ADDR echo[s] TX, expected $echo_tx_nr" 17130639fa23SPaolo Abeni else 171403668c65SMatthieu Baerts print_ok 17150639fa23SPaolo Abeni fi 17160639fa23SPaolo Abeni} 17170639fa23SPaolo Abeni 1718dd72b0feSGeliang Tangchk_rm_nr() 1719dd72b0feSGeliang Tang{ 1720dd72b0feSGeliang Tang local rm_addr_nr=$1 1721dd72b0feSGeliang Tang local rm_subflow_nr=$2 17226fa0174aSPaolo Abeni local invert 17236fa0174aSPaolo Abeni local simult 1724dd72b0feSGeliang Tang local count 17257d9bf018SGeliang Tang local addr_ns=$ns1 17267d9bf018SGeliang Tang local subflow_ns=$ns2 17277d9bf018SGeliang Tang local extra_msg="" 17287028ba8aSGeliang Tang 17296fa0174aSPaolo Abeni shift 2 17306fa0174aSPaolo Abeni while [ -n "$1" ]; do 17316fa0174aSPaolo Abeni [ "$1" = "invert" ] && invert=true 17326fa0174aSPaolo Abeni [ "$1" = "simult" ] && simult=true 17336fa0174aSPaolo Abeni shift 17346fa0174aSPaolo Abeni done 17356fa0174aSPaolo Abeni 17366fa0174aSPaolo Abeni if [ -z $invert ]; then 17376fa0174aSPaolo Abeni addr_ns=$ns1 17386fa0174aSPaolo Abeni subflow_ns=$ns2 17396fa0174aSPaolo Abeni elif [ $invert = "true" ]; then 17407028ba8aSGeliang Tang addr_ns=$ns2 17417028ba8aSGeliang Tang subflow_ns=$ns1 17427d9bf018SGeliang Tang extra_msg="invert" 17437028ba8aSGeliang Tang fi 1744dd72b0feSGeliang Tang 174503668c65SMatthieu Baerts print_check "rm" 174600079f18SMatthieu Baerts count=$(get_counter ${addr_ns} "MPTcpExtRmAddr") 174700079f18SMatthieu Baerts if [ -z "$count" ]; then 174803668c65SMatthieu Baerts print_skip 174900079f18SMatthieu Baerts elif [ "$count" != "$rm_addr_nr" ]; then 175003668c65SMatthieu Baerts fail_test "got $count RM_ADDR[s] expected $rm_addr_nr" 1751dd72b0feSGeliang Tang else 175203668c65SMatthieu Baerts print_ok 1753dd72b0feSGeliang Tang fi 1754dd72b0feSGeliang Tang 175503668c65SMatthieu Baerts print_check "rmsf" 175647867f0aSMatthieu Baerts count=$(get_counter ${subflow_ns} "MPTcpExtRmSubflow") 175747867f0aSMatthieu Baerts if [ -z "$count" ]; then 175803668c65SMatthieu Baerts print_skip 175947867f0aSMatthieu Baerts elif [ -n "$simult" ]; then 1760d8d08302SMatthieu Baerts local cnt suffix 1761d8d08302SMatthieu Baerts 176247867f0aSMatthieu Baerts cnt=$(get_counter ${addr_ns} "MPTcpExtRmSubflow") 17636fa0174aSPaolo Abeni 17646fa0174aSPaolo Abeni # in case of simult flush, the subflow removal count on each side is 17656fa0174aSPaolo Abeni # unreliable 17666fa0174aSPaolo Abeni count=$((count + cnt)) 17676fa0174aSPaolo Abeni [ "$count" != "$rm_subflow_nr" ] && suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]" 17686fa0174aSPaolo Abeni if [ $count -ge "$rm_subflow_nr" ] && \ 17696fa0174aSPaolo Abeni [ "$count" -le "$((rm_subflow_nr *2 ))" ]; then 177003668c65SMatthieu Baerts print_ok "$suffix" 17716fa0174aSPaolo Abeni else 177203668c65SMatthieu Baerts fail_test "got $count RM_SUBFLOW[s] expected in range [$rm_subflow_nr:$((rm_subflow_nr*2))]" 17736fa0174aSPaolo Abeni fi 177447867f0aSMatthieu Baerts elif [ "$count" != "$rm_subflow_nr" ]; then 177503668c65SMatthieu Baerts fail_test "got $count RM_SUBFLOW[s] expected $rm_subflow_nr" 1776dd72b0feSGeliang Tang else 177703668c65SMatthieu Baerts print_ok 1778dd72b0feSGeliang Tang fi 1779dd72b0feSGeliang Tang 178003668c65SMatthieu Baerts print_info "$extra_msg" 1781dd72b0feSGeliang Tang} 1782dd72b0feSGeliang Tang 17830639fa23SPaolo Abenichk_rm_tx_nr() 17840639fa23SPaolo Abeni{ 17850639fa23SPaolo Abeni local rm_addr_tx_nr=$1 17860639fa23SPaolo Abeni 178703668c65SMatthieu Baerts print_check "rm TX" 178800079f18SMatthieu Baerts count=$(get_counter ${ns2} "MPTcpExtRmAddrTx") 178900079f18SMatthieu Baerts if [ -z "$count" ]; then 179003668c65SMatthieu Baerts print_skip 179100079f18SMatthieu Baerts elif [ "$count" != "$rm_addr_tx_nr" ]; then 179203668c65SMatthieu Baerts fail_test "got $count RM_ADDR[s] expected $rm_addr_tx_nr" 17930639fa23SPaolo Abeni else 179403668c65SMatthieu Baerts print_ok 17950639fa23SPaolo Abeni fi 17960639fa23SPaolo Abeni} 17970639fa23SPaolo Abeni 1798718eb44eSGeliang Tangchk_prio_nr() 1799718eb44eSGeliang Tang{ 1800718eb44eSGeliang Tang local mp_prio_nr_tx=$1 1801718eb44eSGeliang Tang local mp_prio_nr_rx=$2 1802718eb44eSGeliang Tang local count 1803718eb44eSGeliang Tang 180403668c65SMatthieu Baerts print_check "ptx" 180547867f0aSMatthieu Baerts count=$(get_counter ${ns1} "MPTcpExtMPPrioTx") 180647867f0aSMatthieu Baerts if [ -z "$count" ]; then 180703668c65SMatthieu Baerts print_skip 180847867f0aSMatthieu Baerts elif [ "$count" != "$mp_prio_nr_tx" ]; then 180903668c65SMatthieu Baerts fail_test "got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" 1810718eb44eSGeliang Tang else 181103668c65SMatthieu Baerts print_ok 1812718eb44eSGeliang Tang fi 1813718eb44eSGeliang Tang 181403668c65SMatthieu Baerts print_check "prx" 181547867f0aSMatthieu Baerts count=$(get_counter ${ns1} "MPTcpExtMPPrioRx") 181647867f0aSMatthieu Baerts if [ -z "$count" ]; then 181703668c65SMatthieu Baerts print_skip 181847867f0aSMatthieu Baerts elif [ "$count" != "$mp_prio_nr_rx" ]; then 181903668c65SMatthieu Baerts fail_test "got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" 1820718eb44eSGeliang Tang else 182103668c65SMatthieu Baerts print_ok 1822718eb44eSGeliang Tang fi 1823718eb44eSGeliang Tang} 1824718eb44eSGeliang Tang 1825e274f715SPaolo Abenichk_subflow_nr() 1826e274f715SPaolo Abeni{ 182703668c65SMatthieu Baerts local msg="$1" 182803668c65SMatthieu Baerts local subflow_nr=$2 1829e274f715SPaolo Abeni local cnt1 1830e274f715SPaolo Abeni local cnt2 1831a635a8c3SPaolo Abeni local dump_stats 1832e274f715SPaolo Abeni 183303668c65SMatthieu Baerts print_check "${msg}" 1834e274f715SPaolo Abeni 1835e274f715SPaolo Abeni cnt1=$(ss -N $ns1 -tOni | grep -c token) 1836e274f715SPaolo Abeni cnt2=$(ss -N $ns2 -tOni | grep -c token) 18370fcd72dfSMatthieu Baerts if [ "$cnt1" != "$subflow_nr" ] || [ "$cnt2" != "$subflow_nr" ]; then 183803668c65SMatthieu Baerts fail_test "got $cnt1:$cnt2 subflows expected $subflow_nr" 1839e274f715SPaolo Abeni dump_stats=1 1840e274f715SPaolo Abeni else 184103668c65SMatthieu Baerts print_ok 1842e274f715SPaolo Abeni fi 1843e274f715SPaolo Abeni 1844a635a8c3SPaolo Abeni if [ "${dump_stats}" = 1 ]; then 1845a635a8c3SPaolo Abeni ss -N $ns1 -tOni 1846a635a8c3SPaolo Abeni ss -N $ns1 -tOni | grep token 1847a635a8c3SPaolo Abeni ip -n $ns1 mptcp endpoint 1848a635a8c3SPaolo Abeni fi 1849e274f715SPaolo Abeni} 1850e274f715SPaolo Abeni 18519095ce97SGeliang Tangchk_mptcp_info() 18529095ce97SGeliang Tang{ 1853d7ced753SGeliang Tang local info1=$1 1854d7ced753SGeliang Tang local exp1=$2 1855d7ced753SGeliang Tang local info2=$3 1856d7ced753SGeliang Tang local exp2=$4 18579095ce97SGeliang Tang local cnt1 18589095ce97SGeliang Tang local cnt2 18599095ce97SGeliang Tang local dump_stats 18609095ce97SGeliang Tang 186103668c65SMatthieu Baerts print_check "mptcp_info ${info1:0:8}=$exp1:$exp2" 18629095ce97SGeliang Tang 1863d7ced753SGeliang Tang cnt1=$(ss -N $ns1 -inmHM | grep "$info1:" | 1864d7ced753SGeliang Tang sed -n 's/.*\('"$info1"':\)\([[:digit:]]*\).*$/\2/p;q') 1865d7ced753SGeliang Tang cnt2=$(ss -N $ns2 -inmHM | grep "$info2:" | 1866d7ced753SGeliang Tang sed -n 's/.*\('"$info2"':\)\([[:digit:]]*\).*$/\2/p;q') 1867d7ced753SGeliang Tang # 'ss' only display active connections and counters that are not 0. 18689095ce97SGeliang Tang [ -z "$cnt1" ] && cnt1=0 18699095ce97SGeliang Tang [ -z "$cnt2" ] && cnt2=0 1870d7ced753SGeliang Tang 1871d7ced753SGeliang Tang if [ "$cnt1" != "$exp1" ] || [ "$cnt2" != "$exp2" ]; then 187203668c65SMatthieu Baerts fail_test "got $cnt1:$cnt2 $info1:$info2 expected $exp1:$exp2" 18739095ce97SGeliang Tang dump_stats=1 18749095ce97SGeliang Tang else 187503668c65SMatthieu Baerts print_ok 18769095ce97SGeliang Tang fi 18779095ce97SGeliang Tang 18789095ce97SGeliang Tang if [ "$dump_stats" = 1 ]; then 18799095ce97SGeliang Tang ss -N $ns1 -inmHM 18809095ce97SGeliang Tang ss -N $ns2 -inmHM 18819095ce97SGeliang Tang fi 18829095ce97SGeliang Tang} 18839095ce97SGeliang Tang 18847d1e6f16SPaolo Abenichk_link_usage() 18857d1e6f16SPaolo Abeni{ 18867d1e6f16SPaolo Abeni local ns=$1 18877d1e6f16SPaolo Abeni local link=$2 18887d1e6f16SPaolo Abeni local out=$3 18897d1e6f16SPaolo Abeni local expected_rate=$4 18904bfadd71SMatthieu Baerts 18914bfadd71SMatthieu Baerts local tx_link tx_total 18924bfadd71SMatthieu Baerts tx_link=$(ip netns exec $ns cat /sys/class/net/$link/statistics/tx_bytes) 1893d8d08302SMatthieu Baerts tx_total=$(stat --format=%s $out) 1894d8d08302SMatthieu Baerts local tx_rate=$((tx_link * 100 / tx_total)) 18957d1e6f16SPaolo Abeni local tolerance=5 18967d1e6f16SPaolo Abeni 189703668c65SMatthieu Baerts print_check "link usage" 1898d8d08302SMatthieu Baerts if [ $tx_rate -lt $((expected_rate - tolerance)) ] || \ 1899d8d08302SMatthieu Baerts [ $tx_rate -gt $((expected_rate + tolerance)) ]; then 190003668c65SMatthieu Baerts fail_test "got $tx_rate% usage, expected $expected_rate%" 19017d1e6f16SPaolo Abeni else 190203668c65SMatthieu Baerts print_ok 19037d1e6f16SPaolo Abeni fi 19047d1e6f16SPaolo Abeni} 19057d1e6f16SPaolo Abeni 1906f98c2bcaSMat Martineauwait_attempt_fail() 190746e967d1SPaolo Abeni{ 190846e967d1SPaolo Abeni local timeout_ms=$((timeout_poll * 1000)) 190946e967d1SPaolo Abeni local time=0 191046e967d1SPaolo Abeni local ns=$1 191146e967d1SPaolo Abeni 191246e967d1SPaolo Abeni while [ $time -lt $timeout_ms ]; do 19131e777bd8SMatthieu Baerts local cnt 19141e777bd8SMatthieu Baerts 191547867f0aSMatthieu Baerts cnt=$(get_counter ${ns} "TcpAttemptFails") 191646e967d1SPaolo Abeni 191746e967d1SPaolo Abeni [ "$cnt" = 1 ] && return 1 191846e967d1SPaolo Abeni time=$((time + 100)) 191946e967d1SPaolo Abeni sleep 0.1 192046e967d1SPaolo Abeni done 192146e967d1SPaolo Abeni return 1 192246e967d1SPaolo Abeni} 192346e967d1SPaolo Abeni 19245ac1d2d6SMat Martineauset_userspace_pm() 19255ac1d2d6SMat Martineau{ 19265ac1d2d6SMat Martineau local ns=$1 19275ac1d2d6SMat Martineau 19285ac1d2d6SMat Martineau ip netns exec $ns sysctl -q net.mptcp.pm_type=1 19295ac1d2d6SMat Martineau} 19305ac1d2d6SMat Martineau 19311002b89fSGeliang Tangsubflows_tests() 19321002b89fSGeliang Tang{ 1933c7d49c03SMatthieu Baerts if reset "no JOIN"; then 1934b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1935c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 1936ae7bd9ccSMatthieu Baerts fi 1937b08fbf24SPaolo Abeni 19381002b89fSGeliang Tang # subflow limited by client 1939c7d49c03SMatthieu Baerts if reset "single subflow, limited by client"; then 194034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 0 194134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 0 194234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1943b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1944c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 1945ae7bd9ccSMatthieu Baerts fi 1946b08fbf24SPaolo Abeni 19471002b89fSGeliang Tang # subflow limited by server 1948c7d49c03SMatthieu Baerts if reset "single subflow, limited by server"; then 194934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 0 195034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 195134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1952b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1953c7d49c03SMatthieu Baerts chk_join_nr 1 1 0 1954ae7bd9ccSMatthieu Baerts fi 1955b08fbf24SPaolo Abeni 1956b08fbf24SPaolo Abeni # subflow 1957c7d49c03SMatthieu Baerts if reset "single subflow"; then 195834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 195934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 196034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 1961b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1962c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 1963ae7bd9ccSMatthieu Baerts fi 1964b08fbf24SPaolo Abeni 1965b08fbf24SPaolo Abeni # multiple subflows 1966c7d49c03SMatthieu Baerts if reset "multiple subflows"; then 196734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 196834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 196934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 197034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 1971b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1972c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 1973ae7bd9ccSMatthieu Baerts fi 1974b08fbf24SPaolo Abeni 197572bcbc46SPaolo Abeni # multiple subflows limited by server 1976c7d49c03SMatthieu Baerts if reset "multiple subflows, limited by server"; then 197734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 197834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 197934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 198034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 1981b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 1982c7d49c03SMatthieu Baerts chk_join_nr 2 2 1 1983ae7bd9ccSMatthieu Baerts fi 1984c3eaa5f6SGeliang Tang 1985c3eaa5f6SGeliang Tang # single subflow, dev 1986c7d49c03SMatthieu Baerts if reset "single subflow, dev"; then 198734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 198834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 198934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow dev ns2eth3 1990c3eaa5f6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 1991c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 1992ae7bd9ccSMatthieu Baerts fi 19931002b89fSGeliang Tang} 1994b08fbf24SPaolo Abeni 199546e967d1SPaolo Abenisubflows_error_tests() 199646e967d1SPaolo Abeni{ 199746e967d1SPaolo Abeni # If a single subflow is configured, and matches the MPC src 199846e967d1SPaolo Abeni # address, no additional subflow should be created 1999c7d49c03SMatthieu Baerts if reset "no MPC reuse with single endpoint"; then 200034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 200134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 200234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow 2003e571fb09SGeliang Tang speed=slow \ 2004e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2005c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 2006ae7bd9ccSMatthieu Baerts fi 200746e967d1SPaolo Abeni 200846e967d1SPaolo Abeni # multiple subflows, with subflow creation error 20094a0b866aSMatthieu Baerts if reset_with_tcp_filter "multi subflows, with failing subflow" ns1 10.0.3.2 REJECT && 20104a0b866aSMatthieu Baerts continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then 201134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 201234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 201334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 201434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 2015e571fb09SGeliang Tang speed=slow \ 2016e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2017c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2018ae7bd9ccSMatthieu Baerts fi 201946e967d1SPaolo Abeni 202046e967d1SPaolo Abeni # multiple subflows, with subflow timeout on MPJ 20214a0b866aSMatthieu Baerts if reset_with_tcp_filter "multi subflows, with subflow timeout" ns1 10.0.3.2 DROP && 20224a0b866aSMatthieu Baerts continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then 202334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 202434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 202534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 202634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 2027e571fb09SGeliang Tang speed=slow \ 2028e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2029c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2030ae7bd9ccSMatthieu Baerts fi 203146e967d1SPaolo Abeni 203246e967d1SPaolo Abeni # multiple subflows, check that the endpoint corresponding to 203346e967d1SPaolo Abeni # closed subflow (due to reset) is not reused if additional 203446e967d1SPaolo Abeni # subflows are added later 20354a0b866aSMatthieu Baerts if reset_with_tcp_filter "multi subflows, fair usage on close" ns1 10.0.3.2 REJECT && 20364a0b866aSMatthieu Baerts continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then 203734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 203834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 203934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2040e571fb09SGeliang Tang speed=slow \ 2041e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 & 204246e967d1SPaolo Abeni 204346e967d1SPaolo Abeni # mpj subflow will be in TW after the reset 2044f98c2bcaSMat Martineau wait_attempt_fail $ns2 204534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 204646e967d1SPaolo Abeni wait 204746e967d1SPaolo Abeni 204846e967d1SPaolo Abeni # additional subflow could be created only if the PM select 204946e967d1SPaolo Abeni # the later endpoint, skipping the already used one 2050c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2051ae7bd9ccSMatthieu Baerts fi 205246e967d1SPaolo Abeni} 205346e967d1SPaolo Abeni 20541002b89fSGeliang Tangsignal_address_tests() 20551002b89fSGeliang Tang{ 2056b08fbf24SPaolo Abeni # add_address, unused 2057c7d49c03SMatthieu Baerts if reset "unused signal address"; then 205834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2059b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2060c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 20610639fa23SPaolo Abeni chk_add_tx_nr 1 1 2062be613160SGeliang Tang chk_add_nr 1 1 2063ae7bd9ccSMatthieu Baerts fi 2064b08fbf24SPaolo Abeni 2065b08fbf24SPaolo Abeni # accept and use add_addr 2066c7d49c03SMatthieu Baerts if reset "signal address"; then 206734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 206834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 206934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2070b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2071c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2072be613160SGeliang Tang chk_add_nr 1 1 2073ae7bd9ccSMatthieu Baerts fi 2074b08fbf24SPaolo Abeni 2075b08fbf24SPaolo Abeni # accept and use add_addr with an additional subflow 2076b08fbf24SPaolo Abeni # note: signal address in server ns and local addresses in client ns must 2077b08fbf24SPaolo Abeni # belong to different subnets or one of the listed local address could be 2078b08fbf24SPaolo Abeni # used for 'add_addr' subflow 2079c7d49c03SMatthieu Baerts if reset "subflow and signal"; then 208034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 208134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 208234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 208334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2084b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2085c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2086be613160SGeliang Tang chk_add_nr 1 1 2087ae7bd9ccSMatthieu Baerts fi 2088b08fbf24SPaolo Abeni 2089b08fbf24SPaolo Abeni # accept and use add_addr with additional subflows 2090c7d49c03SMatthieu Baerts if reset "multiple subflows and signal"; then 209134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 209234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 209334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 209434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 209534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 2096b08fbf24SPaolo Abeni run_tests $ns1 $ns2 10.0.1.1 2097c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2098be613160SGeliang Tang chk_add_nr 1 1 2099ae7bd9ccSMatthieu Baerts fi 2100ef360019SGeliang Tang 2101ef360019SGeliang Tang # signal addresses 2102c7d49c03SMatthieu Baerts if reset "signal addresses"; then 210334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 210434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 210534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 210634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 210734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 2108ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2109c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2110ef360019SGeliang Tang chk_add_nr 3 3 2111ae7bd9ccSMatthieu Baerts fi 2112ef360019SGeliang Tang 2113ef360019SGeliang Tang # signal invalid addresses 2114c7d49c03SMatthieu Baerts if reset "signal invalid addresses"; then 211534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 211634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 211734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 211834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 211934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 2120ef360019SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2121c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2122ef360019SGeliang Tang chk_add_nr 3 3 2123ae7bd9ccSMatthieu Baerts fi 212433c563adSYonglong Li 212533c563adSYonglong Li # signal addresses race test 2126c7d49c03SMatthieu Baerts if reset "signal addresses race test"; then 212734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 212834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 212934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.1.1 flags signal 213034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 213134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 213234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 213334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.1.2 flags signal 213434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags signal 213534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags signal 213634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags signal 21376ef84b15SPaolo Abeni 21386ef84b15SPaolo Abeni # the peer could possibly miss some addr notification, allow retransmission 21396ef84b15SPaolo Abeni ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 2140e571fb09SGeliang Tang speed=slow \ 2141e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 214286e39e04SPaolo Abeni 2143d4c81bbbSMatthieu Baerts # It is not directly linked to the commit introducing this 2144d4c81bbbSMatthieu Baerts # symbol but for the parent one which is linked anyway. 2145d4c81bbbSMatthieu Baerts if ! mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then 2146d4c81bbbSMatthieu Baerts chk_join_nr 3 3 2 2147d4c81bbbSMatthieu Baerts chk_add_nr 4 4 2148d4c81bbbSMatthieu Baerts else 2149d4c81bbbSMatthieu Baerts chk_join_nr 3 3 3 215086e39e04SPaolo Abeni # the server will not signal the address terminating 215186e39e04SPaolo Abeni # the MPC subflow 215286e39e04SPaolo Abeni chk_add_nr 3 3 2153ae7bd9ccSMatthieu Baerts fi 2154d4c81bbbSMatthieu Baerts fi 21551002b89fSGeliang Tang} 2156b08fbf24SPaolo Abeni 21571002b89fSGeliang Tanglink_failure_tests() 21581002b89fSGeliang Tang{ 21598b819a84SFlorian Westphal # accept and use add_addr with additional subflows and link loss 2160c7d49c03SMatthieu Baerts if reset "multiple flows, signal, link failure"; then 21617d1e6f16SPaolo Abeni # without any b/w limit each veth could spool the packets and get 21627d1e6f16SPaolo Abeni # them acked at xmit time, so that the corresponding subflow will 21637d1e6f16SPaolo Abeni # have almost always no outstanding pkts, the scheduler will pick 21647d1e6f16SPaolo Abeni # always the first subflow and we will have hard time testing 21657d1e6f16SPaolo Abeni # active backup and link switch-over. 21667d1e6f16SPaolo Abeni # Let's set some arbitrary (low) virtual link limits. 21677d1e6f16SPaolo Abeni init_shapers 216834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 216934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 217034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 217134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow 217234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow 21730c93af1fSGeliang Tang test_linkfail=1 \ 21740c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2175c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 21768b819a84SFlorian Westphal chk_add_nr 1 1 21777d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 5 1 2178ae7bd9ccSMatthieu Baerts fi 21797d1e6f16SPaolo Abeni 21807d1e6f16SPaolo Abeni # accept and use add_addr with additional subflows and link loss 21817d1e6f16SPaolo Abeni # for bidirectional transfer 2182c7d49c03SMatthieu Baerts if reset "multi flows, signal, bidi, link fail"; then 21837d1e6f16SPaolo Abeni init_shapers 218434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 218534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 218634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 218734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow 218834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow 21890c93af1fSGeliang Tang test_linkfail=2 \ 21900c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2191c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 21927d1e6f16SPaolo Abeni chk_add_nr 1 1 21937d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 -1 1 2194ae7bd9ccSMatthieu Baerts fi 21957d1e6f16SPaolo Abeni 21967d1e6f16SPaolo Abeni # 2 subflows plus 1 backup subflow with a lossy link, backup 21977d1e6f16SPaolo Abeni # will never be used 2198c7d49c03SMatthieu Baerts if reset "backup subflow unused, link failure"; then 21997d1e6f16SPaolo Abeni init_shapers 220034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 220134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 220234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 220334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 22040c93af1fSGeliang Tang FAILING_LINKS="1" test_linkfail=1 \ 22050c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2206c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 22077d1e6f16SPaolo Abeni chk_add_nr 1 1 22087d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 0 2209ae7bd9ccSMatthieu Baerts fi 22107d1e6f16SPaolo Abeni 22117d1e6f16SPaolo Abeni # 2 lossy links after half transfer, backup will get half of 22127d1e6f16SPaolo Abeni # the traffic 2213c7d49c03SMatthieu Baerts if reset "backup flow used, multi links fail"; then 22147d1e6f16SPaolo Abeni init_shapers 221534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 221634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 221734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 221834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 22190c93af1fSGeliang Tang FAILING_LINKS="1 2" test_linkfail=1 \ 22200c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2221c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 22227d1e6f16SPaolo Abeni chk_add_nr 1 1 22237d1e6f16SPaolo Abeni chk_stale_nr $ns2 2 4 2 22247d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 50 2225ae7bd9ccSMatthieu Baerts fi 22267d1e6f16SPaolo Abeni 22277d1e6f16SPaolo Abeni # use a backup subflow with the first subflow on a lossy link 22287d1e6f16SPaolo Abeni # for bidirectional transfer 2229c7d49c03SMatthieu Baerts if reset "backup flow used, bidi, link failure"; then 22307d1e6f16SPaolo Abeni init_shapers 223134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 223234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 dev ns1eth2 flags signal 223334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 223434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow,backup 22350c93af1fSGeliang Tang FAILING_LINKS="1 2" test_linkfail=2 \ 22360c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2237c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 22387d1e6f16SPaolo Abeni chk_add_nr 1 1 22397d1e6f16SPaolo Abeni chk_stale_nr $ns2 1 -1 2 22407d1e6f16SPaolo Abeni chk_link_usage $ns2 ns2eth3 $cinsent 50 2241ae7bd9ccSMatthieu Baerts fi 22421002b89fSGeliang Tang} 22438b819a84SFlorian Westphal 22441002b89fSGeliang Tangadd_addr_timeout_tests() 22451002b89fSGeliang Tang{ 22468d014eaaSGeliang Tang # add_addr timeout 2247c7d49c03SMatthieu Baerts if reset_with_add_addr_timeout "signal address, ADD_ADDR timeout"; then 224834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 224934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 225034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2251e571fb09SGeliang Tang speed=slow \ 2252e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2253c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 22540639fa23SPaolo Abeni chk_add_tx_nr 4 4 22558d014eaaSGeliang Tang chk_add_nr 4 0 2256ae7bd9ccSMatthieu Baerts fi 22578d014eaaSGeliang Tang 22581002b89fSGeliang Tang # add_addr timeout IPv6 2259c7d49c03SMatthieu Baerts if reset_with_add_addr_timeout "signal address, ADD_ADDR6 timeout" 6; then 226034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 226134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 226234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 2263e571fb09SGeliang Tang speed=slow \ 2264e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2265c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 22661002b89fSGeliang Tang chk_add_nr 4 0 2267ae7bd9ccSMatthieu Baerts fi 22688da6229bSGeliang Tang 22698da6229bSGeliang Tang # signal addresses timeout 2270c7d49c03SMatthieu Baerts if reset_with_add_addr_timeout "signal addresses, ADD_ADDR timeout"; then 227134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 227234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 227334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 227434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 2275e571fb09SGeliang Tang speed=10 \ 2276e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2277c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 22788da6229bSGeliang Tang chk_add_nr 8 0 2279ae7bd9ccSMatthieu Baerts fi 22808da6229bSGeliang Tang 22818da6229bSGeliang Tang # signal invalid addresses timeout 2282c7d49c03SMatthieu Baerts if reset_with_add_addr_timeout "invalid address, ADD_ADDR timeout"; then 228334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 228434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 228534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 228634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 2287e571fb09SGeliang Tang speed=10 \ 2288e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2289c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 22908da6229bSGeliang Tang chk_add_nr 8 0 2291ae7bd9ccSMatthieu Baerts fi 22921002b89fSGeliang Tang} 22931002b89fSGeliang Tang 22941002b89fSGeliang Tangremove_tests() 22951002b89fSGeliang Tang{ 2296dd72b0feSGeliang Tang # single subflow, remove 2297c7d49c03SMatthieu Baerts if reset "remove single subflow"; then 229834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 229934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 230034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2301e571fb09SGeliang Tang addr_nr_ns2=-1 speed=slow \ 2302e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2303c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 23040639fa23SPaolo Abeni chk_rm_tx_nr 1 2305dd72b0feSGeliang Tang chk_rm_nr 1 1 2306ae7bd9ccSMatthieu Baerts fi 2307dd72b0feSGeliang Tang 2308dd72b0feSGeliang Tang # multiple subflows, remove 2309c7d49c03SMatthieu Baerts if reset "remove multiple subflows"; then 231034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 231134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 231234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 231334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2314e571fb09SGeliang Tang addr_nr_ns2=-2 speed=slow \ 2315e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2316c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2317dd72b0feSGeliang Tang chk_rm_nr 2 2 2318ae7bd9ccSMatthieu Baerts fi 2319dd72b0feSGeliang Tang 2320dd72b0feSGeliang Tang # single address, remove 2321c7d49c03SMatthieu Baerts if reset "remove single address"; then 232234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 232334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 232434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2325e571fb09SGeliang Tang addr_nr_ns1=-1 speed=slow \ 2326e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2327c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2328dd72b0feSGeliang Tang chk_add_nr 1 1 23297028ba8aSGeliang Tang chk_rm_nr 1 1 invert 2330ae7bd9ccSMatthieu Baerts fi 2331dd72b0feSGeliang Tang 2332dd72b0feSGeliang Tang # subflow and signal, remove 2333c7d49c03SMatthieu Baerts if reset "remove subflow and signal"; then 233434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 233534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 233634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 233734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2338e571fb09SGeliang Tang addr_nr_ns1=-1 addr_nr_ns2=-1 speed=slow \ 2339e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2340c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2341dd72b0feSGeliang Tang chk_add_nr 1 1 2342dd72b0feSGeliang Tang chk_rm_nr 1 1 2343ae7bd9ccSMatthieu Baerts fi 2344dd72b0feSGeliang Tang 2345dd72b0feSGeliang Tang # subflows and signal, remove 2346c7d49c03SMatthieu Baerts if reset "remove subflows and signal"; then 234734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 234834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 234934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 235034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 235134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 2352e571fb09SGeliang Tang addr_nr_ns1=-1 addr_nr_ns2=-2 speed=10 \ 2353e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2354c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2355dd72b0feSGeliang Tang chk_add_nr 1 1 2356dd72b0feSGeliang Tang chk_rm_nr 2 2 2357ae7bd9ccSMatthieu Baerts fi 2358dd72b0feSGeliang Tang 2359ef360019SGeliang Tang # addresses remove 2360c7d49c03SMatthieu Baerts if reset "remove addresses"; then 236134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 236234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 236334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 236434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 236534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 2366e571fb09SGeliang Tang addr_nr_ns1=-3 speed=10 \ 2367e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2368c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2369ef360019SGeliang Tang chk_add_nr 3 3 2370ef360019SGeliang Tang chk_rm_nr 3 3 invert 2371ae7bd9ccSMatthieu Baerts fi 2372ef360019SGeliang Tang 2373ef360019SGeliang Tang # invalid addresses remove 2374c7d49c03SMatthieu Baerts if reset "remove invalid addresses"; then 237534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 237634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 237734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 237834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 237934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 2380e571fb09SGeliang Tang addr_nr_ns1=-3 speed=10 \ 2381e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2382c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2383ef360019SGeliang Tang chk_add_nr 3 3 2384ef360019SGeliang Tang chk_rm_nr 3 1 invert 2385ae7bd9ccSMatthieu Baerts fi 2386ef360019SGeliang Tang 23876fe4ccdcSGeliang Tang # subflows and signal, flush 2388c7d49c03SMatthieu Baerts if reset "flush subflows and signal"; then 238934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 239034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 239134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 239234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 239334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 2394e571fb09SGeliang Tang addr_nr_ns1=-8 addr_nr_ns2=-8 speed=slow \ 2395e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2396c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 23976fe4ccdcSGeliang Tang chk_add_nr 1 1 23986fa0174aSPaolo Abeni chk_rm_nr 1 3 invert simult 2399ae7bd9ccSMatthieu Baerts fi 2400d2c4333aSGeliang Tang 2401d2c4333aSGeliang Tang # subflows flush 2402c7d49c03SMatthieu Baerts if reset "flush subflows"; then 240334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 240434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 240534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow id 150 240634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 240734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 2408e571fb09SGeliang Tang addr_nr_ns1=-8 addr_nr_ns2=-8 speed=slow \ 2409e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2410c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2411425ba803SMatthieu Baerts 2412425ba803SMatthieu Baerts if mptcp_lib_kversion_ge 5.18; then 24130639fa23SPaolo Abeni chk_rm_tx_nr 0 24146fa0174aSPaolo Abeni chk_rm_nr 0 3 simult 2415425ba803SMatthieu Baerts else 2416425ba803SMatthieu Baerts chk_rm_nr 3 3 2417425ba803SMatthieu Baerts fi 2418ae7bd9ccSMatthieu Baerts fi 2419d2c4333aSGeliang Tang 2420d2c4333aSGeliang Tang # addresses flush 2421c7d49c03SMatthieu Baerts if reset "flush addresses"; then 242234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 242334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 242434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 242534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 242634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 2427e571fb09SGeliang Tang addr_nr_ns1=-8 addr_nr_ns2=-8 speed=slow \ 2428e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2429c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2430d2c4333aSGeliang Tang chk_add_nr 3 3 24316fa0174aSPaolo Abeni chk_rm_nr 3 3 invert simult 2432ae7bd9ccSMatthieu Baerts fi 2433ef360019SGeliang Tang 2434ef360019SGeliang Tang # invalid addresses flush 2435c7d49c03SMatthieu Baerts if reset "flush invalid addresses"; then 243634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 3 3 243734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 243834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 243934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 244034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 3 3 2441e571fb09SGeliang Tang addr_nr_ns1=-8 speed=slow \ 2442e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2443c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2444ef360019SGeliang Tang chk_add_nr 3 3 2445ef360019SGeliang Tang chk_rm_nr 3 1 invert 2446ae7bd9ccSMatthieu Baerts fi 24475e287fe7SGeliang Tang 24485e287fe7SGeliang Tang # remove id 0 subflow 2449c7d49c03SMatthieu Baerts if reset "remove id 0 subflow"; then 245034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 245134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 245234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2453e571fb09SGeliang Tang addr_nr_ns2=-9 speed=slow \ 2454e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2455c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 24565e287fe7SGeliang Tang chk_rm_nr 1 1 2457ae7bd9ccSMatthieu Baerts fi 24585e287fe7SGeliang Tang 24595e287fe7SGeliang Tang # remove id 0 address 2460c7d49c03SMatthieu Baerts if reset "remove id 0 address"; then 246134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 246234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 246334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2464e571fb09SGeliang Tang addr_nr_ns1=-9 speed=slow \ 2465e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2466c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 24675e287fe7SGeliang Tang chk_add_nr 1 1 24685e287fe7SGeliang Tang chk_rm_nr 1 1 invert 2469ae7bd9ccSMatthieu Baerts fi 24701002b89fSGeliang Tang} 24716fe4ccdcSGeliang Tang 24721002b89fSGeliang Tangadd_tests() 24731002b89fSGeliang Tang{ 24746208fd82SGeliang Tang # add single subflow 2475c7d49c03SMatthieu Baerts if reset "add single subflow"; then 247634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 247734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 2478e571fb09SGeliang Tang addr_nr_ns2=1 speed=slow \ 2479e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2480c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2481ae7bd9ccSMatthieu Baerts fi 24826208fd82SGeliang Tang 24836208fd82SGeliang Tang # add signal address 2484c7d49c03SMatthieu Baerts if reset "add signal address"; then 248534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 248634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2487e571fb09SGeliang Tang addr_nr_ns1=1 speed=slow \ 2488e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2489c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 24906208fd82SGeliang Tang chk_add_nr 1 1 2491ae7bd9ccSMatthieu Baerts fi 24926208fd82SGeliang Tang 24936208fd82SGeliang Tang # add multiple subflows 2494c7d49c03SMatthieu Baerts if reset "add multiple subflows"; then 249534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 249634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 2497e571fb09SGeliang Tang addr_nr_ns2=2 speed=slow \ 2498e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2499c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2500ae7bd9ccSMatthieu Baerts fi 25016208fd82SGeliang Tang 25026208fd82SGeliang Tang # add multiple subflows IPv6 2503c7d49c03SMatthieu Baerts if reset "add multiple subflows IPv6"; then 250434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 250534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 2506e571fb09SGeliang Tang addr_nr_ns2=2 speed=slow \ 2507e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2508c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2509ae7bd9ccSMatthieu Baerts fi 25106208fd82SGeliang Tang 25116208fd82SGeliang Tang # add multiple addresses IPv6 2512c7d49c03SMatthieu Baerts if reset "add multiple addresses IPv6"; then 251334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 251434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 2515e571fb09SGeliang Tang addr_nr_ns1=2 speed=slow \ 2516e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2517c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 25186208fd82SGeliang Tang chk_add_nr 2 2 2519ae7bd9ccSMatthieu Baerts fi 25201002b89fSGeliang Tang} 25216208fd82SGeliang Tang 25221002b89fSGeliang Tangipv6_tests() 25231002b89fSGeliang Tang{ 2524523514edSGeliang Tang # subflow IPv6 2525c7d49c03SMatthieu Baerts if reset "single subflow IPv6"; then 252634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 252734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 252834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow 2529e571fb09SGeliang Tang speed=slow \ 2530e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2531c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2532ae7bd9ccSMatthieu Baerts fi 2533523514edSGeliang Tang 2534523514edSGeliang Tang # add_address, unused IPv6 2535c7d49c03SMatthieu Baerts if reset "unused signal address IPv6"; then 253634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 2537e571fb09SGeliang Tang speed=slow \ 2538e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2539c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 2540523514edSGeliang Tang chk_add_nr 1 1 2541ae7bd9ccSMatthieu Baerts fi 2542523514edSGeliang Tang 2543523514edSGeliang Tang # signal address IPv6 2544c7d49c03SMatthieu Baerts if reset "single address IPv6"; then 254534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 254634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 254734aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2548e571fb09SGeliang Tang speed=slow \ 2549e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2550c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2551523514edSGeliang Tang chk_add_nr 1 1 2552ae7bd9ccSMatthieu Baerts fi 2553523514edSGeliang Tang 2554523514edSGeliang Tang # single address IPv6, remove 2555c7d49c03SMatthieu Baerts if reset "remove single address IPv6"; then 255634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 255734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 255834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2559e571fb09SGeliang Tang addr_nr_ns1=-1 speed=slow \ 2560e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2561c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2562523514edSGeliang Tang chk_add_nr 1 1 25637028ba8aSGeliang Tang chk_rm_nr 1 1 invert 2564ae7bd9ccSMatthieu Baerts fi 2565523514edSGeliang Tang 2566523514edSGeliang Tang # subflow and signal IPv6, remove 2567c7d49c03SMatthieu Baerts if reset "remove subflow and signal IPv6"; then 256834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 256934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 257034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 257134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:3::2 dev ns2eth3 flags subflow 2572e571fb09SGeliang Tang addr_nr_ns1=-1 addr_nr_ns2=-1 speed=slow \ 2573e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2574c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2575523514edSGeliang Tang chk_add_nr 1 1 2576523514edSGeliang Tang chk_rm_nr 1 1 2577ae7bd9ccSMatthieu Baerts fi 25781002b89fSGeliang Tang} 2579523514edSGeliang Tang 25801002b89fSGeliang Tangv4mapped_tests() 25811002b89fSGeliang Tang{ 2582a6094788SGeliang Tang # subflow IPv4-mapped to IPv4-mapped 2583c7d49c03SMatthieu Baerts if reset "single subflow IPv4-mapped"; then 258434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 258534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 258634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow 2587a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 2588c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2589ae7bd9ccSMatthieu Baerts fi 2590a6094788SGeliang Tang 2591a6094788SGeliang Tang # signal address IPv4-mapped with IPv4-mapped sk 2592c7d49c03SMatthieu Baerts if reset "signal address IPv4-mapped"; then 259334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 259434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 259534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal 2596a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 2597c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2598a6094788SGeliang Tang chk_add_nr 1 1 2599ae7bd9ccSMatthieu Baerts fi 2600a6094788SGeliang Tang 2601a6094788SGeliang Tang # subflow v4-map-v6 2602c7d49c03SMatthieu Baerts if reset "single subflow v4-map-v6"; then 260334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 260434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 260534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2606a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 2607c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2608ae7bd9ccSMatthieu Baerts fi 2609a6094788SGeliang Tang 2610a6094788SGeliang Tang # signal address v4-map-v6 2611c7d49c03SMatthieu Baerts if reset "signal address v4-map-v6"; then 261234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 261334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 261434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2615a6094788SGeliang Tang run_tests $ns1 $ns2 "::ffff:10.0.1.1" 2616c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2617a6094788SGeliang Tang chk_add_nr 1 1 2618ae7bd9ccSMatthieu Baerts fi 2619a6094788SGeliang Tang 2620a6094788SGeliang Tang # subflow v6-map-v4 2621c7d49c03SMatthieu Baerts if reset "single subflow v6-map-v4"; then 262234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 262334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 262434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 "::ffff:10.0.3.2" flags subflow 2625a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2626c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2627ae7bd9ccSMatthieu Baerts fi 2628a6094788SGeliang Tang 2629a6094788SGeliang Tang # signal address v6-map-v4 2630c7d49c03SMatthieu Baerts if reset "signal address v6-map-v4"; then 263134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 263234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 263334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 "::ffff:10.0.2.1" flags signal 2634a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2635c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2636a6094788SGeliang Tang chk_add_nr 1 1 2637ae7bd9ccSMatthieu Baerts fi 2638a6094788SGeliang Tang 2639a6094788SGeliang Tang # no subflow IPv6 to v4 address 2640c7d49c03SMatthieu Baerts if reset "no JOIN with diff families v4-v6"; then 264134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 264234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 264334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow 2644a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2645c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 2646ae7bd9ccSMatthieu Baerts fi 2647a6094788SGeliang Tang 2648a6094788SGeliang Tang # no subflow IPv6 to v4 address even if v6 has a valid v4 at the end 2649c7d49c03SMatthieu Baerts if reset "no JOIN with diff families v4-v6-2"; then 265034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 265134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 265234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 dead:beef:2::10.0.3.2 flags subflow 2653a6094788SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2654c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 2655ae7bd9ccSMatthieu Baerts fi 2656a6094788SGeliang Tang 2657a6094788SGeliang Tang # no subflow IPv4 to v6 address, no need to slow down too then 2658c7d49c03SMatthieu Baerts if reset "no JOIN with diff families v6-v4"; then 265934aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 266034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 266134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2662a6094788SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2663c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 2664ae7bd9ccSMatthieu Baerts fi 26651002b89fSGeliang Tang} 2666a6094788SGeliang Tang 2667ad349374SPaolo Abenimixed_tests() 2668ad349374SPaolo Abeni{ 26696673851bSMatthieu Baerts if reset "IPv4 sockets do not use IPv6 addresses" && 26706673851bSMatthieu Baerts continue_if mptcp_lib_kversion_ge 6.3; then 2671ad349374SPaolo Abeni pm_nl_set_limits $ns1 0 1 2672ad349374SPaolo Abeni pm_nl_set_limits $ns2 1 1 2673ad349374SPaolo Abeni pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 2674e571fb09SGeliang Tang speed=slow \ 2675e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2676ad349374SPaolo Abeni chk_join_nr 0 0 0 2677ad349374SPaolo Abeni fi 2678ad349374SPaolo Abeni 2679ad349374SPaolo Abeni # Need an IPv6 mptcp socket to allow subflows of both families 26806673851bSMatthieu Baerts if reset "simult IPv4 and IPv6 subflows" && 26816673851bSMatthieu Baerts continue_if mptcp_lib_kversion_ge 6.3; then 2682ad349374SPaolo Abeni pm_nl_set_limits $ns1 0 1 2683ad349374SPaolo Abeni pm_nl_set_limits $ns2 1 1 2684ad349374SPaolo Abeni pm_nl_add_endpoint $ns1 10.0.1.1 flags signal 2685e571fb09SGeliang Tang speed=slow \ 2686e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:2::1 2687ad349374SPaolo Abeni chk_join_nr 1 1 1 2688ad349374SPaolo Abeni fi 2689ad349374SPaolo Abeni 2690ad349374SPaolo Abeni # cross families subflows will not be created even in fullmesh mode 26916673851bSMatthieu Baerts if reset "simult IPv4 and IPv6 subflows, fullmesh 1x1" && 26926673851bSMatthieu Baerts continue_if mptcp_lib_kversion_ge 6.3; then 2693ad349374SPaolo Abeni pm_nl_set_limits $ns1 0 4 2694ad349374SPaolo Abeni pm_nl_set_limits $ns2 1 4 2695ad349374SPaolo Abeni pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow,fullmesh 2696ad349374SPaolo Abeni pm_nl_add_endpoint $ns1 10.0.1.1 flags signal 2697e571fb09SGeliang Tang speed=slow \ 2698e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:2::1 2699ad349374SPaolo Abeni chk_join_nr 1 1 1 2700ad349374SPaolo Abeni fi 2701ad349374SPaolo Abeni 2702ad349374SPaolo Abeni # fullmesh still tries to create all the possibly subflows with 2703ad349374SPaolo Abeni # matching family 27046673851bSMatthieu Baerts if reset "simult IPv4 and IPv6 subflows, fullmesh 2x2" && 27056673851bSMatthieu Baerts continue_if mptcp_lib_kversion_ge 6.3; then 2706ad349374SPaolo Abeni pm_nl_set_limits $ns1 0 4 2707ad349374SPaolo Abeni pm_nl_set_limits $ns2 2 4 2708ad349374SPaolo Abeni pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2709ad349374SPaolo Abeni pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal 2710e571fb09SGeliang Tang fullmesh=1 speed=slow \ 2711e571fb09SGeliang Tang run_tests $ns1 $ns2 dead:beef:1::1 2712ad349374SPaolo Abeni chk_join_nr 4 4 4 2713ad349374SPaolo Abeni fi 2714ad349374SPaolo Abeni} 2715ad349374SPaolo Abeni 27161002b89fSGeliang Tangbackup_tests() 27171002b89fSGeliang Tang{ 2718718eb44eSGeliang Tang # single subflow, backup 271907216a3cSMatthieu Baerts if reset "single subflow, backup" && 272007216a3cSMatthieu Baerts continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; 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 10.0.3.2 flags subflow,backup 2724e571fb09SGeliang Tang sflags=nobackup speed=slow \ 2725e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2726c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2727718eb44eSGeliang Tang chk_prio_nr 0 1 2728ae7bd9ccSMatthieu Baerts fi 2729718eb44eSGeliang Tang 2730718eb44eSGeliang Tang # single address, backup 273107216a3cSMatthieu Baerts if reset "single address, backup" && 273207216a3cSMatthieu Baerts continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then 273334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 273434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 273534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2736e571fb09SGeliang Tang sflags=backup speed=slow \ 2737e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2738c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2739718eb44eSGeliang Tang chk_add_nr 1 1 2740d045b9ebSPaolo Abeni chk_prio_nr 1 1 2741ae7bd9ccSMatthieu Baerts fi 274233397b83SGeliang Tang 274333397b83SGeliang Tang # single address with port, backup 274407216a3cSMatthieu Baerts if reset "single address with port, backup" && 274507216a3cSMatthieu Baerts continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then 274634aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 274734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 274834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2749e571fb09SGeliang Tang sflags=backup speed=slow \ 2750e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2751c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 275233397b83SGeliang Tang chk_add_nr 1 1 2753d045b9ebSPaolo Abeni chk_prio_nr 1 1 2754ae7bd9ccSMatthieu Baerts fi 2755914f6a59SPaolo Abeni 2756632978f0SMatthieu Baerts if reset "mpc backup" && 2757632978f0SMatthieu Baerts continue_if mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"; then 2758914f6a59SPaolo Abeni pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,backup 2759e571fb09SGeliang Tang speed=slow \ 2760e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2761914f6a59SPaolo Abeni chk_join_nr 0 0 0 2762914f6a59SPaolo Abeni chk_prio_nr 0 1 2763914f6a59SPaolo Abeni fi 2764914f6a59SPaolo Abeni 2765632978f0SMatthieu Baerts if reset "mpc backup both sides" && 2766632978f0SMatthieu Baerts continue_if mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"; then 2767914f6a59SPaolo Abeni pm_nl_add_endpoint $ns1 10.0.1.1 flags subflow,backup 2768914f6a59SPaolo Abeni pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,backup 2769e571fb09SGeliang Tang speed=slow \ 2770e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2771914f6a59SPaolo Abeni chk_join_nr 0 0 0 2772914f6a59SPaolo Abeni chk_prio_nr 1 1 2773914f6a59SPaolo Abeni fi 2774914f6a59SPaolo Abeni 2775632978f0SMatthieu Baerts if reset "mpc switch to backup" && 2776632978f0SMatthieu Baerts continue_if mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"; then 2777914f6a59SPaolo Abeni pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow 2778e571fb09SGeliang Tang sflags=backup speed=slow \ 2779e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2780914f6a59SPaolo Abeni chk_join_nr 0 0 0 2781914f6a59SPaolo Abeni chk_prio_nr 0 1 2782914f6a59SPaolo Abeni fi 2783914f6a59SPaolo Abeni 2784632978f0SMatthieu Baerts if reset "mpc switch to backup both sides" && 2785632978f0SMatthieu Baerts continue_if mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"; then 2786914f6a59SPaolo Abeni pm_nl_add_endpoint $ns1 10.0.1.1 flags subflow 2787914f6a59SPaolo Abeni pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow 2788e571fb09SGeliang Tang sflags=backup speed=slow \ 2789e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2790914f6a59SPaolo Abeni chk_join_nr 0 0 0 2791914f6a59SPaolo Abeni chk_prio_nr 1 1 2792914f6a59SPaolo Abeni fi 27931002b89fSGeliang Tang} 2794718eb44eSGeliang Tang 2795178d0232SGeliang TangLISTENER_CREATED=15 #MPTCP_EVENT_LISTENER_CREATED 2796178d0232SGeliang TangLISTENER_CLOSED=16 #MPTCP_EVENT_LISTENER_CLOSED 2797178d0232SGeliang Tang 2798178d0232SGeliang TangAF_INET=2 2799178d0232SGeliang TangAF_INET6=10 2800178d0232SGeliang Tang 2801178d0232SGeliang Tangverify_listener_events() 2802178d0232SGeliang Tang{ 2803178d0232SGeliang Tang local evt=$1 2804178d0232SGeliang Tang local e_type=$2 2805178d0232SGeliang Tang local e_family=$3 2806178d0232SGeliang Tang local e_saddr=$4 2807178d0232SGeliang Tang local e_sport=$5 2808178d0232SGeliang Tang local type 2809178d0232SGeliang Tang local family 2810178d0232SGeliang Tang local saddr 2811178d0232SGeliang Tang local sport 281296b84195SMatthieu Baerts local name 2813178d0232SGeliang Tang 2814178d0232SGeliang Tang if [ $e_type = $LISTENER_CREATED ]; then 281596b84195SMatthieu Baerts name="LISTENER_CREATED" 2816178d0232SGeliang Tang elif [ $e_type = $LISTENER_CLOSED ]; then 281796b84195SMatthieu Baerts name="LISTENER_CLOSED " 281896b84195SMatthieu Baerts else 281996b84195SMatthieu Baerts name="$e_type" 2820178d0232SGeliang Tang fi 2821178d0232SGeliang Tang 282203668c65SMatthieu Baerts print_check "$name $e_saddr:$e_sport" 282396b84195SMatthieu Baerts 28240471bb47SMatthieu Baerts if ! mptcp_lib_kallsyms_has "mptcp_event_pm_listener$"; then 282503668c65SMatthieu Baerts print_skip "event not supported" 28260471bb47SMatthieu Baerts return 28270471bb47SMatthieu Baerts fi 28280471bb47SMatthieu Baerts 282996b84195SMatthieu Baerts type=$(grep "type:$e_type," $evt | sed -n 's/.*\(type:\)\([[:digit:]]*\).*$/\2/p;q') 283096b84195SMatthieu Baerts family=$(grep "type:$e_type," $evt | sed -n 's/.*\(family:\)\([[:digit:]]*\).*$/\2/p;q') 283196b84195SMatthieu Baerts sport=$(grep "type:$e_type," $evt | sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q') 2832178d0232SGeliang Tang if [ $family ] && [ $family = $AF_INET6 ]; then 283396b84195SMatthieu Baerts saddr=$(grep "type:$e_type," $evt | sed -n 's/.*\(saddr6:\)\([0-9a-f:.]*\).*$/\2/p;q') 2834178d0232SGeliang Tang else 283596b84195SMatthieu Baerts saddr=$(grep "type:$e_type," $evt | sed -n 's/.*\(saddr4:\)\([0-9.]*\).*$/\2/p;q') 2836178d0232SGeliang Tang fi 2837178d0232SGeliang Tang 2838178d0232SGeliang Tang if [ $type ] && [ $type = $e_type ] && 2839178d0232SGeliang Tang [ $family ] && [ $family = $e_family ] && 2840178d0232SGeliang Tang [ $saddr ] && [ $saddr = $e_saddr ] && 2841178d0232SGeliang Tang [ $sport ] && [ $sport = $e_sport ]; then 284203668c65SMatthieu Baerts print_ok 2843178d0232SGeliang Tang return 0 2844178d0232SGeliang Tang fi 284503668c65SMatthieu Baerts fail_test "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport" 2846178d0232SGeliang Tang} 2847178d0232SGeliang Tang 28481002b89fSGeliang Tangadd_addr_ports_tests() 28491002b89fSGeliang Tang{ 28508a127bf6SGeliang Tang # signal address with port 2851c7d49c03SMatthieu Baerts if reset "signal address with port"; then 285234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 285334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 285434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 28558a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2856c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 28578a127bf6SGeliang Tang chk_add_nr 1 1 1 2858ae7bd9ccSMatthieu Baerts fi 28598a127bf6SGeliang Tang 28608a127bf6SGeliang Tang # subflow and signal with port 2861c7d49c03SMatthieu Baerts if reset "subflow and signal with port"; then 286234aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 286334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 286434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 286534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 28668a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2867c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 28688a127bf6SGeliang Tang chk_add_nr 1 1 1 2869ae7bd9ccSMatthieu Baerts fi 28708a127bf6SGeliang Tang 28718a127bf6SGeliang Tang # single address with port, remove 2872178d0232SGeliang Tang # pm listener events 2873178d0232SGeliang Tang if reset_with_events "remove single address with port"; then 287434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 287534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 287634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 2877e571fb09SGeliang Tang addr_nr_ns1=-1 speed=slow \ 2878e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2879c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 28808a127bf6SGeliang Tang chk_add_nr 1 1 1 28817028ba8aSGeliang Tang chk_rm_nr 1 1 invert 2882178d0232SGeliang Tang 2883178d0232SGeliang Tang verify_listener_events $evts_ns1 $LISTENER_CREATED $AF_INET 10.0.2.1 10100 2884178d0232SGeliang Tang verify_listener_events $evts_ns1 $LISTENER_CLOSED $AF_INET 10.0.2.1 10100 2885178d0232SGeliang Tang kill_events_pids 2886ae7bd9ccSMatthieu Baerts fi 28878a127bf6SGeliang Tang 28888a127bf6SGeliang Tang # subflow and signal with port, remove 2889c7d49c03SMatthieu Baerts if reset "remove subflow and signal with port"; then 289034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 289134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 289234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 289334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2894e571fb09SGeliang Tang addr_nr_ns1=-1 addr_nr_ns2=-1 speed=slow \ 2895e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2896c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 28978a127bf6SGeliang Tang chk_add_nr 1 1 1 28988a127bf6SGeliang Tang chk_rm_nr 1 1 2899ae7bd9ccSMatthieu Baerts fi 29008a127bf6SGeliang Tang 29018a127bf6SGeliang Tang # subflows and signal with port, flush 2902c7d49c03SMatthieu Baerts if reset "flush subflows and signal with port"; then 290334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 290434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 290534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 290634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 290734aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 2908e571fb09SGeliang Tang addr_nr_ns1=-8 addr_nr_ns2=-2 speed=slow \ 2909e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2910c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 29118a127bf6SGeliang Tang chk_add_nr 1 1 29126fa0174aSPaolo Abeni chk_rm_nr 1 3 invert simult 2913ae7bd9ccSMatthieu Baerts fi 29148a127bf6SGeliang Tang 29158a127bf6SGeliang Tang # multiple addresses with port 2916c7d49c03SMatthieu Baerts if reset "multiple addresses with port"; then 291734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 291834aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 291934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10100 292034aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 29218a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2922c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 29238a127bf6SGeliang Tang chk_add_nr 2 2 2 2924ae7bd9ccSMatthieu Baerts fi 29258a127bf6SGeliang Tang 29268a127bf6SGeliang Tang # multiple addresses with ports 2927c7d49c03SMatthieu Baerts if reset "multiple addresses with ports"; then 292834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 292934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 293034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.3.1 flags signal port 10101 293134aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 29328a127bf6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2933c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 29348a127bf6SGeliang Tang chk_add_nr 2 2 2 2935ae7bd9ccSMatthieu Baerts fi 29361002b89fSGeliang Tang} 29378a127bf6SGeliang Tang 29381002b89fSGeliang Tangsyncookies_tests() 29391002b89fSGeliang Tang{ 294000587187SFlorian Westphal # single subflow, syncookies 2941c7d49c03SMatthieu Baerts if reset_with_cookies "single subflow with syn cookies"; then 294234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 294334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 294434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 294500587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 2946c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2947ae7bd9ccSMatthieu Baerts fi 294800587187SFlorian Westphal 294900587187SFlorian Westphal # multiple subflows with syn cookies 2950c7d49c03SMatthieu Baerts if reset_with_cookies "multiple subflows with syn cookies"; then 295134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 295234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 295334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 295434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 295500587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 2956c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2957ae7bd9ccSMatthieu Baerts fi 295800587187SFlorian Westphal 295900587187SFlorian Westphal # multiple subflows limited by server 2960c7d49c03SMatthieu Baerts if reset_with_cookies "subflows limited by server w cookies"; then 296134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 296234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 2 296334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 296434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 296500587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 2966c7d49c03SMatthieu Baerts chk_join_nr 2 1 1 2967ae7bd9ccSMatthieu Baerts fi 296800587187SFlorian Westphal 296900587187SFlorian Westphal # test signal address with cookies 2970c7d49c03SMatthieu Baerts if reset_with_cookies "signal address with syn cookies"; then 297134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 297234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 297334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 297400587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 2975c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 2976be613160SGeliang Tang chk_add_nr 1 1 2977ae7bd9ccSMatthieu Baerts fi 297800587187SFlorian Westphal 297900587187SFlorian Westphal # test cookie with subflow and signal 2980c7d49c03SMatthieu Baerts if reset_with_cookies "subflow and signal w cookies"; then 298134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 298234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 2 298334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 2 298434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 298500587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 2986c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 2987be613160SGeliang Tang chk_add_nr 1 1 2988ae7bd9ccSMatthieu Baerts fi 298900587187SFlorian Westphal 299000587187SFlorian Westphal # accept and use add_addr with additional subflows 2991c7d49c03SMatthieu Baerts if reset_with_cookies "subflows and signal w. cookies"; then 299234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 3 299334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 299434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 299534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 299634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 299700587187SFlorian Westphal run_tests $ns1 $ns2 10.0.1.1 2998c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 2999be613160SGeliang Tang chk_add_nr 1 1 3000ae7bd9ccSMatthieu Baerts fi 30011002b89fSGeliang Tang} 30021002b89fSGeliang Tang 3003af66d3e1SGeliang Tangchecksum_tests() 3004af66d3e1SGeliang Tang{ 3005af66d3e1SGeliang Tang # checksum test 0 0 3006ae7bd9ccSMatthieu Baerts if reset_with_checksum 0 0; then 300734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 300834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 3009af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3010c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 3011ae7bd9ccSMatthieu Baerts fi 3012af66d3e1SGeliang Tang 3013af66d3e1SGeliang Tang # checksum test 1 1 3014ae7bd9ccSMatthieu Baerts if reset_with_checksum 1 1; then 301534aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 301634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 3017af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3018c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 3019ae7bd9ccSMatthieu Baerts fi 3020af66d3e1SGeliang Tang 3021af66d3e1SGeliang Tang # checksum test 0 1 3022ae7bd9ccSMatthieu Baerts if reset_with_checksum 0 1; then 302334aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 302434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 3025af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3026c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 3027ae7bd9ccSMatthieu Baerts fi 3028af66d3e1SGeliang Tang 3029af66d3e1SGeliang Tang # checksum test 1 0 3030ae7bd9ccSMatthieu Baerts if reset_with_checksum 1 0; then 303134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 1 303234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 0 1 3033af66d3e1SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3034c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 3035ae7bd9ccSMatthieu Baerts fi 3036af66d3e1SGeliang Tang} 3037af66d3e1SGeliang Tang 30380cddb4a6SGeliang Tangdeny_join_id0_tests() 30390cddb4a6SGeliang Tang{ 30400cddb4a6SGeliang Tang # subflow allow join id0 ns1 3041c7d49c03SMatthieu Baerts if reset_with_allow_join_id0 "single subflow allow join id0 ns1" 1 0; then 304234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 304334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 304434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 30450cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3046c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 3047ae7bd9ccSMatthieu Baerts fi 30480cddb4a6SGeliang Tang 30490cddb4a6SGeliang Tang # subflow allow join id0 ns2 3050c7d49c03SMatthieu Baerts if reset_with_allow_join_id0 "single subflow allow join id0 ns2" 0 1; then 305134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 305234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 305334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 30540cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3055c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 3056ae7bd9ccSMatthieu Baerts fi 30570cddb4a6SGeliang Tang 30580cddb4a6SGeliang Tang # signal address allow join id0 ns1 30590cddb4a6SGeliang Tang # ADD_ADDRs are not affected by allow_join_id0 value. 3060c7d49c03SMatthieu Baerts if reset_with_allow_join_id0 "signal address allow join id0 ns1" 1 0; then 306134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 306234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 306334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 30640cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3065c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 30660cddb4a6SGeliang Tang chk_add_nr 1 1 3067ae7bd9ccSMatthieu Baerts fi 30680cddb4a6SGeliang Tang 30690cddb4a6SGeliang Tang # signal address allow join id0 ns2 30700cddb4a6SGeliang Tang # ADD_ADDRs are not affected by allow_join_id0 value. 3071c7d49c03SMatthieu Baerts if reset_with_allow_join_id0 "signal address allow join id0 ns2" 0 1; then 307234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 1 307334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 1 307434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 30750cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3076c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 30770cddb4a6SGeliang Tang chk_add_nr 1 1 3078ae7bd9ccSMatthieu Baerts fi 30790cddb4a6SGeliang Tang 30800cddb4a6SGeliang Tang # subflow and address allow join id0 ns1 3081c7d49c03SMatthieu Baerts if reset_with_allow_join_id0 "subflow and address allow join id0 1" 1 0; then 308234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 308334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 308434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 308534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 30860cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3087c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 3088ae7bd9ccSMatthieu Baerts fi 30890cddb4a6SGeliang Tang 30900cddb4a6SGeliang Tang # subflow and address allow join id0 ns2 3091c7d49c03SMatthieu Baerts if reset_with_allow_join_id0 "subflow and address allow join id0 2" 0 1; then 309234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 2 309334aa6e3bSGeliang Tang pm_nl_set_limits $ns2 2 2 309434aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 309534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 30960cddb4a6SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3097c7d49c03SMatthieu Baerts chk_join_nr 1 1 1 3098ae7bd9ccSMatthieu Baerts fi 30990cddb4a6SGeliang Tang} 31000cddb4a6SGeliang Tang 31014f49d633SGeliang Tangfullmesh_tests() 31024f49d633SGeliang Tang{ 31034f49d633SGeliang Tang # fullmesh 1 31044f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added before the connection, 31054f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added during the connection. 3106c7d49c03SMatthieu Baerts if reset "fullmesh test 2x1"; then 310734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 0 4 310834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 4 310934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,fullmesh 311034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,fullmesh 3111e571fb09SGeliang Tang addr_nr_ns1=1 speed=slow \ 3112e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3113c7d49c03SMatthieu Baerts chk_join_nr 4 4 4 31144f49d633SGeliang Tang chk_add_nr 1 1 3115ae7bd9ccSMatthieu Baerts fi 31164f49d633SGeliang Tang 31174f49d633SGeliang Tang # fullmesh 2 31184f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 31194f49d633SGeliang Tang # 1 fullmesh addr in ns2, added during the connection. 3120c7d49c03SMatthieu Baerts if reset "fullmesh test 1x1"; then 312134aa6e3bSGeliang Tang pm_nl_set_limits $ns1 1 3 312234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 3 312334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 3124e571fb09SGeliang Tang fullmesh=1 speed=slow \ 3125e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3126c7d49c03SMatthieu Baerts chk_join_nr 3 3 3 31274f49d633SGeliang Tang chk_add_nr 1 1 3128ae7bd9ccSMatthieu Baerts fi 31294f49d633SGeliang Tang 31304f49d633SGeliang Tang # fullmesh 3 31314f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 31324f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added during the connection. 3133c7d49c03SMatthieu Baerts if reset "fullmesh test 1x2"; then 313434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 5 313534aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 5 313634aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 3137e571fb09SGeliang Tang fullmesh=2 speed=slow \ 3138e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3139c7d49c03SMatthieu Baerts chk_join_nr 5 5 5 31404f49d633SGeliang Tang chk_add_nr 1 1 3141ae7bd9ccSMatthieu Baerts fi 31424f49d633SGeliang Tang 31434f49d633SGeliang Tang # fullmesh 4 31444f49d633SGeliang Tang # 1 non-fullmesh addr in ns1, added before the connection, 31454f49d633SGeliang Tang # 2 fullmesh addrs in ns2, added during the connection, 31464f49d633SGeliang Tang # limit max_subflows to 4. 3147c7d49c03SMatthieu Baerts if reset "fullmesh test 1x2, limited"; then 314834aa6e3bSGeliang Tang pm_nl_set_limits $ns1 2 4 314934aa6e3bSGeliang Tang pm_nl_set_limits $ns2 1 4 315034aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 3151e571fb09SGeliang Tang fullmesh=2 speed=slow \ 3152e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3153c7d49c03SMatthieu Baerts chk_join_nr 4 4 4 31544f49d633SGeliang Tang chk_add_nr 1 1 3155ae7bd9ccSMatthieu Baerts fi 31566a0653b9SGeliang Tang 31576a0653b9SGeliang Tang # set fullmesh flag 31589db34c42SMatthieu Baerts if reset "set fullmesh flag test" && 31599db34c42SMatthieu Baerts continue_if mptcp_lib_kversion_ge 5.18; then 316034aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 316134aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow 316234aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 3163e571fb09SGeliang Tang addr_nr_ns2=1 sflags=fullmesh speed=slow \ 3164e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3165c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 31666a0653b9SGeliang Tang chk_rm_nr 0 1 3167ae7bd9ccSMatthieu Baerts fi 31686a0653b9SGeliang Tang 31696a0653b9SGeliang Tang # set nofullmesh flag 31709db34c42SMatthieu Baerts if reset "set nofullmesh flag test" && 31719db34c42SMatthieu Baerts continue_if mptcp_lib_kversion_ge 5.18; then 317234aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 317334aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow,fullmesh 317434aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 3175e571fb09SGeliang Tang fullmesh=1 sflags=nofullmesh speed=slow \ 3176e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3177c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 31786a0653b9SGeliang Tang chk_rm_nr 0 1 3179ae7bd9ccSMatthieu Baerts fi 31806a0653b9SGeliang Tang 31816a0653b9SGeliang Tang # set backup,fullmesh flags 31829db34c42SMatthieu Baerts if reset "set backup,fullmesh flags test" && 31839db34c42SMatthieu Baerts continue_if mptcp_lib_kversion_ge 5.18; then 318434aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 318534aa6e3bSGeliang Tang pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow 318634aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 3187e571fb09SGeliang Tang addr_nr_ns2=1 sflags=backup,fullmesh speed=slow \ 3188e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3189c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 31906a0653b9SGeliang Tang chk_prio_nr 0 1 31916a0653b9SGeliang Tang chk_rm_nr 0 1 3192ae7bd9ccSMatthieu Baerts fi 31936a0653b9SGeliang Tang 31946a0653b9SGeliang Tang # set nobackup,nofullmesh flags 31959db34c42SMatthieu Baerts if reset "set nobackup,nofullmesh flags test" && 31969db34c42SMatthieu Baerts continue_if mptcp_lib_kversion_ge 5.18; then 319734aa6e3bSGeliang Tang pm_nl_set_limits $ns1 4 4 319834aa6e3bSGeliang Tang pm_nl_set_limits $ns2 4 4 319934aa6e3bSGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,backup,fullmesh 3200e571fb09SGeliang Tang sflags=nobackup,nofullmesh speed=slow \ 3201e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3202c7d49c03SMatthieu Baerts chk_join_nr 2 2 2 32036a0653b9SGeliang Tang chk_prio_nr 0 1 32046a0653b9SGeliang Tang chk_rm_nr 0 1 3205ae7bd9ccSMatthieu Baerts fi 32064f49d633SGeliang Tang} 32074f49d633SGeliang Tang 320801542c9bSGeliang Tangfastclose_tests() 320901542c9bSGeliang Tang{ 3210ae947bb2SMatthieu Baerts if reset_check_counter "fastclose test" "MPTcpExtMPFastcloseTx"; then 3211080b7f57SGeliang Tang test_linkfail=1024 fastclose=client \ 3212595ef566SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3213c7d49c03SMatthieu Baerts chk_join_nr 0 0 0 321401542c9bSGeliang Tang chk_fclose_nr 1 1 321501542c9bSGeliang Tang chk_rst_nr 1 1 invert 3216ae7bd9ccSMatthieu Baerts fi 32176bf41020SPaolo Abeni 3218ae947bb2SMatthieu Baerts if reset_check_counter "fastclose server test" "MPTcpExtMPFastcloseRx"; then 3219080b7f57SGeliang Tang test_linkfail=1024 fastclose=server \ 3220595ef566SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 32216bf41020SPaolo Abeni chk_join_nr 0 0 0 32226bf41020SPaolo Abeni chk_fclose_nr 1 1 invert 32236bf41020SPaolo Abeni chk_rst_nr 1 1 32246bf41020SPaolo Abeni fi 322501542c9bSGeliang Tang} 322601542c9bSGeliang Tang 3227b6e074e1SGeliang Tangpedit_action_pkts() 3228b6e074e1SGeliang Tang{ 3229b6e074e1SGeliang Tang tc -n $ns2 -j -s action show action pedit index 100 | \ 3230c43ce398SGeliang Tang grep "packets" | \ 3231b6e074e1SGeliang Tang sed 's/.*"packets":\([0-9]\+\),.*/\1/' 3232b6e074e1SGeliang Tang} 3233b6e074e1SGeliang Tang 3234b6e074e1SGeliang Tangfail_tests() 3235b6e074e1SGeliang Tang{ 3236b6e074e1SGeliang Tang # single subflow 3237b6e074e1SGeliang Tang if reset_with_fail "Infinite map" 1; then 32380c93af1fSGeliang Tang test_linkfail=128 \ 32390c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 3240b6e074e1SGeliang Tang chk_join_nr 0 0 0 +1 +0 1 0 1 "$(pedit_action_pkts)" 32411f7d325fSGeliang Tang chk_fail_nr 1 -1 invert 3242b6e074e1SGeliang Tang fi 32432ba18161SGeliang Tang 32442ba18161SGeliang Tang # multiple subflows 32452ba18161SGeliang Tang if reset_with_fail "MP_FAIL MP_RST" 2; then 32462ba18161SGeliang Tang tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit delay 5 32472ba18161SGeliang Tang pm_nl_set_limits $ns1 0 1 32482ba18161SGeliang Tang pm_nl_set_limits $ns2 0 1 32492ba18161SGeliang Tang pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow 32500c93af1fSGeliang Tang test_linkfail=1024 \ 32510c93af1fSGeliang Tang run_tests $ns1 $ns2 10.0.1.1 32522ba18161SGeliang Tang chk_join_nr 1 1 1 1 0 1 1 0 "$(pedit_action_pkts)" 32532ba18161SGeliang Tang fi 3254b6e074e1SGeliang Tang} 3255b6e074e1SGeliang Tang 32564369c198SGeliang Tanguserspace_pm_add_addr() 32574369c198SGeliang Tang{ 32584369c198SGeliang Tang local addr=$1 32594369c198SGeliang Tang local id=$2 32604369c198SGeliang Tang local tk 32614369c198SGeliang Tang 32624369c198SGeliang Tang tk=$(grep "type:1," "$evts_ns1" | 32634369c198SGeliang Tang sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q') 32644369c198SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl ann $addr token $tk id $id 32654369c198SGeliang Tang sleep 1 32664369c198SGeliang Tang} 32674369c198SGeliang Tang 32684369c198SGeliang Tanguserspace_pm_rm_sf_addr_ns1() 32694369c198SGeliang Tang{ 32704369c198SGeliang Tang local addr=$1 32714369c198SGeliang Tang local id=$2 32724369c198SGeliang Tang local tk sp da dp 32734369c198SGeliang Tang 32744369c198SGeliang Tang tk=$(grep "type:1," "$evts_ns1" | 32754369c198SGeliang Tang sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q') 32764369c198SGeliang Tang sp=$(grep "type:10" "$evts_ns1" | 32774369c198SGeliang Tang sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q') 32784369c198SGeliang Tang da=$(grep "type:10" "$evts_ns1" | 32794369c198SGeliang Tang sed -n 's/.*\(daddr6:\)\([0-9a-f:.]*\).*$/\2/p;q') 32804369c198SGeliang Tang dp=$(grep "type:10" "$evts_ns1" | 32814369c198SGeliang Tang sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q') 32824369c198SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl rem token $tk id $id 32834369c198SGeliang Tang ip netns exec $ns1 ./pm_nl_ctl dsf lip "::ffff:$addr" \ 32844369c198SGeliang Tang lport $sp rip $da rport $dp token $tk 32854369c198SGeliang Tang wait_rm_addr $ns1 1 32864369c198SGeliang Tang wait_rm_sf $ns1 1 32874369c198SGeliang Tang} 32884369c198SGeliang Tang 32894369c198SGeliang Tanguserspace_pm_add_sf() 32904369c198SGeliang Tang{ 32914369c198SGeliang Tang local addr=$1 32924369c198SGeliang Tang local id=$2 32934369c198SGeliang Tang local tk da dp 32944369c198SGeliang Tang 32954369c198SGeliang Tang tk=$(sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2") 32964369c198SGeliang Tang da=$(sed -n 's/.*\(daddr4:\)\([0-9.]*\).*$/\2/p;q' "$evts_ns2") 32974369c198SGeliang Tang dp=$(sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2") 32984369c198SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl csf lip $addr lid $id \ 32994369c198SGeliang Tang rip $da rport $dp token $tk 33004369c198SGeliang Tang sleep 1 33014369c198SGeliang Tang} 33024369c198SGeliang Tang 33034369c198SGeliang Tanguserspace_pm_rm_sf_addr_ns2() 33044369c198SGeliang Tang{ 33054369c198SGeliang Tang local addr=$1 33064369c198SGeliang Tang local id=$2 33074369c198SGeliang Tang local tk da dp sp 33084369c198SGeliang Tang 33094369c198SGeliang Tang tk=$(sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2") 33104369c198SGeliang Tang da=$(sed -n 's/.*\(daddr4:\)\([0-9.]*\).*$/\2/p;q' "$evts_ns2") 33114369c198SGeliang Tang dp=$(sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2") 33124369c198SGeliang Tang sp=$(grep "type:10" "$evts_ns2" | 33134369c198SGeliang Tang sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q') 33144369c198SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl rem token $tk id $id 33154369c198SGeliang Tang ip netns exec $ns2 ./pm_nl_ctl dsf lip $addr lport $sp \ 33164369c198SGeliang Tang rip $da rport $dp token $tk 33174369c198SGeliang Tang wait_rm_addr $ns2 1 33184369c198SGeliang Tang wait_rm_sf $ns2 1 33194369c198SGeliang Tang} 33204369c198SGeliang Tang 33215ac1d2d6SMat Martineauuserspace_tests() 33225ac1d2d6SMat Martineau{ 33235ac1d2d6SMat Martineau # userspace pm type prevents add_addr 3324f2b492b0SMatthieu Baerts if reset "userspace pm type prevents add_addr" && 3325f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 33265ac1d2d6SMat Martineau set_userspace_pm $ns1 33275ac1d2d6SMat Martineau pm_nl_set_limits $ns1 0 2 33285ac1d2d6SMat Martineau pm_nl_set_limits $ns2 0 2 33295ac1d2d6SMat Martineau pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 33305ac1d2d6SMat Martineau run_tests $ns1 $ns2 10.0.1.1 33315ac1d2d6SMat Martineau chk_join_nr 0 0 0 33325ac1d2d6SMat Martineau chk_add_nr 0 0 33335ac1d2d6SMat Martineau fi 33345ac1d2d6SMat Martineau 3335b3b71bf9SMat Martineau # userspace pm type does not echo add_addr without daemon 3336f2b492b0SMatthieu Baerts if reset "userspace pm no echo w/o daemon" && 3337f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 3338b3b71bf9SMat Martineau set_userspace_pm $ns2 3339b3b71bf9SMat Martineau pm_nl_set_limits $ns1 0 2 3340b3b71bf9SMat Martineau pm_nl_set_limits $ns2 0 2 3341b3b71bf9SMat Martineau pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 3342b3b71bf9SMat Martineau run_tests $ns1 $ns2 10.0.1.1 3343b3b71bf9SMat Martineau chk_join_nr 0 0 0 3344b3b71bf9SMat Martineau chk_add_nr 1 0 3345b3b71bf9SMat Martineau fi 3346b3b71bf9SMat Martineau 33475ac1d2d6SMat Martineau # userspace pm type rejects join 3348f2b492b0SMatthieu Baerts if reset "userspace pm type rejects join" && 3349f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 33505ac1d2d6SMat Martineau set_userspace_pm $ns1 33515ac1d2d6SMat Martineau pm_nl_set_limits $ns1 1 1 33525ac1d2d6SMat Martineau pm_nl_set_limits $ns2 1 1 33535ac1d2d6SMat Martineau pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 33545ac1d2d6SMat Martineau run_tests $ns1 $ns2 10.0.1.1 33555ac1d2d6SMat Martineau chk_join_nr 1 1 0 33565ac1d2d6SMat Martineau fi 33575ac1d2d6SMat Martineau 33585ac1d2d6SMat Martineau # userspace pm type does not send join 3359f2b492b0SMatthieu Baerts if reset "userspace pm type does not send join" && 3360f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 33615ac1d2d6SMat Martineau set_userspace_pm $ns2 33625ac1d2d6SMat Martineau pm_nl_set_limits $ns1 1 1 33635ac1d2d6SMat Martineau pm_nl_set_limits $ns2 1 1 33645ac1d2d6SMat Martineau pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 33655ac1d2d6SMat Martineau run_tests $ns1 $ns2 10.0.1.1 33665ac1d2d6SMat Martineau chk_join_nr 0 0 0 33675ac1d2d6SMat Martineau fi 33685ac1d2d6SMat Martineau 33695ac1d2d6SMat Martineau # userspace pm type prevents mp_prio 3370f2b492b0SMatthieu Baerts if reset "userspace pm type prevents mp_prio" && 3371f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 33725ac1d2d6SMat Martineau set_userspace_pm $ns1 33735ac1d2d6SMat Martineau pm_nl_set_limits $ns1 1 1 33745ac1d2d6SMat Martineau pm_nl_set_limits $ns2 1 1 33755ac1d2d6SMat Martineau pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 3376e571fb09SGeliang Tang sflags=backup speed=slow \ 3377e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 33785ac1d2d6SMat Martineau chk_join_nr 1 1 0 33795ac1d2d6SMat Martineau chk_prio_nr 0 0 33805ac1d2d6SMat Martineau fi 33815ac1d2d6SMat Martineau 33825ac1d2d6SMat Martineau # userspace pm type prevents rm_addr 3383f2b492b0SMatthieu Baerts if reset "userspace pm type prevents rm_addr" && 3384f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 33855ac1d2d6SMat Martineau set_userspace_pm $ns1 33865ac1d2d6SMat Martineau set_userspace_pm $ns2 33875ac1d2d6SMat Martineau pm_nl_set_limits $ns1 0 1 33885ac1d2d6SMat Martineau pm_nl_set_limits $ns2 0 1 33895ac1d2d6SMat Martineau pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 3390e571fb09SGeliang Tang addr_nr_ns2=-1 speed=slow \ 3391e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 33925ac1d2d6SMat Martineau chk_join_nr 0 0 0 33935ac1d2d6SMat Martineau chk_rm_nr 0 0 33945ac1d2d6SMat Martineau fi 339597040cf9SGeliang Tang 339697040cf9SGeliang Tang # userspace pm add & remove address 3397f2b492b0SMatthieu Baerts if reset_with_events "userspace pm add & remove address" && 3398f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 339997040cf9SGeliang Tang set_userspace_pm $ns1 340097040cf9SGeliang Tang pm_nl_set_limits $ns2 1 1 3401e571fb09SGeliang Tang speed=10 \ 3402e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 & 34034369c198SGeliang Tang local tests_pid=$! 34044369c198SGeliang Tang wait_mpj $ns1 34054369c198SGeliang Tang userspace_pm_add_addr 10.0.2.1 10 340697040cf9SGeliang Tang chk_join_nr 1 1 1 340797040cf9SGeliang Tang chk_add_nr 1 1 3408d7ced753SGeliang Tang chk_mptcp_info subflows 1 subflows 1 3409d7ced753SGeliang Tang chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 34104369c198SGeliang Tang userspace_pm_rm_sf_addr_ns1 10.0.2.1 10 341197040cf9SGeliang Tang chk_rm_nr 1 1 invert 3412d7ced753SGeliang Tang chk_mptcp_info subflows 0 subflows 0 3413a3735625SGeliang Tang kill_events_pids 34144369c198SGeliang Tang wait $tests_pid 341597040cf9SGeliang Tang fi 34165e986ec4SGeliang Tang 34175e986ec4SGeliang Tang # userspace pm create destroy subflow 3418f2b492b0SMatthieu Baerts if reset_with_events "userspace pm create destroy subflow" && 3419f2b492b0SMatthieu Baerts continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 34205e986ec4SGeliang Tang set_userspace_pm $ns2 34215e986ec4SGeliang Tang pm_nl_set_limits $ns1 0 1 3422e571fb09SGeliang Tang speed=10 \ 3423e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 & 34244369c198SGeliang Tang local tests_pid=$! 34254369c198SGeliang Tang wait_mpj $ns2 34264369c198SGeliang Tang userspace_pm_add_sf 10.0.3.2 20 34275e986ec4SGeliang Tang chk_join_nr 1 1 1 3428d7ced753SGeliang Tang chk_mptcp_info subflows 1 subflows 1 34294369c198SGeliang Tang userspace_pm_rm_sf_addr_ns2 10.0.3.2 20 34306c160b63SGeliang Tang chk_rm_nr 1 1 3431d7ced753SGeliang Tang chk_mptcp_info subflows 0 subflows 0 3432a3735625SGeliang Tang kill_events_pids 34334369c198SGeliang Tang wait $tests_pid 34345e986ec4SGeliang Tang fi 34355ac1d2d6SMat Martineau} 34365ac1d2d6SMat Martineau 3437e274f715SPaolo Abeniendpoint_tests() 343869c6ce7bSPaolo Abeni{ 343936c4127aSMatthieu Baerts # subflow_rebuild_header is needed to support the implicit flag 344069c6ce7bSPaolo Abeni # userspace pm type prevents add_addr 344136c4127aSMatthieu Baerts if reset "implicit EP" && 344236c4127aSMatthieu Baerts mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then 344369c6ce7bSPaolo Abeni pm_nl_set_limits $ns1 2 2 344469c6ce7bSPaolo Abeni pm_nl_set_limits $ns2 2 2 344569c6ce7bSPaolo Abeni pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 3446e571fb09SGeliang Tang speed=slow \ 3447e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2>/dev/null & 344869c6ce7bSPaolo Abeni 344969c6ce7bSPaolo Abeni wait_mpj $ns1 345003668c65SMatthieu Baerts pm_nl_check_endpoint "creation" \ 345169c6ce7bSPaolo Abeni $ns2 10.0.2.2 id 1 flags implicit 3452d7ced753SGeliang Tang chk_mptcp_info subflows 1 subflows 1 3453d7ced753SGeliang Tang chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 345469c6ce7bSPaolo Abeni 345569c6ce7bSPaolo Abeni pm_nl_add_endpoint $ns2 10.0.2.2 id 33 345603668c65SMatthieu Baerts pm_nl_check_endpoint "ID change is prevented" \ 345769c6ce7bSPaolo Abeni $ns2 10.0.2.2 id 1 flags implicit 345869c6ce7bSPaolo Abeni 345969c6ce7bSPaolo Abeni pm_nl_add_endpoint $ns2 10.0.2.2 flags signal 346003668c65SMatthieu Baerts pm_nl_check_endpoint "modif is allowed" \ 346169c6ce7bSPaolo Abeni $ns2 10.0.2.2 id 1 flags signal 3462070d6dafSMatthieu Baerts kill_tests_wait 3463ae7bd9ccSMatthieu Baerts fi 3464e274f715SPaolo Abeni 346536c4127aSMatthieu Baerts if reset "delete and re-add" && 346636c4127aSMatthieu Baerts mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then 3467e274f715SPaolo Abeni pm_nl_set_limits $ns1 1 1 3468e274f715SPaolo Abeni pm_nl_set_limits $ns2 1 1 3469e274f715SPaolo Abeni pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow 3470e571fb09SGeliang Tang test_linkfail=4 speed=20 \ 3471e571fb09SGeliang Tang run_tests $ns1 $ns2 10.0.1.1 2>/dev/null & 3472e274f715SPaolo Abeni 3473e274f715SPaolo Abeni wait_mpj $ns2 347403668c65SMatthieu Baerts chk_subflow_nr "before delete" 2 3475d7ced753SGeliang Tang chk_mptcp_info subflows 1 subflows 1 34769095ce97SGeliang Tang 3477e274f715SPaolo Abeni pm_nl_del_endpoint $ns2 2 10.0.2.2 3478e274f715SPaolo Abeni sleep 0.5 347903668c65SMatthieu Baerts chk_subflow_nr "after delete" 1 3480d7ced753SGeliang Tang chk_mptcp_info subflows 0 subflows 0 3481e274f715SPaolo Abeni 3482e274f715SPaolo Abeni pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow 3483e274f715SPaolo Abeni wait_mpj $ns2 348403668c65SMatthieu Baerts chk_subflow_nr "after re-add" 2 3485d7ced753SGeliang Tang chk_mptcp_info subflows 1 subflows 1 3486070d6dafSMatthieu Baerts kill_tests_wait 3487e274f715SPaolo Abeni fi 348869c6ce7bSPaolo Abeni} 348969c6ce7bSPaolo Abeni 349022514d52SMatthieu Baerts# [$1: error message] 34911002b89fSGeliang Tangusage() 34921002b89fSGeliang Tang{ 349322514d52SMatthieu Baerts if [ -n "${1}" ]; then 349422514d52SMatthieu Baerts echo "${1}" 349522514d52SMatthieu Baerts ret=1 349622514d52SMatthieu Baerts fi 349722514d52SMatthieu Baerts 34981002b89fSGeliang Tang echo "mptcp_join usage:" 34993afd0280SMatthieu Baerts 35003afd0280SMatthieu Baerts local key 35013afd0280SMatthieu Baerts for key in "${!all_tests[@]}"; do 35023afd0280SMatthieu Baerts echo " -${key} ${all_tests[${key}]}" 35033afd0280SMatthieu Baerts done 35043afd0280SMatthieu Baerts 3505a673321aSMat Martineau echo " -c capture pcap files" 3506af66d3e1SGeliang Tang echo " -C enable data checksum" 3507621bd393SGeliang Tang echo " -i use ip mptcp" 35081002b89fSGeliang Tang echo " -h help" 350922514d52SMatthieu Baerts 3510c7d49c03SMatthieu Baerts echo "[test ids|names]" 3511ae7bd9ccSMatthieu Baerts 351222514d52SMatthieu Baerts exit ${ret} 35131002b89fSGeliang Tang} 35141002b89fSGeliang Tang 3515a673321aSMat Martineau 35163afd0280SMatthieu Baerts# Use a "simple" array to force an specific order we cannot have with an associative one 35173afd0280SMatthieu Baertsall_tests_sorted=( 35183afd0280SMatthieu Baerts f@subflows_tests 35193afd0280SMatthieu Baerts e@subflows_error_tests 35203afd0280SMatthieu Baerts s@signal_address_tests 35213afd0280SMatthieu Baerts l@link_failure_tests 35223afd0280SMatthieu Baerts t@add_addr_timeout_tests 35233afd0280SMatthieu Baerts r@remove_tests 35243afd0280SMatthieu Baerts a@add_tests 35253afd0280SMatthieu Baerts 6@ipv6_tests 35263afd0280SMatthieu Baerts 4@v4mapped_tests 3527ad349374SPaolo Abeni M@mixed_tests 35283afd0280SMatthieu Baerts b@backup_tests 35293afd0280SMatthieu Baerts p@add_addr_ports_tests 35303afd0280SMatthieu Baerts k@syncookies_tests 35313afd0280SMatthieu Baerts S@checksum_tests 35323afd0280SMatthieu Baerts d@deny_join_id0_tests 35333afd0280SMatthieu Baerts m@fullmesh_tests 35343afd0280SMatthieu Baerts z@fastclose_tests 3535b6e074e1SGeliang Tang F@fail_tests 35365ac1d2d6SMat Martineau u@userspace_tests 3537e274f715SPaolo Abeni I@endpoint_tests 35383afd0280SMatthieu Baerts) 35393afd0280SMatthieu Baerts 35403afd0280SMatthieu Baertsall_tests_args="" 35413afd0280SMatthieu Baertsall_tests_names=() 35423afd0280SMatthieu Baertsfor subtests in "${all_tests_sorted[@]}"; do 35433afd0280SMatthieu Baerts key="${subtests%@*}" 35443afd0280SMatthieu Baerts value="${subtests#*@}" 35453afd0280SMatthieu Baerts 35463afd0280SMatthieu Baerts all_tests_args+="${key}" 35473afd0280SMatthieu Baerts all_tests_names+=("${value}") 35483afd0280SMatthieu Baerts all_tests[${key}]="${value}" 35493afd0280SMatthieu Baertsdone 35503afd0280SMatthieu Baerts 3551826d7bdcSMatthieu Baertstests=() 35523afd0280SMatthieu Baertswhile getopts "${all_tests_args}cCih" opt; do 35531002b89fSGeliang Tang case $opt in 35543afd0280SMatthieu Baerts ["${all_tests_args}"]) 35553afd0280SMatthieu Baerts tests+=("${all_tests[${opt}]}") 355669c6ce7bSPaolo Abeni ;; 3557a673321aSMat Martineau c) 3558826d7bdcSMatthieu Baerts capture=1 3559a673321aSMat Martineau ;; 3560af66d3e1SGeliang Tang C) 3561826d7bdcSMatthieu Baerts checksum=1 3562af66d3e1SGeliang Tang ;; 3563621bd393SGeliang Tang i) 3564826d7bdcSMatthieu Baerts ip_mptcp=1 3565621bd393SGeliang Tang ;; 356622514d52SMatthieu Baerts h) 35671002b89fSGeliang Tang usage 35681002b89fSGeliang Tang ;; 356922514d52SMatthieu Baerts *) 357022514d52SMatthieu Baerts usage "Unknown option: -${opt}" 357122514d52SMatthieu Baerts ;; 35721002b89fSGeliang Tang esac 35731002b89fSGeliang Tangdone 357400587187SFlorian Westphal 3575ae7bd9ccSMatthieu Baertsshift $((OPTIND - 1)) 3576ae7bd9ccSMatthieu Baerts 3577ae7bd9ccSMatthieu Baertsfor arg in "${@}"; do 3578ae7bd9ccSMatthieu Baerts if [[ "${arg}" =~ ^[0-9]+$ ]]; then 3579c7d49c03SMatthieu Baerts only_tests_ids+=("${arg}") 3580ae7bd9ccSMatthieu Baerts else 3581c7d49c03SMatthieu Baerts only_tests_names+=("${arg}") 3582ae7bd9ccSMatthieu Baerts fi 3583ae7bd9ccSMatthieu Baertsdone 3584ae7bd9ccSMatthieu Baerts 3585826d7bdcSMatthieu Baertsif [ ${#tests[@]} -eq 0 ]; then 35863afd0280SMatthieu Baerts tests=("${all_tests_names[@]}") 35873afd0280SMatthieu Baertsfi 35883afd0280SMatthieu Baerts 3589826d7bdcSMatthieu Baertsfor subtests in "${tests[@]}"; do 3590826d7bdcSMatthieu Baerts "${subtests}" 3591826d7bdcSMatthieu Baertsdone 3592826d7bdcSMatthieu Baerts 359339aab882SMatthieu Baertsif [ ${ret} -ne 0 ]; then 359439aab882SMatthieu Baerts echo 359539aab882SMatthieu Baerts echo "${#failed_tests[@]} failure(s) has(ve) been detected:" 359639aab882SMatthieu Baerts for i in $(get_failed_tests_ids); do 359739aab882SMatthieu Baerts echo -e "\t- ${i}: ${failed_tests[${i}]}" 359839aab882SMatthieu Baerts done 359939aab882SMatthieu Baerts echo 360039aab882SMatthieu Baertsfi 360139aab882SMatthieu Baerts 36027f117cd3SMatthieu Baertsappend_prev_results 36037f117cd3SMatthieu Baertsmptcp_lib_result_print_all_tap 36047f117cd3SMatthieu Baerts 3605b08fbf24SPaolo Abeniexit $ret 3606