|
|
|
@ -1000,6 +1000,7 @@ impl_info!(
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/// Provides information about a loaded program, like name, id and statistics
|
|
|
|
|
#[doc(alias = "bpf_prog_info")]
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub struct ProgramInfo(bpf_prog_info);
|
|
|
|
|
|
|
|
|
@ -1099,6 +1100,27 @@ impl ProgramInfo {
|
|
|
|
|
Ok(ProgramFd(fd))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The accumulated time that the program has been actively running.
|
|
|
|
|
///
|
|
|
|
|
/// This is not to be confused with the duration since the program was
|
|
|
|
|
/// first loaded on the host.
|
|
|
|
|
///
|
|
|
|
|
/// Note this field is only updated for as long as
|
|
|
|
|
/// [`enable_stats`](crate::sys::enable_stats) is enabled
|
|
|
|
|
/// with [`Stats::RunTime`](crate::sys::Stats::RunTime).
|
|
|
|
|
pub fn run_time(&self) -> Duration {
|
|
|
|
|
Duration::from_nanos(self.0.run_time_ns)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The accumulated execution count of the program.
|
|
|
|
|
///
|
|
|
|
|
/// Note this field is only updated for as long as
|
|
|
|
|
/// [`enable_stats`](crate::sys::enable_stats) is enabled
|
|
|
|
|
/// with [`Stats::RunTime`](crate::sys::Stats::RunTime).
|
|
|
|
|
pub fn run_count(&self) -> u64 {
|
|
|
|
|
self.0.run_cnt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Loads a program from a pinned path in bpffs.
|
|
|
|
|
pub fn from_pin<P: AsRef<Path>>(path: P) -> Result<Self, ProgramError> {
|
|
|
|
|
use std::os::unix::ffi::OsStrExt as _;
|
|
|
|
|