pub struct OpenMapImpl<'obj, T = ()> { /* private fields */ }
Expand description
Represents a parsed but not yet loaded BPF map.
This object exposes operations that need to happen before the map is created.
Some methods require working with raw bytes. You may find libraries such as
plain
helpful.
Implementations§
Source§impl<'obj> OpenMapImpl<'obj>
impl<'obj> OpenMapImpl<'obj>
Source§impl<'obj> OpenMapImpl<'obj, Mut>
impl<'obj> OpenMapImpl<'obj, Mut>
Sourcepub fn new_mut(object: &'obj mut bpf_map) -> Self
pub fn new_mut(object: &'obj mut bpf_map) -> Self
Create a new OpenMapMut
from a ptr to a libbpf_sys::bpf_map
.
Sourcepub fn initial_value_mut(&mut self) -> Option<&mut [u8]>
pub fn initial_value_mut(&mut self) -> Option<&mut [u8]>
Retrieve the initial value of the map.
Sourcepub fn set_map_ifindex(&mut self, idx: u32)
pub fn set_map_ifindex(&mut self, idx: u32)
Bind map to a particular network device.
Used for offloading maps to hardware.
Sourcepub fn set_initial_value(&mut self, data: &[u8]) -> Result<()>
pub fn set_initial_value(&mut self, data: &[u8]) -> Result<()>
Set the initial value of the map.
Sourcepub fn set_key_size(&mut self, size: u32) -> Result<()>
pub fn set_key_size(&mut self, size: u32) -> Result<()>
Set the key size of the map in bytes.
Sourcepub fn set_value_size(&mut self, size: u32) -> Result<()>
pub fn set_value_size(&mut self, size: u32) -> Result<()>
Set the value size of the map in bytes.
Sourcepub fn set_max_entries(&mut self, count: u32) -> Result<()>
pub fn set_max_entries(&mut self, count: u32) -> Result<()>
Set the maximum number of entries this map can have.
Sourcepub fn set_map_flags(&mut self, flags: u32) -> Result<()>
pub fn set_map_flags(&mut self, flags: u32) -> Result<()>
Set flags on this map.
pub fn set_numa_node(&mut self, numa_node: u32) -> Result<()>
pub fn set_inner_map_fd(&mut self, inner_map_fd: BorrowedFd<'_>) -> Result<()>
pub fn set_map_extra(&mut self, map_extra: u64) -> Result<()>
Sourcepub fn set_autocreate(&mut self, autocreate: bool) -> Result<()>
pub fn set_autocreate(&mut self, autocreate: bool) -> Result<()>
Set whether or not libbpf should automatically create this map during load phase.
Sourcepub fn set_pin_path<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
pub fn set_pin_path<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
Set where the map should be pinned.
Note this does not actually create the pin.
Sourcepub fn reuse_fd(&mut self, fd: BorrowedFd<'_>) -> Result<()>
pub fn reuse_fd(&mut self, fd: BorrowedFd<'_>) -> Result<()>
Reuse an fd for a BPF map
Trait Implementations§
Source§impl<T> AsRawLibbpf for OpenMapImpl<'_, T>
impl<T> AsRawLibbpf for OpenMapImpl<'_, T>
Source§fn as_libbpf_object(&self) -> NonNull<Self::LibbpfType>
fn as_libbpf_object(&self) -> NonNull<Self::LibbpfType>
Retrieve the underlying libbpf_sys::bpf_map
.
Source§type LibbpfType = bpf_map
type LibbpfType = bpf_map
libbpf
type.