make sure everything is marked correctly

pull/431/head
Ricky Han 2 years ago
parent 9525b1a370
commit 6ce60ad21d

@ -64,7 +64,7 @@ impl<T: AsRef<MapData>, V: Pod> BloomFilter<T, V> {
/// Inserts a value into the map.
pub fn insert(&self, value: impl Borrow<V>, flags: u64) -> Result<(), MapError> {
let fd = self.inner.as_ref().fd_or_err()?;
bpf_map_push_elem(fd, &value, flags).map_err(|(_, io_error)| MapError::SyscallError {
bpf_map_push_elem(fd, value.borrow(), flags).map_err(|(_, io_error)| MapError::SyscallError {
call: "bpf_map_push_elem".to_owned(),
io_error,
})?;

@ -30,7 +30,7 @@ pub(crate) fn insert<K: Pod, V: Pod>(
Ok(())
}
pub(crate) fn remove<K>(map: &mut MapData, key: &K) -> Result<(), MapError> {
pub(crate) fn remove<K: Pod>(map: &mut MapData, key: &K) -> Result<(), MapError> {
let fd = map.fd_or_err()?;
bpf_map_delete_elem(fd, key)
.map(|_| ())

@ -123,7 +123,7 @@ impl<T: AsMut<MapData>, K: Pod, V: Pod> PerCpuHashMap<T, K, V> {
flags: u64,
) -> Result<(), MapError> {
let fd = self.inner.as_mut().fd_or_err()?;
bpf_map_update_elem_per_cpu(fd, &key, &values, flags).map_err(|(_, io_error)| {
bpf_map_update_elem_per_cpu(fd, key.borrow(), &values, flags).map_err(|(_, io_error)| {
MapError::SyscallError {
call: "bpf_map_update_elem".to_owned(),
io_error,

@ -81,7 +81,7 @@ impl<T: AsMut<MapData>, V: Pod> Queue<T, V> {
/// [`MapError::SyscallError`] if `bpf_map_update_elem` fails.
pub fn push(&mut self, value: impl Borrow<V>, flags: u64) -> Result<(), MapError> {
let fd = self.inner.as_mut().fd_or_err()?;
bpf_map_push_elem(fd, &value, flags).map_err(|(_, io_error)| MapError::SyscallError {
bpf_map_push_elem(fd, value.borrow(), flags).map_err(|(_, io_error)| MapError::SyscallError {
call: "bpf_map_push_elem".to_owned(),
io_error,
})?;

@ -251,7 +251,7 @@ pub(crate) fn bpf_map_update_elem<K: Pod, V: Pod>(
sys_bpf(bpf_cmd::BPF_MAP_UPDATE_ELEM, &attr)
}
pub(crate) fn bpf_map_push_elem<V>(fd: RawFd, value: &V, flags: u64) -> SysResult {
pub(crate) fn bpf_map_push_elem<V: Pod>(fd: RawFd, value: &V, flags: u64) -> SysResult {
let mut attr = unsafe { mem::zeroed::<bpf_attr>() };
let u = unsafe { &mut attr.__bindgen_anon_2 };
@ -279,7 +279,7 @@ pub(crate) fn bpf_map_update_elem_ptr<K, V>(
sys_bpf(bpf_cmd::BPF_MAP_UPDATE_ELEM, &attr)
}
pub(crate) fn bpf_map_update_elem_per_cpu<K, V: Pod>(
pub(crate) fn bpf_map_update_elem_per_cpu<K: Pod, V: Pod>(
fd: RawFd,
key: &K,
values: &PerCpuValues<V>,
@ -289,7 +289,7 @@ pub(crate) fn bpf_map_update_elem_per_cpu<K, V: Pod>(
bpf_map_update_elem_ptr(fd, key, mem.as_mut_ptr(), flags)
}
pub(crate) fn bpf_map_delete_elem<K>(fd: RawFd, key: &K) -> SysResult {
pub(crate) fn bpf_map_delete_elem<K: Pod>(fd: RawFd, key: &K) -> SysResult {
let mut attr = unsafe { mem::zeroed::<bpf_attr>() };
let u = unsafe { &mut attr.__bindgen_anon_2 };
@ -299,7 +299,7 @@ pub(crate) fn bpf_map_delete_elem<K>(fd: RawFd, key: &K) -> SysResult {
sys_bpf(bpf_cmd::BPF_MAP_DELETE_ELEM, &attr)
}
pub(crate) fn bpf_map_get_next_key<K>(
pub(crate) fn bpf_map_get_next_key<K: Pod>(
fd: RawFd,
key: Option<&K>,
) -> Result<Option<K>, (c_long, io::Error)> {

Loading…
Cancel
Save