summaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/bpf.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2020-12-03 21:46:32 +0100
committerAlexei Starovoitov <ast@kernel.org>2020-12-04 02:38:21 +0100
commit91abb4a6d79df6c4dcd86d85632df53c8cca2dcf (patch)
tree557fc11c841adeb6784e7baa5cda3c95b6381073 /tools/lib/bpf/bpf.c
parentlibbpf: Factor out low-level BPF program loading helper (diff)
downloadlinux-91abb4a6d79df6c4dcd86d85632df53c8cca2dcf.tar.xz
linux-91abb4a6d79df6c4dcd86d85632df53c8cca2dcf.zip
libbpf: Support attachment of BPF tracing programs to kernel modules
Teach libbpf to search for BTF types in kernel modules for tracing BPF programs. This allows attachment of raw_tp/fentry/fexit/fmod_ret/etc BPF program types to tracepoints and functions in kernel modules. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20201203204634.1325171-13-andrii@kernel.org
Diffstat (limited to 'tools/lib/bpf/bpf.c')
-rw-r--r--tools/lib/bpf/bpf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 5d681ce32b37..bba48ff4c5c0 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -231,8 +231,11 @@ int libbpf__bpf_prog_load(const struct bpf_prog_load_params *load_attr)
attr.prog_type = load_attr->prog_type;
attr.expected_attach_type = load_attr->expected_attach_type;
+ if (load_attr->attach_prog_fd)
+ attr.attach_prog_fd = load_attr->attach_prog_fd;
+ else
+ attr.attach_btf_obj_fd = load_attr->attach_btf_obj_fd;
attr.attach_btf_id = load_attr->attach_btf_id;
- attr.attach_prog_fd = load_attr->attach_prog_fd;
attr.prog_ifindex = load_attr->prog_ifindex;
attr.kern_version = load_attr->kern_version;