2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-26 22:24:09 +08:00
linux-next/tools/lib/bpf
Andrey Ignatov 956b620fcf libbpf: Introduce libbpf_attach_type_by_name
There is a common use-case when ELF object contains multiple BPF
programs and every program has its own section name. If it's cgroup-bpf
then programs have to be 1) loaded and 2) attached to a cgroup.

It's convenient to have information necessary to load BPF program
together with program itself. This is where section name works fine in
conjunction with libbpf_prog_type_by_name that identifies prog_type and
expected_attach_type and these can be used with BPF_PROG_LOAD.

But there is currently no way to identify attach_type by section name
and it leads to messy code in user space that reinvents guessing logic
every time it has to identify attach type to use with BPF_PROG_ATTACH.

The patch introduces libbpf_attach_type_by_name that guesses attach type
by section name if a program can be attached.

The difference between expected_attach_type provided by
libbpf_prog_type_by_name and attach_type provided by
libbpf_attach_type_by_name is the former is used at BPF_PROG_LOAD time
and can be zero if a program of prog_type X has only one corresponding
attach type Y whether the latter provides specific attach type to use
with BPF_PROG_ATTACH.

No new section names were added to section_names array. Only existing
ones were reorganized and attach_type was added where appropriate.

Signed-off-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-09-27 21:14:59 +02:00
..
.gitignore tools lib bpf: Change FEATURE-DUMP to FEATURE-DUMP.libbpf 2015-11-05 12:47:51 -03:00
bpf.c tools/bpf: move bpf/lib netlink related functions into a new file 2018-09-06 22:34:08 -07:00
bpf.h bpf: Test BPF_PROG_TYPE_SK_REUSEPORT 2018-08-11 01:58:46 +02:00
btf.c Merge ra.kernel.org:/pub/scm/linux/kernel/git/davem/net 2018-08-11 17:52:00 -07:00
btf.h Merge ra.kernel.org:/pub/scm/linux/kernel/git/davem/net 2018-08-11 17:52:00 -07:00
Build Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2018-09-25 20:29:38 -07:00
libbpf_errno.c tools/bpf: add more netlink functionalities in lib/bpf 2018-09-06 22:34:08 -07:00
libbpf.c libbpf: Introduce libbpf_attach_type_by_name 2018-09-27 21:14:59 +02:00
libbpf.h libbpf: Introduce libbpf_attach_type_by_name 2018-09-27 21:14:59 +02:00
Makefile tools: libbpf: remove libelf-getphdrnum feature detection 2018-07-16 16:36:49 -07:00
netlink.c tools/bpf: fix a netlink recv issue 2018-09-11 14:26:30 -07:00
nlattr.c tools/bpf: add more netlink functionalities in lib/bpf 2018-09-06 22:34:08 -07:00
nlattr.h tools/bpf: add more netlink functionalities in lib/bpf 2018-09-06 22:34:08 -07:00
str_error.c tools lib bpf: Provide wrapper for strerror_r to build in !_GNU_SOURCE systems 2018-09-18 10:16:18 -03:00
str_error.h tools lib bpf: Provide wrapper for strerror_r to build in !_GNU_SOURCE systems 2018-09-18 10:16:18 -03:00