linux/tools
Andrii Nakryiko 1bdb6c9a1c libbpf: Add a bunch of attribute getters/setters for map definitions
Add a bunch of getter for various aspects of BPF map. Some of these attribute
(e.g., key_size, value_size, type, etc) are available right now in struct
bpf_map_def, but this patch adds getter allowing to fetch them individually.
bpf_map_def approach isn't very scalable, when ABI stability requirements are
taken into account. It's much easier to extend libbpf and add support for new
features, when each aspect of BPF map has separate getter/setter.

Getters follow the common naming convention of not explicitly having "get" in
its name: bpf_map__type() returns map type, bpf_map__key_size() returns
key_size. Setters, though, explicitly have set in their name:
bpf_map__set_type(), bpf_map__set_key_size().

This patch ensures we now have a getter and a setter for the following
map attributes:
  - type;
  - max_entries;
  - map_flags;
  - numa_node;
  - key_size;
  - value_size;
  - ifindex.

bpf_map__resize() enforces unnecessary restriction of max_entries > 0. It is
unnecessary, because libbpf actually supports zero max_entries for some cases
(e.g., for PERF_EVENT_ARRAY map) and treats it specially during map creation
time. To allow setting max_entries=0, new bpf_map__set_max_entries() setter is
added. bpf_map__resize()'s behavior is preserved for backwards compatibility
reasons.

Map ifindex getter is added as well. There is a setter already, but no
corresponding getter. Fix this assymetry as well. bpf_map__set_ifindex()
itself is converted from void function into error-returning one, similar to
other setters. The only error returned right now is -EBUSY, if BPF map is
already loaded and has corresponding FD.

One lacking attribute with no ability to get/set or even specify it
declaratively is numa_node. This patch fixes this gap and both adds
programmatic getter/setter, as well as adds support for numa_node field in
BTF-defined map.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20200621062112.3006313-1-andriin@fb.com
2020-06-23 00:01:32 +02:00
..
accounting
arch Fix for arch/sh build regression with newer binutils, removal of SH5, 2020-06-06 15:22:01 -07:00
bootconfig tools/bootconfig: Add a summary of test cases and return error 2020-05-19 21:09:23 -04:00
bpf tools/bpftool: Relicense bpftool's BPF profiler prog as dual-license GPL/BSD 2020-06-20 00:27:19 +02:00
build perf build: Remove libaudit from the default feature checks 2020-05-29 16:51:13 -03:00
cgroup Merge branch 'block-5.7' into for-5.8/block 2020-05-09 16:13:58 -06:00
debugging
edid
firewire
firmware
gpio tools: gpio: add bias flags to lsgpio 2020-05-05 18:27:09 +02:00
hv
iio
include Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-06-13 16:27:13 -07:00
io_uring
kvm/kvm_stat
laptop
leds
lib libbpf: Add a bunch of attribute getters/setters for map definitions 2020-06-23 00:01:32 +02:00
memory-model
nfsd
objtool Rebase locking/kcsan to locking/urgent 2020-06-11 20:02:46 +02:00
pci
pcmcia
perf perf tools: Remove some duplicated includes 2020-06-02 11:09:41 -03:00
power Merge branch 'acpica' 2020-06-10 17:27:28 +02:00
scripts
spi
testing selftests/bpf: Test access to bpf map pointer 2020-06-22 22:22:59 +02:00
thermal/tmon
time
usb
virtio
vm tools/vm/page_owner_sort.c: filter out unneeded line 2020-06-03 20:09:49 -07:00
wmi
Makefile