• Quentin Monnet's avatar
    bpftool: Switch to libbpf's hashmap for pinned paths of BPF objects · 8f184732
    Quentin Monnet authored
    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: default avatarQuentin Monnet <quentin@isovalent.com>
    Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211023205154.6710-4-quentin@isovalent.com
    8f184732
link.c 9.42 KB