Skip to content

Commit 3644d28

Browse files
ThinkerYzu1anakryiko
authored andcommitted
libbpf: Set btf_value_type_id of struct bpf_map for struct_ops.
For a struct_ops map, btf_value_type_id is the type ID of it's struct type. This value is required by bpftool to generate skeleton including pointers of shadow types. The code generator gets the type ID from bpf_map__btf_value_type_id() in order to get the type information of the struct type of a map. Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20240229064523.2091270-2-thinker.li@gmail.com
1 parent 896880f commit 3644d28

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,7 @@ static int init_struct_ops_maps(struct bpf_object *obj, const char *sec_name,
12291229
map->name = strdup(var_name);
12301230
if (!map->name)
12311231
return -ENOMEM;
1232+
map->btf_value_type_id = type_id;
12321233

12331234
map->def.type = BPF_MAP_TYPE_STRUCT_OPS;
12341235
map->def.key_size = sizeof(int);
@@ -4857,6 +4858,10 @@ static int bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map, b
48574858
create_attr.btf_value_type_id = 0;
48584859
map->btf_key_type_id = 0;
48594860
map->btf_value_type_id = 0;
4861+
break;
4862+
case BPF_MAP_TYPE_STRUCT_OPS:
4863+
create_attr.btf_value_type_id = 0;
4864+
break;
48604865
default:
48614866
break;
48624867
}

0 commit comments

Comments
 (0)