[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211022171647.27885-1-quentin@isovalent.com>
Date: Fri, 22 Oct 2021 18:16:42 +0100
From: Quentin Monnet <quentin@...valent.com>
To: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>
Cc: netdev@...r.kernel.org, bpf@...r.kernel.org,
Quentin Monnet <quentin@...valent.com>
Subject: [PATCH bpf-next 0/5] bpftool: Switch to libbpf's hashmap for referencing BPF objects
When listing BPF objects, bpftool can print a number of properties about
items holding references to these objects. For example, it can show pinned
paths for BPF programs, maps, and links; or programs and maps using a given
BTF object; or the names and PIDs of processes referencing BPF objects. To
collect this information, bpftool uses hash maps (to be clear: the data
structures, inside bpftool - we are not talking of BPF maps). It uses the
implementation available from the kernel, and picks it up from
tools/include/linux/hashtable.h.
This patchset converts bpftool's hash maps to a distinct implementation
instead, the one coming with libbpf. The main motivation for this change is
that it should ease the path towards a potential out-of-tree mirror for
bpftool, like the one libbpf already has. Although it's not perfect to
depend on libbpf's internal components, bpftool is intimately tied with the
library anyway, and this looks better than depending too much on (non-UAPI)
kernel headers.
The first two patches contain preparatory work on the Makefile and on the
initialisation of the hash maps for collecting pinned paths for objects.
Then the transition is split into several steps, one for each kind of
properties for which the collection is backed by hash maps.
Quentin Monnet (5):
bpftool: Remove Makefile dep. on $(LIBBPF) for $(LIBBPF_INTERNAL_HDRS)
bpftool: Do not expose and init hash maps for pinned path in main.c
bpftool: Switch to libbpf's hashmap for pinned paths of BPF objects
bpftool: Switch to libbpf's hashmap for programs/maps in BTF listing
bpftool: Switch to libbpf's hashmap for PIDs/names references
tools/bpf/bpftool/Makefile | 12 ++--
tools/bpf/bpftool/btf.c | 133 +++++++++++++++----------------------
tools/bpf/bpftool/common.c | 50 +++++++-------
tools/bpf/bpftool/link.c | 44 +++++++-----
tools/bpf/bpftool/main.c | 17 +----
tools/bpf/bpftool/main.h | 54 +++++++--------
tools/bpf/bpftool/map.c | 44 +++++++-----
tools/bpf/bpftool/pids.c | 84 ++++++++++++-----------
tools/bpf/bpftool/prog.c | 44 +++++++-----
9 files changed, 246 insertions(+), 236 deletions(-)
--
2.30.2
Powered by blists - more mailing lists