diff options
author | Kui-Feng Lee <thinker.li@gmail.com> | 2024-01-19 14:49:57 -0800 |
---|---|---|
committer | Martin KaFai Lau <martin.lau@kernel.org> | 2024-01-23 16:37:44 -0800 |
commit | 1338b93346587a2a6ac79bbcf55ef5b357745573 (patch) | |
tree | 3200810e4d2c138d8ecec7ab4303446db88a1bf7 /kernel/bpf/bpf_struct_ops.c | |
parent | 47f4f657acd5d04c78c5c5ac7022cba9ce3b4a7d (diff) | |
download | linux-1338b93346587a2a6ac79bbcf55ef5b357745573.tar.gz linux-1338b93346587a2a6ac79bbcf55ef5b357745573.tar.bz2 linux-1338b93346587a2a6ac79bbcf55ef5b357745573.zip |
bpf: pass btf object id in bpf_map_info.
Include btf object id (btf_obj_id) in bpf_map_info so that tools (ex:
bpftools struct_ops dump) know the correct btf from the kernel to look up
type information of struct_ops types.
Since struct_ops types can be defined and registered in a module. The
type information of a struct_ops type are defined in the btf of the
module defining it. The userspace tools need to know which btf is for
the module defining a struct_ops type.
Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Link: https://lore.kernel.org/r/20240119225005.668602-7-thinker.li@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Diffstat (limited to 'kernel/bpf/bpf_struct_ops.c')
-rw-r--r-- | kernel/bpf/bpf_struct_ops.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c index 5ddcca4c4fba..5e98af4fc2e2 100644 --- a/kernel/bpf/bpf_struct_ops.c +++ b/kernel/bpf/bpf_struct_ops.c @@ -947,3 +947,10 @@ err_out: kfree(link); return err; } + +void bpf_map_struct_ops_info_fill(struct bpf_map_info *info, struct bpf_map *map) +{ + struct bpf_struct_ops_map *st_map = (struct bpf_struct_ops_map *)map; + + info->btf_vmlinux_id = btf_obj_id(st_map->btf); +} |