|
|
@ -31,6 +31,22 @@ impl<K, V> HashMap<K, V> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub const fn pinned(max_entries: u32, flags: u32, pinning: u32) -> HashMap<K, V> {
|
|
|
|
|
|
|
|
HashMap {
|
|
|
|
|
|
|
|
def: bpf_map_def {
|
|
|
|
|
|
|
|
type_: BPF_MAP_TYPE_HASH,
|
|
|
|
|
|
|
|
key_size: mem::size_of::<K>() as u32,
|
|
|
|
|
|
|
|
value_size: mem::size_of::<V>() as u32,
|
|
|
|
|
|
|
|
max_entries,
|
|
|
|
|
|
|
|
map_flags: flags,
|
|
|
|
|
|
|
|
id: 0,
|
|
|
|
|
|
|
|
pinning,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
_k: PhantomData,
|
|
|
|
|
|
|
|
_v: PhantomData,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub unsafe fn get(&mut self, key: &K) -> Option<&V> {
|
|
|
|
pub unsafe fn get(&mut self, key: &K) -> Option<&V> {
|
|
|
|
let value = bpf_map_lookup_elem(
|
|
|
|
let value = bpf_map_lookup_elem(
|
|
|
|
&mut self.def as *mut _ as *mut _,
|
|
|
|
&mut self.def as *mut _ as *mut _,
|
|
|
|