Skip to main content

KernelAuxiliaryOps

Trait KernelAuxiliaryOps 

Source
pub trait KernelAuxiliaryOps:
    Send
    + Sync
    + 'static {
Show 15 methods // Required methods fn get_unified_map_from_ptr<F, R>(ptr: *const u8, func: F) -> BpfResult<R> where F: FnOnce(&mut UnifiedMap) -> BpfResult<R>; fn get_unified_map_from_fd<F, R>(map_fd: u32, func: F) -> BpfResult<R> where F: FnOnce(&mut UnifiedMap) -> BpfResult<R>; fn get_unified_map_ptr_from_fd(map_fd: u32) -> BpfResult<*const u8>; fn translate_instruction( instruction: Vec<u8>, ) -> BpfResult<Vec<impl EbpfInst>>; fn copy_from_user( src: *const u8, size: usize, dst: &mut [u8], ) -> BpfResult<()>; fn copy_to_user(dest: *mut u8, size: usize, src: &[u8]) -> BpfResult<()>; fn current_cpu_id() -> u32; fn perf_event_output( ctx: *mut c_void, fd: u32, flags: u32, data: &[u8], ) -> BpfResult<()>; fn string_from_user_cstr(ptr: *const u8) -> BpfResult<String>; fn ebpf_write_str(str: &str) -> BpfResult<()>; fn ebpf_time_ns() -> BpfResult<u64>; fn alloc_page() -> BpfResult<usize>; fn free_page(phys_addr: usize); fn vmap(phys_addrs: &[usize]) -> BpfResult<usize>; fn unmap(vaddr: usize);
}
Expand description

The KernelAuxiliaryOps trait provides auxiliary operations which should be implemented by the kernel or a kernel-like environment.

Required Methods§

Source

fn get_unified_map_from_ptr<F, R>(ptr: *const u8, func: F) -> BpfResult<R>
where F: FnOnce(&mut UnifiedMap) -> BpfResult<R>,

Get a unified map from a pointer.

Source

fn get_unified_map_from_fd<F, R>(map_fd: u32, func: F) -> BpfResult<R>
where F: FnOnce(&mut UnifiedMap) -> BpfResult<R>,

Get a unified map from a file descriptor.

Source

fn get_unified_map_ptr_from_fd(map_fd: u32) -> BpfResult<*const u8>

Get a unified map pointer from a file descriptor.

Source

fn translate_instruction(instruction: Vec<u8>) -> BpfResult<Vec<impl EbpfInst>>

Translate eBPF instructions, which may involve relocating map file descriptors.

Source

fn copy_from_user(src: *const u8, size: usize, dst: &mut [u8]) -> BpfResult<()>

Copy data from a user space pointer to a kernel space buffer.

Source

fn copy_to_user(dest: *mut u8, size: usize, src: &[u8]) -> BpfResult<()>

Copy data from a kernel space buffer to a user space pointer.

Source

fn current_cpu_id() -> u32

Get the current CPU ID.

Source

fn perf_event_output( ctx: *mut c_void, fd: u32, flags: u32, data: &[u8], ) -> BpfResult<()>

Output some data to a perf buf

Source

fn string_from_user_cstr(ptr: *const u8) -> BpfResult<String>

Read a string from a user space pointer.

Source

fn ebpf_write_str(str: &str) -> BpfResult<()>

For ebpf print helper functions

Source

fn ebpf_time_ns() -> BpfResult<u64>

For ebpf ktime helper functions

Source

fn alloc_page() -> BpfResult<usize>

Allocate pages in kernel space. Return the physical address of the allocated page.

Source

fn free_page(phys_addr: usize)

Free the allocated page in kernel space.

Source

fn vmap(phys_addrs: &[usize]) -> BpfResult<usize>

Create a virtual mapping for the given physical addresses. Return the virtual address.

Source

fn unmap(vaddr: usize)

Unmap the given virtual address.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§