libbpf: Add generic bpf_program__attach()
authorAndrii Nakryiko <andriin@fb.com>
Sat, 14 Dec 2019 01:43:26 +0000 (17:43 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 15 Dec 2019 23:58:04 +0000 (15:58 -0800)
commitd7a18ea7e8b612669acd0131fd075e5c735c1ce5
tree7f7ebd5bd4dfb74c107270cd775ce7ec23e28a7a
parent0d13bfce023ac7cef4d0a50b83750254ce31c479
libbpf: Add generic bpf_program__attach()

Generalize BPF program attaching and allow libbpf to auto-detect type (and
extra parameters, where applicable) and attach supported BPF program types
based on program sections. Currently this is supported for:
- kprobe/kretprobe;
- tracepoint;
- raw tracepoint;
- tracing programs (typed raw TP/fentry/fexit).

More types support can be trivially added within this framework.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20191214014341.3442258-3-andriin@fb.com
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf.h
tools/lib/bpf/libbpf.map
tools/testing/selftests/bpf/prog_tests/probe_user.c