From 5b1a3ed866c6ad7c97279326c0b45e16b8fbcfd3 Mon Sep 17 00:00:00 2001 From: tirex Date: Tue, 21 Jun 2022 20:32:11 +0200 Subject: [PATCH] Fix return value for map removing/deleting --- bpf/aya-bpf/src/maps/hash_map.rs | 2 +- bpf/aya-bpf/src/maps/lpm_trie.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bpf/aya-bpf/src/maps/hash_map.rs b/bpf/aya-bpf/src/maps/hash_map.rs index 13aa1aed..35383e05 100644 --- a/bpf/aya-bpf/src/maps/hash_map.rs +++ b/bpf/aya-bpf/src/maps/hash_map.rs @@ -354,5 +354,5 @@ fn insert(def: *mut bpf_map_def, key: &K, value: &V, flags: u64) -> Result #[inline] fn remove(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) } diff --git a/bpf/aya-bpf/src/maps/lpm_trie.rs b/bpf/aya-bpf/src/maps/lpm_trie.rs index b0eeefb3..bbe6662e 100644 --- a/bpf/aya-bpf/src/maps/lpm_trie.rs +++ b/bpf/aya-bpf/src/maps/lpm_trie.rs @@ -86,7 +86,7 @@ impl LpmTrie { 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) } }