All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-next] selftests: mptcp: cover mixed accepts on one listener
@ 2026-12-03  9:45 zibuyu
  2026-12-03  9:54 ` sashiko-bot
  2026-12-03 11:06 ` MPTCP CI
  0 siblings, 2 replies; 3+ messages in thread
From: zibuyu @ 2026-12-03  9:45 UTC (permalink / raw)
  To: mptcp

The socket option test handles one MPTCP connection per listener. It
leaves the passive TCP fallback path untested when other children of
the same listener negotiate MPTCP.

Connect an MPTCP client, a TCP client and another MPTCP client to the
same listener. Keep all three connections open, check SO_PROTOCOL on
each accepted socket and verify that it reads its own client's byte.
The existing socket option test runs this sequence for IPv4 and IPv6.

OpenAI Codex generated the test and ran the socket option selftests.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/426
Signed-off-by: zibuyu <zibuyu423@gmail.com>
---
 .../selftests/net/mptcp/mptcp_sockopt.c       | 53 ++++++++++++++-----
 1 file changed, 41 insertions(+), 12 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index b6e58d936ebe..5c027f7d43a7 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -26,6 +26,7 @@
 
 #include <linux/tcp.h>
 #include <linux/compiler.h>
+#include <linux/kernel.h>
 
 static int pf = AF_INET;
 
@@ -703,22 +704,49 @@ static int xaccept(int s)
 	return fd;
 }
 
-static int server(int pipefd)
+static void test_mixed_accept(int listener, const char *addr, const char *port)
 {
-	int fd = -1, r;
+	static const int protos[] = { IPPROTO_MPTCP, IPPROTO_TCP, IPPROTO_MPTCP };
+	int clients[ARRAY_SIZE(protos)], accepted[ARRAY_SIZE(protos)];
+	size_t i;
 
-	switch (pf) {
-	case AF_INET:
-		fd = sock_listen_mptcp("127.0.0.1", "15432");
-		break;
-	case AF_INET6:
-		fd = sock_listen_mptcp("::1", "15432");
-		break;
-	default:
-		xerror("Unknown pf %d\n", pf);
-		break;
+	for (i = 0; i < ARRAY_SIZE(protos); i++) {
+		char tag = 'A' + i;
+
+		clients[i] = sock_connect_mptcp(addr, port, protos[i]);
+		accepted[i] = xaccept(listener);
+		if (write(clients[i], &tag, 1) != 1)
+			die_perror("write client tag");
 	}
 
+	/* Check each child while the negotiated and fallback sockets coexist. */
+	for (i = 0; i < ARRAY_SIZE(protos); i++) {
+		int proto;
+		socklen_t len = sizeof(proto);
+		char tag;
+
+		if (getsockopt(accepted[i], SOL_SOCKET, SO_PROTOCOL, &proto, &len))
+			die_perror("getsockopt SO_PROTOCOL");
+		if (proto != protos[i])
+			xerror("accept %zu: got protocol %d, expected %d", i, proto, protos[i]);
+
+		if (read(accepted[i], &tag, 1) != 1 || tag != 'A' + i)
+			xerror("accept %zu: did not receive its client tag", i);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(protos); i++) {
+		close(accepted[i]);
+		close(clients[i]);
+	}
+}
+
+static int server(int pipefd)
+{
+	const char *addr = pf == AF_INET6 ? "::1" : "127.0.0.1";
+	const char *port = "15432";
+	int fd, r;
+
+	fd = sock_listen_mptcp(addr, port);
 	r = write(pipefd, "conn", 4);
 	assert(r == 4);
 
@@ -726,6 +754,7 @@ static int server(int pipefd)
 	r = xaccept(fd);
 
 	process_one_client(r, pipefd);
+	test_mixed_accept(fd, addr, port);
 
 	close(fd);
 	return 0;
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH mptcp-next] selftests: mptcp: cover mixed accepts on one listener
  2026-12-03  9:45 [PATCH mptcp-next] selftests: mptcp: cover mixed accepts on one listener zibuyu
@ 2026-12-03  9:54 ` sashiko-bot
  2026-12-03 11:06 ` MPTCP CI
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-03  9:54 UTC (permalink / raw)
  To: zibuyu, mptcp

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] selftests: mptcp: UAPI linux/kernel.h shadows ARRAY_SIZE and
  breaks build
--

commit aa719ae60eaeb0cc26e571bc88875f675f4fdba7
Author: zibuyu <zibuyu423@gmail.com>

selftests: mptcp: cover mixed accepts on one listener

This commit adds test_mixed_accept() to mptcp_sockopt.c to connect MPTCP,
TCP, and MPTCP clients to the same listener and verify SO_PROTOCOL and
client data on each accepted socket.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/426

> diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
> index b8158a1198eba..cb3e8b2e0b8eb 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
> +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
> @@ -26,6 +26,7 @@
>  
>  #include <linux/tcp.h>
>  #include <linux/compiler.h>
> +#include <linux/kernel.h>
>  
>  static int pf = AF_INET;
>  
> @@ -705,22 +706,49 @@ static int xaccept(int s)
>  	return fd;
>  }
>  
> -static int server(int pipefd)
> +static void test_mixed_accept(int listener, const char *addr, const char *port)
>  {
> -	int fd = -1, r;
> +	static const int protos[] = { IPPROTO_MPTCP, IPPROTO_TCP, IPPROTO_MPTCP };
> +	int clients[ARRAY_SIZE(protos)], accepted[ARRAY_SIZE(protos)];

[Severity: Medium]
Can #include <linux/kernel.h> fail to provide ARRAY_SIZE() when UAPI headers
are installed, breaking the mptcp_sockopt build?

tools/testing/selftests/net/mptcp/Makefile puts -I$(top_srcdir)/usr/include
ahead of -I$(top_srcdir)/tools/include:

tools/testing/selftests/net/mptcp/Makefile:
	CFLAGS += -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
	CFLAGS += -I$(top_srcdir)/tools/include

When UAPI headers are installed (for example via make kselftest),
#include <linux/kernel.h> resolves to $(top_srcdir)/usr/include/linux/kernel.h
instead of tools/include/linux/kernel.h.  The UAPI header does not define
ARRAY_SIZE(), so compiling mptcp_sockopt.c fails in test_mixed_accept().

Including kselftest.h instead of linux/kernel.h would provide ARRAY_SIZE()
without colliding with the UAPI header.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203094509.3382752-1-zibuyu423@gmail.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH mptcp-next] selftests: mptcp: cover mixed accepts on one listener
  2026-12-03  9:45 [PATCH mptcp-next] selftests: mptcp: cover mixed accepts on one listener zibuyu
  2026-12-03  9:54 ` sashiko-bot
@ 2026-12-03 11:06 ` MPTCP CI
  1 sibling, 0 replies; 3+ messages in thread
From: MPTCP CI @ 2026-12-03 11:06 UTC (permalink / raw)
  To: zibuyu; +Cc: mptcp

Hi zibuyu,

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): Script error! ❓
- KVM Validation: normal (only selftest_mptcp_join): Script error! ❓
- KVM Validation: debug (except selftest_mptcp_join): Script error! ❓
- KVM Validation: debug (only selftest_mptcp_join): Script error! ❓
- KVM Validation: btf-normal (only bpftest_all): Script error! ❓
- KVM Validation: btf-debug (only bpftest_all): Script error! ❓
- Perf: Unstable: regression:sched-baseline regression:sched-bbr(2) regression:sched-mem-pressure validation:sched-loss(2) ⚠️  (69 new outliers to review)
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/47085221074

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


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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-03 11:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  9:45 [PATCH mptcp-next] selftests: mptcp: cover mixed accepts on one listener zibuyu
2026-12-03  9:54 ` sashiko-bot
2026-12-03 11:06 ` MPTCP CI

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.