bpf: add btf pointer to struct bpf_ctx_arg_aux.
authorKui-Feng Lee <thinker.li@gmail.com>
Fri, 9 Feb 2024 02:37:47 +0000 (18:37 -0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Tue, 13 Feb 2024 23:16:44 +0000 (15:16 -0800)
Enable the providers to use types defined in a module instead of in the
kernel (btf_vmlinux).

Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Link: https://lore.kernel.org/r/20240209023750.1153905-2-thinker.li@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
include/linux/bpf.h
kernel/bpf/btf.c

index 1ebbee1d648ed9258fd60413595e0e9caa7c6153..3b7836f0a83efbcb192b9714a9c7e777d87672e1 100644 (file)
@@ -1415,6 +1415,7 @@ struct bpf_jit_poke_descriptor {
 struct bpf_ctx_arg_aux {
        u32 offset;
        enum bpf_reg_type reg_type;
+       struct btf *btf;
        u32 btf_id;
 };
 
index 8e06d29961f1a4ff615b0c071cd12196f3b57bb2..cf100b5573ca4badc9c2352d207c4107c97db2af 100644 (file)
@@ -6266,7 +6266,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,
                        }
 
                        info->reg_type = ctx_arg_info->reg_type;
-                       info->btf = btf_vmlinux;
+                       info->btf = ctx_arg_info->btf ? : btf_vmlinux;
                        info->btf_id = ctx_arg_info->btf_id;
                        return true;
                }