summaryrefslogtreecommitdiff
path: root/tools/lib/bpf/bpf.h
diff options
context:
space:
mode:
authorKui-Feng Lee <thinker.li@gmail.com>2024-01-20 01:50:03 +0300
committerMartin KaFai Lau <martin.lau@kernel.org>2024-01-24 04:12:52 +0300
commit9e926acda0c2e21bca431a1818665ddcd6939755 (patch)
tree4d4f1f22b84386dcd06c0402d196ffb748be121b /tools/lib/bpf/bpf.h
parentf6be98d19985411ca1f3d53413d94d5b7f41c200 (diff)
downloadlinux-9e926acda0c2e21bca431a1818665ddcd6939755.tar.xz
libbpf: Find correct module BTFs for struct_ops maps and progs.
Locate the module BTFs for struct_ops maps and progs and pass them to the kernel. This ensures that the kernel correctly resolves type IDs from the appropriate module BTFs. For the map of a struct_ops object, the FD of the module BTF is set to bpf_map to keep a reference to the module BTF. The FD is passed to the kernel as value_type_btf_obj_fd when the struct_ops object is loaded. For a bpf_struct_ops prog, attach_btf_obj_fd of bpf_prog is the FD of a module BTF in the kernel. Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/r/20240119225005.668602-13-thinker.li@gmail.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Diffstat (limited to 'tools/lib/bpf/bpf.h')
-rw-r--r--tools/lib/bpf/bpf.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index d0f53772bdc0..53b0bee053ad 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -51,8 +51,10 @@ struct bpf_map_create_opts {
__u32 numa_node;
__u32 map_ifindex;
+ __s32 value_type_btf_obj_fd;
+ size_t:0;
};
-#define bpf_map_create_opts__last_field map_ifindex
+#define bpf_map_create_opts__last_field value_type_btf_obj_fd
LIBBPF_API int bpf_map_create(enum bpf_map_type map_type,
const char *map_name,