mirror of https://github.com/aya-rs/aya
aya: add support for map-bound XDP programs
Such programs are to be bound to cpumap or devmap instead of the usual network interfaces.reviewable/pr527/r2
parent
238bcc6e74
commit
4d06c651ae
@ -0,0 +1,24 @@
|
||||
//! XDP programs.
|
||||
|
||||
use crate::generated::bpf_attach_type;
|
||||
|
||||
/// Defines where to attach an `XDP` program.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum XdpAttachType {
|
||||
/// Attach to a network interface.
|
||||
Interface,
|
||||
/// Attach to a cpumap. Requires kernel 5.9 or later.
|
||||
CpuMap,
|
||||
/// Attach to a devmap. Requires kernel 5.8 or later.
|
||||
DevMap,
|
||||
}
|
||||
|
||||
impl From<XdpAttachType> for bpf_attach_type {
|
||||
fn from(value: XdpAttachType) -> Self {
|
||||
match value {
|
||||
XdpAttachType::Interface => bpf_attach_type::BPF_XDP,
|
||||
XdpAttachType::CpuMap => bpf_attach_type::BPF_XDP_CPUMAP,
|
||||
XdpAttachType::DevMap => bpf_attach_type::BPF_XDP_DEVMAP,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue