From 16bcff70988ab32f2c825d21ed7041d736d11d61 Mon Sep 17 00:00:00 2001 From: Ihor Solodrai Date: Wed, 22 Jul 2026 16:35:14 -0700 Subject: [PATCH] libbpf: Export btf__find_by_name_kind_own() btf__find_by_name_kind() searches the base BTF before the split BTF, so in case of a name collision between base and split it always returns a base type. Tools that process split BTF may need to restrict a lookup to the split's own types. The internal helper btf__find_by_name_kind_own() already does exactly that. Make it a public API. Signed-off-by: Ihor Solodrai Signed-off-by: Andrii Nakryiko Reviewed-by: Eduard Zingerman Link: https://lore.kernel.org/bpf/20260722233518.778854-5-ihor.solodrai@linux.dev --- src/btf.h | 2 ++ src/libbpf.map | 1 + src/libbpf_internal.h | 2 -- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/btf.h b/src/btf.h index 1a31f2d..587172c 100644 --- a/src/btf.h +++ b/src/btf.h @@ -172,6 +172,8 @@ LIBBPF_API __s32 btf__find_by_name(const struct btf *btf, const char *type_name); LIBBPF_API __s32 btf__find_by_name_kind(const struct btf *btf, const char *type_name, __u32 kind); +LIBBPF_API __s32 btf__find_by_name_kind_own(const struct btf *btf, + const char *type_name, __u32 kind); LIBBPF_API __u32 btf__type_cnt(const struct btf *btf); LIBBPF_API const struct btf *btf__base_btf(const struct btf *btf); LIBBPF_API const struct btf_type *btf__type_by_id(const struct btf *btf, diff --git a/src/libbpf.map b/src/libbpf.map index b731df1..08ab2ea 100644 --- a/src/libbpf.map +++ b/src/libbpf.map @@ -460,5 +460,6 @@ LIBBPF_1.8.0 { global: bpf_program__attach_tracing_multi; bpf_program__clone; + btf__find_by_name_kind_own; btf__new_empty_opts; } LIBBPF_1.7.0; diff --git a/src/libbpf_internal.h b/src/libbpf_internal.h index d5b7db7..7a74abb 100644 --- a/src/libbpf_internal.h +++ b/src/libbpf_internal.h @@ -596,8 +596,6 @@ typedef int (*type_id_visit_fn)(__u32 *type_id, void *ctx); typedef int (*str_off_visit_fn)(__u32 *str_off, void *ctx); int btf_ext_visit_type_ids(struct btf_ext *btf_ext, type_id_visit_fn visit, void *ctx); int btf_ext_visit_str_offs(struct btf_ext *btf_ext, str_off_visit_fn visit, void *ctx); -__s32 btf__find_by_name_kind_own(const struct btf *btf, const char *type_name, - __u32 kind); /* handle direct returned errors */ static inline int libbpf_err(int ret)