diff --git a/bpf/aya-bpf/src/maps/hash_map.rs b/bpf/aya-bpf/src/maps/hash_map.rs index 861d4669..a1269d04 100644 --- a/bpf/aya-bpf/src/maps/hash_map.rs +++ b/bpf/aya-bpf/src/maps/hash_map.rs @@ -31,6 +31,22 @@ impl HashMap { } } + pub const fn pinned(max_entries: u32, flags: u32, pinning: u32) -> HashMap { + HashMap { + def: bpf_map_def { + type_: BPF_MAP_TYPE_HASH, + key_size: mem::size_of::() as u32, + value_size: mem::size_of::() as u32, + max_entries, + map_flags: flags, + id: 0, + pinning, + }, + _k: PhantomData, + _v: PhantomData, + } + } + pub unsafe fn get(&mut self, key: &K) -> Option<&V> { let value = bpf_map_lookup_elem( &mut self.def as *mut _ as *mut _,