Skip to main content

ProgramInfo

Struct ProgramInfo 

Source
pub struct ProgramInfo(/* private fields */);
Expand description

Provides metadata information about a loaded eBPF program.

Introduced in kernel v4.13.

Implementations§

Source§

impl ProgramInfo

Source

pub fn program_type(&self) -> bpf_prog_type

The type of program.

Introduced in kernel v4.13.

Source

pub const fn id(&self) -> u32

The unique ID for this program.

Introduced in kernel v4.13.

Source

pub const fn tag(&self) -> u64

The program tag.

The tag is a SHA sum of the program’s instructions which be used as an alternative to Self::id(). A program’s ID can vary every time it’s loaded or unloaded, but the tag will remain the same.

Introduced in kernel v4.13.

Source

pub const fn size_jitted(&self) -> u32

The size in bytes of the program’s JIT-compiled machine code.

Note that this field is only updated when BPF JIT compiler is enabled. Kernels v4.15 and above may already have it enabled by default.

Introduced in kernel v4.13.

Source

pub fn size_translated(&self) -> Option<u32>

The size in bytes of the program’s translated eBPF bytecode.

The translated bytecode is after it has been passed though the verifier where it was possibly modified by the kernel.

None is returned if the field is not available.

Introduced in kernel v4.15.

Source

pub fn loaded_at(&self) -> Option<SystemTime>

The time when the program was loaded.

None is returned if the field is not available.

Introduced in kernel v4.15.

Source

pub fn created_by_uid(&self) -> Option<u32>

The user ID of the process who loaded the program.

None is returned if the field is not available.

Introduced in kernel v4.15.

Source

pub fn map_ids(&self) -> Result<Option<Vec<u32>>, ProgramError>

The IDs of the maps used by the program.

None is returned if the field is not available.

Introduced in kernel v4.15.

Source

pub fn name(&self) -> &[u8]

The name of the program as was provided when it was load. This is limited to 16 bytes.

Introduced in kernel v4.15.

Source

pub fn name_as_str(&self) -> Option<&str>

The name of the program as a &str.

None is returned if the name was not valid unicode or if field is not available.

Introduced in kernel v4.15.

Source

pub fn gpl_compatible(&self) -> Option<bool>

Returns true if the program is defined with a GPL-compatible license.

None is returned if the field is not available.

Introduced in kernel v4.18.

Source

pub fn btf_id(&self) -> Option<u32>

The BTF ID for the program.

Introduced in kernel v5.0.

Source

pub const fn run_time(&self) -> Duration

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 is enabled with Stats::RunTime.

Introduced in kernel v5.1.

Source

pub const fn run_count(&self) -> u64

The accumulated execution count of the program.

Note this field is only updated for as long as enable_stats is enabled with Stats::RunTime.

Introduced in kernel v5.1.

Source

pub fn verified_instruction_count(&self) -> Option<u32>

The number of verified instructions in the program.

This may be less than the total number of instructions in the compiled program due to dead code elimination in the verifier.

None is returned if the field is not available.

Introduced in kernel v5.16.

Source

pub fn memory_locked(&self) -> Result<u32, ProgramError>

How much memory in bytes has been allocated and locked for the program.

Source

pub fn fd(&self) -> Result<ProgramFd, ProgramError>

Returns a file descriptor referencing the program.

The returned file descriptor can be closed at any time and doing so does not influence the life cycle of the program.

Uses kernel v4.13 features.

Source

pub fn from_pin<P: AsRef<Path>>(path: P) -> Result<Self, ProgramError>

Loads a program from a pinned path in bpffs.

Uses kernel v4.4 and v4.13 features.

Trait Implementations§

Source§

impl Debug for ProgramInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.