]> git.dujemihanovic.xyz Git - linux.git/commit
bpftool: Do not expose and init hash maps for pinned path in main.c
authorQuentin Monnet <quentin@isovalent.com>
Sat, 23 Oct 2021 20:51:51 +0000 (21:51 +0100)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 26 Oct 2021 00:31:38 +0000 (17:31 -0700)
commit46241271d18f3ae095b7ec3d9d136d8f4e28e025
tree430d856d30c519e5ffeaa2dea4fe4f6d7c35214c
parent8b6c46241c774c83998092a4eafe40f054568881
bpftool: Do not expose and init hash maps for pinned path in main.c

BPF programs, maps, and links, can all be listed with their pinned paths
by bpftool, when the "-f" option is provided. To do so, bpftool builds
hash maps containing all pinned paths for each kind of objects.

These three hash maps are always initialised in main.c, and exposed
through main.h. There appear to be no particular reason to do so: we can
just as well make them static to the files that need them (prog.c,
map.c, and link.c respectively), and initialise them only when we want
to show objects and the "-f" switch is provided.

This may prevent unnecessary memory allocations if the implementation of
the hash maps was to change in the future.

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