Skip to content

Commit

Permalink
selftests: mptcp: test last time mptcp_info
Browse files Browse the repository at this point in the history
This patch adds a new helper chk_msk_info() to show the counters in
mptcp_info of the given info, and check that the timestamps move
forward. Use it to show newly added last_data_sent, last_data_recv
and last_ack_recv in mptcp_info in chk_last_time_info().

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang authored and intel-lab-lkp committed Apr 2, 2024
1 parent 095dce9 commit e9c82dd
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tools/testing/selftests/net/mptcp/diag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,53 @@ chk_msk_cestab()
"${expected}" "${msg}" ""
}

msk_info_get_value()
{
local port="${1}"
local info="${2}"

ss -N ${ns} -inHM dport ${port} | \
mptcp_lib_get_info_value "${info}" "${info}"
}

chk_msk_info()
{
local port="${1}"
local info="${2}"
local cnt="${3}"
local now=$(msk_info_get_value ${port} "${info}")
local delta_ms=250

mptcp_lib_print_title "....chk ${info}"
if { [ -z "${cnt}" ] || [ -z "${now}" ]; } &&
! mptcp_lib_expect_all_features; then
mptcp_lib_pr_skip "Feature probably not supported"
mptcp_lib_result_skip "${info}"
elif [ "$((cnt1 + ${delta_ms}))" -lt "${now}" ]; then
mptcp_lib_pr_ok
mptcp_lib_result_pass "${info}"
else
mptcp_lib_pr_fail "value of ${info} changed by $((now - cnt))ms," \
"expected at least ${delta_ms}ms"
mptcp_lib_result_fail "${info}"
ret=${KSFT_FAIL}
fi
}

chk_last_time_info()
{
local port="${1}"
local cnt1=$(msk_info_get_value ${port} "last_data_sent")
local cnt2=$(msk_info_get_value ${port} "last_data_recv")
local cnt3=$(msk_info_get_value ${port} "last_ack_recv")

sleep 0.5

chk_msk_info "${port}" "last_data_sent" "${cnt1}"
chk_msk_info "${port}" "last_data_recv" "${cnt2}"
chk_msk_info "${port}" "last_ack_recv" "${cnt3}"
}

wait_connected()
{
local listener_ns="${1}"
Expand Down Expand Up @@ -233,6 +280,7 @@ echo "b" | \
127.0.0.1 >/dev/null &
wait_connected $ns 10000
chk_msk_nr 2 "after MPC handshake "
chk_last_time_info 10000
chk_msk_remote_key_nr 2 "....chk remote_key"
chk_msk_fallback_nr 0 "....chk no fallback"
chk_msk_inuse 2
Expand Down

0 comments on commit e9c82dd

Please sign in to comment.