]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: bpf__find_by_name[_kind] should use btf__get_nr_types()
authorAlan Maguire <alan.maguire@oracle.com>
Sun, 15 Nov 2020 10:46:35 +0000 (10:46 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 17 Nov 2020 04:51:34 +0000 (20:51 -0800)
commit663044e873a1335a8372233cf2cc6c0a02a594f8
tree7f5196cd11d19baeb101bc885d18e0d43037fd64
parent9bff3fc58b2fb42f7ab391a268727c1cb0e78e3d
libbpf: bpf__find_by_name[_kind] should use btf__get_nr_types()

When operating on split BTF, btf__find_by_name[_kind] will not
iterate over all types since they use btf->nr_types to show
the number of types to iterate over. For split BTF this is
the number of types _on top of base BTF_, so it will
underestimate the number of types to iterate over, especially
for vmlinux + module BTF, where the latter is much smaller.

Use btf__get_nr_types() instead.

Fixes: d2ab0e191188 ("libbpf: Implement basic split BTF support")
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/1605437195-2175-1-git-send-email-alan.maguire@oracle.com
tools/lib/bpf/btf.c