aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/bpf.c
diff options
context:
space:
mode:
authorKui-Feng Lee <[email protected]>2022-05-10 20:59:22 +0000
committerAndrii Nakryiko <[email protected]>2022-05-11 04:58:40 +0000
commit129b9c5ee2c18c3e36ec289140b5149f301118d1 (patch)
treecc4553cafe1b604183d9aae42002f7bf1db58c08 /tools/lib/bpf/bpf.c
parentbpf, x86: Attach a cookie to fentry/fexit/fmod_ret/lsm. (diff)
downloadkernel-129b9c5ee2c18c3e36ec289140b5149f301118d1.tar.gz
kernel-129b9c5ee2c18c3e36ec289140b5149f301118d1.zip
libbpf: Assign cookies to links in libbpf.
Add a cookie field to the attributes of bpf_link_create(). Add bpf_program__attach_trace_opts() to attach a cookie to a link. Signed-off-by: Kui-Feng Lee <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/lib/bpf/bpf.c')
-rw-r--r--tools/lib/bpf/bpf.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index a9d292c106c2..5660268e103f 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -863,6 +863,14 @@ int bpf_link_create(int prog_fd, int target_fd,
if (!OPTS_ZEROED(opts, kprobe_multi))
return libbpf_err(-EINVAL);
break;
+ case BPF_TRACE_FENTRY:
+ case BPF_TRACE_FEXIT:
+ case BPF_MODIFY_RETURN:
+ case BPF_LSM_MAC:
+ attr.link_create.tracing.cookie = OPTS_GET(opts, tracing.cookie, 0);
+ if (!OPTS_ZEROED(opts, tracing))
+ return libbpf_err(-EINVAL);
+ break;
default:
if (!OPTS_ZEROED(opts, flags))
return libbpf_err(-EINVAL);