]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests/bpf: Update sk_storage_omem_uncharge test
authorAmery Hung <ameryhung@gmail.com>
Thu, 5 Feb 2026 22:29:10 +0000 (14:29 -0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Fri, 6 Feb 2026 22:48:04 +0000 (14:48 -0800)
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().

Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Amery Hung <ameryhung@gmail.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20260205222916.1788211-13-ameryhung@gmail.com
tools/testing/selftests/bpf/progs/sk_storage_omem_uncharge.c

index 46d6eb2a3b177d13e5c71544ca9d542f78c564f0..c8f4815c8dfb6d224e88c87295913e5f2dd4952a 100644 (file)
@@ -6,7 +6,6 @@
 #include <bpf/bpf_tracing.h>
 #include <bpf/bpf_core_read.h>
 
-void *local_storage_ptr = NULL;
 void *sk_ptr = NULL;
 int cookie_found = 0;
 __u64 cookie = 0;
@@ -19,21 +18,17 @@ struct {
        __type(value, int);
 } sk_storage SEC(".maps");
 
-SEC("fexit/bpf_local_storage_destroy")
-int BPF_PROG(bpf_local_storage_destroy, struct bpf_local_storage *local_storage)
+SEC("fexit/bpf_sk_storage_free")
+int BPF_PROG(bpf_sk_storage_free, struct sock *sk)
 {
-       struct sock *sk;
-
-       if (local_storage_ptr != local_storage)
+       if (sk_ptr != sk)
                return 0;
 
-       sk = bpf_core_cast(sk_ptr, struct sock);
        if (sk->sk_cookie.counter != cookie)
                return 0;
 
        cookie_found++;
        omem = sk->sk_omem_alloc.counter;
-       local_storage_ptr = NULL;
 
        return 0;
 }
@@ -50,7 +45,6 @@ int BPF_PROG(inet6_sock_destruct, struct sock *sk)
        if (value && *value == 0xdeadbeef) {
                cookie_found++;
                sk_ptr = sk;
-               local_storage_ptr = sk->sk_bpf_storage;
        }
 
        return 0;