]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Allow "incomplete" basic tracing SEC() definitions
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 28 Apr 2022 18:53:47 +0000 (11:53 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 28 Apr 2022 21:45:59 +0000 (23:45 +0200)
commit31cce05434db1c3d8f9c48b460101927b4c94e99
tree84d4746943e67e4195480a1266901efcf6c7bc48
parentcc1d0f3073e560965d3a12b16ab188372af3bb44
libbpf: Allow "incomplete" basic tracing SEC() definitions

In a lot of cases the target of kprobe/kretprobe, tracepoint, raw
tracepoint, etc BPF program might not be known at the compilation time
and will be discovered at runtime. This was always a supported case by
libbpf, with APIs like bpf_program__attach_{kprobe,tracepoint,etc}()
accepting full target definition, regardless of what was defined in
SEC() definition in BPF source code.

Unfortunately, up till now libbpf still enforced users to specify at
least something for the fake target, e.g., SEC("kprobe/whatever"), which
is cumbersome and somewhat misleading.

This patch allows target-less SEC() definitions for basic tracing BPF
program types:

  - kprobe/kretprobe;
  - multi-kprobe/multi-kretprobe;
  - tracepoints;
  - raw tracepoints.

Such target-less SEC() definitions are meant to specify declaratively
proper BPF program type only. Attachment of them will have to be handled
programmatically using correct APIs. As such, skeleton's auto-attachment
of such BPF programs is skipped and generic bpf_program__attach() will
fail, if attempted, due to the lack of enough target information.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20220428185349.3799599-2-andrii@kernel.org
tools/lib/bpf/libbpf.c