]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Refactor BTF map definition parsing
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 23 Apr 2021 18:13:36 +0000 (11:13 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 23 Apr 2021 21:05:26 +0000 (14:05 -0700)
commitb6cc49aa963953e3a396018cb381d5ba77fd1e87
tree68508d7da319263b308001faabb28714e3ad6979
parentc722e51c12d22952235e6717d8669f931ee9560c
libbpf: Refactor BTF map definition parsing

Refactor BTF-defined maps parsing logic to allow it to be nicely reused by BPF
static linker. Further, at least for BPF static linker, it's important to know
which attributes of a BPF map were defined explicitly, so provide a bit set
for each known portion of BTF map definition. This allows BPF static linker to
do a simple check when dealing with extern map declarations.

The same capabilities allow to distinguish attributes explicitly set to zero
(e.g., __uint(max_entries, 0)) vs the case of not specifying it at all (no
max_entries attribute at all). Libbpf is currently not utilizing that, but it
could be useful for backwards compatibility reasons later.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20210423181348.1801389-7-andrii@kernel.org
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf_internal.h