From: Martin KaFai Lau <martin.lau@linux.dev>
To: Jordan Rife <jordan@jrife.io>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Stanislav Fomichev <stfomichev@gmail.com>,
netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v4 bpf-next 11/12] selftests/bpf: Create iter_tcp_destroy test program
Date: Tue, 8 Jul 2025 16:39:44 -0700 [thread overview]
Message-ID: <ca23af7b-28cf-4453-bd53-c0507b3b4e8f@linux.dev> (raw)
In-Reply-To: <20250707155102.672692-12-jordan@jrife.io>
On 7/7/25 8:50 AM, Jordan Rife wrote:
> Prepare for bucket resume tests for established TCP sockets by creating
> a program to immediately destroy and remove sockets from the TCP ehash
> table, since close() is not deterministic.
>
> Signed-off-by: Jordan Rife <jordan@jrife.io>
> ---
> .../selftests/bpf/progs/sock_iter_batch.c | 22 +++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/progs/sock_iter_batch.c b/tools/testing/selftests/bpf/progs/sock_iter_batch.c
> index a36361e4a5de..14513aa77800 100644
> --- a/tools/testing/selftests/bpf/progs/sock_iter_batch.c
> +++ b/tools/testing/selftests/bpf/progs/sock_iter_batch.c
> @@ -70,6 +70,28 @@ int iter_tcp_soreuse(struct bpf_iter__tcp *ctx)
> return 0;
> }
>
> +int bpf_sock_destroy(struct sock_common *sk) __ksym;
A nit.
The kfunc declaration should be already in the vmlinux.h, so this line is no
longer needed. The bpf CI has the new pahole for this.
> +volatile const __u64 destroy_cookie;
> +
> +SEC("iter/tcp")
> +int iter_tcp_destroy(struct bpf_iter__tcp *ctx)
> +{
> + struct sock_common *sk_common = (struct sock_common *)ctx->sk_common;
> + __u64 sock_cookie;
> +
> + if (!sk_common)
> + return 0;
> +
> + sock_cookie = bpf_get_socket_cookie(sk_common);
> + if (sock_cookie != destroy_cookie)
> + return 0;
> +
> + bpf_sock_destroy(sk_common);
> + bpf_seq_write(ctx->meta->seq, &sock_cookie, sizeof(sock_cookie));
> +
> + return 0;
> +}
> +
> #define udp_sk(ptr) container_of(ptr, struct udp_sock, inet.sk)
>
> SEC("iter/udp")
next prev parent reply other threads:[~2025-07-08 23:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-07 15:50 [PATCH v4 bpf-next 00/12] bpf: tcp: Exactly-once socket iteration Jordan Rife
2025-07-07 15:50 ` [PATCH v4 bpf-next 01/12] bpf: tcp: Make mem flags configurable through bpf_iter_tcp_realloc_batch Jordan Rife
2025-07-07 15:50 ` [PATCH v4 bpf-next 02/12] bpf: tcp: Make sure iter->batch always contains a full bucket snapshot Jordan Rife
2025-07-08 23:16 ` Martin KaFai Lau
2025-07-08 23:30 ` Martin KaFai Lau
2025-07-07 15:50 ` [PATCH v4 bpf-next 03/12] bpf: tcp: Get rid of st_bucket_done Jordan Rife
2025-07-07 15:50 ` [PATCH v4 bpf-next 04/12] bpf: tcp: Use bpf_tcp_iter_batch_item for bpf_tcp_iter_state batch items Jordan Rife
2025-07-07 15:50 ` [PATCH v4 bpf-next 05/12] bpf: tcp: Avoid socket skips and repeats during iteration Jordan Rife
2025-07-07 15:50 ` [PATCH v4 bpf-next 06/12] selftests/bpf: Add tests for bucket resume logic in listening sockets Jordan Rife
2025-07-07 15:50 ` [PATCH v4 bpf-next 07/12] selftests/bpf: Allow for iteration over multiple ports Jordan Rife
2025-07-07 15:50 ` [PATCH v4 bpf-next 08/12] selftests/bpf: Allow for iteration over multiple states Jordan Rife
2025-07-07 15:50 ` [PATCH v4 bpf-next 09/12] selftests/bpf: Make ehash buckets configurable in socket iterator tests Jordan Rife
2025-07-07 15:50 ` [PATCH v4 bpf-next 10/12] selftests/bpf: Create established sockets " Jordan Rife
2025-07-07 15:50 ` [PATCH v4 bpf-next 11/12] selftests/bpf: Create iter_tcp_destroy test program Jordan Rife
2025-07-08 23:39 ` Martin KaFai Lau [this message]
2025-07-07 15:51 ` [PATCH v4 bpf-next 12/12] selftests/bpf: Add tests for bucket resume logic in established sockets Jordan Rife
2025-07-08 23:44 ` Martin KaFai Lau
2025-07-09 22:47 ` Jordan Rife
2025-07-07 18:31 ` [PATCH v4 bpf-next 00/12] bpf: tcp: Exactly-once socket iteration Stanislav Fomichev
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=ca23af7b-28cf-4453-bd53-c0507b3b4e8f@linux.dev \
--to=martin.lau@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jordan@jrife.io \
--cc=kuniyu@google.com \
--cc=netdev@vger.kernel.org \
--cc=stfomichev@gmail.com \
--cc=willemdebruijn.kernel@gmail.com \
/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 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.