aya: switch to rustified enums

pull/1/head
Alessandro Decina 4 years ago
parent bdca32cebf
commit 29f2d9b2d9

@ -3,8 +3,10 @@ use bindgen::{self, Builder, EnumVariation};
pub fn user_builder() -> Builder {
let bindgen = bindgen::builder()
.layout_tests(false)
.default_enum_style(EnumVariation::ModuleConsts)
.prepend_enum_name(false);
.prepend_enum_name(false)
.default_enum_style(EnumVariation::Rust {
non_exhaustive: false,
});
bindgen
}

@ -80,7 +80,8 @@ impl Bpf {
let mut maps = Vec::new();
for (_, mut obj) in obj.maps.drain() {
if obj.def.map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY && obj.def.max_entries == 0 {
if obj.def.map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY as u32 && obj.def.max_entries == 0
{
obj.def.max_entries = *possible_cpus()
.map_err(|error| BpfError::FileError {
path: PathBuf::from(POSSIBLE_CPUS),

@ -182,153 +182,157 @@ impl bpf_insn {
__bindgen_bitfield_unit
}
}
pub mod bpf_cmd {
pub type Type = ::std::os::raw::c_uint;
pub const BPF_MAP_CREATE: Type = 0;
pub const BPF_MAP_LOOKUP_ELEM: Type = 1;
pub const BPF_MAP_UPDATE_ELEM: Type = 2;
pub const BPF_MAP_DELETE_ELEM: Type = 3;
pub const BPF_MAP_GET_NEXT_KEY: Type = 4;
pub const BPF_PROG_LOAD: Type = 5;
pub const BPF_OBJ_PIN: Type = 6;
pub const BPF_OBJ_GET: Type = 7;
pub const BPF_PROG_ATTACH: Type = 8;
pub const BPF_PROG_DETACH: Type = 9;
pub const BPF_PROG_TEST_RUN: Type = 10;
pub const BPF_PROG_GET_NEXT_ID: Type = 11;
pub const BPF_MAP_GET_NEXT_ID: Type = 12;
pub const BPF_PROG_GET_FD_BY_ID: Type = 13;
pub const BPF_MAP_GET_FD_BY_ID: Type = 14;
pub const BPF_OBJ_GET_INFO_BY_FD: Type = 15;
pub const BPF_PROG_QUERY: Type = 16;
pub const BPF_RAW_TRACEPOINT_OPEN: Type = 17;
pub const BPF_BTF_LOAD: Type = 18;
pub const BPF_BTF_GET_FD_BY_ID: Type = 19;
pub const BPF_TASK_FD_QUERY: Type = 20;
pub const BPF_MAP_LOOKUP_AND_DELETE_ELEM: Type = 21;
pub const BPF_MAP_FREEZE: Type = 22;
pub const BPF_BTF_GET_NEXT_ID: Type = 23;
pub const BPF_MAP_LOOKUP_BATCH: Type = 24;
pub const BPF_MAP_LOOKUP_AND_DELETE_BATCH: Type = 25;
pub const BPF_MAP_UPDATE_BATCH: Type = 26;
pub const BPF_MAP_DELETE_BATCH: Type = 27;
pub const BPF_LINK_CREATE: Type = 28;
pub const BPF_LINK_UPDATE: Type = 29;
pub const BPF_LINK_GET_FD_BY_ID: Type = 30;
pub const BPF_LINK_GET_NEXT_ID: Type = 31;
pub const BPF_ENABLE_STATS: Type = 32;
pub const BPF_ITER_CREATE: Type = 33;
pub const BPF_LINK_DETACH: Type = 34;
pub const BPF_PROG_BIND_MAP: Type = 35;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum bpf_cmd {
BPF_MAP_CREATE = 0,
BPF_MAP_LOOKUP_ELEM = 1,
BPF_MAP_UPDATE_ELEM = 2,
BPF_MAP_DELETE_ELEM = 3,
BPF_MAP_GET_NEXT_KEY = 4,
BPF_PROG_LOAD = 5,
BPF_OBJ_PIN = 6,
BPF_OBJ_GET = 7,
BPF_PROG_ATTACH = 8,
BPF_PROG_DETACH = 9,
BPF_PROG_TEST_RUN = 10,
BPF_PROG_GET_NEXT_ID = 11,
BPF_MAP_GET_NEXT_ID = 12,
BPF_PROG_GET_FD_BY_ID = 13,
BPF_MAP_GET_FD_BY_ID = 14,
BPF_OBJ_GET_INFO_BY_FD = 15,
BPF_PROG_QUERY = 16,
BPF_RAW_TRACEPOINT_OPEN = 17,
BPF_BTF_LOAD = 18,
BPF_BTF_GET_FD_BY_ID = 19,
BPF_TASK_FD_QUERY = 20,
BPF_MAP_LOOKUP_AND_DELETE_ELEM = 21,
BPF_MAP_FREEZE = 22,
BPF_BTF_GET_NEXT_ID = 23,
BPF_MAP_LOOKUP_BATCH = 24,
BPF_MAP_LOOKUP_AND_DELETE_BATCH = 25,
BPF_MAP_UPDATE_BATCH = 26,
BPF_MAP_DELETE_BATCH = 27,
BPF_LINK_CREATE = 28,
BPF_LINK_UPDATE = 29,
BPF_LINK_GET_FD_BY_ID = 30,
BPF_LINK_GET_NEXT_ID = 31,
BPF_ENABLE_STATS = 32,
BPF_ITER_CREATE = 33,
BPF_LINK_DETACH = 34,
BPF_PROG_BIND_MAP = 35,
}
pub mod bpf_map_type {
pub type Type = ::std::os::raw::c_uint;
pub const BPF_MAP_TYPE_UNSPEC: Type = 0;
pub const BPF_MAP_TYPE_HASH: Type = 1;
pub const BPF_MAP_TYPE_ARRAY: Type = 2;
pub const BPF_MAP_TYPE_PROG_ARRAY: Type = 3;
pub const BPF_MAP_TYPE_PERF_EVENT_ARRAY: Type = 4;
pub const BPF_MAP_TYPE_PERCPU_HASH: Type = 5;
pub const BPF_MAP_TYPE_PERCPU_ARRAY: Type = 6;
pub const BPF_MAP_TYPE_STACK_TRACE: Type = 7;
pub const BPF_MAP_TYPE_CGROUP_ARRAY: Type = 8;
pub const BPF_MAP_TYPE_LRU_HASH: Type = 9;
pub const BPF_MAP_TYPE_LRU_PERCPU_HASH: Type = 10;
pub const BPF_MAP_TYPE_LPM_TRIE: Type = 11;
pub const BPF_MAP_TYPE_ARRAY_OF_MAPS: Type = 12;
pub const BPF_MAP_TYPE_HASH_OF_MAPS: Type = 13;
pub const BPF_MAP_TYPE_DEVMAP: Type = 14;
pub const BPF_MAP_TYPE_SOCKMAP: Type = 15;
pub const BPF_MAP_TYPE_CPUMAP: Type = 16;
pub const BPF_MAP_TYPE_XSKMAP: Type = 17;
pub const BPF_MAP_TYPE_SOCKHASH: Type = 18;
pub const BPF_MAP_TYPE_CGROUP_STORAGE: Type = 19;
pub const BPF_MAP_TYPE_REUSEPORT_SOCKARRAY: Type = 20;
pub const BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE: Type = 21;
pub const BPF_MAP_TYPE_QUEUE: Type = 22;
pub const BPF_MAP_TYPE_STACK: Type = 23;
pub const BPF_MAP_TYPE_SK_STORAGE: Type = 24;
pub const BPF_MAP_TYPE_DEVMAP_HASH: Type = 25;
pub const BPF_MAP_TYPE_STRUCT_OPS: Type = 26;
pub const BPF_MAP_TYPE_RINGBUF: Type = 27;
pub const BPF_MAP_TYPE_INODE_STORAGE: Type = 28;
pub const BPF_MAP_TYPE_TASK_STORAGE: Type = 29;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum bpf_map_type {
BPF_MAP_TYPE_UNSPEC = 0,
BPF_MAP_TYPE_HASH = 1,
BPF_MAP_TYPE_ARRAY = 2,
BPF_MAP_TYPE_PROG_ARRAY = 3,
BPF_MAP_TYPE_PERF_EVENT_ARRAY = 4,
BPF_MAP_TYPE_PERCPU_HASH = 5,
BPF_MAP_TYPE_PERCPU_ARRAY = 6,
BPF_MAP_TYPE_STACK_TRACE = 7,
BPF_MAP_TYPE_CGROUP_ARRAY = 8,
BPF_MAP_TYPE_LRU_HASH = 9,
BPF_MAP_TYPE_LRU_PERCPU_HASH = 10,
BPF_MAP_TYPE_LPM_TRIE = 11,
BPF_MAP_TYPE_ARRAY_OF_MAPS = 12,
BPF_MAP_TYPE_HASH_OF_MAPS = 13,
BPF_MAP_TYPE_DEVMAP = 14,
BPF_MAP_TYPE_SOCKMAP = 15,
BPF_MAP_TYPE_CPUMAP = 16,
BPF_MAP_TYPE_XSKMAP = 17,
BPF_MAP_TYPE_SOCKHASH = 18,
BPF_MAP_TYPE_CGROUP_STORAGE = 19,
BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 20,
BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 21,
BPF_MAP_TYPE_QUEUE = 22,
BPF_MAP_TYPE_STACK = 23,
BPF_MAP_TYPE_SK_STORAGE = 24,
BPF_MAP_TYPE_DEVMAP_HASH = 25,
BPF_MAP_TYPE_STRUCT_OPS = 26,
BPF_MAP_TYPE_RINGBUF = 27,
BPF_MAP_TYPE_INODE_STORAGE = 28,
BPF_MAP_TYPE_TASK_STORAGE = 29,
}
pub mod bpf_prog_type {
pub type Type = ::std::os::raw::c_uint;
pub const BPF_PROG_TYPE_UNSPEC: Type = 0;
pub const BPF_PROG_TYPE_SOCKET_FILTER: Type = 1;
pub const BPF_PROG_TYPE_KPROBE: Type = 2;
pub const BPF_PROG_TYPE_SCHED_CLS: Type = 3;
pub const BPF_PROG_TYPE_SCHED_ACT: Type = 4;
pub const BPF_PROG_TYPE_TRACEPOINT: Type = 5;
pub const BPF_PROG_TYPE_XDP: Type = 6;
pub const BPF_PROG_TYPE_PERF_EVENT: Type = 7;
pub const BPF_PROG_TYPE_CGROUP_SKB: Type = 8;
pub const BPF_PROG_TYPE_CGROUP_SOCK: Type = 9;
pub const BPF_PROG_TYPE_LWT_IN: Type = 10;
pub const BPF_PROG_TYPE_LWT_OUT: Type = 11;
pub const BPF_PROG_TYPE_LWT_XMIT: Type = 12;
pub const BPF_PROG_TYPE_SOCK_OPS: Type = 13;
pub const BPF_PROG_TYPE_SK_SKB: Type = 14;
pub const BPF_PROG_TYPE_CGROUP_DEVICE: Type = 15;
pub const BPF_PROG_TYPE_SK_MSG: Type = 16;
pub const BPF_PROG_TYPE_RAW_TRACEPOINT: Type = 17;
pub const BPF_PROG_TYPE_CGROUP_SOCK_ADDR: Type = 18;
pub const BPF_PROG_TYPE_LWT_SEG6LOCAL: Type = 19;
pub const BPF_PROG_TYPE_LIRC_MODE2: Type = 20;
pub const BPF_PROG_TYPE_SK_REUSEPORT: Type = 21;
pub const BPF_PROG_TYPE_FLOW_DISSECTOR: Type = 22;
pub const BPF_PROG_TYPE_CGROUP_SYSCTL: Type = 23;
pub const BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE: Type = 24;
pub const BPF_PROG_TYPE_CGROUP_SOCKOPT: Type = 25;
pub const BPF_PROG_TYPE_TRACING: Type = 26;
pub const BPF_PROG_TYPE_STRUCT_OPS: Type = 27;
pub const BPF_PROG_TYPE_EXT: Type = 28;
pub const BPF_PROG_TYPE_LSM: Type = 29;
pub const BPF_PROG_TYPE_SK_LOOKUP: Type = 30;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum bpf_prog_type {
BPF_PROG_TYPE_UNSPEC = 0,
BPF_PROG_TYPE_SOCKET_FILTER = 1,
BPF_PROG_TYPE_KPROBE = 2,
BPF_PROG_TYPE_SCHED_CLS = 3,
BPF_PROG_TYPE_SCHED_ACT = 4,
BPF_PROG_TYPE_TRACEPOINT = 5,
BPF_PROG_TYPE_XDP = 6,
BPF_PROG_TYPE_PERF_EVENT = 7,
BPF_PROG_TYPE_CGROUP_SKB = 8,
BPF_PROG_TYPE_CGROUP_SOCK = 9,
BPF_PROG_TYPE_LWT_IN = 10,
BPF_PROG_TYPE_LWT_OUT = 11,
BPF_PROG_TYPE_LWT_XMIT = 12,
BPF_PROG_TYPE_SOCK_OPS = 13,
BPF_PROG_TYPE_SK_SKB = 14,
BPF_PROG_TYPE_CGROUP_DEVICE = 15,
BPF_PROG_TYPE_SK_MSG = 16,
BPF_PROG_TYPE_RAW_TRACEPOINT = 17,
BPF_PROG_TYPE_CGROUP_SOCK_ADDR = 18,
BPF_PROG_TYPE_LWT_SEG6LOCAL = 19,
BPF_PROG_TYPE_LIRC_MODE2 = 20,
BPF_PROG_TYPE_SK_REUSEPORT = 21,
BPF_PROG_TYPE_FLOW_DISSECTOR = 22,
BPF_PROG_TYPE_CGROUP_SYSCTL = 23,
BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE = 24,
BPF_PROG_TYPE_CGROUP_SOCKOPT = 25,
BPF_PROG_TYPE_TRACING = 26,
BPF_PROG_TYPE_STRUCT_OPS = 27,
BPF_PROG_TYPE_EXT = 28,
BPF_PROG_TYPE_LSM = 29,
BPF_PROG_TYPE_SK_LOOKUP = 30,
}
pub mod bpf_attach_type {
pub type Type = ::std::os::raw::c_uint;
pub const BPF_CGROUP_INET_INGRESS: Type = 0;
pub const BPF_CGROUP_INET_EGRESS: Type = 1;
pub const BPF_CGROUP_INET_SOCK_CREATE: Type = 2;
pub const BPF_CGROUP_SOCK_OPS: Type = 3;
pub const BPF_SK_SKB_STREAM_PARSER: Type = 4;
pub const BPF_SK_SKB_STREAM_VERDICT: Type = 5;
pub const BPF_CGROUP_DEVICE: Type = 6;
pub const BPF_SK_MSG_VERDICT: Type = 7;
pub const BPF_CGROUP_INET4_BIND: Type = 8;
pub const BPF_CGROUP_INET6_BIND: Type = 9;
pub const BPF_CGROUP_INET4_CONNECT: Type = 10;
pub const BPF_CGROUP_INET6_CONNECT: Type = 11;
pub const BPF_CGROUP_INET4_POST_BIND: Type = 12;
pub const BPF_CGROUP_INET6_POST_BIND: Type = 13;
pub const BPF_CGROUP_UDP4_SENDMSG: Type = 14;
pub const BPF_CGROUP_UDP6_SENDMSG: Type = 15;
pub const BPF_LIRC_MODE2: Type = 16;
pub const BPF_FLOW_DISSECTOR: Type = 17;
pub const BPF_CGROUP_SYSCTL: Type = 18;
pub const BPF_CGROUP_UDP4_RECVMSG: Type = 19;
pub const BPF_CGROUP_UDP6_RECVMSG: Type = 20;
pub const BPF_CGROUP_GETSOCKOPT: Type = 21;
pub const BPF_CGROUP_SETSOCKOPT: Type = 22;
pub const BPF_TRACE_RAW_TP: Type = 23;
pub const BPF_TRACE_FENTRY: Type = 24;
pub const BPF_TRACE_FEXIT: Type = 25;
pub const BPF_MODIFY_RETURN: Type = 26;
pub const BPF_LSM_MAC: Type = 27;
pub const BPF_TRACE_ITER: Type = 28;
pub const BPF_CGROUP_INET4_GETPEERNAME: Type = 29;
pub const BPF_CGROUP_INET6_GETPEERNAME: Type = 30;
pub const BPF_CGROUP_INET4_GETSOCKNAME: Type = 31;
pub const BPF_CGROUP_INET6_GETSOCKNAME: Type = 32;
pub const BPF_XDP_DEVMAP: Type = 33;
pub const BPF_CGROUP_INET_SOCK_RELEASE: Type = 34;
pub const BPF_XDP_CPUMAP: Type = 35;
pub const BPF_SK_LOOKUP: Type = 36;
pub const BPF_XDP: Type = 37;
pub const __MAX_BPF_ATTACH_TYPE: Type = 38;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum bpf_attach_type {
BPF_CGROUP_INET_INGRESS = 0,
BPF_CGROUP_INET_EGRESS = 1,
BPF_CGROUP_INET_SOCK_CREATE = 2,
BPF_CGROUP_SOCK_OPS = 3,
BPF_SK_SKB_STREAM_PARSER = 4,
BPF_SK_SKB_STREAM_VERDICT = 5,
BPF_CGROUP_DEVICE = 6,
BPF_SK_MSG_VERDICT = 7,
BPF_CGROUP_INET4_BIND = 8,
BPF_CGROUP_INET6_BIND = 9,
BPF_CGROUP_INET4_CONNECT = 10,
BPF_CGROUP_INET6_CONNECT = 11,
BPF_CGROUP_INET4_POST_BIND = 12,
BPF_CGROUP_INET6_POST_BIND = 13,
BPF_CGROUP_UDP4_SENDMSG = 14,
BPF_CGROUP_UDP6_SENDMSG = 15,
BPF_LIRC_MODE2 = 16,
BPF_FLOW_DISSECTOR = 17,
BPF_CGROUP_SYSCTL = 18,
BPF_CGROUP_UDP4_RECVMSG = 19,
BPF_CGROUP_UDP6_RECVMSG = 20,
BPF_CGROUP_GETSOCKOPT = 21,
BPF_CGROUP_SETSOCKOPT = 22,
BPF_TRACE_RAW_TP = 23,
BPF_TRACE_FENTRY = 24,
BPF_TRACE_FEXIT = 25,
BPF_MODIFY_RETURN = 26,
BPF_LSM_MAC = 27,
BPF_TRACE_ITER = 28,
BPF_CGROUP_INET4_GETPEERNAME = 29,
BPF_CGROUP_INET6_GETPEERNAME = 30,
BPF_CGROUP_INET4_GETSOCKNAME = 31,
BPF_CGROUP_INET6_GETSOCKNAME = 32,
BPF_XDP_DEVMAP = 33,
BPF_CGROUP_INET_SOCK_RELEASE = 34,
BPF_XDP_CPUMAP = 35,
BPF_SK_LOOKUP = 36,
BPF_XDP = 37,
__MAX_BPF_ATTACH_TYPE = 38,
}
#[repr(C)]
#[derive(Copy, Clone)]
@ -650,57 +654,60 @@ pub struct btf_var_secinfo {
pub offset: __u32,
pub size: __u32,
}
pub mod perf_type_id {
pub type Type = ::std::os::raw::c_uint;
pub const PERF_TYPE_HARDWARE: Type = 0;
pub const PERF_TYPE_SOFTWARE: Type = 1;
pub const PERF_TYPE_TRACEPOINT: Type = 2;
pub const PERF_TYPE_HW_CACHE: Type = 3;
pub const PERF_TYPE_RAW: Type = 4;
pub const PERF_TYPE_BREAKPOINT: Type = 5;
pub const PERF_TYPE_MAX: Type = 6;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum perf_type_id {
PERF_TYPE_HARDWARE = 0,
PERF_TYPE_SOFTWARE = 1,
PERF_TYPE_TRACEPOINT = 2,
PERF_TYPE_HW_CACHE = 3,
PERF_TYPE_RAW = 4,
PERF_TYPE_BREAKPOINT = 5,
PERF_TYPE_MAX = 6,
}
pub mod perf_sw_ids {
pub type Type = ::std::os::raw::c_uint;
pub const PERF_COUNT_SW_CPU_CLOCK: Type = 0;
pub const PERF_COUNT_SW_TASK_CLOCK: Type = 1;
pub const PERF_COUNT_SW_PAGE_FAULTS: Type = 2;
pub const PERF_COUNT_SW_CONTEXT_SWITCHES: Type = 3;
pub const PERF_COUNT_SW_CPU_MIGRATIONS: Type = 4;
pub const PERF_COUNT_SW_PAGE_FAULTS_MIN: Type = 5;
pub const PERF_COUNT_SW_PAGE_FAULTS_MAJ: Type = 6;
pub const PERF_COUNT_SW_ALIGNMENT_FAULTS: Type = 7;
pub const PERF_COUNT_SW_EMULATION_FAULTS: Type = 8;
pub const PERF_COUNT_SW_DUMMY: Type = 9;
pub const PERF_COUNT_SW_BPF_OUTPUT: Type = 10;
pub const PERF_COUNT_SW_MAX: Type = 11;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum perf_sw_ids {
PERF_COUNT_SW_CPU_CLOCK = 0,
PERF_COUNT_SW_TASK_CLOCK = 1,
PERF_COUNT_SW_PAGE_FAULTS = 2,
PERF_COUNT_SW_CONTEXT_SWITCHES = 3,
PERF_COUNT_SW_CPU_MIGRATIONS = 4,
PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
PERF_COUNT_SW_ALIGNMENT_FAULTS = 7,
PERF_COUNT_SW_EMULATION_FAULTS = 8,
PERF_COUNT_SW_DUMMY = 9,
PERF_COUNT_SW_BPF_OUTPUT = 10,
PERF_COUNT_SW_MAX = 11,
}
pub mod perf_event_sample_format {
pub type Type = ::std::os::raw::c_ulong;
pub const PERF_SAMPLE_IP: Type = 1;
pub const PERF_SAMPLE_TID: Type = 2;
pub const PERF_SAMPLE_TIME: Type = 4;
pub const PERF_SAMPLE_ADDR: Type = 8;
pub const PERF_SAMPLE_READ: Type = 16;
pub const PERF_SAMPLE_CALLCHAIN: Type = 32;
pub const PERF_SAMPLE_ID: Type = 64;
pub const PERF_SAMPLE_CPU: Type = 128;
pub const PERF_SAMPLE_PERIOD: Type = 256;
pub const PERF_SAMPLE_STREAM_ID: Type = 512;
pub const PERF_SAMPLE_RAW: Type = 1024;
pub const PERF_SAMPLE_BRANCH_STACK: Type = 2048;
pub const PERF_SAMPLE_REGS_USER: Type = 4096;
pub const PERF_SAMPLE_STACK_USER: Type = 8192;
pub const PERF_SAMPLE_WEIGHT: Type = 16384;
pub const PERF_SAMPLE_DATA_SRC: Type = 32768;
pub const PERF_SAMPLE_IDENTIFIER: Type = 65536;
pub const PERF_SAMPLE_TRANSACTION: Type = 131072;
pub const PERF_SAMPLE_REGS_INTR: Type = 262144;
pub const PERF_SAMPLE_PHYS_ADDR: Type = 524288;
pub const PERF_SAMPLE_AUX: Type = 1048576;
pub const PERF_SAMPLE_CGROUP: Type = 2097152;
pub const PERF_SAMPLE_MAX: Type = 4194304;
pub const __PERF_SAMPLE_CALLCHAIN_EARLY: Type = 9223372036854775808;
#[repr(u64)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum perf_event_sample_format {
PERF_SAMPLE_IP = 1,
PERF_SAMPLE_TID = 2,
PERF_SAMPLE_TIME = 4,
PERF_SAMPLE_ADDR = 8,
PERF_SAMPLE_READ = 16,
PERF_SAMPLE_CALLCHAIN = 32,
PERF_SAMPLE_ID = 64,
PERF_SAMPLE_CPU = 128,
PERF_SAMPLE_PERIOD = 256,
PERF_SAMPLE_STREAM_ID = 512,
PERF_SAMPLE_RAW = 1024,
PERF_SAMPLE_BRANCH_STACK = 2048,
PERF_SAMPLE_REGS_USER = 4096,
PERF_SAMPLE_STACK_USER = 8192,
PERF_SAMPLE_WEIGHT = 16384,
PERF_SAMPLE_DATA_SRC = 32768,
PERF_SAMPLE_IDENTIFIER = 65536,
PERF_SAMPLE_TRANSACTION = 131072,
PERF_SAMPLE_REGS_INTR = 262144,
PERF_SAMPLE_PHYS_ADDR = 524288,
PERF_SAMPLE_AUX = 1048576,
PERF_SAMPLE_CGROUP = 2097152,
PERF_SAMPLE_MAX = 4194304,
__PERF_SAMPLE_CALLCHAIN_EARLY = 9223372036854775808,
}
#[repr(C)]
#[derive(Copy, Clone)]
@ -1451,41 +1458,53 @@ pub struct perf_event_header {
pub misc: __u16,
pub size: __u16,
}
pub mod perf_event_type {
pub type Type = ::std::os::raw::c_uint;
pub const PERF_RECORD_MMAP: Type = 1;
pub const PERF_RECORD_LOST: Type = 2;
pub const PERF_RECORD_COMM: Type = 3;
pub const PERF_RECORD_EXIT: Type = 4;
pub const PERF_RECORD_THROTTLE: Type = 5;
pub const PERF_RECORD_UNTHROTTLE: Type = 6;
pub const PERF_RECORD_FORK: Type = 7;
pub const PERF_RECORD_READ: Type = 8;
pub const PERF_RECORD_SAMPLE: Type = 9;
pub const PERF_RECORD_MMAP2: Type = 10;
pub const PERF_RECORD_AUX: Type = 11;
pub const PERF_RECORD_ITRACE_START: Type = 12;
pub const PERF_RECORD_LOST_SAMPLES: Type = 13;
pub const PERF_RECORD_SWITCH: Type = 14;
pub const PERF_RECORD_SWITCH_CPU_WIDE: Type = 15;
pub const PERF_RECORD_NAMESPACES: Type = 16;
pub const PERF_RECORD_KSYMBOL: Type = 17;
pub const PERF_RECORD_BPF_EVENT: Type = 18;
pub const PERF_RECORD_CGROUP: Type = 19;
pub const PERF_RECORD_MAX: Type = 20;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum perf_event_type {
PERF_RECORD_MMAP = 1,
PERF_RECORD_LOST = 2,
PERF_RECORD_COMM = 3,
PERF_RECORD_EXIT = 4,
PERF_RECORD_THROTTLE = 5,
PERF_RECORD_UNTHROTTLE = 6,
PERF_RECORD_FORK = 7,
PERF_RECORD_READ = 8,
PERF_RECORD_SAMPLE = 9,
PERF_RECORD_MMAP2 = 10,
PERF_RECORD_AUX = 11,
PERF_RECORD_ITRACE_START = 12,
PERF_RECORD_LOST_SAMPLES = 13,
PERF_RECORD_SWITCH = 14,
PERF_RECORD_SWITCH_CPU_WIDE = 15,
PERF_RECORD_NAMESPACES = 16,
PERF_RECORD_KSYMBOL = 17,
PERF_RECORD_BPF_EVENT = 18,
PERF_RECORD_CGROUP = 19,
PERF_RECORD_MAX = 20,
}
pub mod _bindgen_ty_79 {
pub type Type = ::std::os::raw::c_uint;
pub const IFLA_XDP_UNSPEC: Type = 0;
pub const IFLA_XDP_FD: Type = 1;
pub const IFLA_XDP_ATTACHED: Type = 2;
pub const IFLA_XDP_FLAGS: Type = 3;
pub const IFLA_XDP_PROG_ID: Type = 4;
pub const IFLA_XDP_DRV_PROG_ID: Type = 5;
pub const IFLA_XDP_SKB_PROG_ID: Type = 6;
pub const IFLA_XDP_HW_PROG_ID: Type = 7;
pub const IFLA_XDP_EXPECTED_FD: Type = 8;
pub const __IFLA_XDP_MAX: Type = 9;
pub const IFLA_XDP_UNSPEC: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_UNSPEC;
pub const IFLA_XDP_FD: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_FD;
pub const IFLA_XDP_ATTACHED: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_ATTACHED;
pub const IFLA_XDP_FLAGS: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_FLAGS;
pub const IFLA_XDP_PROG_ID: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_PROG_ID;
pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_DRV_PROG_ID;
pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_SKB_PROG_ID;
pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_HW_PROG_ID;
pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_EXPECTED_FD;
pub const __IFLA_XDP_MAX: _bindgen_ty_79 = _bindgen_ty_79::__IFLA_XDP_MAX;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum _bindgen_ty_79 {
IFLA_XDP_UNSPEC = 0,
IFLA_XDP_FD = 1,
IFLA_XDP_ATTACHED = 2,
IFLA_XDP_FLAGS = 3,
IFLA_XDP_PROG_ID = 4,
IFLA_XDP_DRV_PROG_ID = 5,
IFLA_XDP_SKB_PROG_ID = 6,
IFLA_XDP_HW_PROG_ID = 7,
IFLA_XDP_EXPECTED_FD = 8,
__IFLA_XDP_MAX = 9,
}
#[doc = "\t\tLink layer specific messages."]
#[repr(C)]

@ -182,153 +182,157 @@ impl bpf_insn {
__bindgen_bitfield_unit
}
}
pub mod bpf_cmd {
pub type Type = ::std::os::raw::c_uint;
pub const BPF_MAP_CREATE: Type = 0;
pub const BPF_MAP_LOOKUP_ELEM: Type = 1;
pub const BPF_MAP_UPDATE_ELEM: Type = 2;
pub const BPF_MAP_DELETE_ELEM: Type = 3;
pub const BPF_MAP_GET_NEXT_KEY: Type = 4;
pub const BPF_PROG_LOAD: Type = 5;
pub const BPF_OBJ_PIN: Type = 6;
pub const BPF_OBJ_GET: Type = 7;
pub const BPF_PROG_ATTACH: Type = 8;
pub const BPF_PROG_DETACH: Type = 9;
pub const BPF_PROG_TEST_RUN: Type = 10;
pub const BPF_PROG_GET_NEXT_ID: Type = 11;
pub const BPF_MAP_GET_NEXT_ID: Type = 12;
pub const BPF_PROG_GET_FD_BY_ID: Type = 13;
pub const BPF_MAP_GET_FD_BY_ID: Type = 14;
pub const BPF_OBJ_GET_INFO_BY_FD: Type = 15;
pub const BPF_PROG_QUERY: Type = 16;
pub const BPF_RAW_TRACEPOINT_OPEN: Type = 17;
pub const BPF_BTF_LOAD: Type = 18;
pub const BPF_BTF_GET_FD_BY_ID: Type = 19;
pub const BPF_TASK_FD_QUERY: Type = 20;
pub const BPF_MAP_LOOKUP_AND_DELETE_ELEM: Type = 21;
pub const BPF_MAP_FREEZE: Type = 22;
pub const BPF_BTF_GET_NEXT_ID: Type = 23;
pub const BPF_MAP_LOOKUP_BATCH: Type = 24;
pub const BPF_MAP_LOOKUP_AND_DELETE_BATCH: Type = 25;
pub const BPF_MAP_UPDATE_BATCH: Type = 26;
pub const BPF_MAP_DELETE_BATCH: Type = 27;
pub const BPF_LINK_CREATE: Type = 28;
pub const BPF_LINK_UPDATE: Type = 29;
pub const BPF_LINK_GET_FD_BY_ID: Type = 30;
pub const BPF_LINK_GET_NEXT_ID: Type = 31;
pub const BPF_ENABLE_STATS: Type = 32;
pub const BPF_ITER_CREATE: Type = 33;
pub const BPF_LINK_DETACH: Type = 34;
pub const BPF_PROG_BIND_MAP: Type = 35;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum bpf_cmd {
BPF_MAP_CREATE = 0,
BPF_MAP_LOOKUP_ELEM = 1,
BPF_MAP_UPDATE_ELEM = 2,
BPF_MAP_DELETE_ELEM = 3,
BPF_MAP_GET_NEXT_KEY = 4,
BPF_PROG_LOAD = 5,
BPF_OBJ_PIN = 6,
BPF_OBJ_GET = 7,
BPF_PROG_ATTACH = 8,
BPF_PROG_DETACH = 9,
BPF_PROG_TEST_RUN = 10,
BPF_PROG_GET_NEXT_ID = 11,
BPF_MAP_GET_NEXT_ID = 12,
BPF_PROG_GET_FD_BY_ID = 13,
BPF_MAP_GET_FD_BY_ID = 14,
BPF_OBJ_GET_INFO_BY_FD = 15,
BPF_PROG_QUERY = 16,
BPF_RAW_TRACEPOINT_OPEN = 17,
BPF_BTF_LOAD = 18,
BPF_BTF_GET_FD_BY_ID = 19,
BPF_TASK_FD_QUERY = 20,
BPF_MAP_LOOKUP_AND_DELETE_ELEM = 21,
BPF_MAP_FREEZE = 22,
BPF_BTF_GET_NEXT_ID = 23,
BPF_MAP_LOOKUP_BATCH = 24,
BPF_MAP_LOOKUP_AND_DELETE_BATCH = 25,
BPF_MAP_UPDATE_BATCH = 26,
BPF_MAP_DELETE_BATCH = 27,
BPF_LINK_CREATE = 28,
BPF_LINK_UPDATE = 29,
BPF_LINK_GET_FD_BY_ID = 30,
BPF_LINK_GET_NEXT_ID = 31,
BPF_ENABLE_STATS = 32,
BPF_ITER_CREATE = 33,
BPF_LINK_DETACH = 34,
BPF_PROG_BIND_MAP = 35,
}
pub mod bpf_map_type {
pub type Type = ::std::os::raw::c_uint;
pub const BPF_MAP_TYPE_UNSPEC: Type = 0;
pub const BPF_MAP_TYPE_HASH: Type = 1;
pub const BPF_MAP_TYPE_ARRAY: Type = 2;
pub const BPF_MAP_TYPE_PROG_ARRAY: Type = 3;
pub const BPF_MAP_TYPE_PERF_EVENT_ARRAY: Type = 4;
pub const BPF_MAP_TYPE_PERCPU_HASH: Type = 5;
pub const BPF_MAP_TYPE_PERCPU_ARRAY: Type = 6;
pub const BPF_MAP_TYPE_STACK_TRACE: Type = 7;
pub const BPF_MAP_TYPE_CGROUP_ARRAY: Type = 8;
pub const BPF_MAP_TYPE_LRU_HASH: Type = 9;
pub const BPF_MAP_TYPE_LRU_PERCPU_HASH: Type = 10;
pub const BPF_MAP_TYPE_LPM_TRIE: Type = 11;
pub const BPF_MAP_TYPE_ARRAY_OF_MAPS: Type = 12;
pub const BPF_MAP_TYPE_HASH_OF_MAPS: Type = 13;
pub const BPF_MAP_TYPE_DEVMAP: Type = 14;
pub const BPF_MAP_TYPE_SOCKMAP: Type = 15;
pub const BPF_MAP_TYPE_CPUMAP: Type = 16;
pub const BPF_MAP_TYPE_XSKMAP: Type = 17;
pub const BPF_MAP_TYPE_SOCKHASH: Type = 18;
pub const BPF_MAP_TYPE_CGROUP_STORAGE: Type = 19;
pub const BPF_MAP_TYPE_REUSEPORT_SOCKARRAY: Type = 20;
pub const BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE: Type = 21;
pub const BPF_MAP_TYPE_QUEUE: Type = 22;
pub const BPF_MAP_TYPE_STACK: Type = 23;
pub const BPF_MAP_TYPE_SK_STORAGE: Type = 24;
pub const BPF_MAP_TYPE_DEVMAP_HASH: Type = 25;
pub const BPF_MAP_TYPE_STRUCT_OPS: Type = 26;
pub const BPF_MAP_TYPE_RINGBUF: Type = 27;
pub const BPF_MAP_TYPE_INODE_STORAGE: Type = 28;
pub const BPF_MAP_TYPE_TASK_STORAGE: Type = 29;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum bpf_map_type {
BPF_MAP_TYPE_UNSPEC = 0,
BPF_MAP_TYPE_HASH = 1,
BPF_MAP_TYPE_ARRAY = 2,
BPF_MAP_TYPE_PROG_ARRAY = 3,
BPF_MAP_TYPE_PERF_EVENT_ARRAY = 4,
BPF_MAP_TYPE_PERCPU_HASH = 5,
BPF_MAP_TYPE_PERCPU_ARRAY = 6,
BPF_MAP_TYPE_STACK_TRACE = 7,
BPF_MAP_TYPE_CGROUP_ARRAY = 8,
BPF_MAP_TYPE_LRU_HASH = 9,
BPF_MAP_TYPE_LRU_PERCPU_HASH = 10,
BPF_MAP_TYPE_LPM_TRIE = 11,
BPF_MAP_TYPE_ARRAY_OF_MAPS = 12,
BPF_MAP_TYPE_HASH_OF_MAPS = 13,
BPF_MAP_TYPE_DEVMAP = 14,
BPF_MAP_TYPE_SOCKMAP = 15,
BPF_MAP_TYPE_CPUMAP = 16,
BPF_MAP_TYPE_XSKMAP = 17,
BPF_MAP_TYPE_SOCKHASH = 18,
BPF_MAP_TYPE_CGROUP_STORAGE = 19,
BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 20,
BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 21,
BPF_MAP_TYPE_QUEUE = 22,
BPF_MAP_TYPE_STACK = 23,
BPF_MAP_TYPE_SK_STORAGE = 24,
BPF_MAP_TYPE_DEVMAP_HASH = 25,
BPF_MAP_TYPE_STRUCT_OPS = 26,
BPF_MAP_TYPE_RINGBUF = 27,
BPF_MAP_TYPE_INODE_STORAGE = 28,
BPF_MAP_TYPE_TASK_STORAGE = 29,
}
pub mod bpf_prog_type {
pub type Type = ::std::os::raw::c_uint;
pub const BPF_PROG_TYPE_UNSPEC: Type = 0;
pub const BPF_PROG_TYPE_SOCKET_FILTER: Type = 1;
pub const BPF_PROG_TYPE_KPROBE: Type = 2;
pub const BPF_PROG_TYPE_SCHED_CLS: Type = 3;
pub const BPF_PROG_TYPE_SCHED_ACT: Type = 4;
pub const BPF_PROG_TYPE_TRACEPOINT: Type = 5;
pub const BPF_PROG_TYPE_XDP: Type = 6;
pub const BPF_PROG_TYPE_PERF_EVENT: Type = 7;
pub const BPF_PROG_TYPE_CGROUP_SKB: Type = 8;
pub const BPF_PROG_TYPE_CGROUP_SOCK: Type = 9;
pub const BPF_PROG_TYPE_LWT_IN: Type = 10;
pub const BPF_PROG_TYPE_LWT_OUT: Type = 11;
pub const BPF_PROG_TYPE_LWT_XMIT: Type = 12;
pub const BPF_PROG_TYPE_SOCK_OPS: Type = 13;
pub const BPF_PROG_TYPE_SK_SKB: Type = 14;
pub const BPF_PROG_TYPE_CGROUP_DEVICE: Type = 15;
pub const BPF_PROG_TYPE_SK_MSG: Type = 16;
pub const BPF_PROG_TYPE_RAW_TRACEPOINT: Type = 17;
pub const BPF_PROG_TYPE_CGROUP_SOCK_ADDR: Type = 18;
pub const BPF_PROG_TYPE_LWT_SEG6LOCAL: Type = 19;
pub const BPF_PROG_TYPE_LIRC_MODE2: Type = 20;
pub const BPF_PROG_TYPE_SK_REUSEPORT: Type = 21;
pub const BPF_PROG_TYPE_FLOW_DISSECTOR: Type = 22;
pub const BPF_PROG_TYPE_CGROUP_SYSCTL: Type = 23;
pub const BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE: Type = 24;
pub const BPF_PROG_TYPE_CGROUP_SOCKOPT: Type = 25;
pub const BPF_PROG_TYPE_TRACING: Type = 26;
pub const BPF_PROG_TYPE_STRUCT_OPS: Type = 27;
pub const BPF_PROG_TYPE_EXT: Type = 28;
pub const BPF_PROG_TYPE_LSM: Type = 29;
pub const BPF_PROG_TYPE_SK_LOOKUP: Type = 30;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum bpf_prog_type {
BPF_PROG_TYPE_UNSPEC = 0,
BPF_PROG_TYPE_SOCKET_FILTER = 1,
BPF_PROG_TYPE_KPROBE = 2,
BPF_PROG_TYPE_SCHED_CLS = 3,
BPF_PROG_TYPE_SCHED_ACT = 4,
BPF_PROG_TYPE_TRACEPOINT = 5,
BPF_PROG_TYPE_XDP = 6,
BPF_PROG_TYPE_PERF_EVENT = 7,
BPF_PROG_TYPE_CGROUP_SKB = 8,
BPF_PROG_TYPE_CGROUP_SOCK = 9,
BPF_PROG_TYPE_LWT_IN = 10,
BPF_PROG_TYPE_LWT_OUT = 11,
BPF_PROG_TYPE_LWT_XMIT = 12,
BPF_PROG_TYPE_SOCK_OPS = 13,
BPF_PROG_TYPE_SK_SKB = 14,
BPF_PROG_TYPE_CGROUP_DEVICE = 15,
BPF_PROG_TYPE_SK_MSG = 16,
BPF_PROG_TYPE_RAW_TRACEPOINT = 17,
BPF_PROG_TYPE_CGROUP_SOCK_ADDR = 18,
BPF_PROG_TYPE_LWT_SEG6LOCAL = 19,
BPF_PROG_TYPE_LIRC_MODE2 = 20,
BPF_PROG_TYPE_SK_REUSEPORT = 21,
BPF_PROG_TYPE_FLOW_DISSECTOR = 22,
BPF_PROG_TYPE_CGROUP_SYSCTL = 23,
BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE = 24,
BPF_PROG_TYPE_CGROUP_SOCKOPT = 25,
BPF_PROG_TYPE_TRACING = 26,
BPF_PROG_TYPE_STRUCT_OPS = 27,
BPF_PROG_TYPE_EXT = 28,
BPF_PROG_TYPE_LSM = 29,
BPF_PROG_TYPE_SK_LOOKUP = 30,
}
pub mod bpf_attach_type {
pub type Type = ::std::os::raw::c_uint;
pub const BPF_CGROUP_INET_INGRESS: Type = 0;
pub const BPF_CGROUP_INET_EGRESS: Type = 1;
pub const BPF_CGROUP_INET_SOCK_CREATE: Type = 2;
pub const BPF_CGROUP_SOCK_OPS: Type = 3;
pub const BPF_SK_SKB_STREAM_PARSER: Type = 4;
pub const BPF_SK_SKB_STREAM_VERDICT: Type = 5;
pub const BPF_CGROUP_DEVICE: Type = 6;
pub const BPF_SK_MSG_VERDICT: Type = 7;
pub const BPF_CGROUP_INET4_BIND: Type = 8;
pub const BPF_CGROUP_INET6_BIND: Type = 9;
pub const BPF_CGROUP_INET4_CONNECT: Type = 10;
pub const BPF_CGROUP_INET6_CONNECT: Type = 11;
pub const BPF_CGROUP_INET4_POST_BIND: Type = 12;
pub const BPF_CGROUP_INET6_POST_BIND: Type = 13;
pub const BPF_CGROUP_UDP4_SENDMSG: Type = 14;
pub const BPF_CGROUP_UDP6_SENDMSG: Type = 15;
pub const BPF_LIRC_MODE2: Type = 16;
pub const BPF_FLOW_DISSECTOR: Type = 17;
pub const BPF_CGROUP_SYSCTL: Type = 18;
pub const BPF_CGROUP_UDP4_RECVMSG: Type = 19;
pub const BPF_CGROUP_UDP6_RECVMSG: Type = 20;
pub const BPF_CGROUP_GETSOCKOPT: Type = 21;
pub const BPF_CGROUP_SETSOCKOPT: Type = 22;
pub const BPF_TRACE_RAW_TP: Type = 23;
pub const BPF_TRACE_FENTRY: Type = 24;
pub const BPF_TRACE_FEXIT: Type = 25;
pub const BPF_MODIFY_RETURN: Type = 26;
pub const BPF_LSM_MAC: Type = 27;
pub const BPF_TRACE_ITER: Type = 28;
pub const BPF_CGROUP_INET4_GETPEERNAME: Type = 29;
pub const BPF_CGROUP_INET6_GETPEERNAME: Type = 30;
pub const BPF_CGROUP_INET4_GETSOCKNAME: Type = 31;
pub const BPF_CGROUP_INET6_GETSOCKNAME: Type = 32;
pub const BPF_XDP_DEVMAP: Type = 33;
pub const BPF_CGROUP_INET_SOCK_RELEASE: Type = 34;
pub const BPF_XDP_CPUMAP: Type = 35;
pub const BPF_SK_LOOKUP: Type = 36;
pub const BPF_XDP: Type = 37;
pub const __MAX_BPF_ATTACH_TYPE: Type = 38;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum bpf_attach_type {
BPF_CGROUP_INET_INGRESS = 0,
BPF_CGROUP_INET_EGRESS = 1,
BPF_CGROUP_INET_SOCK_CREATE = 2,
BPF_CGROUP_SOCK_OPS = 3,
BPF_SK_SKB_STREAM_PARSER = 4,
BPF_SK_SKB_STREAM_VERDICT = 5,
BPF_CGROUP_DEVICE = 6,
BPF_SK_MSG_VERDICT = 7,
BPF_CGROUP_INET4_BIND = 8,
BPF_CGROUP_INET6_BIND = 9,
BPF_CGROUP_INET4_CONNECT = 10,
BPF_CGROUP_INET6_CONNECT = 11,
BPF_CGROUP_INET4_POST_BIND = 12,
BPF_CGROUP_INET6_POST_BIND = 13,
BPF_CGROUP_UDP4_SENDMSG = 14,
BPF_CGROUP_UDP6_SENDMSG = 15,
BPF_LIRC_MODE2 = 16,
BPF_FLOW_DISSECTOR = 17,
BPF_CGROUP_SYSCTL = 18,
BPF_CGROUP_UDP4_RECVMSG = 19,
BPF_CGROUP_UDP6_RECVMSG = 20,
BPF_CGROUP_GETSOCKOPT = 21,
BPF_CGROUP_SETSOCKOPT = 22,
BPF_TRACE_RAW_TP = 23,
BPF_TRACE_FENTRY = 24,
BPF_TRACE_FEXIT = 25,
BPF_MODIFY_RETURN = 26,
BPF_LSM_MAC = 27,
BPF_TRACE_ITER = 28,
BPF_CGROUP_INET4_GETPEERNAME = 29,
BPF_CGROUP_INET6_GETPEERNAME = 30,
BPF_CGROUP_INET4_GETSOCKNAME = 31,
BPF_CGROUP_INET6_GETSOCKNAME = 32,
BPF_XDP_DEVMAP = 33,
BPF_CGROUP_INET_SOCK_RELEASE = 34,
BPF_XDP_CPUMAP = 35,
BPF_SK_LOOKUP = 36,
BPF_XDP = 37,
__MAX_BPF_ATTACH_TYPE = 38,
}
#[repr(C)]
#[derive(Copy, Clone)]
@ -650,57 +654,60 @@ pub struct btf_var_secinfo {
pub offset: __u32,
pub size: __u32,
}
pub mod perf_type_id {
pub type Type = ::std::os::raw::c_uint;
pub const PERF_TYPE_HARDWARE: Type = 0;
pub const PERF_TYPE_SOFTWARE: Type = 1;
pub const PERF_TYPE_TRACEPOINT: Type = 2;
pub const PERF_TYPE_HW_CACHE: Type = 3;
pub const PERF_TYPE_RAW: Type = 4;
pub const PERF_TYPE_BREAKPOINT: Type = 5;
pub const PERF_TYPE_MAX: Type = 6;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum perf_type_id {
PERF_TYPE_HARDWARE = 0,
PERF_TYPE_SOFTWARE = 1,
PERF_TYPE_TRACEPOINT = 2,
PERF_TYPE_HW_CACHE = 3,
PERF_TYPE_RAW = 4,
PERF_TYPE_BREAKPOINT = 5,
PERF_TYPE_MAX = 6,
}
pub mod perf_sw_ids {
pub type Type = ::std::os::raw::c_uint;
pub const PERF_COUNT_SW_CPU_CLOCK: Type = 0;
pub const PERF_COUNT_SW_TASK_CLOCK: Type = 1;
pub const PERF_COUNT_SW_PAGE_FAULTS: Type = 2;
pub const PERF_COUNT_SW_CONTEXT_SWITCHES: Type = 3;
pub const PERF_COUNT_SW_CPU_MIGRATIONS: Type = 4;
pub const PERF_COUNT_SW_PAGE_FAULTS_MIN: Type = 5;
pub const PERF_COUNT_SW_PAGE_FAULTS_MAJ: Type = 6;
pub const PERF_COUNT_SW_ALIGNMENT_FAULTS: Type = 7;
pub const PERF_COUNT_SW_EMULATION_FAULTS: Type = 8;
pub const PERF_COUNT_SW_DUMMY: Type = 9;
pub const PERF_COUNT_SW_BPF_OUTPUT: Type = 10;
pub const PERF_COUNT_SW_MAX: Type = 11;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum perf_sw_ids {
PERF_COUNT_SW_CPU_CLOCK = 0,
PERF_COUNT_SW_TASK_CLOCK = 1,
PERF_COUNT_SW_PAGE_FAULTS = 2,
PERF_COUNT_SW_CONTEXT_SWITCHES = 3,
PERF_COUNT_SW_CPU_MIGRATIONS = 4,
PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
PERF_COUNT_SW_ALIGNMENT_FAULTS = 7,
PERF_COUNT_SW_EMULATION_FAULTS = 8,
PERF_COUNT_SW_DUMMY = 9,
PERF_COUNT_SW_BPF_OUTPUT = 10,
PERF_COUNT_SW_MAX = 11,
}
pub mod perf_event_sample_format {
pub type Type = ::std::os::raw::c_ulong;
pub const PERF_SAMPLE_IP: Type = 1;
pub const PERF_SAMPLE_TID: Type = 2;
pub const PERF_SAMPLE_TIME: Type = 4;
pub const PERF_SAMPLE_ADDR: Type = 8;
pub const PERF_SAMPLE_READ: Type = 16;
pub const PERF_SAMPLE_CALLCHAIN: Type = 32;
pub const PERF_SAMPLE_ID: Type = 64;
pub const PERF_SAMPLE_CPU: Type = 128;
pub const PERF_SAMPLE_PERIOD: Type = 256;
pub const PERF_SAMPLE_STREAM_ID: Type = 512;
pub const PERF_SAMPLE_RAW: Type = 1024;
pub const PERF_SAMPLE_BRANCH_STACK: Type = 2048;
pub const PERF_SAMPLE_REGS_USER: Type = 4096;
pub const PERF_SAMPLE_STACK_USER: Type = 8192;
pub const PERF_SAMPLE_WEIGHT: Type = 16384;
pub const PERF_SAMPLE_DATA_SRC: Type = 32768;
pub const PERF_SAMPLE_IDENTIFIER: Type = 65536;
pub const PERF_SAMPLE_TRANSACTION: Type = 131072;
pub const PERF_SAMPLE_REGS_INTR: Type = 262144;
pub const PERF_SAMPLE_PHYS_ADDR: Type = 524288;
pub const PERF_SAMPLE_AUX: Type = 1048576;
pub const PERF_SAMPLE_CGROUP: Type = 2097152;
pub const PERF_SAMPLE_MAX: Type = 4194304;
pub const __PERF_SAMPLE_CALLCHAIN_EARLY: Type = 9223372036854775808;
#[repr(u64)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum perf_event_sample_format {
PERF_SAMPLE_IP = 1,
PERF_SAMPLE_TID = 2,
PERF_SAMPLE_TIME = 4,
PERF_SAMPLE_ADDR = 8,
PERF_SAMPLE_READ = 16,
PERF_SAMPLE_CALLCHAIN = 32,
PERF_SAMPLE_ID = 64,
PERF_SAMPLE_CPU = 128,
PERF_SAMPLE_PERIOD = 256,
PERF_SAMPLE_STREAM_ID = 512,
PERF_SAMPLE_RAW = 1024,
PERF_SAMPLE_BRANCH_STACK = 2048,
PERF_SAMPLE_REGS_USER = 4096,
PERF_SAMPLE_STACK_USER = 8192,
PERF_SAMPLE_WEIGHT = 16384,
PERF_SAMPLE_DATA_SRC = 32768,
PERF_SAMPLE_IDENTIFIER = 65536,
PERF_SAMPLE_TRANSACTION = 131072,
PERF_SAMPLE_REGS_INTR = 262144,
PERF_SAMPLE_PHYS_ADDR = 524288,
PERF_SAMPLE_AUX = 1048576,
PERF_SAMPLE_CGROUP = 2097152,
PERF_SAMPLE_MAX = 4194304,
__PERF_SAMPLE_CALLCHAIN_EARLY = 9223372036854775808,
}
#[repr(C)]
#[derive(Copy, Clone)]
@ -1451,41 +1458,53 @@ pub struct perf_event_header {
pub misc: __u16,
pub size: __u16,
}
pub mod perf_event_type {
pub type Type = ::std::os::raw::c_uint;
pub const PERF_RECORD_MMAP: Type = 1;
pub const PERF_RECORD_LOST: Type = 2;
pub const PERF_RECORD_COMM: Type = 3;
pub const PERF_RECORD_EXIT: Type = 4;
pub const PERF_RECORD_THROTTLE: Type = 5;
pub const PERF_RECORD_UNTHROTTLE: Type = 6;
pub const PERF_RECORD_FORK: Type = 7;
pub const PERF_RECORD_READ: Type = 8;
pub const PERF_RECORD_SAMPLE: Type = 9;
pub const PERF_RECORD_MMAP2: Type = 10;
pub const PERF_RECORD_AUX: Type = 11;
pub const PERF_RECORD_ITRACE_START: Type = 12;
pub const PERF_RECORD_LOST_SAMPLES: Type = 13;
pub const PERF_RECORD_SWITCH: Type = 14;
pub const PERF_RECORD_SWITCH_CPU_WIDE: Type = 15;
pub const PERF_RECORD_NAMESPACES: Type = 16;
pub const PERF_RECORD_KSYMBOL: Type = 17;
pub const PERF_RECORD_BPF_EVENT: Type = 18;
pub const PERF_RECORD_CGROUP: Type = 19;
pub const PERF_RECORD_MAX: Type = 20;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum perf_event_type {
PERF_RECORD_MMAP = 1,
PERF_RECORD_LOST = 2,
PERF_RECORD_COMM = 3,
PERF_RECORD_EXIT = 4,
PERF_RECORD_THROTTLE = 5,
PERF_RECORD_UNTHROTTLE = 6,
PERF_RECORD_FORK = 7,
PERF_RECORD_READ = 8,
PERF_RECORD_SAMPLE = 9,
PERF_RECORD_MMAP2 = 10,
PERF_RECORD_AUX = 11,
PERF_RECORD_ITRACE_START = 12,
PERF_RECORD_LOST_SAMPLES = 13,
PERF_RECORD_SWITCH = 14,
PERF_RECORD_SWITCH_CPU_WIDE = 15,
PERF_RECORD_NAMESPACES = 16,
PERF_RECORD_KSYMBOL = 17,
PERF_RECORD_BPF_EVENT = 18,
PERF_RECORD_CGROUP = 19,
PERF_RECORD_MAX = 20,
}
pub mod _bindgen_ty_79 {
pub type Type = ::std::os::raw::c_uint;
pub const IFLA_XDP_UNSPEC: Type = 0;
pub const IFLA_XDP_FD: Type = 1;
pub const IFLA_XDP_ATTACHED: Type = 2;
pub const IFLA_XDP_FLAGS: Type = 3;
pub const IFLA_XDP_PROG_ID: Type = 4;
pub const IFLA_XDP_DRV_PROG_ID: Type = 5;
pub const IFLA_XDP_SKB_PROG_ID: Type = 6;
pub const IFLA_XDP_HW_PROG_ID: Type = 7;
pub const IFLA_XDP_EXPECTED_FD: Type = 8;
pub const __IFLA_XDP_MAX: Type = 9;
pub const IFLA_XDP_UNSPEC: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_UNSPEC;
pub const IFLA_XDP_FD: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_FD;
pub const IFLA_XDP_ATTACHED: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_ATTACHED;
pub const IFLA_XDP_FLAGS: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_FLAGS;
pub const IFLA_XDP_PROG_ID: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_PROG_ID;
pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_DRV_PROG_ID;
pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_SKB_PROG_ID;
pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_HW_PROG_ID;
pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_79 = _bindgen_ty_79::IFLA_XDP_EXPECTED_FD;
pub const __IFLA_XDP_MAX: _bindgen_ty_79 = _bindgen_ty_79::__IFLA_XDP_MAX;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum _bindgen_ty_79 {
IFLA_XDP_UNSPEC = 0,
IFLA_XDP_FD = 1,
IFLA_XDP_ATTACHED = 2,
IFLA_XDP_FLAGS = 3,
IFLA_XDP_PROG_ID = 4,
IFLA_XDP_DRV_PROG_ID = 5,
IFLA_XDP_SKB_PROG_ID = 6,
IFLA_XDP_HW_PROG_ID = 7,
IFLA_XDP_EXPECTED_FD = 8,
__IFLA_XDP_MAX = 9,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]

@ -27,7 +27,7 @@ impl<T: Deref<Target = Map>, K: Pod, V: Pod> HashMap<T, K, V> {
let map_type = map.obj.def.map_type;
// validate the map definition
if map_type != BPF_MAP_TYPE_HASH {
if map_type != BPF_MAP_TYPE_HASH as u32 {
return Err(MapError::InvalidMapType {
map_type: map_type as u32,
})?;
@ -155,7 +155,7 @@ mod tests {
obj::Map {
name: name.to_string(),
def: bpf_map_def {
map_type: BPF_MAP_TYPE_HASH,
map_type: BPF_MAP_TYPE_HASH as u32,
key_size: 4,
value_size: 4,
max_entries: 1024,
@ -206,7 +206,7 @@ mod tests {
obj: obj::Map {
name: "TEST".to_string(),
def: bpf_map_def {
map_type: BPF_MAP_TYPE_PERF_EVENT_ARRAY,
map_type: BPF_MAP_TYPE_PERF_EVENT_ARRAY as u32,
key_size: 4,
value_size: 4,
max_entries: 1024,

@ -1,7 +1,8 @@
use std::{ffi::CString, io, os::unix::io::RawFd};
use std::{convert::TryFrom, ffi::CString, io, os::unix::io::RawFd};
use thiserror::Error;
use crate::{
generated::bpf_map_type,
obj,
sys::{bpf_create_map, bpf_map_get_next_key},
Pod,
@ -197,6 +198,49 @@ impl<K: Pod, V: Pod> Iterator for MapIter<'_, K, V> {
}
}
impl TryFrom<u32> for bpf_map_type {
type Error = MapError;
fn try_from(map_type: u32) -> Result<Self, Self::Error> {
use bpf_map_type::*;
Ok(match map_type {
x if x == BPF_MAP_TYPE_UNSPEC as u32 => BPF_MAP_TYPE_UNSPEC,
x if x == BPF_MAP_TYPE_HASH as u32 => BPF_MAP_TYPE_HASH,
x if x == BPF_MAP_TYPE_ARRAY as u32 => BPF_MAP_TYPE_ARRAY,
x if x == BPF_MAP_TYPE_PROG_ARRAY as u32 => BPF_MAP_TYPE_PROG_ARRAY,
x if x == BPF_MAP_TYPE_PERF_EVENT_ARRAY as u32 => BPF_MAP_TYPE_PERF_EVENT_ARRAY,
x if x == BPF_MAP_TYPE_PERCPU_HASH as u32 => BPF_MAP_TYPE_PERCPU_HASH,
x if x == BPF_MAP_TYPE_PERCPU_ARRAY as u32 => BPF_MAP_TYPE_PERCPU_ARRAY,
x if x == BPF_MAP_TYPE_STACK_TRACE as u32 => BPF_MAP_TYPE_STACK_TRACE,
x if x == BPF_MAP_TYPE_CGROUP_ARRAY as u32 => BPF_MAP_TYPE_CGROUP_ARRAY,
x if x == BPF_MAP_TYPE_LRU_HASH as u32 => BPF_MAP_TYPE_LRU_HASH,
x if x == BPF_MAP_TYPE_LRU_PERCPU_HASH as u32 => BPF_MAP_TYPE_LRU_PERCPU_HASH,
x if x == BPF_MAP_TYPE_LPM_TRIE as u32 => BPF_MAP_TYPE_LPM_TRIE,
x if x == BPF_MAP_TYPE_ARRAY_OF_MAPS as u32 => BPF_MAP_TYPE_ARRAY_OF_MAPS,
x if x == BPF_MAP_TYPE_HASH_OF_MAPS as u32 => BPF_MAP_TYPE_HASH_OF_MAPS,
x if x == BPF_MAP_TYPE_DEVMAP as u32 => BPF_MAP_TYPE_DEVMAP,
x if x == BPF_MAP_TYPE_SOCKMAP as u32 => BPF_MAP_TYPE_SOCKMAP,
x if x == BPF_MAP_TYPE_CPUMAP as u32 => BPF_MAP_TYPE_CPUMAP,
x if x == BPF_MAP_TYPE_XSKMAP as u32 => BPF_MAP_TYPE_XSKMAP,
x if x == BPF_MAP_TYPE_SOCKHASH as u32 => BPF_MAP_TYPE_SOCKHASH,
x if x == BPF_MAP_TYPE_CGROUP_STORAGE as u32 => BPF_MAP_TYPE_CGROUP_STORAGE,
x if x == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY as u32 => BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
x if x == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE as u32 => {
BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE
}
x if x == BPF_MAP_TYPE_QUEUE as u32 => BPF_MAP_TYPE_QUEUE,
x if x == BPF_MAP_TYPE_STACK as u32 => BPF_MAP_TYPE_STACK,
x if x == BPF_MAP_TYPE_SK_STORAGE as u32 => BPF_MAP_TYPE_SK_STORAGE,
x if x == BPF_MAP_TYPE_DEVMAP_HASH as u32 => BPF_MAP_TYPE_DEVMAP_HASH,
x if x == BPF_MAP_TYPE_STRUCT_OPS as u32 => BPF_MAP_TYPE_STRUCT_OPS,
x if x == BPF_MAP_TYPE_RINGBUF as u32 => BPF_MAP_TYPE_RINGBUF,
x if x == BPF_MAP_TYPE_INODE_STORAGE as u32 => BPF_MAP_TYPE_INODE_STORAGE,
x if x == BPF_MAP_TYPE_TASK_STORAGE as u32 => BPF_MAP_TYPE_TASK_STORAGE,
_ => return Err(MapError::InvalidMapType { map_type }),
})
}
}
#[cfg(test)]
mod tests {
use libc::EFAULT;
@ -213,7 +257,7 @@ mod tests {
obj::Map {
name: name.to_string(),
def: bpf_map_def {
map_type: BPF_MAP_TYPE_HASH,
map_type: BPF_MAP_TYPE_HASH as u32,
key_size: 4,
value_size: 4,
max_entries: 1024,

@ -11,7 +11,10 @@ use libc::{c_int, close, munmap, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE};
use thiserror::Error;
use crate::{
generated::{perf_event_header, perf_event_mmap_page, perf_event_type::*},
generated::{
perf_event_header, perf_event_mmap_page,
perf_event_type::{PERF_RECORD_LOST, PERF_RECORD_SAMPLE},
},
sys::{perf_event_ioctl, perf_event_open},
PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE,
};
@ -148,7 +151,7 @@ impl PerfBuffer {
let read_event = |event_start, event_type, base, buf: &mut BytesMut| {
let sample_size = match event_type {
PERF_RECORD_SAMPLE | PERF_RECORD_LOST => {
x if x == PERF_RECORD_SAMPLE as u32 || x == PERF_RECORD_LOST as u32 => {
let mut size = [0u8; mem::size_of::<u32>()];
fill_buf(
event_start + mem::size_of::<perf_event_header>(),
@ -166,7 +169,7 @@ impl PerfBuffer {
% self.size;
match event_type {
PERF_RECORD_SAMPLE => {
x if x == PERF_RECORD_SAMPLE as u32 => {
buf.clear();
if sample_size > buf.capacity() {
return Err(PerfBufferError::MoreSpaceNeeded { size: sample_size });
@ -178,7 +181,7 @@ impl PerfBuffer {
Ok(Some((1, 0)))
}
PERF_RECORD_LOST => {
x if x == PERF_RECORD_LOST as u32 => {
let mut count = [0u8; mem::size_of::<u64>()];
fill_buf(
event_start + mem::size_of::<perf_event_header>() + mem::size_of::<u64>(),
@ -369,7 +372,7 @@ mod tests {
let evt = LostSamples {
header: perf_event_header {
type_: PERF_RECORD_LOST,
type_: PERF_RECORD_LOST as u32,
misc: 0,
size: mem::size_of::<LostSamples>() as u16,
},
@ -405,7 +408,7 @@ mod tests {
let sample = PerfSample {
s_hdr: Sample {
header: perf_event_header {
type_: PERF_RECORD_SAMPLE,
type_: PERF_RECORD_SAMPLE as u32,
misc: 0,
size: mem::size_of::<PerfSample<T>>() as u16,
},
@ -512,7 +515,7 @@ mod tests {
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
let header = perf_event_header {
type_: PERF_RECORD_SAMPLE,
type_: PERF_RECORD_SAMPLE as u32,
misc: 0,
size: mem::size_of::<PerfSample<u64>>() as u16,
};
@ -542,7 +545,7 @@ mod tests {
let sample = PerfSample {
s_hdr: Sample {
header: perf_event_header {
type_: PERF_RECORD_SAMPLE,
type_: PERF_RECORD_SAMPLE as u32,
misc: 0,
size: mem::size_of::<PerfSample<u64>>() as u16,
},

@ -75,7 +75,7 @@ pub struct PerfMap<T: DerefMut<Target = Map>> {
impl<T: DerefMut<Target = Map>> PerfMap<T> {
pub fn new(map: T) -> Result<PerfMap<T>, PerfMapError> {
let map_type = map.obj.def.map_type;
if map_type != BPF_MAP_TYPE_PERF_EVENT_ARRAY {
if map_type != BPF_MAP_TYPE_PERF_EVENT_ARRAY as u32 {
return Err(MapError::InvalidMapType {
map_type: map_type as u32,
})?;

@ -22,7 +22,7 @@ pub struct ProgramArray<T: Deref<Target = Map>> {
impl<T: Deref<Target = Map>> ProgramArray<T> {
pub fn new(map: T) -> Result<ProgramArray<T>, MapError> {
let map_type = map.obj.def.map_type;
if map_type != BPF_MAP_TYPE_PROG_ARRAY {
if map_type != BPF_MAP_TYPE_PROG_ARRAY as u32 {
return Err(MapError::InvalidMapType {
map_type: map_type as u32,
})?;

@ -340,7 +340,7 @@ fn parse_map(section: &Section, name: &str) -> Result<Map, ParseError> {
let (def, data) = if name == ".bss" || name.starts_with(".data") || name.starts_with(".rodata")
{
let def = bpf_map_def {
map_type: BPF_MAP_TYPE_ARRAY,
map_type: BPF_MAP_TYPE_ARRAY as u32,
key_size: mem::size_of::<u32>() as u32,
value_size: section.data.len() as u32,
max_entries: 1,
@ -541,7 +541,7 @@ mod tests {
section_index: 0,
name,
def: bpf_map_def {
map_type: BPF_MAP_TYPE_ARRAY,
map_type: _map_type,
key_size: 4,
value_size,
max_entries: 1,

@ -5,15 +5,7 @@ pub mod trace_point;
pub mod xdp;
use libc::{close, ENOSPC};
use std::{
cell::RefCell,
cmp,
convert::TryFrom,
ffi::CStr,
io,
os::{raw::c_uint, unix::io::RawFd},
rc::Rc,
};
use std::{cell::RefCell, cmp, convert::TryFrom, ffi::CStr, io, os::unix::io::RawFd, rc::Rc};
use thiserror::Error;
use perf_attach::*;
@ -22,7 +14,7 @@ pub use socket_filter::{SocketFilter, SocketFilterError};
pub use trace_point::{TracePoint, TracePointError};
pub use xdp::{Xdp, XdpError};
use crate::{obj, sys::bpf_load_program};
use crate::{generated::bpf_prog_type, obj, sys::bpf_load_program};
#[derive(Debug, Error)]
pub enum ProgramError {
#[error("the program is already loaded")]
@ -102,7 +94,7 @@ impl Program {
load_program(self.prog_type(), self.data_mut())
}
fn prog_type(&self) -> c_uint {
fn prog_type(&self) -> bpf_prog_type {
use crate::generated::bpf_prog_type::*;
match self {
Program::KProbe(_) => BPF_PROG_TYPE_KPROBE,
@ -205,7 +197,7 @@ impl VerifierLog {
}
}
fn load_program(prog_type: c_uint, data: &mut ProgramData) -> Result<(), ProgramError> {
fn load_program(prog_type: bpf_prog_type, data: &mut ProgramData) -> Result<(), ProgramError> {
let ProgramData { obj, fd, .. } = data;
if fd.is_some() {
return Err(ProgramError::AlreadyLoaded);

@ -7,11 +7,11 @@ use std::{
slice,
};
use libc::{c_long, c_uint, ENOENT};
use libc::{c_long, ENOENT};
use crate::{
bpf_map_def,
generated::{bpf_attach_type, bpf_attr, bpf_cmd, bpf_insn},
generated::{bpf_attach_type, bpf_attr, bpf_cmd, bpf_insn, bpf_prog_type},
programs::VerifierLog,
sys::SysResult,
Pod, BPF_OBJ_NAME_LEN,
@ -38,7 +38,7 @@ pub(crate) fn bpf_create_map(name: &CStr, def: &bpf_map_def) -> SysResult {
}
pub(crate) fn bpf_load_program(
ty: c_uint,
ty: bpf_prog_type,
insns: &[bpf_insn],
license: &CStr,
kernel_version: u32,
@ -47,7 +47,7 @@ pub(crate) fn bpf_load_program(
let mut attr = unsafe { mem::zeroed::<bpf_attr>() };
let u = unsafe { &mut attr.__bindgen_anon_3 };
u.prog_type = ty;
u.prog_type = ty as u32;
u.expected_attach_type = 0;
u.insns = insns.as_ptr() as u64;
u.insn_cnt = insns.len() as u32;
@ -67,7 +67,7 @@ fn lookup<K: Pod, V: Pod>(
fd: RawFd,
key: &K,
flags: u64,
cmd: bpf_cmd::Type,
cmd: bpf_cmd,
) -> Result<Option<V>, (c_long, io::Error)> {
let mut attr = unsafe { mem::zeroed::<bpf_attr>() };
let mut value = MaybeUninit::uninit();
@ -164,19 +164,19 @@ pub(crate) fn bpf_map_get_next_key<K>(
pub(crate) fn bpf_link_create(
prog_fd: RawFd,
target_fd: RawFd,
attach_type: bpf_attach_type::Type,
attach_type: bpf_attach_type,
flags: u32,
) -> SysResult {
let mut attr = unsafe { mem::zeroed::<bpf_attr>() };
attr.link_create.prog_fd = prog_fd as u32;
attr.link_create.__bindgen_anon_1.target_fd = target_fd as u32;
attr.link_create.attach_type = attach_type;
attr.link_create.attach_type = attach_type as u32;
attr.link_create.flags = flags;
sys_bpf(bpf_cmd::BPF_LINK_CREATE, &attr)
}
fn sys_bpf<'a>(cmd: bpf_cmd::Type, attr: &'a bpf_attr) -> SysResult {
fn sys_bpf<'a>(cmd: bpf_cmd, attr: &'a bpf_attr) -> SysResult {
syscall(Syscall::Bpf { cmd, attr })
}

@ -24,7 +24,7 @@ pub(crate) type SysResult = Result<c_long, (c_long, io::Error)>;
#[cfg_attr(test, allow(dead_code))]
pub(crate) enum Syscall<'a> {
Bpf {
cmd: bpf_cmd::Type,
cmd: bpf_cmd,
attr: &'a bpf_attr,
},
PerfEventOpen {

@ -17,7 +17,7 @@ pub(crate) fn perf_event_open(cpu: c_int) -> SysResult {
attr.config = PERF_COUNT_SW_BPF_OUTPUT as u64;
attr.size = mem::size_of::<perf_event_attr>() as u32;
attr.type_ = PERF_TYPE_SOFTWARE;
attr.type_ = PERF_TYPE_SOFTWARE as u32;
attr.sample_type = PERF_SAMPLE_RAW as u64;
attr.__bindgen_anon_1.sample_period = 1;
attr.__bindgen_anon_2.wakeup_events = 1;
@ -67,7 +67,7 @@ pub(crate) fn perf_event_open_trace_point(id: u32) -> SysResult {
let mut attr = unsafe { mem::zeroed::<perf_event_attr>() };
attr.size = mem::size_of::<perf_event_attr>() as u32;
attr.type_ = PERF_TYPE_TRACEPOINT;
attr.type_ = PERF_TYPE_TRACEPOINT as u32;
attr.config = id as u64;
syscall(Syscall::PerfEventOpen {
@ -87,3 +87,34 @@ pub(crate) fn perf_event_ioctl(fd: c_int, request: c_ulong, arg: c_int) -> SysRe
#[cfg(test)]
return crate::sys::TEST_SYSCALL.with(|test_impl| unsafe { test_impl.borrow()(call) });
}
/*
impl TryFrom<u32> for perf_event_type {
PERF_RECORD_MMAP = 1,
PERF_RECORD_LOST = 2,
PERF_RECORD_COMM = 3,
PERF_RECORD_EXIT = 4,
PERF_RECORD_THROTTLE = 5,
PERF_RECORD_UNTHROTTLE = 6,
PERF_RECORD_FORK = 7,
PERF_RECORD_READ = 8,
PERF_RECORD_SAMPLE = 9,
PERF_RECORD_MMAP2 = 10,
PERF_RECORD_AUX = 11,
PERF_RECORD_ITRACE_START = 12,
PERF_RECORD_LOST_SAMPLES = 13,
PERF_RECORD_SWITCH = 14,
PERF_RECORD_SWITCH_CPU_WIDE = 15,
PERF_RECORD_NAMESPACES = 16,
PERF_RECORD_KSYMBOL = 17,
PERF_RECORD_BPF_EVENT = 18,
PERF_RECORD_CGROUP = 19,
PERF_RECORD_MAX
type Error = ();
fn try_from(value: u32) -> Result<Self, Self::Error> {
todo!()
}
}
*/

@ -13,11 +13,13 @@ pub fn codegen(opts: &Options) -> Result<(), anyhow::Error> {
fn codegen_internal_btf_bindings(opts: &Options) -> Result<(), anyhow::Error> {
let dir = PathBuf::from("aya");
let generated = dir.join("src/generated");
let mut bindgen = bindgen::user_builder().header(
opts.libbpf_dir
.join("src/libbpf_internal.h")
.to_string_lossy(),
);
let mut bindgen = bindgen::user_builder()
.header(
opts.libbpf_dir
.join("src/libbpf_internal.h")
.to_string_lossy(),
)
.constified_enum_module("bpf_core_relo_kind");
let types = ["bpf_core_relo", "btf_ext_header"];

Loading…
Cancel
Save