From: Kuniyuki Iwashima <kuniyu@google.com>
To: jt26wzz@gmail.com
Cc: davem@davemloft.net, dsahern@kernel.org, edumazet@google.com,
horms@kernel.org, kuba@kernel.org, kuniyu@google.com,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
ncardwell@google.com, netdev@vger.kernel.org, pabeni@redhat.com,
shuah@kernel.org, tamird@kernel.org
Subject: Re: [PATCH net v2 2/2] selftests/bpf: check epoll readiness after reuseport migration
Date: Tue, 21 Apr 2026 07:15:09 +0000 [thread overview]
Message-ID: <20260421072017.1653163-1-kuniyu@google.com> (raw)
In-Reply-To: <20260418181333.1713389-3-jt26wzz@gmail.com>
From: Zhenzhong Wu <jt26wzz@gmail.com>
Date: Sun, 19 Apr 2026 02:13:33 +0800
> After migrate_dance() moves established children to the target
> listener, add it to an epoll set and verify that epoll_wait(..., 0)
> reports it ready before accept().
>
> This adds epoll coverage for the TCP_ESTABLISHED reuseport migration
> case in migrate_reuseport.
>
> Keep the check limited to TCP_ESTABLISHED cases. TCP_SYN_RECV and
> TCP_NEW_SYN_RECV still depend on asynchronous handshake completion,
> so a zero-timeout epoll_wait() would race there.
>
> Signed-off-by: Zhenzhong Wu <jt26wzz@gmail.com>
> ---
> .../bpf/prog_tests/migrate_reuseport.c | 32 ++++++++++++++++++-
> 1 file changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c b/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c
> index 653b0a20f..580a53424 100644
> --- a/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c
> +++ b/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c
> @@ -18,13 +18,16 @@
> * 9. call shutdown() for the second server
> * and migrate the requests in the accept queue
> * to the last server socket.
> - * 10. call accept() for the last server socket.
> + * 10. for TCP_ESTABLISHED cases, call epoll_wait(..., 0)
> + * for the last server socket.
> + * 11. call accept() for the last server socket.
> *
> * Author: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
> */
>
> #include <bpf/bpf.h>
> #include <bpf/libbpf.h>
> +#include <sys/epoll.h>
>
> #include "test_progs.h"
> #include "test_migrate_reuseport.skel.h"
> @@ -522,6 +525,33 @@ static void run_test(struct migrate_reuseport_test_case *test_case,
> goto close_clients;
> }
>
> + /* Only TCP_ESTABLISHED has already-migrated accept-queue entries
> + * here. Later states still depend on follow-up handshake work.
> + */
> + if (test_case->state == BPF_TCP_ESTABLISHED) {
> + struct epoll_event ev = {
> + .events = EPOLLIN,
> + };
> + int epfd;
> + int nfds;
> +
> + epfd = epoll_create1(EPOLL_CLOEXEC);
> + if (!ASSERT_NEQ(epfd, -1, "epoll_create1"))
> + goto close_clients;
> +
> + ev.data.fd = test_case->servers[MIGRATED_TO];
> + if (!ASSERT_OK(epoll_ctl(epfd, EPOLL_CTL_ADD,
> + test_case->servers[MIGRATED_TO], &ev),
> + "epoll_ctl"))
> + goto close_epfd;
> +
> + nfds = epoll_wait(epfd, &ev, 1, 0);
> + ASSERT_EQ(nfds, 1, "epoll_wait");
Thanks for the update, but the test passes without patch 1.
I think it would be best to test just after shutdown()
where migration happens.
Also, TCP_SYN_RECV should be covered in the same way.
---8<---
diff --git a/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c b/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c
index 580a534249a7..66fea936649e 100644
--- a/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c
+++ b/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c
@@ -353,8 +353,29 @@ static int update_maps(struct migrate_reuseport_test_case *test_case,
static int migrate_dance(struct migrate_reuseport_test_case *test_case)
{
+ struct epoll_event ev = {
+ .events = EPOLLIN,
+ };
+ int epoll, nfds;
int i, err;
+ if (test_case->state != BPF_TCP_NEW_SYN_RECV) {
+ epoll = epoll_create1(0);
+ if (!ASSERT_NEQ(epoll, -1, "epoll_create1"))
+ return -1;
+
+ ev.data.fd = test_case->servers[MIGRATED_TO];
+ if (!ASSERT_OK(epoll_ctl(epoll, EPOLL_CTL_ADD,
+ test_case->servers[MIGRATED_TO], &ev),
+ "epoll_ctl")) {
+ goto close_epoll;
+ }
+
+ nfds = epoll_wait(epoll, &ev, 1, 0);
+ if (!ASSERT_EQ(nfds, 0, "epoll_wait 1"))
+ goto close_epoll;
+ }
+
/* Migrate TCP_ESTABLISHED and TCP_SYN_RECV requests
* to the last listener based on eBPF.
*/
@@ -368,6 +389,15 @@ static int migrate_dance(struct migrate_reuseport_test_case *test_case)
if (test_case->state == BPF_TCP_NEW_SYN_RECV)
return 0;
+ nfds = epoll_wait(epoll, &ev, 1, 0);
+ if (!ASSERT_EQ(nfds, 1, "epoll_wait 2")) {
+close_epoll:
+ close(epoll);
+ return -1;
+ }
+
+ close(epoll);
+
/* Note that we use the second listener instead of the
* first one here.
*
@@ -525,33 +555,6 @@ static void run_test(struct migrate_reuseport_test_case *test_case,
goto close_clients;
}
- /* Only TCP_ESTABLISHED has already-migrated accept-queue entries
- * here. Later states still depend on follow-up handshake work.
- */
- if (test_case->state == BPF_TCP_ESTABLISHED) {
- struct epoll_event ev = {
- .events = EPOLLIN,
- };
- int epfd;
- int nfds;
-
- epfd = epoll_create1(EPOLL_CLOEXEC);
- if (!ASSERT_NEQ(epfd, -1, "epoll_create1"))
- goto close_clients;
-
- ev.data.fd = test_case->servers[MIGRATED_TO];
- if (!ASSERT_OK(epoll_ctl(epfd, EPOLL_CTL_ADD,
- test_case->servers[MIGRATED_TO], &ev),
- "epoll_ctl"))
- goto close_epfd;
-
- nfds = epoll_wait(epfd, &ev, 1, 0);
- ASSERT_EQ(nfds, 1, "epoll_wait");
-
-close_epfd:
- close(epfd);
- }
-
count_requests(test_case, skel);
close_clients:
---8<---
next prev parent reply other threads:[~2026-04-21 7:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-18 18:13 [PATCH net v2 0/2] tcp: fix listener wakeup after reuseport migration Zhenzhong Wu
2026-04-18 18:13 ` [PATCH net v2 1/2] tcp: call sk_data_ready() after listener migration Zhenzhong Wu
2026-04-18 18:13 ` [PATCH net v2 2/2] selftests/bpf: check epoll readiness after reuseport migration Zhenzhong Wu
2026-04-21 7:15 ` Kuniyuki Iwashima [this message]
2026-04-21 11:16 ` Zhenzhong Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260421072017.1653163-1-kuniyu@google.com \
--to=kuniyu@google.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jt26wzz@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=tamird@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox