pub struct EbpfPtr<'a, T> { /* private fields */ }Expand description
Pointer to a buffer that may be shared between eBPF programs. It allows to safely pass around pointers to the data stored in eBPF maps and access the data referenced by the pointer.
Implementations§
Source§impl<'a, T> EbpfPtr<'a, T>where
T: Sized,
impl<'a, T> EbpfPtr<'a, T>where
T: Sized,
Sourcepub unsafe fn new(ptr: *mut T) -> Self
pub unsafe fn new(ptr: *mut T) -> Self
Creates a new EbpfPtr from the specified pointer.
§Safety
Caller must ensure that the buffer referenced by ptr is valid for
lifetime 'a and there are no other mutable references to the same memory.
Sourcepub unsafe fn deref(&self) -> &'a T
pub unsafe fn deref(&self) -> &'a T
§Safety
Caller must ensure that the value cannot be updated by other threads while the returned reference is live.
Sourcepub unsafe fn deref_mut(&self) -> &'a mut T
pub unsafe fn deref_mut(&self) -> &'a mut T
§Safety
Caller must ensure that the value is not being used by other threads.
pub fn get_field<F, const OFFSET: usize>(&self) -> EbpfPtr<'a, F>
pub fn ptr(&self) -> *mut T
Source§impl EbpfPtr<'_, u64>
impl EbpfPtr<'_, u64>
Sourcepub fn load_relaxed(&self) -> u64
pub fn load_relaxed(&self) -> u64
Loads the value referenced by the pointer. Atomicity is guaranteed if and only if the pointer is 8-byte aligned.
Sourcepub fn store_relaxed(&self, value: u64)
pub fn store_relaxed(&self, value: u64)
Stores the value at the memory referenced by the pointer. Atomicity
is guaranteed if and only if the pointer is 8-byte aligned.
Source§impl EbpfPtr<'_, u32>
impl EbpfPtr<'_, u32>
Sourcepub fn load_relaxed(&self) -> u32
pub fn load_relaxed(&self) -> u32
Loads the value referenced by the pointer. Atomicity is guaranteed if and only if the pointer is 4-byte aligned.
Sourcepub fn store_relaxed(&self, value: u32)
pub fn store_relaxed(&self, value: u32)
Stores the value at the memory referenced by the pointer. Atomicity
is guaranteed if and only if the pointer is 4-byte aligned.
Source§impl EbpfPtr<'_, i32>
impl EbpfPtr<'_, i32>
Sourcepub fn load_relaxed(&self) -> i32
pub fn load_relaxed(&self) -> i32
Loads the value referenced by the pointer. Atomicity is guaranteed if and only if the pointer is 4-byte aligned.
Sourcepub fn store_relaxed(&self, value: i32)
pub fn store_relaxed(&self, value: i32)
Stores the value at the memory referenced by the pointer. Atomicity
is guaranteed if and only if the pointer is 4-byte aligned.
Trait Implementations§
Source§impl<'a, T> ProgramArgument for EbpfPtr<'a, T>where
&'a mut T: ProgramArgument,
Implements ProgramArgument for EbpfPtr when it’s implemented for
&'a mut T.
impl<'a, T> ProgramArgument for EbpfPtr<'a, T>where
&'a mut T: ProgramArgument,
Implements ProgramArgument for EbpfPtr when it’s implemented for
&'a mut T.
Source§fn get_type() -> &'static Type
fn get_type() -> &'static Type
Self. Used when program argument types
are checked statically.Source§fn field_mappings() -> &'static [FieldMapping]
fn field_mappings() -> &'static [FieldMapping]
get_type() must be a PtrToStruct.Source§fn struct_mapping() -> Option<StructMapping>
fn struct_mapping() -> Option<StructMapping>
StructMapping that should be applied with this argument. Implementations
should override field_mappings() and keep default implementation of struct_mapping().Source§fn get_value_type(&self) -> Type
fn get_value_type(&self) -> Type
Self. For most types this is the
same type that’s returned by get_type(), but that’s not always the case.
In particular for scalar values this will return Type::ScalarValue with
the actual value of the scalar and with unknown_mask = 0.