Selaa lähdekoodia

Merge pull request #369 from chenhengqi/lpm-trie-flag

aya-bpf/maps: Create LPMTrie with BPF_F_NO_PREALLOC
Michal Rostecki 2 vuotta sitten
vanhempi
commit
7942c3ac19
1 muutettua tiedostoa jossa 3 lisäystä ja 0 poistoa
  1. 3 0
      bpf/aya-bpf/src/maps/lpm_trie.rs

+ 3 - 0
bpf/aya-bpf/src/maps/lpm_trie.rs

@@ -1,5 +1,6 @@
 use core::{cell::UnsafeCell, marker::PhantomData, mem, ptr::NonNull};
 
+use aya_bpf_bindings::bindings::BPF_F_NO_PREALLOC;
 use aya_bpf_cty::{c_long, c_void};
 
 use crate::{
@@ -33,6 +34,7 @@ impl<K> Key<K> {
 
 impl<K, V> LpmTrie<K, V> {
     pub const fn with_max_entries(max_entries: u32, flags: u32) -> LpmTrie<K, V> {
+        let flags = flags | BPF_F_NO_PREALLOC;
         LpmTrie {
             def: UnsafeCell::new(build_def::<K, V>(
                 BPF_MAP_TYPE_LPM_TRIE,
@@ -46,6 +48,7 @@ impl<K, V> LpmTrie<K, V> {
     }
 
     pub const fn pinned(max_entries: u32, flags: u32) -> LpmTrie<K, V> {
+        let flags = flags | BPF_F_NO_PREALLOC;
         LpmTrie {
             def: UnsafeCell::new(build_def::<K, V>(
                 BPF_MAP_TYPE_LPM_TRIE,