* [PATCH mptcp-next v2] selftests: mptcp: cover mixed accepts on one listener
@ 2026-12-03 13:51 zibuyu
2026-12-03 17:37 ` Matthieu Baerts
0 siblings, 1 reply; 2+ messages in thread
From: zibuyu @ 2026-12-03 13:51 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>
---
Changes in v2:
- Include kselftest.h for ARRAY_SIZE(). With the UAPI headers installed,
<linux/kernel.h> resolves to the exported header and the build fails.
Built the MPTCP selftests with the installed UAPI headers. All 11
mptcp_sockopt.sh subtests passed, including IPv4 and IPv6. The host
kernel skipped the optional IP_RECVERR and IPV6_RECVERR checks.
v1: https://lore.kernel.org/mptcp/20261203094509.3382752-1-zibuyu423@gmail.com/
tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 54 ++++++++++++++++++-----
1 file changed, 42 insertions(+), 12 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index b8158a1..aa90fe5 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -27,6 +27,8 @@
#include <linux/tcp.h>
#include <linux/compiler.h>
+#include "../../kselftest.h"
+
static int pf = AF_INET;
#ifndef IPPROTO_MPTCP
@@ -705,22 +707,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);
@@ -728,6 +757,7 @@ static int server(int pipefd)
r = xaccept(fd);
process_one_client(r, pipefd);
+ test_mixed_accept(fd, addr, port);
close(fd);
return 0;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH mptcp-next v2] selftests: mptcp: cover mixed accepts on one listener
2026-12-03 13:51 [PATCH mptcp-next v2] selftests: mptcp: cover mixed accepts on one listener zibuyu
@ 2026-12-03 17:37 ` Matthieu Baerts
0 siblings, 0 replies; 2+ messages in thread
From: Matthieu Baerts @ 2026-12-03 17:37 UTC (permalink / raw)
To: zibuyu; +Cc: mptcp
Hi
On 03/12/2026 14:51, zibuyu wrote:
> 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>
> ---
> Changes in v2:
> - Include kselftest.h for ARRAY_SIZE(). With the UAPI headers installed,
> <linux/kernel.h> resolves to the exported header and the build fails.
>
> Built the MPTCP selftests with the installed UAPI headers. All 11
> mptcp_sockopt.sh subtests passed, including IPv4 and IPv6. The host
> kernel skipped the optional IP_RECVERR and IPV6_RECVERR checks.
It looks like this patch is corrupted:
Applying: selftests: mptcp: cover mixed accepts on one listener
error: corrupt patch at line 97
error: could not build fake ancestor
I didn't check why, but don't hesitate to use b4 to send patches:
https://www.mptcp.dev/contributing.html#it-is-easy-with-b4
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-03 17:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 13:51 [PATCH mptcp-next v2] selftests: mptcp: cover mixed accepts on one listener zibuyu
2026-12-03 17:37 ` Matthieu Baerts
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.