]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpftool: Display cookie for raw_tp link probe
authorTao Chen <chen.dylane@linux.dev>
Tue, 3 Jun 2025 15:43:09 +0000 (23:43 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 5 Jun 2025 18:44:52 +0000 (11:44 -0700)
Display cookie for raw_tp link probe, in plain mode:

 #bpftool link

22: raw_tracepoint  prog 14
        tp 'sys_enter'  cookie 23925373020405760
        pids test_progs(176)

And in json mode:

 #bpftool link -j | jq

[
  {
    "id": 47,
    "type": "raw_tracepoint",
    "prog_id": 79,
    "tp_name": "sys_enter",
    "cookie": 23925373020405760,
    "pids": [
      {
        "pid": 274,
        "comm": "test_progs"
      }
    ]
  }
]

Signed-off-by: Tao Chen <chen.dylane@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/bpf/20250603154309.3063644-3-chen.dylane@linux.dev
tools/bpf/bpftool/link.c

index 3535afc80a49999da4156e7d50e7b9bff6275016..cb67ce4eba241894fb5b47fd771fa149878bfae3 100644 (file)
@@ -485,6 +485,7 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
        case BPF_LINK_TYPE_RAW_TRACEPOINT:
                jsonw_string_field(json_wtr, "tp_name",
                                   u64_to_ptr(info->raw_tracepoint.tp_name));
+               jsonw_uint_field(json_wtr, "cookie", info->raw_tracepoint.cookie);
                break;
        case BPF_LINK_TYPE_TRACING:
                err = get_prog_info(info->prog_id, &prog_info);
@@ -879,6 +880,8 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
        case BPF_LINK_TYPE_RAW_TRACEPOINT:
                printf("\n\ttp '%s'  ",
                       (const char *)u64_to_ptr(info->raw_tracepoint.tp_name));
+               if (info->raw_tracepoint.cookie)
+                       printf("cookie %llu  ", info->raw_tracepoint.cookie);
                break;
        case BPF_LINK_TYPE_TRACING:
                err = get_prog_info(info->prog_id, &prog_info);