mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-05 08:09:07 +08:00
libbpf: Allow version suffixes (___smth) for struct_ops types
E.g. allow the following struct_ops definitions:
struct bpf_testmod_ops___v1 { int (*test)(void); };
struct bpf_testmod_ops___v2 { int (*test)(void); };
SEC(".struct_ops.link")
struct bpf_testmod_ops___v1 a = { .test = ... }
SEC(".struct_ops.link")
struct bpf_testmod_ops___v2 b = { .test = ... }
Where both bpf_testmod_ops__v1 and bpf_testmod_ops__v2 would be
resolved as 'struct bpf_testmod_ops' from kernel BTF.
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: David Vernet <void@manifault.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240306104529.6453-2-eddyz87@gmail.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
00b08dceea
commit
f7fd5dbc07
@@ -948,7 +948,7 @@ static int find_btf_by_prefix_kind(const struct btf *btf, const char *prefix,
|
|||||||
const char *name, __u32 kind);
|
const char *name, __u32 kind);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
find_struct_ops_kern_types(struct bpf_object *obj, const char *tname,
|
find_struct_ops_kern_types(struct bpf_object *obj, const char *tname_raw,
|
||||||
struct module_btf **mod_btf,
|
struct module_btf **mod_btf,
|
||||||
const struct btf_type **type, __u32 *type_id,
|
const struct btf_type **type, __u32 *type_id,
|
||||||
const struct btf_type **vtype, __u32 *vtype_id,
|
const struct btf_type **vtype, __u32 *vtype_id,
|
||||||
@@ -958,8 +958,12 @@ find_struct_ops_kern_types(struct bpf_object *obj, const char *tname,
|
|||||||
const struct btf_member *kern_data_member;
|
const struct btf_member *kern_data_member;
|
||||||
struct btf *btf;
|
struct btf *btf;
|
||||||
__s32 kern_vtype_id, kern_type_id;
|
__s32 kern_vtype_id, kern_type_id;
|
||||||
|
char tname[256];
|
||||||
__u32 i;
|
__u32 i;
|
||||||
|
|
||||||
|
snprintf(tname, sizeof(tname), "%.*s",
|
||||||
|
(int)bpf_core_essential_name_len(tname_raw), tname_raw);
|
||||||
|
|
||||||
kern_type_id = find_ksym_btf_id(obj, tname, BTF_KIND_STRUCT,
|
kern_type_id = find_ksym_btf_id(obj, tname, BTF_KIND_STRUCT,
|
||||||
&btf, mod_btf);
|
&btf, mod_btf);
|
||||||
if (kern_type_id < 0) {
|
if (kern_type_id < 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user