bpftool: Switch to libbpf's hashmap for pinned paths of BPF objects
authorQuentin Monnet <quentin@isovalent.com>
Sat, 23 Oct 2021 20:51:52 +0000 (21:51 +0100)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 26 Oct 2021 00:31:38 +0000 (17:31 -0700)
commit8f184732b60b74a8f8ba0d9a5c248bf611b1ebba
treefbf12e3231af7eb7feb1428d2956301d9834fecf
parent46241271d18f3ae095b7ec3d9d136d8f4e28e025
bpftool: Switch to libbpf's hashmap for pinned paths of BPF objects

In order to show pinned paths for BPF programs, maps, or links when
listing them with the "-f" option, bpftool creates hash maps to store
all relevant paths under the bpffs. So far, it would rely on the
kernel implementation (from tools/include/linux/hashtable.h).

We can make bpftool rely on libbpf's implementation instead. The
motivation is to make bpftool less dependent of kernel headers, to ease
the path to a potential out-of-tree mirror, like libbpf has.

This commit is the first step of the conversion: the hash maps for
pinned paths for programs, maps, and links are converted to libbpf's
hashmap.{c,h}. Other hash maps used for the PIDs of process holding
references to BPF objects are left unchanged for now. On the build side,
this requires adding a dependency to a second header internal to libbpf,
and making it a dependency for the bootstrap bpftool version as well.
The rest of the changes are a rather straightforward conversion.

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211023205154.6710-4-quentin@isovalent.com
tools/bpf/bpftool/Makefile
tools/bpf/bpftool/common.c
tools/bpf/bpftool/link.c
tools/bpf/bpftool/main.h
tools/bpf/bpftool/map.c
tools/bpf/bpftool/prog.c