Skip to content

Commit

Permalink
aya: add program_info() api to program
Browse files Browse the repository at this point in the history
Add a new api to the outer level `Program` structure.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
  • Loading branch information
astoycos committed Aug 14, 2023
1 parent d8f56f7 commit 8c15a20
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions aya/src/programs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,40 @@ impl Program {
Program::CgroupDevice(p) => p.fd(),
}
}

/// Returns information about a loaded program with the [`ProgramInfo`] structure.
///
/// This information is populated at load time by the kernel and can be used
/// to correlate a given [`Program`] to it's corresponding [`ProgramInfo`]
/// metadata.
pub fn program_info(&self) -> Result<ProgramInfo, ProgramError> {
match self {
Program::KProbe(p) => p.program_info(),
Program::UProbe(p) => p.program_info(),
Program::TracePoint(p) => p.program_info(),
Program::SocketFilter(p) => p.program_info(),
Program::Xdp(p) => p.program_info(),
Program::SkMsg(p) => p.program_info(),
Program::SkSkb(p) => p.program_info(),
Program::SockOps(p) => p.program_info(),
Program::SchedClassifier(p) => p.program_info(),
Program::CgroupSkb(p) => p.program_info(),
Program::CgroupSysctl(p) => p.program_info(),
Program::CgroupSockopt(p) => p.program_info(),
Program::LircMode2(p) => p.program_info(),
Program::PerfEvent(p) => p.program_info(),
Program::RawTracePoint(p) => p.program_info(),
Program::Lsm(p) => p.program_info(),
Program::BtfTracePoint(p) => p.program_info(),
Program::FEntry(p) => p.program_info(),
Program::FExit(p) => p.program_info(),
Program::Extension(p) => p.program_info(),
Program::CgroupSockAddr(p) => p.program_info(),
Program::SkLookup(p) => p.program_info(),
Program::CgroupSock(p) => p.program_info(),
Program::CgroupDevice(p) => p.program_info(),
}
}
}

#[derive(Debug)]
Expand Down

0 comments on commit 8c15a20

Please sign in to comment.