This patch introduces a new 'chk_diag' test in diag.sh. It retrieves
the token for a specified MPTCP socket (msk) using the 'ss' command and
then accesses the 'mptcp_diag_dump_one' in kernel via ./mptcp_diag
to verify if the correct token is returned.
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/524
Signed-off-by: Gang Yan <yangang@kylinos.cn>
---
tools/testing/selftests/net/mptcp/diag.sh | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
index 2bd0c1eb70c5..9a57c27b14b9 100755
--- a/tools/testing/selftests/net/mptcp/diag.sh
+++ b/tools/testing/selftests/net/mptcp/diag.sh
@@ -200,6 +200,28 @@ chk_msk_cestab()
"${expected}" "${msg}" ""
}
+chk_dumpone()
+{
+ local ss_token="$(ss -inmHMN $ns | grep 'token:' |\
+ head -n 1 |\
+ sed 's/.*token:\([0-9a-f]*\).*/\1/')"
+ local token="$(ip netns exec $ns ./mptcp_diag -t $ss_token |\
+ grep 'token:' |\
+ sed 's/.*token:\([0-9a-f]*\).*/\1/')"
+ local msg="...chk dumpone"
+
+ mptcp_lib_print_title "$msg"
+ if [ "$ss_token" != "$token" ]; then
+ mptcp_lib_pr_fail "expected $ss_token found $token"
+ mptcp_lib_result_fail "${msg}"
+ ret=${KSFT_FAIL}
+ else
+ mptcp_lib_pr_ok
+ mptcp_lib_result_pass "${msg}"
+ fi
+
+}
+
msk_info_get_value()
{
local port="${1}"
@@ -290,6 +312,7 @@ chk_msk_remote_key_nr 2 "....chk remote_key"
chk_msk_fallback_nr 0 "....chk no fallback"
chk_msk_inuse 2
chk_msk_cestab 2
+chk_dumpone
flush_pids
chk_msk_inuse 0 "2->0"
--
2.43.0
Hi Gang Yan, On 20/02/2025 08:11, Gang Yan wrote: > This patch introduces a new 'chk_diag' test in diag.sh. It retrieves > the token for a specified MPTCP socket (msk) using the 'ss' command and > then accesses the 'mptcp_diag_dump_one' in kernel via ./mptcp_diag > to verify if the correct token is returned. > > Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/524 > Signed-off-by: Gang Yan <yangang@kylinos.cn> > --- > tools/testing/selftests/net/mptcp/diag.sh | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh > index 2bd0c1eb70c5..9a57c27b14b9 100755 > --- a/tools/testing/selftests/net/mptcp/diag.sh > +++ b/tools/testing/selftests/net/mptcp/diag.sh > @@ -200,6 +200,28 @@ chk_msk_cestab() > "${expected}" "${msg}" "" > } > > +chk_dumpone() > +{ > + local ss_token="$(ss -inmHMN $ns | grep 'token:' |\ > + head -n 1 |\ > + sed 's/.*token:\([0-9a-f]*\).*/\1/')" > + local token="$(ip netns exec $ns ./mptcp_diag -t $ss_token |\ > + grep 'token:' |\ > + sed 's/.*token:\([0-9a-f]*\).*/\1/')" (Or use "grep 'token:' | cut -d: -f2") BTW, mptcp_diag should probably print all the different fields from mptcp_info, and add a space after ':' token: (...) bytes_sent: (...) And then we could do this: ./mptcp_diag -t (...) | awk '/^token: / { print $2 }' > + local msg="...chk dumpone" There should be one more '.'. See the tests logs: # 13 ....chk 2 cestab [ OK ] # 14 ...chk dumpone [ OK ] # 15 ....chk 2->0 msk in use after flush [ OK ] Also, probably better with 'dump_one'. > + > + mptcp_lib_print_title "$msg" > + if [ "$ss_token" != "$token" ]; then Please use tabs for the indentation. > + mptcp_lib_pr_fail "expected $ss_token found $token" > + mptcp_lib_result_fail "${msg}" > + ret=${KSFT_FAIL} > + else > + mptcp_lib_pr_ok > + mptcp_lib_result_pass "${msg}" Please use tabs for the indentation. > + fi > + > +} > + > msk_info_get_value() > { > local port="${1}" > @@ -290,6 +312,7 @@ chk_msk_remote_key_nr 2 "....chk remote_key" > chk_msk_fallback_nr 0 "....chk no fallback" > chk_msk_inuse 2 > chk_msk_cestab 2 > +chk_dumpone > flush_pids > > chk_msk_inuse 0 "2->0" Cheers, Matt -- Sponsored by the NGI0 Core fund.
© 2016 - 2025 Red Hat, Inc.