From 98e8c78376286bbdc8c7ee3f0292b878cec24b99 Mon Sep 17 00:00:00 2001 From: Michal R Date: Tue, 7 Oct 2025 13:25:00 +0200 Subject: [PATCH] aya-ebpf: Make use of `Borrow` and `BorrowMut` in map methods Let callers pass either owned objects or references. We do that already in the user-space methods. --- ebpf/aya-ebpf/src/btf_maps/array.rs | 6 +- ebpf/aya-ebpf/src/maps/array.rs | 6 +- ebpf/aya-ebpf/src/maps/bloom_filter.rs | 10 +- ebpf/aya-ebpf/src/maps/hash_map.rs | 102 +++++++----- ebpf/aya-ebpf/src/maps/lpm_trie.rs | 19 ++- .../src/maps/perf/perf_event_array.rs | 13 +- ebpf/aya-ebpf/src/maps/queue.rs | 13 +- ebpf/aya-ebpf/src/maps/ring_buf.rs | 4 +- ebpf/aya-ebpf/src/maps/sock_hash.rs | 44 ++++-- ebpf/aya-ebpf/src/maps/stack.rs | 6 +- ebpf/aya-ebpf/src/maps/stack_trace.rs | 10 +- test/integration-ebpf/src/map_test.rs | 2 +- test/integration-ebpf/src/memmove_test.rs | 2 +- test/integration-ebpf/src/uprobe_cookie.rs | 2 +- xtask/public-api/aya-ebpf.txt | 148 +++++++++--------- 15 files changed, 225 insertions(+), 162 deletions(-) diff --git a/ebpf/aya-ebpf/src/btf_maps/array.rs b/ebpf/aya-ebpf/src/btf_maps/array.rs index 0ef9bebd..91878fa2 100644 --- a/ebpf/aya-ebpf/src/btf_maps/array.rs +++ b/ebpf/aya-ebpf/src/btf_maps/array.rs @@ -1,4 +1,4 @@ -use core::{cell::UnsafeCell, ptr::NonNull}; +use core::{borrow::Borrow, cell::UnsafeCell, ptr::NonNull}; use crate::{bindings::bpf_map_type::BPF_MAP_TYPE_ARRAY, btf_map_def, cty::c_long, insert, lookup}; @@ -51,7 +51,7 @@ impl Array { /// 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.0.get().cast(), &index, value, flags) + pub fn set(&self, index: u32, value: impl Borrow, flags: u64) -> Result<(), c_long> { + insert(self.0.get().cast(), &index, value.borrow(), flags) } } diff --git a/ebpf/aya-ebpf/src/maps/array.rs b/ebpf/aya-ebpf/src/maps/array.rs index 9da0a67b..c9e98b1a 100644 --- a/ebpf/aya-ebpf/src/maps/array.rs +++ b/ebpf/aya-ebpf/src/maps/array.rs @@ -1,4 +1,4 @@ -use core::{cell::UnsafeCell, marker::PhantomData, mem, ptr::NonNull}; +use core::{borrow::Borrow, cell::UnsafeCell, marker::PhantomData, mem, ptr::NonNull}; use aya_ebpf_cty::c_long; @@ -69,7 +69,7 @@ impl Array { /// 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().cast(), &index, value, flags) + pub fn set(&self, index: u32, value: impl Borrow, flags: u64) -> Result<(), c_long> { + insert(self.def.get().cast(), &index, value.borrow(), flags) } } diff --git a/ebpf/aya-ebpf/src/maps/bloom_filter.rs b/ebpf/aya-ebpf/src/maps/bloom_filter.rs index 52328c99..52e7cb45 100644 --- a/ebpf/aya-ebpf/src/maps/bloom_filter.rs +++ b/ebpf/aya-ebpf/src/maps/bloom_filter.rs @@ -1,4 +1,4 @@ -use core::{marker::PhantomData, mem, ptr}; +use core::{borrow::Borrow, marker::PhantomData, mem, ptr}; use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_BLOOM_FILTER}, @@ -38,22 +38,22 @@ impl BloomFilter { } #[inline] - pub fn contains(&mut self, value: &T) -> Result<(), i64> { + pub fn contains(&mut self, value: impl Borrow) -> Result<(), i64> { let ret = unsafe { bpf_map_peek_elem( ptr::from_ref(&self.def).cast_mut().cast(), - ptr::from_ref(value).cast_mut().cast(), + ptr::from_ref(value.borrow()).cast_mut().cast(), ) }; (ret == 0).then_some(()).ok_or(ret) } #[inline] - pub fn insert(&mut self, value: &T, flags: u64) -> Result<(), i64> { + pub fn insert(&mut self, value: impl Borrow, flags: u64) -> Result<(), i64> { let ret = unsafe { bpf_map_push_elem( ptr::from_ref(&self.def).cast_mut().cast(), - ptr::from_ref(value).cast(), + ptr::from_ref(value.borrow()).cast(), flags, ) }; diff --git a/ebpf/aya-ebpf/src/maps/hash_map.rs b/ebpf/aya-ebpf/src/maps/hash_map.rs index 72690e9b..1b34ac03 100644 --- a/ebpf/aya-ebpf/src/maps/hash_map.rs +++ b/ebpf/aya-ebpf/src/maps/hash_map.rs @@ -1,4 +1,4 @@ -use core::{cell::UnsafeCell, marker::PhantomData, mem}; +use core::{borrow::Borrow, cell::UnsafeCell, marker::PhantomData, mem}; use aya_ebpf_bindings::bindings::bpf_map_type::{ BPF_MAP_TYPE_LRU_HASH, BPF_MAP_TYPE_LRU_PERCPU_HASH, BPF_MAP_TYPE_PERCPU_HASH, @@ -56,16 +56,16 @@ impl HashMap { /// of `insert` or `remove`, and any element removed from the map might get aliased by another /// element in the map, causing garbage to be read, or corruption in case of writes. #[inline] - pub unsafe fn get(&self, key: &K) -> Option<&V> { - unsafe { get(self.def.get(), key) } + pub unsafe fn get(&self, key: impl Borrow) -> Option<&V> { + unsafe { get(self.def.get(), key.borrow()) } } /// Retrieve the value associate with `key` from the map. /// The same caveat as `get` applies, but this returns a raw pointer and it's up to the caller /// to decide whether it's safe to dereference the pointer or not. #[inline] - pub fn get_ptr(&self, key: &K) -> Option<*const V> { - get_ptr(self.def.get(), key) + pub fn get_ptr(&self, key: impl Borrow) -> Option<*const V> { + get_ptr(self.def.get(), key.borrow()) } /// Retrieve the value associate with `key` from the map. @@ -73,18 +73,23 @@ impl HashMap { /// concurrent writes, but it's up to the caller to decide whether it's safe to dereference the /// pointer or not. #[inline] - pub fn get_ptr_mut(&self, key: &K) -> Option<*mut V> { - get_ptr_mut(self.def.get(), key) + pub fn get_ptr_mut(&self, key: impl Borrow) -> Option<*mut V> { + get_ptr_mut(self.def.get(), key.borrow()) } #[inline] - pub fn insert(&self, key: &K, value: &V, flags: u64) -> Result<(), c_long> { - insert(self.def.get().cast(), key, value, flags) + pub fn insert( + &self, + key: impl Borrow, + value: impl Borrow, + flags: u64, + ) -> Result<(), c_long> { + insert(self.def.get().cast(), key.borrow(), value.borrow(), flags) } #[inline] - pub fn remove(&self, key: &K) -> Result<(), c_long> { - remove(self.def.get().cast(), key) + pub fn remove(&self, key: impl Borrow) -> Result<(), c_long> { + remove(self.def.get().cast(), key.borrow()) } } @@ -132,16 +137,16 @@ impl LruHashMap { /// of `insert` or `remove`, and any element removed from the map might get aliased by another /// element in the map, causing garbage to be read, or corruption in case of writes. #[inline] - pub unsafe fn get(&self, key: &K) -> Option<&V> { - unsafe { get(self.def.get(), key) } + pub unsafe fn get(&self, key: impl Borrow) -> Option<&V> { + unsafe { get(self.def.get(), key.borrow()) } } /// Retrieve the value associate with `key` from the map. /// The same caveat as `get` applies, but this returns a raw pointer and it's up to the caller /// to decide whether it's safe to dereference the pointer or not. #[inline] - pub fn get_ptr(&self, key: &K) -> Option<*const V> { - get_ptr(self.def.get(), key) + pub fn get_ptr(&self, key: impl Borrow) -> Option<*const V> { + get_ptr(self.def.get(), key.borrow()) } /// Retrieve the value associate with `key` from the map. @@ -149,18 +154,23 @@ impl LruHashMap { /// concurrent writes, but it's up to the caller to decide whether it's safe to dereference the /// pointer or not. #[inline] - pub fn get_ptr_mut(&self, key: &K) -> Option<*mut V> { - get_ptr_mut(self.def.get(), key) + pub fn get_ptr_mut(&self, key: impl Borrow) -> Option<*mut V> { + get_ptr_mut(self.def.get(), key.borrow()) } #[inline] - pub fn insert(&self, key: &K, value: &V, flags: u64) -> Result<(), c_long> { - insert(self.def.get().cast(), key, value, flags) + pub fn insert( + &self, + key: impl Borrow, + value: impl Borrow, + flags: u64, + ) -> Result<(), c_long> { + insert(self.def.get().cast(), key.borrow(), value.borrow(), flags) } #[inline] - pub fn remove(&self, key: &K) -> Result<(), c_long> { - remove(self.def.get().cast(), key) + pub fn remove(&self, key: impl Borrow) -> Result<(), c_long> { + remove(self.def.get().cast(), key.borrow()) } } @@ -208,16 +218,16 @@ impl PerCpuHashMap { /// of `insert` or `remove`, and any element removed from the map might get aliased by another /// element in the map, causing garbage to be read, or corruption in case of writes. #[inline] - pub unsafe fn get(&self, key: &K) -> Option<&V> { - unsafe { get(self.def.get(), key) } + pub unsafe fn get(&self, key: impl Borrow) -> Option<&V> { + unsafe { get(self.def.get(), key.borrow()) } } /// Retrieve the value associate with `key` from the map. /// The same caveat as `get` applies, but this returns a raw pointer and it's up to the caller /// to decide whether it's safe to dereference the pointer or not. #[inline] - pub fn get_ptr(&self, key: &K) -> Option<*const V> { - get_ptr(self.def.get(), key) + pub fn get_ptr(&self, key: impl Borrow) -> Option<*const V> { + get_ptr(self.def.get(), key.borrow()) } /// Retrieve the value associate with `key` from the map. @@ -225,18 +235,23 @@ impl PerCpuHashMap { /// concurrent writes, but it's up to the caller to decide whether it's safe to dereference the /// pointer or not. #[inline] - pub fn get_ptr_mut(&self, key: &K) -> Option<*mut V> { - get_ptr_mut(self.def.get(), key) + pub fn get_ptr_mut(&self, key: impl Borrow) -> Option<*mut V> { + get_ptr_mut(self.def.get(), key.borrow()) } #[inline] - pub fn insert(&self, key: &K, value: &V, flags: u64) -> Result<(), c_long> { - insert(self.def.get().cast(), key, value, flags) + pub fn insert( + &self, + key: impl Borrow, + value: impl Borrow, + flags: u64, + ) -> Result<(), c_long> { + insert(self.def.get().cast(), key.borrow(), value.borrow(), flags) } #[inline] - pub fn remove(&self, key: &K) -> Result<(), c_long> { - remove(self.def.get().cast(), key) + pub fn remove(&self, key: impl Borrow) -> Result<(), c_long> { + remove(self.def.get().cast(), key.borrow()) } } @@ -284,16 +299,16 @@ impl LruPerCpuHashMap { /// of `insert` or `remove`, and any element removed from the map might get aliased by another /// element in the map, causing garbage to be read, or corruption in case of writes. #[inline] - pub unsafe fn get(&self, key: &K) -> Option<&V> { - unsafe { get(self.def.get(), key) } + pub unsafe fn get(&self, key: impl Borrow) -> Option<&V> { + unsafe { get(self.def.get(), key.borrow()) } } /// Retrieve the value associate with `key` from the map. /// The same caveat as `get` applies, but this returns a raw pointer and it's up to the caller /// to decide whether it's safe to dereference the pointer or not. #[inline] - pub fn get_ptr(&self, key: &K) -> Option<*const V> { - get_ptr(self.def.get(), key) + pub fn get_ptr(&self, key: impl Borrow) -> Option<*const V> { + get_ptr(self.def.get(), key.borrow()) } /// Retrieve the value associate with `key` from the map. @@ -301,18 +316,23 @@ impl LruPerCpuHashMap { /// concurrent writes, but it's up to the caller to decide whether it's safe to dereference the /// pointer or not. #[inline] - pub fn get_ptr_mut(&self, key: &K) -> Option<*mut V> { - get_ptr_mut(self.def.get(), key) + pub fn get_ptr_mut(&self, key: impl Borrow) -> Option<*mut V> { + get_ptr_mut(self.def.get(), key.borrow()) } #[inline] - pub fn insert(&self, key: &K, value: &V, flags: u64) -> Result<(), c_long> { - insert(self.def.get().cast(), key, value, flags) + pub fn insert( + &self, + key: impl Borrow, + value: impl Borrow, + flags: u64, + ) -> Result<(), c_long> { + insert(self.def.get().cast(), key.borrow(), value.borrow(), flags) } #[inline] - pub fn remove(&self, key: &K) -> Result<(), c_long> { - remove(self.def.get().cast(), key) + pub fn remove(&self, key: impl Borrow) -> Result<(), c_long> { + remove(self.def.get().cast(), key.borrow()) } } diff --git a/ebpf/aya-ebpf/src/maps/lpm_trie.rs b/ebpf/aya-ebpf/src/maps/lpm_trie.rs index 876712d3..b86f7d60 100644 --- a/ebpf/aya-ebpf/src/maps/lpm_trie.rs +++ b/ebpf/aya-ebpf/src/maps/lpm_trie.rs @@ -1,4 +1,4 @@ -use core::{cell::UnsafeCell, marker::PhantomData, mem}; +use core::{borrow::Borrow, cell::UnsafeCell, marker::PhantomData, mem}; use aya_ebpf_bindings::bindings::BPF_F_NO_PREALLOC; use aya_ebpf_cty::c_long; @@ -63,18 +63,23 @@ impl LpmTrie { } #[inline] - pub fn get(&self, key: &Key) -> Option<&V> { - lookup(self.def.get().cast(), key).map(|p| unsafe { p.as_ref() }) + pub fn get(&self, key: impl Borrow>) -> Option<&V> { + lookup(self.def.get().cast(), key.borrow()).map(|p| unsafe { p.as_ref() }) } #[inline] - pub fn insert(&self, key: &Key, value: &V, flags: u64) -> Result<(), c_long> { - insert(self.def.get().cast(), key, value, flags) + pub fn insert( + &self, + key: impl Borrow>, + value: impl Borrow, + flags: u64, + ) -> Result<(), c_long> { + insert(self.def.get().cast(), key.borrow(), value.borrow(), flags) } #[inline] - pub fn remove(&self, key: &Key) -> Result<(), c_long> { - remove(self.def.get().cast(), key) + pub fn remove(&self, key: impl Borrow>) -> Result<(), c_long> { + remove(self.def.get().cast(), key.borrow()) } } diff --git a/ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs b/ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs index 6c6a3a56..3dd61b30 100644 --- a/ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs +++ b/ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs @@ -1,4 +1,4 @@ -use core::{cell::UnsafeCell, marker::PhantomData, mem, ptr}; +use core::{borrow::Borrow, cell::UnsafeCell, marker::PhantomData, mem, ptr}; use crate::{ EbpfContext, @@ -46,11 +46,18 @@ impl PerfEventArray { } } - pub fn output(&self, ctx: &C, data: &T, flags: u32) { + pub fn output(&self, ctx: &C, data: impl Borrow, flags: u32) { self.output_at_index(ctx, BPF_F_CURRENT_CPU as u32, data, flags) } - pub fn output_at_index(&self, ctx: &C, index: u32, data: &T, flags: u32) { + pub fn output_at_index( + &self, + ctx: &C, + index: u32, + data: impl Borrow, + flags: u32, + ) { + let data = data.borrow(); let flags = (u64::from(flags) << 32) | u64::from(index); unsafe { bpf_perf_event_output( diff --git a/ebpf/aya-ebpf/src/maps/queue.rs b/ebpf/aya-ebpf/src/maps/queue.rs index 51dbfe86..596905b8 100644 --- a/ebpf/aya-ebpf/src/maps/queue.rs +++ b/ebpf/aya-ebpf/src/maps/queue.rs @@ -1,4 +1,4 @@ -use core::{cell::UnsafeCell, marker::PhantomData, mem, ptr}; +use core::{borrow::Borrow, cell::UnsafeCell, marker::PhantomData, mem, ptr}; use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_QUEUE}, @@ -45,9 +45,14 @@ impl Queue { } } - pub fn push(&self, value: &T, flags: u64) -> Result<(), i64> { - let ret = - unsafe { bpf_map_push_elem(self.def.get().cast(), ptr::from_ref(value).cast(), flags) }; + pub fn push(&self, value: impl Borrow, flags: u64) -> Result<(), i64> { + let ret = unsafe { + bpf_map_push_elem( + self.def.get().cast(), + ptr::from_ref(value.borrow()).cast(), + flags, + ) + }; (ret == 0).then_some(()).ok_or(ret) } diff --git a/ebpf/aya-ebpf/src/maps/ring_buf.rs b/ebpf/aya-ebpf/src/maps/ring_buf.rs index abbeba2e..873462be 100644 --- a/ebpf/aya-ebpf/src/maps/ring_buf.rs +++ b/ebpf/aya-ebpf/src/maps/ring_buf.rs @@ -1,4 +1,5 @@ use core::{ + borrow::Borrow, cell::UnsafeCell, mem, mem::MaybeUninit, @@ -205,7 +206,8 @@ impl RingBuf { /// /// [`reserve`]: RingBuf::reserve /// [`submit`]: RingBufEntry::submit - pub fn output(&self, data: &T, flags: u64) -> Result<(), i64> { + pub fn output(&self, data: impl Borrow, flags: u64) -> Result<(), i64> { + let data = data.borrow(); assert_eq!(8 % mem::align_of_val(data), 0); let ret = unsafe { bpf_ringbuf_output( diff --git a/ebpf/aya-ebpf/src/maps/sock_hash.rs b/ebpf/aya-ebpf/src/maps/sock_hash.rs index 1acc85ba..fc070a97 100644 --- a/ebpf/aya-ebpf/src/maps/sock_hash.rs +++ b/ebpf/aya-ebpf/src/maps/sock_hash.rs @@ -1,4 +1,9 @@ -use core::{borrow::Borrow, cell::UnsafeCell, marker::PhantomData, mem, ptr}; +use core::{ + borrow::{Borrow, BorrowMut}, + cell::UnsafeCell, + marker::PhantomData, + mem, ptr, +}; use crate::{ EbpfContext as _, @@ -51,35 +56,50 @@ impl SockHash { } } - pub fn update(&self, key: &mut K, sk_ops: &mut bpf_sock_ops, flags: u64) -> Result<(), i64> { + pub fn update( + &self, + mut key: impl BorrowMut, + mut sk_ops: impl BorrowMut, + flags: u64, + ) -> Result<(), i64> { let ret = unsafe { bpf_sock_hash_update( - ptr::from_mut(sk_ops), + ptr::from_mut(sk_ops.borrow_mut()), self.def.get().cast(), - ptr::from_mut(key).cast(), + ptr::from_mut(key.borrow_mut()).cast(), flags, ) }; (ret == 0).then_some(()).ok_or(ret) } - pub fn redirect_msg(&self, ctx: &SkMsgContext, key: &mut K, flags: u64) -> i64 { + pub fn redirect_msg( + &self, + ctx: impl Borrow, + mut key: impl BorrowMut, + flags: u64, + ) -> i64 { unsafe { bpf_msg_redirect_hash( - ctx.msg, + ctx.borrow().msg, self.def.get().cast(), - ptr::from_mut(key).cast(), + ptr::from_mut(key.borrow_mut()).cast(), flags, ) } } - pub fn redirect_skb(&self, ctx: &SkBuffContext, key: &mut K, flags: u64) -> i64 { + pub fn redirect_skb( + &self, + ctx: impl Borrow, + mut key: impl BorrowMut, + flags: u64, + ) -> i64 { unsafe { bpf_sk_redirect_hash( - ctx.skb.skb, + ctx.borrow().skb.skb, self.def.get().cast(), - ptr::from_mut(key).cast(), + ptr::from_mut(key.borrow_mut()).cast(), flags, ) } @@ -87,12 +107,12 @@ impl SockHash { pub fn redirect_sk_lookup( &mut self, - ctx: &SkLookupContext, + ctx: impl Borrow, key: impl Borrow, flags: u64, ) -> Result<(), u32> { let sk = lookup(self.def.get().cast(), key.borrow()).ok_or(1u32)?; - let ret = unsafe { bpf_sk_assign(ctx.as_ptr().cast(), sk.as_ptr(), flags) }; + let ret = unsafe { bpf_sk_assign(ctx.borrow().as_ptr().cast(), sk.as_ptr(), flags) }; unsafe { bpf_sk_release(sk.as_ptr()) }; match ret { 0 => Ok(()), diff --git a/ebpf/aya-ebpf/src/maps/stack.rs b/ebpf/aya-ebpf/src/maps/stack.rs index 66a4a4d8..f50a9a84 100644 --- a/ebpf/aya-ebpf/src/maps/stack.rs +++ b/ebpf/aya-ebpf/src/maps/stack.rs @@ -1,4 +1,4 @@ -use core::{marker::PhantomData, mem, ptr}; +use core::{borrow::Borrow, marker::PhantomData, mem, ptr}; use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_STACK}, @@ -43,11 +43,11 @@ impl Stack { } } - pub fn push(&self, value: &T, flags: u64) -> Result<(), i64> { + pub fn push(&self, value: impl Borrow, flags: u64) -> Result<(), i64> { let ret = unsafe { bpf_map_push_elem( ptr::from_ref(&self.def).cast_mut().cast(), - ptr::from_ref(value).cast(), + ptr::from_ref(value.borrow()).cast(), flags, ) }; diff --git a/ebpf/aya-ebpf/src/maps/stack_trace.rs b/ebpf/aya-ebpf/src/maps/stack_trace.rs index 305e6d53..a7931694 100644 --- a/ebpf/aya-ebpf/src/maps/stack_trace.rs +++ b/ebpf/aya-ebpf/src/maps/stack_trace.rs @@ -1,4 +1,4 @@ -use core::{cell::UnsafeCell, mem}; +use core::{borrow::Borrow, cell::UnsafeCell, mem}; use crate::{ EbpfContext, @@ -46,8 +46,12 @@ impl StackTrace { } #[expect(clippy::missing_safety_doc)] - pub unsafe fn get_stackid(&self, ctx: &C, flags: u64) -> Result { - let ret = unsafe { bpf_get_stackid(ctx.as_ptr(), self.def.get().cast(), flags) }; + pub unsafe fn get_stackid( + &self, + ctx: impl Borrow, + flags: u64, + ) -> Result { + let ret = unsafe { bpf_get_stackid(ctx.borrow().as_ptr(), self.def.get().cast(), flags) }; if ret < 0 { Err(ret) } else { Ok(ret) } } } diff --git a/test/integration-ebpf/src/map_test.rs b/test/integration-ebpf/src/map_test.rs index 6868020d..eac1823d 100644 --- a/test/integration-ebpf/src/map_test.rs +++ b/test/integration-ebpf/src/map_test.rs @@ -31,7 +31,7 @@ fn simple_prog(_ctx: SkBuffContext) -> i64 { // If we use the literal value `0` instead of the local variable `i`, then an additional // `.rodata` map will be associated with the program. let i = 0; - BAZ.get_ptr(&i); + BAZ.get_ptr(i); 0 } diff --git a/test/integration-ebpf/src/memmove_test.rs b/test/integration-ebpf/src/memmove_test.rs index 3b9ec94c..c39a292a 100644 --- a/test/integration-ebpf/src/memmove_test.rs +++ b/test/integration-ebpf/src/memmove_test.rs @@ -44,7 +44,7 @@ fn do_dnat(ctx: XdpContext) -> u32 { fn try_do_dnat(ctx: XdpContext) -> Result { let index = 0; - if let Some(nat) = unsafe { RULES.get(&index) } { + if let Some(nat) = unsafe { RULES.get(index) } { let hproto: *const EtherType = ptr_at(&ctx, mem::offset_of!(EthHdr, ether_type))?; match unsafe { *hproto } { EtherType::Ipv6 => { diff --git a/test/integration-ebpf/src/uprobe_cookie.rs b/test/integration-ebpf/src/uprobe_cookie.rs index a0912d23..8d10b478 100644 --- a/test/integration-ebpf/src/uprobe_cookie.rs +++ b/test/integration-ebpf/src/uprobe_cookie.rs @@ -18,5 +18,5 @@ static RING_BUF: RingBuf = RingBuf::with_byte_size(0, 0); fn uprobe_cookie(ctx: ProbeContext) { let cookie = unsafe { helpers::bpf_get_attach_cookie(ctx.as_ptr()) }; let cookie_bytes = cookie.to_le_bytes(); - let _res = RING_BUF.output(&cookie_bytes, 0); + let _res = RING_BUF.output::<[u8; 8]>(&cookie_bytes, 0); } diff --git a/xtask/public-api/aya-ebpf.txt b/xtask/public-api/aya-ebpf.txt index e43ff231..ea62c132 100644 --- a/xtask/public-api/aya-ebpf.txt +++ b/xtask/public-api/aya-ebpf.txt @@ -10,7 +10,7 @@ pub fn aya_ebpf::btf_maps::array::Array::get(&self, index: u32) -> core pub fn aya_ebpf::btf_maps::array::Array::get_ptr(&self, index: u32) -> core::option::Option<*const T> pub fn aya_ebpf::btf_maps::array::Array::get_ptr_mut(&self, index: u32) -> core::option::Option<*mut T> pub const fn aya_ebpf::btf_maps::array::Array::new() -> Self -pub fn aya_ebpf::btf_maps::array::Array::set(&self, index: u32, value: &T, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::btf_maps::array::Array::set(&self, index: u32, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> impl core::marker::Sync for aya_ebpf::btf_maps::array::Array impl !core::marker::Freeze for aya_ebpf::btf_maps::array::Array impl !core::marker::Send for aya_ebpf::btf_maps::array::Array @@ -118,7 +118,7 @@ pub fn aya_ebpf::btf_maps::array::Array::get(&self, index: u32) -> core pub fn aya_ebpf::btf_maps::array::Array::get_ptr(&self, index: u32) -> core::option::Option<*const T> pub fn aya_ebpf::btf_maps::array::Array::get_ptr_mut(&self, index: u32) -> core::option::Option<*mut T> pub const fn aya_ebpf::btf_maps::array::Array::new() -> Self -pub fn aya_ebpf::btf_maps::array::Array::set(&self, index: u32, value: &T, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::btf_maps::array::Array::set(&self, index: u32, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> impl core::marker::Sync for aya_ebpf::btf_maps::array::Array impl !core::marker::Freeze for aya_ebpf::btf_maps::array::Array impl !core::marker::Send for aya_ebpf::btf_maps::array::Array @@ -252,7 +252,7 @@ pub fn aya_ebpf::maps::array::Array::get(&self, index: u32) -> core::option:: pub fn aya_ebpf::maps::array::Array::get_ptr(&self, index: u32) -> core::option::Option<*const T> pub fn aya_ebpf::maps::array::Array::get_ptr_mut(&self, index: u32) -> core::option::Option<*mut T> pub const fn aya_ebpf::maps::array::Array::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::array::Array::set(&self, index: u32, value: &T, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::array::Array::set(&self, index: u32, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::array::Array::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::array::Array impl !core::marker::Freeze for aya_ebpf::maps::array::Array @@ -279,8 +279,8 @@ pub fn aya_ebpf::maps::array::Array::from(t: T) -> T pub mod aya_ebpf::maps::bloom_filter #[repr(transparent)] pub struct aya_ebpf::maps::bloom_filter::BloomFilter impl aya_ebpf::maps::bloom_filter::BloomFilter -pub fn aya_ebpf::maps::bloom_filter::BloomFilter::contains(&mut self, value: &T) -> core::result::Result<(), i64> -pub fn aya_ebpf::maps::bloom_filter::BloomFilter::insert(&mut self, value: &T, flags: u64) -> core::result::Result<(), i64> +pub fn aya_ebpf::maps::bloom_filter::BloomFilter::contains(&mut self, value: impl core::borrow::Borrow) -> core::result::Result<(), i64> +pub fn aya_ebpf::maps::bloom_filter::BloomFilter::insert(&mut self, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), i64> pub const fn aya_ebpf::maps::bloom_filter::BloomFilter::pinned(max_entries: u32, flags: u32) -> Self pub const fn aya_ebpf::maps::bloom_filter::BloomFilter::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Freeze for aya_ebpf::maps::bloom_filter::BloomFilter @@ -308,12 +308,12 @@ pub fn aya_ebpf::maps::bloom_filter::BloomFilter::from(t: T) -> T pub mod aya_ebpf::maps::hash_map #[repr(transparent)] pub struct aya_ebpf::maps::hash_map::HashMap impl aya_ebpf::maps::hash_map::HashMap -pub unsafe fn aya_ebpf::maps::hash_map::HashMap::get(&self, key: &K) -> core::option::Option<&V> -pub fn aya_ebpf::maps::hash_map::HashMap::get_ptr(&self, key: &K) -> core::option::Option<*const V> -pub fn aya_ebpf::maps::hash_map::HashMap::get_ptr_mut(&self, key: &K) -> core::option::Option<*mut V> -pub fn aya_ebpf::maps::hash_map::HashMap::insert(&self, key: &K, value: &V, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub unsafe fn aya_ebpf::maps::hash_map::HashMap::get(&self, key: impl core::borrow::Borrow) -> core::option::Option<&V> +pub fn aya_ebpf::maps::hash_map::HashMap::get_ptr(&self, key: impl core::borrow::Borrow) -> core::option::Option<*const V> +pub fn aya_ebpf::maps::hash_map::HashMap::get_ptr_mut(&self, key: impl core::borrow::Borrow) -> core::option::Option<*mut V> +pub fn aya_ebpf::maps::hash_map::HashMap::insert(&self, key: impl core::borrow::Borrow, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::HashMap::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::hash_map::HashMap::remove(&self, key: &K) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::hash_map::HashMap::remove(&self, key: impl core::borrow::Borrow) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::HashMap::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::hash_map::HashMap impl !core::marker::Freeze for aya_ebpf::maps::hash_map::HashMap @@ -339,12 +339,12 @@ impl core::convert::From for aya_ebpf::maps::hash_map::HashMap pub fn aya_ebpf::maps::hash_map::HashMap::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::hash_map::LruHashMap impl aya_ebpf::maps::hash_map::LruHashMap -pub unsafe fn aya_ebpf::maps::hash_map::LruHashMap::get(&self, key: &K) -> core::option::Option<&V> -pub fn aya_ebpf::maps::hash_map::LruHashMap::get_ptr(&self, key: &K) -> core::option::Option<*const V> -pub fn aya_ebpf::maps::hash_map::LruHashMap::get_ptr_mut(&self, key: &K) -> core::option::Option<*mut V> -pub fn aya_ebpf::maps::hash_map::LruHashMap::insert(&self, key: &K, value: &V, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub unsafe fn aya_ebpf::maps::hash_map::LruHashMap::get(&self, key: impl core::borrow::Borrow) -> core::option::Option<&V> +pub fn aya_ebpf::maps::hash_map::LruHashMap::get_ptr(&self, key: impl core::borrow::Borrow) -> core::option::Option<*const V> +pub fn aya_ebpf::maps::hash_map::LruHashMap::get_ptr_mut(&self, key: impl core::borrow::Borrow) -> core::option::Option<*mut V> +pub fn aya_ebpf::maps::hash_map::LruHashMap::insert(&self, key: impl core::borrow::Borrow, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::LruHashMap::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::hash_map::LruHashMap::remove(&self, key: &K) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::hash_map::LruHashMap::remove(&self, key: impl core::borrow::Borrow) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::LruHashMap::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::hash_map::LruHashMap impl !core::marker::Freeze for aya_ebpf::maps::hash_map::LruHashMap @@ -370,12 +370,12 @@ impl core::convert::From for aya_ebpf::maps::hash_map::LruHashMap pub fn aya_ebpf::maps::hash_map::LruHashMap::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::hash_map::LruPerCpuHashMap impl aya_ebpf::maps::hash_map::LruPerCpuHashMap -pub unsafe fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::get(&self, key: &K) -> core::option::Option<&V> -pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::get_ptr(&self, key: &K) -> core::option::Option<*const V> -pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::get_ptr_mut(&self, key: &K) -> core::option::Option<*mut V> -pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::insert(&self, key: &K, value: &V, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub unsafe fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::get(&self, key: impl core::borrow::Borrow) -> core::option::Option<&V> +pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::get_ptr(&self, key: impl core::borrow::Borrow) -> core::option::Option<*const V> +pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::get_ptr_mut(&self, key: impl core::borrow::Borrow) -> core::option::Option<*mut V> +pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::insert(&self, key: impl core::borrow::Borrow, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::remove(&self, key: &K) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::remove(&self, key: impl core::borrow::Borrow) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::hash_map::LruPerCpuHashMap impl !core::marker::Freeze for aya_ebpf::maps::hash_map::LruPerCpuHashMap @@ -401,12 +401,12 @@ impl core::convert::From for aya_ebpf::maps::hash_map::LruPerCpuHashMap::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::hash_map::PerCpuHashMap impl aya_ebpf::maps::hash_map::PerCpuHashMap -pub unsafe fn aya_ebpf::maps::hash_map::PerCpuHashMap::get(&self, key: &K) -> core::option::Option<&V> -pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::get_ptr(&self, key: &K) -> core::option::Option<*const V> -pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::get_ptr_mut(&self, key: &K) -> core::option::Option<*mut V> -pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::insert(&self, key: &K, value: &V, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub unsafe fn aya_ebpf::maps::hash_map::PerCpuHashMap::get(&self, key: impl core::borrow::Borrow) -> core::option::Option<&V> +pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::get_ptr(&self, key: impl core::borrow::Borrow) -> core::option::Option<*const V> +pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::get_ptr_mut(&self, key: impl core::borrow::Borrow) -> core::option::Option<*mut V> +pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::insert(&self, key: impl core::borrow::Borrow, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::PerCpuHashMap::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::remove(&self, key: &K) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::remove(&self, key: impl core::borrow::Borrow) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::PerCpuHashMap::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::hash_map::PerCpuHashMap impl !core::marker::Freeze for aya_ebpf::maps::hash_map::PerCpuHashMap @@ -460,10 +460,10 @@ impl core::convert::From for aya_ebpf::maps::lpm_trie::Key pub fn aya_ebpf::maps::lpm_trie::Key::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::lpm_trie::LpmTrie impl aya_ebpf::maps::lpm_trie::LpmTrie -pub fn aya_ebpf::maps::lpm_trie::LpmTrie::get(&self, key: &aya_ebpf::maps::lpm_trie::Key) -> core::option::Option<&V> -pub fn aya_ebpf::maps::lpm_trie::LpmTrie::insert(&self, key: &aya_ebpf::maps::lpm_trie::Key, value: &V, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::lpm_trie::LpmTrie::get(&self, key: impl core::borrow::Borrow>) -> core::option::Option<&V> +pub fn aya_ebpf::maps::lpm_trie::LpmTrie::insert(&self, key: impl core::borrow::Borrow>, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::lpm_trie::LpmTrie::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::lpm_trie::LpmTrie::remove(&self, key: &aya_ebpf::maps::lpm_trie::Key) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::lpm_trie::LpmTrie::remove(&self, key: impl core::borrow::Borrow>) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::lpm_trie::LpmTrie::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::lpm_trie::LpmTrie impl !core::marker::Freeze for aya_ebpf::maps::lpm_trie::LpmTrie @@ -521,8 +521,8 @@ pub mod aya_ebpf::maps::perf #[repr(transparent)] pub struct aya_ebpf::maps::perf::PerfEventArray impl aya_ebpf::maps::PerfEventArray pub const fn aya_ebpf::maps::PerfEventArray::new(flags: u32) -> Self -pub fn aya_ebpf::maps::PerfEventArray::output(&self, ctx: &C, data: &T, flags: u32) -pub fn aya_ebpf::maps::PerfEventArray::output_at_index(&self, ctx: &C, index: u32, data: &T, flags: u32) +pub fn aya_ebpf::maps::PerfEventArray::output(&self, ctx: &C, data: impl core::borrow::Borrow, flags: u32) +pub fn aya_ebpf::maps::PerfEventArray::output_at_index(&self, ctx: &C, index: u32, data: impl core::borrow::Borrow, flags: u32) pub const fn aya_ebpf::maps::PerfEventArray::pinned(flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::PerfEventArray impl !core::marker::Freeze for aya_ebpf::maps::PerfEventArray @@ -608,7 +608,7 @@ impl aya_ebpf::maps::queue::Queue pub fn aya_ebpf::maps::queue::Queue::peek(&self) -> core::option::Option pub const fn aya_ebpf::maps::queue::Queue::pinned(max_entries: u32, flags: u32) -> Self pub fn aya_ebpf::maps::queue::Queue::pop(&self) -> core::option::Option -pub fn aya_ebpf::maps::queue::Queue::push(&self, value: &T, flags: u64) -> core::result::Result<(), i64> +pub fn aya_ebpf::maps::queue::Queue::push(&self, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), i64> pub const fn aya_ebpf::maps::queue::Queue::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::queue::Queue impl !core::marker::Freeze for aya_ebpf::maps::queue::Queue @@ -635,7 +635,7 @@ pub fn aya_ebpf::maps::queue::Queue::from(t: T) -> T pub mod aya_ebpf::maps::ring_buf #[repr(transparent)] pub struct aya_ebpf::maps::ring_buf::RingBuf impl aya_ebpf::maps::ring_buf::RingBuf -pub fn aya_ebpf::maps::ring_buf::RingBuf::output(&self, data: &T, flags: u64) -> core::result::Result<(), i64> +pub fn aya_ebpf::maps::ring_buf::RingBuf::output(&self, data: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), i64> pub const fn aya_ebpf::maps::ring_buf::RingBuf::pinned(byte_size: u32, flags: u32) -> Self pub fn aya_ebpf::maps::ring_buf::RingBuf::query(&self, flags: u64) -> u64 pub fn aya_ebpf::maps::ring_buf::RingBuf::reserve(&self, flags: u64) -> core::option::Option> @@ -733,10 +733,10 @@ pub mod aya_ebpf::maps::sock_hash #[repr(transparent)] pub struct aya_ebpf::maps::sock_hash::SockHash impl aya_ebpf::maps::sock_hash::SockHash pub const fn aya_ebpf::maps::sock_hash::SockHash::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::sock_hash::SockHash::redirect_msg(&self, ctx: &aya_ebpf::programs::sk_msg::SkMsgContext, key: &mut K, flags: u64) -> i64 -pub fn aya_ebpf::maps::sock_hash::SockHash::redirect_sk_lookup(&mut self, ctx: &aya_ebpf::programs::sk_lookup::SkLookupContext, key: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), u32> -pub fn aya_ebpf::maps::sock_hash::SockHash::redirect_skb(&self, ctx: &aya_ebpf::programs::sk_buff::SkBuffContext, key: &mut K, flags: u64) -> i64 -pub fn aya_ebpf::maps::sock_hash::SockHash::update(&self, key: &mut K, sk_ops: &mut aya_ebpf_bindings::x86_64::bindings::bpf_sock_ops, flags: u64) -> core::result::Result<(), i64> +pub fn aya_ebpf::maps::sock_hash::SockHash::redirect_msg(&self, ctx: impl core::borrow::Borrow, key: impl core::borrow::BorrowMut, flags: u64) -> i64 +pub fn aya_ebpf::maps::sock_hash::SockHash::redirect_sk_lookup(&mut self, ctx: impl core::borrow::Borrow, key: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), u32> +pub fn aya_ebpf::maps::sock_hash::SockHash::redirect_skb(&self, ctx: impl core::borrow::Borrow, key: impl core::borrow::BorrowMut, flags: u64) -> i64 +pub fn aya_ebpf::maps::sock_hash::SockHash::update(&self, key: impl core::borrow::BorrowMut, sk_ops: impl core::borrow::BorrowMut, flags: u64) -> core::result::Result<(), i64> pub const fn aya_ebpf::maps::sock_hash::SockHash::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::sock_hash::SockHash impl !core::marker::Freeze for aya_ebpf::maps::sock_hash::SockHash @@ -797,7 +797,7 @@ impl aya_ebpf::maps::stack::Stack pub fn aya_ebpf::maps::stack::Stack::peek(&self) -> core::option::Option pub const fn aya_ebpf::maps::stack::Stack::pinned(max_entries: u32, flags: u32) -> Self pub fn aya_ebpf::maps::stack::Stack::pop(&self) -> core::option::Option -pub fn aya_ebpf::maps::stack::Stack::push(&self, value: &T, flags: u64) -> core::result::Result<(), i64> +pub fn aya_ebpf::maps::stack::Stack::push(&self, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), i64> pub const fn aya_ebpf::maps::stack::Stack::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Freeze for aya_ebpf::maps::stack::Stack impl core::marker::Send for aya_ebpf::maps::stack::Stack where T: core::marker::Send @@ -824,7 +824,7 @@ pub fn aya_ebpf::maps::stack::Stack::from(t: T) -> T pub mod aya_ebpf::maps::stack_trace #[repr(transparent)] pub struct aya_ebpf::maps::stack_trace::StackTrace impl aya_ebpf::maps::stack_trace::StackTrace -pub unsafe fn aya_ebpf::maps::stack_trace::StackTrace::get_stackid(&self, ctx: &C, flags: u64) -> core::result::Result +pub unsafe fn aya_ebpf::maps::stack_trace::StackTrace::get_stackid(&self, ctx: impl core::borrow::Borrow, flags: u64) -> core::result::Result pub const fn aya_ebpf::maps::stack_trace::StackTrace::pinned(max_entries: u32, flags: u32) -> Self pub const fn aya_ebpf::maps::stack_trace::StackTrace::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::stack_trace::StackTrace @@ -967,7 +967,7 @@ pub fn aya_ebpf::maps::array::Array::get(&self, index: u32) -> core::option:: pub fn aya_ebpf::maps::array::Array::get_ptr(&self, index: u32) -> core::option::Option<*const T> pub fn aya_ebpf::maps::array::Array::get_ptr_mut(&self, index: u32) -> core::option::Option<*mut T> pub const fn aya_ebpf::maps::array::Array::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::array::Array::set(&self, index: u32, value: &T, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::array::Array::set(&self, index: u32, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::array::Array::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::array::Array impl !core::marker::Freeze for aya_ebpf::maps::array::Array @@ -993,8 +993,8 @@ impl core::convert::From for aya_ebpf::maps::array::Array pub fn aya_ebpf::maps::array::Array::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::BloomFilter impl aya_ebpf::maps::bloom_filter::BloomFilter -pub fn aya_ebpf::maps::bloom_filter::BloomFilter::contains(&mut self, value: &T) -> core::result::Result<(), i64> -pub fn aya_ebpf::maps::bloom_filter::BloomFilter::insert(&mut self, value: &T, flags: u64) -> core::result::Result<(), i64> +pub fn aya_ebpf::maps::bloom_filter::BloomFilter::contains(&mut self, value: impl core::borrow::Borrow) -> core::result::Result<(), i64> +pub fn aya_ebpf::maps::bloom_filter::BloomFilter::insert(&mut self, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), i64> pub const fn aya_ebpf::maps::bloom_filter::BloomFilter::pinned(max_entries: u32, flags: u32) -> Self pub const fn aya_ebpf::maps::bloom_filter::BloomFilter::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Freeze for aya_ebpf::maps::bloom_filter::BloomFilter @@ -1104,12 +1104,12 @@ impl core::convert::From for aya_ebpf::maps::DevMapHash pub fn aya_ebpf::maps::DevMapHash::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::HashMap impl aya_ebpf::maps::hash_map::HashMap -pub unsafe fn aya_ebpf::maps::hash_map::HashMap::get(&self, key: &K) -> core::option::Option<&V> -pub fn aya_ebpf::maps::hash_map::HashMap::get_ptr(&self, key: &K) -> core::option::Option<*const V> -pub fn aya_ebpf::maps::hash_map::HashMap::get_ptr_mut(&self, key: &K) -> core::option::Option<*mut V> -pub fn aya_ebpf::maps::hash_map::HashMap::insert(&self, key: &K, value: &V, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub unsafe fn aya_ebpf::maps::hash_map::HashMap::get(&self, key: impl core::borrow::Borrow) -> core::option::Option<&V> +pub fn aya_ebpf::maps::hash_map::HashMap::get_ptr(&self, key: impl core::borrow::Borrow) -> core::option::Option<*const V> +pub fn aya_ebpf::maps::hash_map::HashMap::get_ptr_mut(&self, key: impl core::borrow::Borrow) -> core::option::Option<*mut V> +pub fn aya_ebpf::maps::hash_map::HashMap::insert(&self, key: impl core::borrow::Borrow, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::HashMap::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::hash_map::HashMap::remove(&self, key: &K) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::hash_map::HashMap::remove(&self, key: impl core::borrow::Borrow) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::HashMap::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::hash_map::HashMap impl !core::marker::Freeze for aya_ebpf::maps::hash_map::HashMap @@ -1135,10 +1135,10 @@ impl core::convert::From for aya_ebpf::maps::hash_map::HashMap pub fn aya_ebpf::maps::hash_map::HashMap::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::LpmTrie impl aya_ebpf::maps::lpm_trie::LpmTrie -pub fn aya_ebpf::maps::lpm_trie::LpmTrie::get(&self, key: &aya_ebpf::maps::lpm_trie::Key) -> core::option::Option<&V> -pub fn aya_ebpf::maps::lpm_trie::LpmTrie::insert(&self, key: &aya_ebpf::maps::lpm_trie::Key, value: &V, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::lpm_trie::LpmTrie::get(&self, key: impl core::borrow::Borrow>) -> core::option::Option<&V> +pub fn aya_ebpf::maps::lpm_trie::LpmTrie::insert(&self, key: impl core::borrow::Borrow>, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::lpm_trie::LpmTrie::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::lpm_trie::LpmTrie::remove(&self, key: &aya_ebpf::maps::lpm_trie::Key) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::lpm_trie::LpmTrie::remove(&self, key: impl core::borrow::Borrow>) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::lpm_trie::LpmTrie::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::lpm_trie::LpmTrie impl !core::marker::Freeze for aya_ebpf::maps::lpm_trie::LpmTrie @@ -1164,12 +1164,12 @@ impl core::convert::From for aya_ebpf::maps::lpm_trie::LpmTrie pub fn aya_ebpf::maps::lpm_trie::LpmTrie::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::LruHashMap impl aya_ebpf::maps::hash_map::LruHashMap -pub unsafe fn aya_ebpf::maps::hash_map::LruHashMap::get(&self, key: &K) -> core::option::Option<&V> -pub fn aya_ebpf::maps::hash_map::LruHashMap::get_ptr(&self, key: &K) -> core::option::Option<*const V> -pub fn aya_ebpf::maps::hash_map::LruHashMap::get_ptr_mut(&self, key: &K) -> core::option::Option<*mut V> -pub fn aya_ebpf::maps::hash_map::LruHashMap::insert(&self, key: &K, value: &V, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub unsafe fn aya_ebpf::maps::hash_map::LruHashMap::get(&self, key: impl core::borrow::Borrow) -> core::option::Option<&V> +pub fn aya_ebpf::maps::hash_map::LruHashMap::get_ptr(&self, key: impl core::borrow::Borrow) -> core::option::Option<*const V> +pub fn aya_ebpf::maps::hash_map::LruHashMap::get_ptr_mut(&self, key: impl core::borrow::Borrow) -> core::option::Option<*mut V> +pub fn aya_ebpf::maps::hash_map::LruHashMap::insert(&self, key: impl core::borrow::Borrow, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::LruHashMap::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::hash_map::LruHashMap::remove(&self, key: &K) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::hash_map::LruHashMap::remove(&self, key: impl core::borrow::Borrow) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::LruHashMap::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::hash_map::LruHashMap impl !core::marker::Freeze for aya_ebpf::maps::hash_map::LruHashMap @@ -1195,12 +1195,12 @@ impl core::convert::From for aya_ebpf::maps::hash_map::LruHashMap pub fn aya_ebpf::maps::hash_map::LruHashMap::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::LruPerCpuHashMap impl aya_ebpf::maps::hash_map::LruPerCpuHashMap -pub unsafe fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::get(&self, key: &K) -> core::option::Option<&V> -pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::get_ptr(&self, key: &K) -> core::option::Option<*const V> -pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::get_ptr_mut(&self, key: &K) -> core::option::Option<*mut V> -pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::insert(&self, key: &K, value: &V, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub unsafe fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::get(&self, key: impl core::borrow::Borrow) -> core::option::Option<&V> +pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::get_ptr(&self, key: impl core::borrow::Borrow) -> core::option::Option<*const V> +pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::get_ptr_mut(&self, key: impl core::borrow::Borrow) -> core::option::Option<*mut V> +pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::insert(&self, key: impl core::borrow::Borrow, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::remove(&self, key: &K) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::remove(&self, key: impl core::borrow::Borrow) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::LruPerCpuHashMap::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::hash_map::LruPerCpuHashMap impl !core::marker::Freeze for aya_ebpf::maps::hash_map::LruPerCpuHashMap @@ -1255,12 +1255,12 @@ impl core::convert::From for aya_ebpf::maps::per_cpu_array::PerCpuArray pub fn aya_ebpf::maps::per_cpu_array::PerCpuArray::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::PerCpuHashMap impl aya_ebpf::maps::hash_map::PerCpuHashMap -pub unsafe fn aya_ebpf::maps::hash_map::PerCpuHashMap::get(&self, key: &K) -> core::option::Option<&V> -pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::get_ptr(&self, key: &K) -> core::option::Option<*const V> -pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::get_ptr_mut(&self, key: &K) -> core::option::Option<*mut V> -pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::insert(&self, key: &K, value: &V, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub unsafe fn aya_ebpf::maps::hash_map::PerCpuHashMap::get(&self, key: impl core::borrow::Borrow) -> core::option::Option<&V> +pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::get_ptr(&self, key: impl core::borrow::Borrow) -> core::option::Option<*const V> +pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::get_ptr_mut(&self, key: impl core::borrow::Borrow) -> core::option::Option<*mut V> +pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::insert(&self, key: impl core::borrow::Borrow, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::PerCpuHashMap::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::remove(&self, key: &K) -> core::result::Result<(), aya_ebpf_cty::od::c_long> +pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::remove(&self, key: impl core::borrow::Borrow) -> core::result::Result<(), aya_ebpf_cty::od::c_long> pub const fn aya_ebpf::maps::hash_map::PerCpuHashMap::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::hash_map::PerCpuHashMap impl !core::marker::Freeze for aya_ebpf::maps::hash_map::PerCpuHashMap @@ -1287,8 +1287,8 @@ pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::PerfEventArray impl aya_ebpf::maps::PerfEventArray pub const fn aya_ebpf::maps::PerfEventArray::new(flags: u32) -> Self -pub fn aya_ebpf::maps::PerfEventArray::output(&self, ctx: &C, data: &T, flags: u32) -pub fn aya_ebpf::maps::PerfEventArray::output_at_index(&self, ctx: &C, index: u32, data: &T, flags: u32) +pub fn aya_ebpf::maps::PerfEventArray::output(&self, ctx: &C, data: impl core::borrow::Borrow, flags: u32) +pub fn aya_ebpf::maps::PerfEventArray::output_at_index(&self, ctx: &C, index: u32, data: impl core::borrow::Borrow, flags: u32) pub const fn aya_ebpf::maps::PerfEventArray::pinned(flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::PerfEventArray impl !core::marker::Freeze for aya_ebpf::maps::PerfEventArray @@ -1372,7 +1372,7 @@ impl aya_ebpf::maps::queue::Queue pub fn aya_ebpf::maps::queue::Queue::peek(&self) -> core::option::Option pub const fn aya_ebpf::maps::queue::Queue::pinned(max_entries: u32, flags: u32) -> Self pub fn aya_ebpf::maps::queue::Queue::pop(&self) -> core::option::Option -pub fn aya_ebpf::maps::queue::Queue::push(&self, value: &T, flags: u64) -> core::result::Result<(), i64> +pub fn aya_ebpf::maps::queue::Queue::push(&self, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), i64> pub const fn aya_ebpf::maps::queue::Queue::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::queue::Queue impl !core::marker::Freeze for aya_ebpf::maps::queue::Queue @@ -1398,7 +1398,7 @@ impl core::convert::From for aya_ebpf::maps::queue::Queue pub fn aya_ebpf::maps::queue::Queue::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::RingBuf impl aya_ebpf::maps::ring_buf::RingBuf -pub fn aya_ebpf::maps::ring_buf::RingBuf::output(&self, data: &T, flags: u64) -> core::result::Result<(), i64> +pub fn aya_ebpf::maps::ring_buf::RingBuf::output(&self, data: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), i64> pub const fn aya_ebpf::maps::ring_buf::RingBuf::pinned(byte_size: u32, flags: u32) -> Self pub fn aya_ebpf::maps::ring_buf::RingBuf::query(&self, flags: u64) -> u64 pub fn aya_ebpf::maps::ring_buf::RingBuf::reserve(&self, flags: u64) -> core::option::Option> @@ -1429,10 +1429,10 @@ pub fn aya_ebpf::maps::ring_buf::RingBuf::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::SockHash impl aya_ebpf::maps::sock_hash::SockHash pub const fn aya_ebpf::maps::sock_hash::SockHash::pinned(max_entries: u32, flags: u32) -> Self -pub fn aya_ebpf::maps::sock_hash::SockHash::redirect_msg(&self, ctx: &aya_ebpf::programs::sk_msg::SkMsgContext, key: &mut K, flags: u64) -> i64 -pub fn aya_ebpf::maps::sock_hash::SockHash::redirect_sk_lookup(&mut self, ctx: &aya_ebpf::programs::sk_lookup::SkLookupContext, key: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), u32> -pub fn aya_ebpf::maps::sock_hash::SockHash::redirect_skb(&self, ctx: &aya_ebpf::programs::sk_buff::SkBuffContext, key: &mut K, flags: u64) -> i64 -pub fn aya_ebpf::maps::sock_hash::SockHash::update(&self, key: &mut K, sk_ops: &mut aya_ebpf_bindings::x86_64::bindings::bpf_sock_ops, flags: u64) -> core::result::Result<(), i64> +pub fn aya_ebpf::maps::sock_hash::SockHash::redirect_msg(&self, ctx: impl core::borrow::Borrow, key: impl core::borrow::BorrowMut, flags: u64) -> i64 +pub fn aya_ebpf::maps::sock_hash::SockHash::redirect_sk_lookup(&mut self, ctx: impl core::borrow::Borrow, key: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), u32> +pub fn aya_ebpf::maps::sock_hash::SockHash::redirect_skb(&self, ctx: impl core::borrow::Borrow, key: impl core::borrow::BorrowMut, flags: u64) -> i64 +pub fn aya_ebpf::maps::sock_hash::SockHash::update(&self, key: impl core::borrow::BorrowMut, sk_ops: impl core::borrow::BorrowMut, flags: u64) -> core::result::Result<(), i64> pub const fn aya_ebpf::maps::sock_hash::SockHash::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::sock_hash::SockHash impl !core::marker::Freeze for aya_ebpf::maps::sock_hash::SockHash @@ -1491,7 +1491,7 @@ impl aya_ebpf::maps::stack::Stack pub fn aya_ebpf::maps::stack::Stack::peek(&self) -> core::option::Option pub const fn aya_ebpf::maps::stack::Stack::pinned(max_entries: u32, flags: u32) -> Self pub fn aya_ebpf::maps::stack::Stack::pop(&self) -> core::option::Option -pub fn aya_ebpf::maps::stack::Stack::push(&self, value: &T, flags: u64) -> core::result::Result<(), i64> +pub fn aya_ebpf::maps::stack::Stack::push(&self, value: impl core::borrow::Borrow, flags: u64) -> core::result::Result<(), i64> pub const fn aya_ebpf::maps::stack::Stack::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Freeze for aya_ebpf::maps::stack::Stack impl core::marker::Send for aya_ebpf::maps::stack::Stack where T: core::marker::Send @@ -1517,7 +1517,7 @@ impl core::convert::From for aya_ebpf::maps::stack::Stack pub fn aya_ebpf::maps::stack::Stack::from(t: T) -> T #[repr(transparent)] pub struct aya_ebpf::maps::StackTrace impl aya_ebpf::maps::stack_trace::StackTrace -pub unsafe fn aya_ebpf::maps::stack_trace::StackTrace::get_stackid(&self, ctx: &C, flags: u64) -> core::result::Result +pub unsafe fn aya_ebpf::maps::stack_trace::StackTrace::get_stackid(&self, ctx: impl core::borrow::Borrow, flags: u64) -> core::result::Result pub const fn aya_ebpf::maps::stack_trace::StackTrace::pinned(max_entries: u32, flags: u32) -> Self pub const fn aya_ebpf::maps::stack_trace::StackTrace::with_max_entries(max_entries: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::stack_trace::StackTrace