[PATCH mptcp-next v2 7/9] selftests: mptcp: mptcp_join.sh: pick v4 bind default when MPTCP IPv6 is missing

Gang Yan posted 9 patches 1 month, 3 weeks ago
[PATCH mptcp-next v2 7/9] selftests: mptcp: mptcp_join.sh: pick v4 bind default when MPTCP IPv6 is missing
Posted by Gang Yan 1 month, 3 weeks ago
From: Gang Yan <yangang@kylinos.cn>

do_transfer() defaults bind_addr to "::", and mptcp_connect.c
auto-selects the protocol family from the bind string (a ':' forces
AF_INET6). On a kernel without CONFIG_MPTCP_IPV6 the listener becomes
socket(AF_INET6, SOCK_STREAM, IPPROTO_MPTCP), which the kernel rejects
with -EAFNOSUPPORT and every subtest that does not override bind_addr
reports "client exit code 2, server 1" — starting with "001 no JOIN" —
even though nothing v6-specific is being tested.

Pick the default from the mptcp_lib_is_v6_enabled flag when v6 is
available, "0.0.0.0" otherwise. Callers that explicitly set bind_addr
are unaffected.

Assisted-by: GLM:5.1 Z.ai
Signed-off-by: Gang Yan <yangang@kylinos.cn>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 550a6b6117a9..26fb5e433384 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -1004,7 +1004,14 @@ do_transfer()
 	local FAILING_LINKS=${FAILING_LINKS:-""}
 	local fastclose=${fastclose:-""}
 	local speed=${speed:-"fast"}
-	local bind_addr=${bind_addr:-"::"}
+	local bind_addr=${bind_addr:-}
+	if [ -z "${bind_addr}" ]; then
+		if mptcp_lib_is_v6_enabled; then
+			bind_addr="::"
+		else
+			bind_addr="0.0.0.0"
+		fi
+	fi
 	local listener_in="${sin}"
 	local connector_in="${cin}"
 	port=$(get_port)
-- 
2.43.0