Skip to content

Commit 8f7d4d0

Browse files
frobwared-e-s-o
authored andcommitted
Enhance bpf_query to show TracingLinkInfo fields
The enhanced TracingLinkInfo struct now includes target_obj_id and target_btf_id fields that are directly available from the kernel's bpf_link_info structure. This eliminates the need for additional syscalls to retrieve BTF information for tracing links. Example output: $ sudo ./target/debug/bpf_query link id= 6 prog_id=1437 type=tracing attach_type=LsmMac target_obj_id=1 target_btf_id=59022 This output correlates with bpftool: $ sudo bpftool link show id 6 6: tracing prog 1437 prog_type lsm attach_type lsm_mac target_obj_id 1 target_btf_id 59022 Signed-off-by: Andrew McDermott <[email protected]>
1 parent 3b5082e commit 8f7d4d0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

examples/bpf_query/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ fn link() {
101101
"id={:4} prog_id={:4} type={}",
102102
link.id, link.prog_id, link_type_str
103103
);
104+
105+
if let query::LinkTypeInfo::Tracing(ref tracing) = link.info {
106+
println!(
107+
" attach_type={:?} target_obj_id={} target_btf_id={}",
108+
tracing.attach_type, tracing.target_obj_id, tracing.target_btf_id
109+
);
110+
}
104111
}
105112
}
106113

libbpf-rs/src/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ pub struct RawTracepointLinkInfo {
623623
pub struct TracingLinkInfo {
624624
/// Attach type of the tracing link.
625625
pub attach_type: ProgramAttachType,
626-
/// Target object ID (prog_id for PROG_EXT, otherwise btf object id).
626+
/// Target object ID (`prog_id` for `PROG_EXT`, otherwise btf object id).
627627
pub target_obj_id: u32,
628628
/// BTF type id inside the target object.
629629
pub target_btf_id: u32,

0 commit comments

Comments
 (0)