@@ -56,6 +56,8 @@ bool btf_member_is_reg_int(const struct btf *btf, const struct btf_type *s,
int btf_find_spin_lock(const struct btf *btf, const struct btf_type *t);
bool btf_type_is_void(const struct btf_type *t);
s32 btf_find_by_name_kind(const struct btf *btf, const char *name, u8 kind);
+s32 btf_find_by_name_kind_next(const struct btf *btf, const char *name, u8 kind,
+ u32 start_id);
const struct btf_type *btf_type_skip_modifiers(const struct btf *btf,
u32 id, u32 *res_id);
const struct btf_type *btf_type_resolve_ptr(const struct btf *btf,
@@ -383,12 +383,18 @@ static bool btf_type_is_datasec(const struct btf_type *t)
}
s32 btf_find_by_name_kind(const struct btf *btf, const char *name, u8 kind)
+{
+ return btf_find_by_name_kind_next(btf, name, kind, 1);
+}
+
+s32 btf_find_by_name_kind_next(const struct btf *btf, const char *name, u8 kind,
+ u32 start_id)
{
const struct btf_type *t;
const char *tname;
u32 i;
- for (i = 1; i <= btf->nr_types; i++) {
+ for (i = start_id; i <= btf->nr_types; i++) {
t = btf->types[i];
if (BTF_INFO_KIND(t->info) != kind)
continue;
Introduce btf_find_by_name_kind_next() function to find btf_id by name and kind starting from specified start_id to reuse the function in finding duplicates (e.g. structs with same name) in btf. Signed-off-by: Andrey Ignatov <rdna@fb.com> --- include/linux/btf.h | 2 ++ kernel/bpf/btf.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-)