Hi! This series starts with two minor clean ups to test_offload.py selftest script.
The next 9 patches extend the abilities of bpftool prog load beyond the simple cgroup use cases. Three new parameters are added: - type - allows specifying program type, independent of how code sections are named; - map - allows reusing existing maps, instead of creating a new map on every program load; - dev - offload/binding to a device. A number of changes to libbpf is required to accomplish the task. The section - program type logic mapping is exposed. We should probably aim to use the libbpf program section naming everywhere. For reuse of maps we need to allow users to set FD for bpf map object in libbpf. Examples Load program my_xdp.o and pin it as /sys/fs/bpf/my_xdp, for xdp program type: $ bpftool prog load my_xdp.o /sys/fs/bpf/my_xdp \ type xdp As above but for offload: $ bpftool prog load my_xdp.o /sys/fs/bpf/my_xdp \ type xdp \ dev netdevsim0 Load program my_maps.o, but for the first map reuse map id 17, and for the map called "other_map" reuse pinned map /sys/fs/bpf/map0: $ bpftool prog load my_maps.o /sys/fs/bpf/prog \ map idx 0 id 17 \ map name other_map pinned /sys/fs/bpf/map0 --- v2: - add compat for reallocarray(). Jakub Kicinski (12): selftests/bpf: remove duplicated word from test offloads selftests/bpf: add Error: prefix in check_extack helper tools: bpftool: refactor argument parsing for prog load tools: bpftool: add support for loading programs for offload tools: libbpf: expose the prog type guessing from section name logic tools: bpftool: allow users to specify program type for prog load tools: libbpf: recognize offload neutral maps tools: libbpf: add extended attributes version of bpf_object__open() tools: bpftool: reimplement bpf_prog_load() for prog load tools: bpf: make use of reallocarray tools: libbpf: allow map reuse tools: bpftool: allow reuse of maps with bpftool prog load .../bpftool/Documentation/bpftool-prog.rst | 33 ++- tools/bpf/bpftool/Makefile | 6 +- tools/bpf/bpftool/bash-completion/bpftool | 96 +++++- tools/bpf/bpftool/main.h | 19 ++ tools/bpf/bpftool/map.c | 4 +- tools/bpf/bpftool/prog.c | 245 ++++++++++++++- tools/bpf/bpftool/xlated_dumper.c | 6 +- tools/build/feature/Makefile | 4 + tools/build/feature/test-reallocarray.c | 8 + tools/include/linux/compiler-gcc.h | 4 + tools/include/linux/overflow.h | 278 ++++++++++++++++++ tools/include/tools/libc_compat.h | 23 ++ tools/lib/bpf/Makefile | 6 +- tools/lib/bpf/libbpf.c | 116 ++++++-- tools/lib/bpf/libbpf.h | 11 + tools/testing/selftests/bpf/test_offload.py | 10 +- 16 files changed, 812 insertions(+), 57 deletions(-) create mode 100644 tools/build/feature/test-reallocarray.c create mode 100644 tools/include/linux/overflow.h create mode 100644 tools/include/tools/libc_compat.h -- 2.17.1