Skip to content

Commit 8fc0c5a

Browse files
jrifeMartin KaFai Lau
authored andcommitted
selftests/bpf: Create iter_tcp_destroy test program
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 <[email protected]> Signed-off-by: Martin KaFai Lau <[email protected]> Acked-by: Stanislav Fomichev <[email protected]>
1 parent 07ebabb commit 8fc0c5a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tools/testing/selftests/bpf/progs/sock_iter_batch.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,27 @@ int iter_tcp_soreuse(struct bpf_iter__tcp *ctx)
7070
return 0;
7171
}
7272

73+
volatile const __u64 destroy_cookie;
74+
75+
SEC("iter/tcp")
76+
int iter_tcp_destroy(struct bpf_iter__tcp *ctx)
77+
{
78+
struct sock_common *sk_common = (struct sock_common *)ctx->sk_common;
79+
__u64 sock_cookie;
80+
81+
if (!sk_common)
82+
return 0;
83+
84+
sock_cookie = bpf_get_socket_cookie(sk_common);
85+
if (sock_cookie != destroy_cookie)
86+
return 0;
87+
88+
bpf_sock_destroy(sk_common);
89+
bpf_seq_write(ctx->meta->seq, &sock_cookie, sizeof(sock_cookie));
90+
91+
return 0;
92+
}
93+
7394
#define udp_sk(ptr) container_of(ptr, struct udp_sock, inet.sk)
7495

7596
SEC("iter/udp")

0 commit comments

Comments
 (0)