diff --git a/ebpf/aya-ebpf/src/maps/array.rs b/ebpf/aya-ebpf/src/maps/array.rs index 87c02e49..d9911547 100644 --- a/ebpf/aya-ebpf/src/maps/array.rs +++ b/ebpf/aya-ebpf/src/maps/array.rs @@ -1,8 +1,10 @@ use core::{cell::UnsafeCell, marker::PhantomData, mem, ptr::NonNull}; +use aya_ebpf_cty::c_long; + use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_ARRAY}, - lookup, + insert, lookup, maps::PinningType, }; @@ -65,4 +67,10 @@ impl Array { unsafe fn lookup(&self, index: u32) -> Option> { lookup(self.def.get(), &index) } + + /// Sets the value of the element at the given index. + #[inline(always)] + pub fn set(&self, index: u32, value: &T, flags: u64) -> Result<(), c_long> { + insert(self.def.get(), &index, value, flags) + } }