Browse Source

Fix return value for map removing/deleting

tirex 2 years ago
parent
commit
5b1a3ed866
2 changed files with 2 additions and 2 deletions
  1. 1 1
      bpf/aya-bpf/src/maps/hash_map.rs
  2. 1 1
      bpf/aya-bpf/src/maps/lpm_trie.rs

+ 1 - 1
bpf/aya-bpf/src/maps/hash_map.rs

@@ -354,5 +354,5 @@ fn insert<K, V>(def: *mut bpf_map_def, key: &K, value: &V, flags: u64) -> Result
 #[inline]
 fn remove<K>(def: *mut bpf_map_def, key: &K) -> Result<(), c_long> {
     let ret = unsafe { bpf_map_delete_elem(def as *mut _, key as *const _ as *const c_void) };
-    (ret >= 0).then(|| ()).ok_or(ret)
+    (ret == 0).then(|| ()).ok_or(ret)
 }

+ 1 - 1
bpf/aya-bpf/src/maps/lpm_trie.rs

@@ -86,7 +86,7 @@ impl<K, V> LpmTrie<K, V> {
         let ret = unsafe {
             bpf_map_delete_elem(self.def.get() as *mut _, key as *const _ as *const c_void)
         };
-        (ret >= 0).then(|| ()).ok_or(ret)
+        (ret == 0).then(|| ()).ok_or(ret)
     }
 }