[PATCH mptcp-next] Squash to "selftests: mptcp: sockopt: add is_mptcp_socket helper"

Geliang Tang posted 1 patch 3 weeks, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/1b103d397cf4a506c608d9ade586e98db770daec.1785460213.git.tanggeliang@kylinos.cn
.../testing/selftests/net/mptcp/mptcp_sockopt.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
[PATCH mptcp-next] Squash to "selftests: mptcp: sockopt: add is_mptcp_socket helper"
Posted by Geliang Tang 3 weeks, 3 days ago
From: Geliang Tang <tanggeliang@kylinos.cn>

Fix the TCP_IS_MPTCP fallback value from 76 to 43 (matches UAPI), and
handle both ENOPROTOOPT and EOPNOTSUPP so old kernels without the
option don't abort via xerror(). Default is_mptcp to -1 (unknown) so
the helper honestly signals "I don't know" instead of falsely claiming
"not MPTCP", and update the three call sites to use > 0 / <= 0

Based-on: <cover.1785380422.git.tanggeliang@kylinos.cn>

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 .../testing/selftests/net/mptcp/mptcp_sockopt.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index cbc594ff7792..24d34f28bb05 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -39,7 +39,7 @@ static int pf = AF_INET;
 #define SOL_MPTCP 284
 #endif
 #ifndef TCP_IS_MPTCP
-#define TCP_IS_MPTCP 76
+#define TCP_IS_MPTCP 43
 #endif
 
 static int proto_tx = IPPROTO_MPTCP;
@@ -591,16 +591,13 @@ static void do_getsockopt_mptcp_full_info(struct so_state *s, int fd)
 
 static int is_mptcp_socket(int fd)
 {
-	int is_mptcp = 0;
+	int is_mptcp = -1;
 	socklen_t optlen;
 
 	optlen = sizeof(is_mptcp);
 	if (getsockopt(fd, IPPROTO_TCP, TCP_IS_MPTCP, &is_mptcp, &optlen) < 0) {
-		if (errno == ENOPROTOOPT) {
-			perror("TCP_IS_MPTCP test skipped");
-			return 0;
-		}
-		xerror("getsockopt TCP_IS_MPTCP");
+		if (errno != ENOPROTOOPT && errno != EOPNOTSUPP)
+			xerror("getsockopt TCP_IS_MPTCP");
 	}
 
 	return is_mptcp;
@@ -608,7 +605,7 @@ static int is_mptcp_socket(int fd)
 
 static void do_getsockopts(struct so_state *s, int fd, size_t r, size_t w)
 {
-	if (!is_mptcp_socket(fd))
+	if (is_mptcp_socket(fd) <= 0)
 		return;
 
 	do_getsockopt_mptcp_info(s, fd, w);
@@ -777,7 +774,7 @@ static void connect_one_server(int fd, int unixfd)
 	if (eof)
 		total += 1; /* sequence advances due to FIN */
 
-	if (is_mptcp_socket(fd))
+	if (is_mptcp_socket(fd) > 0)
 		assert(s.mptcpi_rcv_delta == (uint64_t)total);
 
 	if (inq)
@@ -1012,7 +1009,7 @@ static void process_one_client(int fd, int unixfd)
 	r += ret;
 
 	do_getsockopts(&s, fd, r, w);
-	if (is_mptcp_socket(fd))
+	if (is_mptcp_socket(fd) > 0)
 		check_stat_equal("mptcpi_rcv_delta", s.mptcpi_rcv_delta,
 				 (uint64_t)r + 1); /* +1 for FIN */
 
-- 
2.53.0
Re: [PATCH mptcp-next] Squash to "selftests: mptcp: sockopt: add is_mptcp_socket helper"
Posted by MPTCP CI 3 weeks, 3 days ago
Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/30596626106

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/87682d22935c
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1137792


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)