Skip to content

Commit f9b1c04

Browse files
committed
selftests/bpf: Update sk_storage_omem_uncharge test
Check sk_omem_alloc when the caller of bpf_local_storage_destroy() returns. bpf_local_storage_destroy() now returns the memory to uncharge to the caller instead of directly uncharge. Therefore, in the sk_storage_omem_uncharge, check sk_omem_alloc when bpf_sk_storage_free() returns instead of bpf_local_storage_destroy(). Signed-off-by: Amery Hung <[email protected]>
1 parent b69886c commit f9b1c04

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <bpf/bpf_tracing.h>
77
#include <bpf/bpf_core_read.h>
88

9-
void *local_storage_ptr = NULL;
109
void *sk_ptr = NULL;
1110
int cookie_found = 0;
1211
__u64 cookie = 0;
@@ -19,21 +18,17 @@ struct {
1918
__type(value, int);
2019
} sk_storage SEC(".maps");
2120

22-
SEC("fexit/bpf_local_storage_destroy")
23-
int BPF_PROG(bpf_local_storage_destroy, struct bpf_local_storage *local_storage)
21+
SEC("fexit/bpf_sk_storage_free")
22+
int BPF_PROG(bpf_sk_storage_free, struct sock *sk)
2423
{
25-
struct sock *sk;
26-
27-
if (local_storage_ptr != local_storage)
24+
if (sk_ptr != sk)
2825
return 0;
2926

30-
sk = bpf_core_cast(sk_ptr, struct sock);
3127
if (sk->sk_cookie.counter != cookie)
3228
return 0;
3329

3430
cookie_found++;
3531
omem = sk->sk_omem_alloc.counter;
36-
local_storage_ptr = NULL;
3732

3833
return 0;
3934
}
@@ -50,7 +45,6 @@ int BPF_PROG(inet6_sock_destruct, struct sock *sk)
5045
if (value && *value == 0xdeadbeef) {
5146
cookie_found++;
5247
sk_ptr = sk;
53-
local_storage_ptr = sk->sk_bpf_storage;
5448
}
5549

5650
return 0;

0 commit comments

Comments
 (0)