pub type Program<'obj> = ProgramImpl<'obj>;
Expand description
An immutable loaded BPF program.
Aliased Type§
struct Program<'obj> { /* private fields */ }
Implementations§
Source§impl<'obj> Program<'obj>
impl<'obj> Program<'obj>
Sourcepub fn new(prog: &'obj bpf_program) -> Self
pub fn new(prog: &'obj bpf_program) -> Self
Create a Program
from a libbpf_sys::bpf_program
Sourcepub fn prog_type(&self) -> ProgramType
pub fn prog_type(&self) -> ProgramType
Retrieve the type of the program.
pub fn get_fd_by_id(id: u32) -> Result<OwnedFd>
👎Deprecated: renamed to Program::fd_from_id
Sourcepub fn fd_from_id(id: u32) -> Result<OwnedFd>
pub fn fd_from_id(id: u32) -> Result<OwnedFd>
Returns program file descriptor given a program ID.
pub fn get_id_by_fd(fd: BorrowedFd<'_>) -> Result<u32>
👎Deprecated: renamed to Program::id_from_fd
Sourcepub fn id_from_fd(fd: BorrowedFd<'_>) -> Result<u32>
pub fn id_from_fd(fd: BorrowedFd<'_>) -> Result<u32>
Returns program ID given a file descriptor.
Sourcepub fn fd_from_pinned_path<P: AsRef<Path>>(path: P) -> Result<OwnedFd>
pub fn fd_from_pinned_path<P: AsRef<Path>>(path: P) -> Result<OwnedFd>
Returns fd of a previously pinned program
Returns error, if the pinned path doesn’t represent an eBPF program.
Sourcepub fn attach_type(&self) -> ProgramAttachType
pub fn attach_type(&self) -> ProgramAttachType
Retrieve the attach type of the program.
Sourcepub fn autoload(&self) -> bool
pub fn autoload(&self) -> bool
Return true
if the bpf program is set to autoload, false
otherwise.
Sourcepub fn insn_cnt(&self) -> usize
pub fn insn_cnt(&self) -> usize
Returns the number of instructions that form the program.
Please see note in OpenProgram::insn_cnt
.
Sourcepub fn insns(&self) -> &[bpf_insn]
pub fn insns(&self) -> &[bpf_insn]
Gives read-only access to BPF program’s underlying BPF instructions.
Please see note in OpenProgram::insns
.