aya_obj/programs/xdp.rs
1//! XDP programs.
2
3use crate::generated::bpf_attach_type;
4
5/// Defines where to attach an `XDP` program.
6#[derive(Copy, Clone, Debug)]
7pub enum XdpAttachType {
8 /// Attach to a network interface.
9 Interface,
10 /// Attach to a cpumap. Requires kernel 5.9 or later.
11 CpuMap,
12 /// Attach to a devmap. Requires kernel 5.8 or later.
13 DevMap,
14}
15
16impl From<XdpAttachType> for bpf_attach_type {
17 fn from(value: XdpAttachType) -> Self {
18 match value {
19 XdpAttachType::Interface => Self::BPF_XDP,
20 XdpAttachType::CpuMap => Self::BPF_XDP_CPUMAP,
21 XdpAttachType::DevMap => Self::BPF_XDP_DEVMAP,
22 }
23 }
24}