pub type ProgramMut<'obj> = ProgramImpl<'obj, Mut>;
Expand description
A mutable loaded BPF program.
Aliased Type§
struct ProgramMut<'obj> { /* private fields */ }
Implementations§
Source§impl<'obj> ProgramMut<'obj>
impl<'obj> ProgramMut<'obj>
Sourcepub fn new_mut(prog: &'obj mut bpf_program) -> Self
pub fn new_mut(prog: &'obj mut bpf_program) -> Self
Create a Program
from a libbpf_sys::bpf_program
Sourcepub fn attach_perf_event(&self, pfd: i32) -> Result<Link>
pub fn attach_perf_event(&self, pfd: i32) -> Result<Link>
Attach this program to a perf event.
Sourcepub fn attach_uprobe<T: AsRef<Path>>(
&self,
retprobe: bool,
pid: i32,
binary_path: T,
func_offset: usize,
) -> Result<Link>
pub fn attach_uprobe<T: AsRef<Path>>( &self, retprobe: bool, pid: i32, binary_path: T, func_offset: usize, ) -> Result<Link>
Attach this program to a userspace probe.
Sourcepub fn attach_uprobe_with_opts(
&self,
pid: i32,
binary_path: impl AsRef<Path>,
func_offset: usize,
opts: UprobeOpts,
) -> Result<Link>
pub fn attach_uprobe_with_opts( &self, pid: i32, binary_path: impl AsRef<Path>, func_offset: usize, opts: UprobeOpts, ) -> Result<Link>
Attach this program to a userspace probe, providing additional options.
Sourcepub fn attach_kprobe<T: AsRef<str>>(
&self,
retprobe: bool,
func_name: T,
) -> Result<Link>
pub fn attach_kprobe<T: AsRef<str>>( &self, retprobe: bool, func_name: T, ) -> Result<Link>
Attach this program to a kernel probe.
Sourcepub fn attach_ksyscall<T: AsRef<str>>(
&self,
retprobe: bool,
syscall_name: T,
) -> Result<Link>
pub fn attach_ksyscall<T: AsRef<str>>( &self, retprobe: bool, syscall_name: T, ) -> Result<Link>
Attach this program to the specified syscall
Sourcepub fn attach_tracepoint(
&self,
tp_category: impl AsRef<str>,
tp_name: impl AsRef<str>,
) -> Result<Link>
pub fn attach_tracepoint( &self, tp_category: impl AsRef<str>, tp_name: impl AsRef<str>, ) -> Result<Link>
Attach this program to a kernel tracepoint.
Sourcepub fn attach_tracepoint_with_opts(
&self,
tp_category: impl AsRef<str>,
tp_name: impl AsRef<str>,
tp_opts: TracepointOpts,
) -> Result<Link>
pub fn attach_tracepoint_with_opts( &self, tp_category: impl AsRef<str>, tp_name: impl AsRef<str>, tp_opts: TracepointOpts, ) -> Result<Link>
Attach this program to a kernel tracepoint, providing additional options.
Sourcepub fn attach_raw_tracepoint<T: AsRef<str>>(&self, tp_name: T) -> Result<Link>
pub fn attach_raw_tracepoint<T: AsRef<str>>(&self, tp_name: T) -> Result<Link>
Attach this program to a raw kernel tracepoint.
Sourcepub fn attach_lsm(&self) -> Result<Link>
pub fn attach_lsm(&self) -> Result<Link>
Attach to an LSM hook
Sourcepub fn attach_trace(&self) -> Result<Link>
pub fn attach_trace(&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(&self, netns_fd: i32) -> Result<Link>
pub fn attach_netns(&self, netns_fd: i32) -> Result<Link>
Attach this program to netns-based programs
Sourcepub fn attach_netfilter_with_opts(
&self,
netfilter_opt: NetfilterOpts,
) -> Result<Link>
pub fn attach_netfilter_with_opts( &self, netfilter_opt: NetfilterOpts, ) -> Result<Link>
Attach this program to netfilter programs
Sourcepub fn attach_usdt(
&self,
pid: i32,
binary_path: impl AsRef<Path>,
usdt_provider: impl AsRef<str>,
usdt_name: impl AsRef<str>,
) -> Result<Link>
pub fn attach_usdt( &self, pid: i32, binary_path: impl AsRef<Path>, usdt_provider: impl AsRef<str>, usdt_name: impl AsRef<str>, ) -> Result<Link>
Attach this program to a USDT probe
point. The entry point of the program must be defined with
SEC("usdt")
.
Sourcepub fn attach_usdt_with_opts(
&self,
pid: i32,
binary_path: impl AsRef<Path>,
usdt_provider: impl AsRef<str>,
usdt_name: impl AsRef<str>,
usdt_opts: UsdtOpts,
) -> Result<Link>
pub fn attach_usdt_with_opts( &self, pid: i32, binary_path: impl AsRef<Path>, usdt_provider: impl AsRef<str>, usdt_name: impl AsRef<str>, usdt_opts: UsdtOpts, ) -> Result<Link>
Attach this program to a USDT probe
point, providing additional options. The entry point of the program must
be defined with SEC("usdt")
.
Sourcepub fn attach_iter(&self, map_fd: BorrowedFd<'_>) -> Result<Link>
pub fn attach_iter(&self, map_fd: BorrowedFd<'_>) -> Result<Link>
Attach this program to a
BPF Iterator.
The entry point of the program must be defined with SEC("iter")
or SEC("iter.s")
.
Methods from Deref<Target = Program<'obj>>§
Sourcepub fn prog_type(&self) -> ProgramType
pub fn prog_type(&self) -> ProgramType
Retrieve the type of the 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
.
Sourcepub fn attach_perf_event(&self, pfd: i32) -> Result<Link>
pub fn attach_perf_event(&self, pfd: i32) -> Result<Link>
Attach this program to a perf event.
Sourcepub fn attach_uprobe<T: AsRef<Path>>(
&self,
retprobe: bool,
pid: i32,
binary_path: T,
func_offset: usize,
) -> Result<Link>
pub fn attach_uprobe<T: AsRef<Path>>( &self, retprobe: bool, pid: i32, binary_path: T, func_offset: usize, ) -> Result<Link>
Attach this program to a userspace probe.
Sourcepub fn attach_uprobe_with_opts(
&self,
pid: i32,
binary_path: impl AsRef<Path>,
func_offset: usize,
opts: UprobeOpts,
) -> Result<Link>
pub fn attach_uprobe_with_opts( &self, pid: i32, binary_path: impl AsRef<Path>, func_offset: usize, opts: UprobeOpts, ) -> Result<Link>
Attach this program to a userspace probe, providing additional options.
Sourcepub fn attach_kprobe<T: AsRef<str>>(
&self,
retprobe: bool,
func_name: T,
) -> Result<Link>
pub fn attach_kprobe<T: AsRef<str>>( &self, retprobe: bool, func_name: T, ) -> Result<Link>
Attach this program to a kernel probe.
Sourcepub fn attach_ksyscall<T: AsRef<str>>(
&self,
retprobe: bool,
syscall_name: T,
) -> Result<Link>
pub fn attach_ksyscall<T: AsRef<str>>( &self, retprobe: bool, syscall_name: T, ) -> Result<Link>
Attach this program to the specified syscall
Sourcepub fn attach_tracepoint(
&self,
tp_category: impl AsRef<str>,
tp_name: impl AsRef<str>,
) -> Result<Link>
pub fn attach_tracepoint( &self, tp_category: impl AsRef<str>, tp_name: impl AsRef<str>, ) -> Result<Link>
Attach this program to a kernel tracepoint.
Sourcepub fn attach_tracepoint_with_opts(
&self,
tp_category: impl AsRef<str>,
tp_name: impl AsRef<str>,
tp_opts: TracepointOpts,
) -> Result<Link>
pub fn attach_tracepoint_with_opts( &self, tp_category: impl AsRef<str>, tp_name: impl AsRef<str>, tp_opts: TracepointOpts, ) -> Result<Link>
Attach this program to a kernel tracepoint, providing additional options.
Sourcepub fn attach_raw_tracepoint<T: AsRef<str>>(&self, tp_name: T) -> Result<Link>
pub fn attach_raw_tracepoint<T: AsRef<str>>(&self, tp_name: T) -> Result<Link>
Attach this program to a raw kernel tracepoint.
Sourcepub fn attach_lsm(&self) -> Result<Link>
pub fn attach_lsm(&self) -> Result<Link>
Attach to an LSM hook
Sourcepub fn attach_trace(&self) -> Result<Link>
pub fn attach_trace(&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(&self, netns_fd: i32) -> Result<Link>
pub fn attach_netns(&self, netns_fd: i32) -> Result<Link>
Attach this program to netns-based programs
Sourcepub fn attach_netfilter_with_opts(
&self,
netfilter_opt: NetfilterOpts,
) -> Result<Link>
pub fn attach_netfilter_with_opts( &self, netfilter_opt: NetfilterOpts, ) -> Result<Link>
Attach this program to netfilter programs
Sourcepub fn attach_usdt(
&self,
pid: i32,
binary_path: impl AsRef<Path>,
usdt_provider: impl AsRef<str>,
usdt_name: impl AsRef<str>,
) -> Result<Link>
pub fn attach_usdt( &self, pid: i32, binary_path: impl AsRef<Path>, usdt_provider: impl AsRef<str>, usdt_name: impl AsRef<str>, ) -> Result<Link>
Attach this program to a USDT probe
point. The entry point of the program must be defined with
SEC("usdt")
.
Sourcepub fn attach_usdt_with_opts(
&self,
pid: i32,
binary_path: impl AsRef<Path>,
usdt_provider: impl AsRef<str>,
usdt_name: impl AsRef<str>,
usdt_opts: UsdtOpts,
) -> Result<Link>
pub fn attach_usdt_with_opts( &self, pid: i32, binary_path: impl AsRef<Path>, usdt_provider: impl AsRef<str>, usdt_name: impl AsRef<str>, usdt_opts: UsdtOpts, ) -> Result<Link>
Attach this program to a USDT probe
point, providing additional options. The entry point of the program must
be defined with SEC("usdt")
.
Sourcepub fn attach_iter(&self, map_fd: BorrowedFd<'_>) -> Result<Link>
pub fn attach_iter(&self, map_fd: BorrowedFd<'_>) -> Result<Link>
Attach this program to a
BPF Iterator.
The entry point of the program must be defined with SEC("iter")
or SEC("iter.s")
.