]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Add cookie to raw_tp bpf_link_info
authorTao Chen <chen.dylane@linux.dev>
Tue, 3 Jun 2025 15:43:07 +0000 (23:43 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 5 Jun 2025 18:44:52 +0000 (11:44 -0700)
After commit 68ca5d4eebb8 ("bpf: support BPF cookie in raw tracepoint
(raw_tp, tp_btf) programs"), we can show the cookie in bpf_link_info
like kprobe etc.

Signed-off-by: Tao Chen <chen.dylane@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20250603154309.3063644-1-chen.dylane@linux.dev
include/uapi/linux/bpf.h
kernel/bpf/syscall.c
tools/include/uapi/linux/bpf.h

index 85180e4aaa5a9cda3aa223f8dc32757bc0815961..f1160ebbf526581b38ca5284169099518208915d 100644 (file)
@@ -6651,6 +6651,8 @@ struct bpf_link_info {
                struct {
                        __aligned_u64 tp_name; /* in/out: tp_name buffer ptr */
                        __u32 tp_name_len;     /* in/out: tp_name buffer len */
+                       __u32 :32;
+                       __u64 cookie;
                } raw_tracepoint;
                struct {
                        __u32 attach_type;
index dd5304c6ac3cc1d700cf32dc5aa30e39c55dafee..89d027cd7ca037b8719ed200cdaf9cbe86ae2f38 100644 (file)
@@ -3688,6 +3688,7 @@ static int bpf_raw_tp_link_fill_link_info(const struct bpf_link *link,
                return -EINVAL;
 
        info->raw_tracepoint.tp_name_len = tp_len + 1;
+       info->raw_tracepoint.cookie = raw_tp_link->cookie;
 
        if (!ubuf)
                return 0;
index 85180e4aaa5a9cda3aa223f8dc32757bc0815961..f1160ebbf526581b38ca5284169099518208915d 100644 (file)
@@ -6651,6 +6651,8 @@ struct bpf_link_info {
                struct {
                        __aligned_u64 tp_name; /* in/out: tp_name buffer ptr */
                        __u32 tp_name_len;     /* in/out: tp_name buffer len */
+                       __u32 :32;
+                       __u64 cookie;
                } raw_tracepoint;
                struct {
                        __u32 attach_type;