[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ca23af7b-28cf-4453-bd53-c0507b3b4e8f@linux.dev>
Date: Tue, 8 Jul 2025 16:39:44 -0700
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: Jordan Rife <jordan@...fe.io>
Cc: Daniel Borkmann <daniel@...earbox.net>,
Willem de Bruijn <willemdebruijn.kernel@...il.com>,
Kuniyuki Iwashima <kuniyu@...gle.com>,
Alexei Starovoitov <alexei.starovoitov@...il.com>,
Stanislav Fomichev <stfomichev@...il.com>, netdev@...r.kernel.org,
bpf@...r.kernel.org
Subject: Re: [PATCH v4 bpf-next 11/12] selftests/bpf: Create iter_tcp_destroy
test program
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@...fe.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")
Powered by blists - more mailing lists