]> git.proxmox.com Git - mirror_ubuntu-jammy-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)
commitc7ef5ec9573f05535370d8716576263681cabec7
tree68508d7da319263b308001faabb28714e3ad6979
parent6245947c1b3c6783976e3af113bac30250d0a93e
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