Skip to content

Commit e859e42

Browse files
laoarAlexei Starovoitov
authored andcommitted
bpf: Show target_{obj,btf}_id in tracing link fdinfo
The target_btf_id can help us understand which kernel function is linked by a tracing prog. The target_btf_id and target_obj_id have already been exposed to userspace, so we just need to show them. The result as follows, $ cat /proc/10673/fdinfo/10 pos: 0 flags: 02000000 mnt_id: 15 ino: 2094 link_type: tracing link_id: 2 prog_tag: a04f5eef06a7f555 prog_id: 13 attach_type: 24 target_obj_id: 1 target_btf_id: 13964 Signed-off-by: Yafang Shao <laoar.shao@gmail.com> Acked-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20230517103126.68372-2-laoar.shao@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent effcf62 commit e859e42

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

kernel/bpf/syscall.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,10 +2968,17 @@ static void bpf_tracing_link_show_fdinfo(const struct bpf_link *link,
29682968
{
29692969
struct bpf_tracing_link *tr_link =
29702970
container_of(link, struct bpf_tracing_link, link.link);
2971+
u32 target_btf_id, target_obj_id;
29712972

2973+
bpf_trampoline_unpack_key(tr_link->trampoline->key,
2974+
&target_obj_id, &target_btf_id);
29722975
seq_printf(seq,
2973-
"attach_type:\t%d\n",
2974-
tr_link->attach_type);
2976+
"attach_type:\t%d\n"
2977+
"target_obj_id:\t%u\n"
2978+
"target_btf_id:\t%u\n",
2979+
tr_link->attach_type,
2980+
target_obj_id,
2981+
target_btf_id);
29752982
}
29762983

29772984
static int bpf_tracing_link_fill_link_info(const struct bpf_link *link,

0 commit comments

Comments
 (0)