pub type OpenProgram<'obj> = OpenProgramImpl<'obj>;
Expand description
An immutable parsed but not yet loaded BPF program.
Aliased Type§
struct OpenProgram<'obj> { /* private fields */ }
Implementations§
Source§impl<'obj> OpenProgram<'obj>
impl<'obj> OpenProgram<'obj>
Sourcepub fn new(prog: &'obj bpf_program) -> Self
pub fn new(prog: &'obj bpf_program) -> Self
Create a new OpenProgram
from a ptr to a libbpf_sys::bpf_program
.
Sourcepub fn prog_type(&self) -> ProgramType
pub fn prog_type(&self) -> ProgramType
The ProgramType
of this OpenProgram
.
Sourcepub fn insn_cnt(&self) -> usize
pub fn insn_cnt(&self) -> usize
Returns the number of instructions that form the program.
Note: Keep in mind, libbpf can modify the program’s instructions
and consequently its instruction count, as it processes the BPF object file.
So OpenProgram::insn_cnt
and Program::insn_cnt
may return different values.
Sourcepub fn insns(&self) -> &[bpf_insn]
pub fn insns(&self) -> &[bpf_insn]
Gives read-only access to BPF program’s underlying BPF instructions.
Keep in mind, libbpf can modify and append/delete BPF program’s
instructions as it processes BPF object file and prepares everything for
uploading into the kernel. So OpenProgram::insns
and Program::insns
may return
different sets of instructions. As an example, during BPF object load phase BPF program
instructions will be CO-RE-relocated, BPF subprograms instructions will be appended, ldimm64
instructions will have FDs embedded, etc. So instructions returned before load and after it
might be quite different.