Lines Matching +full:local +full:- +full:pid
2 # SPDX-License-Identifier: GPL-2.0
12 readonly KSFT_TEST="${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}"
14 # These variables are used in some selftests, read-only
15 declare -rx MPTCP_LIB_EVENT_CREATED=1 # MPTCP_EVENT_CREATED
16 declare -rx MPTCP_LIB_EVENT_ESTABLISHED=2 # MPTCP_EVENT_ESTABLISHED
17 declare -rx MPTCP_LIB_EVENT_CLOSED=3 # MPTCP_EVENT_CLOSED
18 declare -rx MPTCP_LIB_EVENT_ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED
19 declare -rx MPTCP_LIB_EVENT_REMOVED=7 # MPTCP_EVENT_REMOVED
20 declare -rx MPTCP_LIB_EVENT_SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED
21 declare -rx MPTCP_LIB_EVENT_SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED
22 declare -rx MPTCP_LIB_EVENT_SUB_PRIORITY=13 # MPTCP_EVENT_SUB_PRIORITY
23 declare -rx MPTCP_LIB_EVENT_LISTENER_CREATED=15 # MPTCP_EVENT_LISTENER_CREATED
24 declare -rx MPTCP_LIB_EVENT_LISTENER_CLOSED=16 # MPTCP_EVENT_LISTENER_CLOSED
26 declare -rx MPTCP_LIB_AF_INET=2
27 declare -rx MPTCP_LIB_AF_INET6=10
34 MPTCP_LIB_TEST_FORMAT="%02u %-50s"
37 # only if supported (or forced) and not disabled, see no-color.org
38 if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } &&
39 [ "${NO_COLOR:-}" != "1" ]; then
56 [ "${SELFTESTS_MPTCP_LIB_OVERRIDE_FLAKY:-}" = 1 ]
65 echo -e "${MPTCP_LIB_START_PRINT:-}${*}${MPTCP_LIB_COLOR_RESET}"
94 local title cmt
110 # $1-2: listener/connector ns ; $3 port ; $4-5 listener/connector stat file
112 local lns="${1}"
113 local cns="${2}"
114 local port="${3}"
115 local lstat="${4}"
116 local cstat="${5}"
118 echo -en "${MPTCP_LIB_COLOR_RED}"
121 ip netns exec "${lns}" ss -Menitam -o "sport = :${port}"
125 ip netns exec "${cns}" ss -Menitam -o "dport = :${port}"
128 echo -en "${MPTCP_LIB_COLOR_RESET}"
135 [ "${SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES:-}" = "1" ]
150 local f="${1}"
152 if [ -f "${f}" ]; then
175 local sym="${1}"
179 grep -q " ${sym}" /proc/kallsyms
184 local sym="${1}"
195 local sym="${1}"
209 local exp_maj="${1%.*}"
210 local exp_min="${1#*.}"
211 local v maj min
214 if [ "${SELFTESTS_MPTCP_LIB_NO_KVERSION_CHECK:-}" = "1" ]; then
218 v=$(uname -r | cut -d'.' -f1,2)
222 if [ "${maj}" -gt "${exp_maj}" ] ||
223 { [ "${maj}" -eq "${exp_maj}" ] && [ "${min}" -ge "${exp_min}" ]; }; then
236 local subtest
239 if [[ "${subtest}" == *" - ${KSFT_TEST}: ${*%% #*}" ]]; then
248 local result="${1}"
249 local time="time="
250 local ts_prev_ms
253 local id=$((${#MPTCP_LIB_SUBTESTS[@]} + 1))
262 time+="$((MPTCP_LIB_SUBTESTS_LAST_TS_MS - ts_prev_ms))ms"
264 MPTCP_LIB_SUBTESTS+=("${result} ${id} - ${KSFT_TEST}: ${*} ${time}")
290 local ret="${1}"
291 local name="${2}"
311 local subtest
313 if [ ${#MPTCP_LIB_SUBTESTS[@]} -eq 0 ] ||
314 [ "${SELFTESTS_MPTCP_LIB_NO_TAP:-}" = "1" ]; then
334 grep "${2}" | sed -n 's/.*\('"${1}"':\)\([0-9a-f:.]*\).*$/\2/p;q'
339 grep "${4:-}" "${2}" | mptcp_lib_get_info_value "${1}" "^type:${3:-1},"
342 # $1: PID
344 [ "${1}" -eq 0 ] && return 0
346 kill -SIGUSR1 "${1}" > /dev/null 2>&1
353 [ -z "${1##*:*}" ]
358 local ns="${1}"
359 local counter="${2}"
360 local count
362 count=$(ip netns exec "${ns}" nstat -asz "${counter}" |
364 if [ -z "${count}" ]; then
373 local name="${1}"
374 local bs="${2}"
375 local size="${3}"
378 echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "${name}"
383 ls -l "${1}" 1>&2
385 tail -c 27 "${1}"
390 local in="${1}"
391 local out="${2}"
392 local what="${3}"
411 local err="${1}"
412 local cmd="${2}"
413 local expected="${3}"
414 local cmd_ret=0
415 local out
421 if [ ${cmd_ret} -ne 0 ]; then
434 local tool
439 if ! ip -Version &> /dev/null; then
445 if ! tc -help &> /dev/null; then
451 if ! ss -h | grep -q MPTCP; then
457 if ! "${tool}" -V &> /dev/null; then
476 local netns
478 ip netns exec "${!netns}" sysctl -q net.mptcp.enabled=1
479 ip netns exec "${!netns}" sysctl -q net.ipv4.conf.all.rp_filter=0
480 ip netns exec "${!netns}" sysctl -q net.ipv4.conf.default.rp_filter=0
487 local netns
489 rm -f /tmp/"${netns}".{nstat,out}
494 local ns="${1}"
495 local evts="${2}"
496 declare -n pid="${3}"
500 mptcp_lib_kill_wait "${pid:-0}"
502 pid=$!
515 local var="${1}"
516 local exp="e_${var}"
517 local prev_ret="${2}"
533 local rc=0
534 local var
545 local evt=${1}
546 local e_type=${2}
547 local e_family=${3}
548 local e_saddr=${4}
549 local e_sport=${5}
550 local type
551 local family
552 local saddr
553 local sport
554 local rc=0
579 local entry id ip flags dev port
582 IFS=, read -r id ip flags dev port <<< "${entry}"
584 echo -n "${ip}"
585 [ -n "${port}" ] && echo -n " port ${port}"
586 echo -n " id ${id}"
587 [ -n "${flags}" ] && echo -n " ${flags}"
588 [ -n "${dev}" ] && echo -n " dev ${dev}"
591 echo -n "id ${id}"
592 echo -n " flags ${flags//" "/","}"
593 [ -n "${dev}" ] && echo -n " dev ${dev}"
594 echo -n " ${ip}"
595 [ -n "${port}" ] && echo -n " ${port}"
602 local ns=${1}
603 local id=${2}
606 ip -n "${ns}" mptcp endpoint show id "${id}"
613 local ns=${1}
614 local addrs=${2}
615 local subflows=${3}
618 ip -n "${ns}" mptcp limits set add_addr_accepted "${addrs}" subflows "${subflows}"
625 local ns=${1}
626 local addr=${2}
627 local flags dev id port
628 local nr=2
630 local p
643 ip -n "${ns}" mptcp endpoint add "${addr}" ${flags//","/" "} \
652 local ns=${1}
653 local id=${2}
654 local addr=${3}
657 [ "${id}" -ne 0 ] && addr=''
658 ip -n "${ns}" mptcp endpoint delete id "${id}" ${addr:+"${addr}"}
665 local ns=${1}
668 ip -n "${ns}" mptcp endpoint flush
675 local ns=${1}
678 ip -n "${ns}" mptcp endpoint show
685 local ns=${1}
686 local id=${2}
687 local flags=${3}
691 ip -n "${ns}" mptcp endpoint change id "${id}" ${flags//","/" "}