|
|
|
@ -1,15 +1,15 @@
|
|
|
|
|
use core::{cell::UnsafeCell, mem, num::NonZeroU32, ptr::NonNull};
|
|
|
|
|
|
|
|
|
|
use aya_bpf_bindings::bindings::{bpf_devmap_val, xdp_action::XDP_REDIRECT};
|
|
|
|
|
use aya_bpf_bindings::bindings::bpf_devmap_val;
|
|
|
|
|
use aya_bpf_cty::c_void;
|
|
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
|
bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_DEVMAP_HASH},
|
|
|
|
|
helpers::{bpf_map_lookup_elem, bpf_redirect_map},
|
|
|
|
|
helpers::bpf_map_lookup_elem,
|
|
|
|
|
maps::PinningType,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
use super::dev_map::DevMapValue;
|
|
|
|
|
use super::{dev_map::DevMapValue, try_redirect_map};
|
|
|
|
|
|
|
|
|
|
/// A map of network devices.
|
|
|
|
|
///
|
|
|
|
@ -140,14 +140,7 @@ impl DevMapHash {
|
|
|
|
|
/// }
|
|
|
|
|
/// ```
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
pub fn redirect(&self, index: u32, flags: u64) -> Result<u32, u32> {
|
|
|
|
|
let ret = unsafe { bpf_redirect_map(self.def.get() as *mut _, index.into(), flags) };
|
|
|
|
|
match ret.unsigned_abs() as u32 {
|
|
|
|
|
XDP_REDIRECT => Ok(XDP_REDIRECT),
|
|
|
|
|
// Return XDP_REDIRECT on success, or the value of the two lower bits of the flags
|
|
|
|
|
// argument on error. Thus I have no idea why it returns a long (i64) instead of
|
|
|
|
|
// something saner, hence the unsigned_abs.
|
|
|
|
|
ret => Err(ret),
|
|
|
|
|
}
|
|
|
|
|
pub fn redirect(&self, key: u32, flags: u64) -> Result<u32, u32> {
|
|
|
|
|
try_redirect_map(&self.def, key, flags)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|