[PATCH mptcp-net v3 2/2] selftests: mptcp: add a check for sndbuf of S/C

Gang Yan
2026-04-07T08:45:30Z

From: Gang Yan <yangang@kylinos.cn>

Add a new chk_sndbuf() helper to diag.sh that extracts the sndbuf (the
'tb' field from 'ss -m' skmem output) for both server and client MPTCP
sockets, and verifies they are equal.

Without the previous patch, it will fails:

'''
05 all listen sockets [ OK ]
06 after MPC handshake [ OK ]
07 ....chk sndbuf server/client [FAIL] server sndbuf=20480 != client sndbuf=2630656
'''

Signed-off-by: Gang Yan <yangang@kylinos.cn>
---
tools/testing/selftests/net/mptcp/diag.sh | 26 +++++++++++++++++++++++
1 file changed, 26 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
index d847ff1737c3..aa01a1dd0bdd 100755
--- a/tools/testing/selftests/net/mptcp/diag.sh
+++ b/tools/testing/selftests/net/mptcp/diag.sh
@@ -322,6 +322,31 @@ wait_connected()
done
}

+chk_sndbuf()
+{
+ local server_sndbuf client_sndbuf msg
+ local port=${1}
+
+ msg="....chk sndbuf server/client"
+ server_sndbuf=$(ss -N "${ns}" -inmHM "sport" "${port}" | grep -oP 'tb\K\d+')
+ client_sndbuf=$(ss -N "${ns}" -inmHM "dport" "${port}" | grep -oP 'tb\K\d+')
+
+ mptcp_lib_print_title "${msg}"
+ if [ -z "${server_sndbuf}" ] || [ -z "${client_sndbuf}" ]; then
+ mptcp_lib_pr_fail "server sndbuf=${server_sndbuf} client sndbuf=${client_sndbuf}"
+ mptcp_lib_result_fail "${msg}"
+ ret=${KSFT_FAIL}
+ elif [ "${server_sndbuf}" != "${client_sndbuf}" ]; then
+ mptcp_lib_pr_fail "server sndbuf=${server_sndbuf} != client sndbuf=${client_sndbuf}"
+ mptcp_lib_result_fail "${msg}"
+ ret=${KSFT_FAIL}
+ else
+ mptcp_lib_pr_ok
+ mptcp_lib_result_pass "${msg}"
+ fi
+}
+
+
trap cleanup EXIT
mptcp_lib_ns_init ns

@@ -341,6 +366,7 @@ echo "b" | \
127.0.0.1 >/dev/null &
wait_connected $ns 10000
chk_msk_nr 2 "after MPC handshake"
+chk_sndbuf 10000
chk_last_time_info 10000
chk_msk_remote_key_nr 2 "....chk remote_key"
chk_msk_fallback_nr 0 "....chk no fallback"
--
2.43.0