Skip to content

Commit 7235a29

Browse files
jrifeKernel Patches Daemon
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]>
1 parent 70e0ef7 commit 7235a29

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

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

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

7597
SEC("iter/udp")

0 commit comments

Comments
 (0)