[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <545ef721-8e86-4b1f-9333-41e37b46e4d6@kernel.org>
Date: Fri, 14 Nov 2025 11:00:42 +0100
From: Matthieu Baerts <matttbe@...nel.org>
To: Martin KaFai Lau <martin.lau@...ux.dev>,
Jiayuan Chen <jiayuan.chen@...ux.dev>
Cc: mptcp@...ts.linux.dev, Mat Martineau <martineau@...nel.org>,
Geliang Tang <geliang@...nel.org>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, Eduard Zingerman <eddyz87@...il.com>,
Song Liu <song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>,
John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Shuah Khan <shuah@...nel.org>,
Florian Westphal <fw@...len.de>, Christoph Paasch <cpaasch@...le.com>,
Peter Krystad <peter.krystad@...ux.intel.com>, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, bpf@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH net v5 3/3] selftests/bpf: Add mptcp test with sockmap
Hi Martin,
On 13/11/2025 22:48, Martin KaFai Lau wrote:
>> diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/
>> testing/selftests/bpf/prog_tests/mptcp.c
>> index f8eb7f9d4fd2..b976fe626343 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
>> @@ -6,11 +6,14 @@
>> #include <netinet/in.h>
>> #include <test_progs.h>
>> #include <unistd.h>
>> +#include <error.h>
>
> I changed to errno.h to be specific. I think you only need the values of
> an errno here.
>> #include "cgroup_helpers.h"
>> #include "network_helpers.h"
>> +#include "socket_helpers.h"
>> #include "mptcp_sock.skel.h"
>> #include "mptcpify.skel.h"
>> #include "mptcp_subflow.skel.h"
>> +#include "mptcp_sockmap.skel.h"
>> #define NS_TEST "mptcp_ns"
>> #define ADDR_1 "10.0.1.1"
>> @@ -436,6 +439,142 @@ static void test_subflow(void)
>> close(cgroup_fd);
>> }
>> +/* Test sockmap on MPTCP server handling non-mp-capable clients. */
>> +static void test_sockmap_with_mptcp_fallback(struct mptcp_sockmap *skel)
>> +{
>> + int listen_fd = -1, client_fd1 = -1, client_fd2 = -1;
>> + int server_fd1 = -1, server_fd2 = -1, sent, recvd;
>> + char snd[9] = "123456789";
>> + char rcv[10];
>> +
>> + /* start server with MPTCP enabled */
>> + listen_fd = start_mptcp_server(AF_INET, NULL, 0, 0);
>> + if (!ASSERT_OK_FD(listen_fd, "sockmap-fb:start_mptcp_server"))
>> + return;
>> +
>> + skel->bss->trace_port = ntohs(get_socket_local_port(listen_fd));
>> + skel->bss->sk_index = 0;
>> + /* create client without MPTCP enabled */
>> + client_fd1 = connect_to_fd_opts(listen_fd, NULL);
>> + if (!ASSERT_OK_FD(client_fd1, "sockmap-fb:connect_to_fd"))
>> + goto end;
>> +
>> + server_fd1 = xaccept_nonblock(listen_fd, NULL, NULL);
>> + skel->bss->sk_index = 1;
>> + client_fd2 = connect_to_fd_opts(listen_fd, NULL);
>> + if (!ASSERT_OK_FD(client_fd2, "sockmap-fb:connect_to_fd"))
>> + goto end;
>> +
>> + server_fd2 = xaccept_nonblock(listen_fd, NULL, NULL);
>> + /* test normal redirect behavior: data sent by client_fd1 can be
>> + * received by client_fd2
>> + */
>> + skel->bss->redirect_idx = 1;
>> + sent = xsend(client_fd1, snd, sizeof(snd), 0);
>> + if (!ASSERT_EQ(sent, sizeof(snd), "sockmap-fb:xsend(client_fd1)"))
>> + goto end;
>> +
>> + /* try to recv more bytes to avoid truncation check */
>> + recvd = recv_timeout(client_fd2, rcv, sizeof(rcv), MSG_DONTWAIT, 2);
>
> I removed the socket_helpers.h usage. The _nonblock, _timeout, and
> MSG_DONTWAIT are unnecessary. I replaced them with the regular accept,
> send, and recv. All fds from network_helpers.c have a default 3s
> timeout instead of 30s in xaccept_nonblock. This matches how most of
> the selftests/bpf are doing it as well.
>
> I also touched up the commit message in patch 2 based on Matt's comment.
Thank you for having applied the patches, and for the modifications you did!
> Applied. Thanks.
>
>> + server_fd = xaccept_nonblock(listen_fd, NULL, NULL);
>> + err = bpf_map_update_elem(bpf_map__fd(skel->maps.sock_map),
>> + &zero, &server_fd, BPF_NOEXIST);
>
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
Powered by blists - more mailing lists