MPTCP Linux Development
 help / color / mirror / Atom feed
From: menglong8.dong@gmail.com
To: mathew.j.martineau@linux.intel.com
Cc: mptcp@lists.linux.dev, Menglong Dong <imagedong@tencent.com>
Subject: [PATCH mptcp-next v5 3/3] selftest: mptcp: add test for mptcp socket in use
Date: Fri,  7 Oct 2022 17:29:22 +0800	[thread overview]
Message-ID: <20221007092922.13169-4-imagedong@tencent.com> (raw)
In-Reply-To: <20221007092922.13169-1-imagedong@tencent.com>

From: Menglong Dong <imagedong@tencent.com>

Add the function chk_msk_inuse() to diag.sh, which is used to check the
statistics of mptcp socket in use. As mptcp socket in listen state will
be closed randomly after 'accept', we need to get the count of listening
mptcp socket through 'ss' command.

mptcp_connect command with '-r' flag seems won't exit after flush_pids,
therefore we need consider this additional statistics. But after the
second flush_pids, it will exit.

All tests pass.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
---
 tools/testing/selftests/net/mptcp/diag.sh | 28 +++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
index 515859a5168b..d969cb45b8a9 100755
--- a/tools/testing/selftests/net/mptcp/diag.sh
+++ b/tools/testing/selftests/net/mptcp/diag.sh
@@ -141,6 +141,28 @@ chk_msk_listen()
 	nr=$(ss -Ml $filter | wc -l)
 }
 
+chk_msk_inuse()
+{
+	local nr listen_nr
+	local expected=$1
+
+	shift 1
+	msg=$*
+
+	nr=$(ip netns exec $ns awk '$1~/^MPTCP$/{print $3}' /proc/net/protocols)
+	listen_nr=$(ss -N $ns -Ml | grep -c LISTEN)
+	expected=$(($expected+$listen_nr))
+
+	printf "%-50s" "$msg"
+
+	if [ $nr != $expected ]; then
+		echo "[ fail ] expected $expected found $nr"
+		ret=$test_cnt
+	else
+		echo "[  ok  ]"
+	fi
+}
+
 # $1: ns, $2: port
 wait_local_port_listen()
 {
@@ -194,8 +216,11 @@ wait_connected $ns 10000
 chk_msk_nr 2 "after MPC handshake "
 chk_msk_remote_key_nr 2 "....chk remote_key"
 chk_msk_fallback_nr 0 "....chk no fallback"
+chk_msk_inuse 2 "msk in use statistics"
 flush_pids
 
+# with '-r' flag, client won't exit after flush_pids
+chk_msk_inuse 1 "msk in use statistics"
 
 echo "a" | \
 	timeout ${timeout_test} \
@@ -231,6 +256,9 @@ for I in `seq 1 $NR_CLIENTS`; do
 done
 
 wait_msk_nr $((NR_CLIENTS*2)) "many msk socket present"
+chk_msk_inuse $((NR_CLIENTS*2+1)) "msk in use statistics"
 flush_pids
 
+chk_msk_inuse 0 "msk in use statistics"
+
 exit $ret
-- 
2.37.2


  parent reply	other threads:[~2022-10-07  9:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-07  9:29 [PATCH mptcp-next v5 0/3] mptcp: add statistics for mptcp socket in use menglong8.dong
2022-10-07  9:29 ` [PATCH mptcp-next v5 1/3] mptcp: introduce 'sk' to replace 'sock->sk' in mptcp_listen() menglong8.dong
2022-10-07  9:29 ` [PATCH mptcp-next v5 2/3] mptcp: add statistics for mptcp socket in use menglong8.dong
2022-10-11  1:11   ` Mat Martineau
2022-10-11  2:23     ` Menglong Dong
2022-10-12  0:51       ` Mat Martineau
2022-10-07  9:29 ` menglong8.dong [this message]
2022-10-07 10:57   ` selftest: mptcp: add test for mptcp socket in use: Tests Results MPTCP CI
2022-10-12  2:24   ` MPTCP CI
2022-10-12 11:31   ` [PATCH mptcp-next v5 3/3] selftest: mptcp: add test for mptcp socket in use Matthieu Baerts
2022-10-12  0:53 ` [PATCH mptcp-next v5 0/3] mptcp: add statistics " Mat Martineau
2022-10-12  9:29   ` Matthieu Baerts
2022-10-12 10:13     ` Menglong Dong
2022-10-28  3:18     ` Menglong Dong
2022-10-31 17:07       ` Matthieu Baerts
2022-11-01 11:54         ` Menglong Dong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221007092922.13169-4-imagedong@tencent.com \
    --to=menglong8.dong@gmail.com \
    --cc=imagedong@tencent.com \
    --cc=mathew.j.martineau@linux.intel.com \
    --cc=mptcp@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox