[PATCH mptcp-next 4/6] selftests: mptcp: add the MP_RST mibs check

Geliang Tang posted 6 patches 3 years, 12 months ago
Maintainers: Jakub Kicinski <kuba@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, KP Singh <kpsingh@kernel.org>, Yonghong Song <yhs@fb.com>, John Fastabend <john.fastabend@gmail.com>, Matthieu Baerts <matthieu.baerts@tessares.net>, Mat Martineau <mathew.j.martineau@linux.intel.com>, Andrii Nakryiko <andrii@kernel.org>, Shuah Khan <shuah@kernel.org>, Song Liu <songliubraving@fb.com>, Martin KaFai Lau <kafai@fb.com>, Alexei Starovoitov <ast@kernel.org>, "David S. Miller" <davem@davemloft.net>
There is a newer version of this series
[PATCH mptcp-next 4/6] selftests: mptcp: add the MP_RST mibs check
Posted by Geliang Tang 3 years, 12 months ago
This patch added a new function chk_rst_nr() to check the numbers
of the MP_RST sending and receiving mibs.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index f71494b87d5e..000272eec5a5 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -802,6 +802,47 @@ chk_fail_nr()
 	[ "${dump_stats}" = 1 ] && dump_stats
 }
 
+chk_rst_nr()
+{
+	local rst_tx=$1
+	local rst_rx=$2
+	local invert=${3:-""}
+	local count
+	local dump_stats
+
+	if [ -z $invert ]; then
+		ns_tx=$ns1
+		ns_rx=$ns2
+	elif [ $invert = "invert" ]; then
+		ns_tx=$ns2
+		ns_rx=$ns1
+	fi
+
+	printf "%-${nr_blank}s %s" " " "rtx"
+	count=`ip netns exec $ns_tx nstat -as | grep MPTcpExtMPRstTx | awk '{print $2}'`
+	[ -z "$count" ] && count=0
+	if [ "$count" != "$rst_tx" ]; then
+		echo "[fail] got $count MP_RST[s] TX expected $rst_tx"
+		ret=1
+		dump_stats=1
+	else
+		echo -n "[ ok ]"
+	fi
+
+	echo -n " - rstrx "
+	count=`ip netns exec $ns_rx nstat -as | grep MPTcpExtMPRstRx | awk '{print $2}'`
+	[ -z "$count" ] && count=0
+	if [ "$count" != "$rst_rx" ]; then
+		echo "[fail] got $count MP_RST[s] RX expected $rst_rx"
+		ret=1
+		dump_stats=1
+	else
+		echo "[ ok ]"
+	fi
+
+	[ "${dump_stats}" = 1 ] && dump_stats
+}
+
 chk_infi_nr()
 {
 	local mp_infi_nr_tx=$1
@@ -920,6 +961,7 @@ chk_join_nr()
 	if [ $checksum -eq 1 ]; then
 		chk_csum_nr
 		chk_fail_nr 0 0
+		chk_rst_nr 0 0
 		chk_infi_nr 0 0
 	fi
 }
-- 
2.34.1