pub struct Program { /* private fields */ }
Expand description
Represents a loaded Program
.
This struct is not safe to clone because the underlying libbpf resource cannot currently be protected from data races.
If you attempt to attach a Program
with the wrong attach method, the attach_*
method will fail with the appropriate error.
Implementations
sourceimpl Program
impl Program
pub fn name(&self) -> &str
pub fn prog_type(&self) -> ProgramType
pub fn attach_type(&self) -> ProgramAttachType
sourcepub fn attach_cgroup(&mut self, cgroup_fd: i32) -> Result<Link>
pub fn attach_cgroup(&mut self, cgroup_fd: i32) -> Result<Link>
Attach this program to a cgroup.
sourcepub fn attach_perf_event(&mut self, pfd: i32) -> Result<Link>
pub fn attach_perf_event(&mut self, pfd: i32) -> Result<Link>
Attach this program to a perf event.
sourcepub fn attach_uprobe<T: AsRef<Path>>(
&mut self,
retprobe: bool,
pid: i32,
binary_path: T,
func_offset: usize
) -> Result<Link>
pub fn attach_uprobe<T: AsRef<Path>>(
&mut self,
retprobe: bool,
pid: i32,
binary_path: T,
func_offset: usize
) -> Result<Link>
Attach this program to a userspace probe.
sourcepub fn attach_kprobe<T: AsRef<str>>(
&mut self,
retprobe: bool,
func_name: T
) -> Result<Link>
pub fn attach_kprobe<T: AsRef<str>>(
&mut self,
retprobe: bool,
func_name: T
) -> Result<Link>
Attach this program to a kernel probe.
sourcepub fn attach_tracepoint<T: AsRef<str>>(
&mut self,
tp_category: T,
tp_name: T
) -> Result<Link>
pub fn attach_tracepoint<T: AsRef<str>>(
&mut self,
tp_category: T,
tp_name: T
) -> Result<Link>
Attach this program to a kernel tracepoint.
sourcepub fn attach_raw_tracepoint<T: AsRef<str>>(
&mut self,
tp_name: T
) -> Result<Link>
pub fn attach_raw_tracepoint<T: AsRef<str>>(
&mut self,
tp_name: T
) -> Result<Link>
Attach this program to a raw kernel tracepoint.
sourcepub fn attach_lsm(&mut self) -> Result<Link>
pub fn attach_lsm(&mut self) -> Result<Link>
Attach to an LSM hook
sourcepub fn attach_trace(&mut self) -> Result<Link>
pub fn attach_trace(&mut self) -> Result<Link>
Attach to a fentry/fexit kernel probe
sourcepub fn attach_sockmap(&self, map_fd: i32) -> Result<()>
pub fn attach_sockmap(&self, map_fd: i32) -> Result<()>
Attach a verdict/parser to a sockmap/sockhash
sourcepub fn attach_netns(&mut self, netns_fd: i32) -> Result<Link>
pub fn attach_netns(&mut self, netns_fd: i32) -> Result<Link>
Attach this program to netns-based programs
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
.
Auto Trait Implementations
impl RefUnwindSafe for Program
impl !Send for Program
impl !Sync for Program
impl Unpin for Program
impl UnwindSafe for Program
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more