diff --git a/aya-obj/include/linux_wrapper.h b/aya-obj/include/linux_wrapper.h index 0e15d93f..ab4f00ae 100644 --- a/aya-obj/include/linux_wrapper.h +++ b/aya-obj/include/linux_wrapper.h @@ -7,8 +7,3 @@ #include #include #include - -/* workaround the fact that bindgen can't parse the IOC macros */ -int AYA_PERF_EVENT_IOC_ENABLE = PERF_EVENT_IOC_ENABLE; -int AYA_PERF_EVENT_IOC_DISABLE = PERF_EVENT_IOC_DISABLE; -int AYA_PERF_EVENT_IOC_SET_BPF = PERF_EVENT_IOC_SET_BPF; diff --git a/aya/src/bpf.rs b/aya/src/bpf.rs index d95797aa..644a2d86 100644 --- a/aya/src/bpf.rs +++ b/aya/src/bpf.rs @@ -1,7 +1,6 @@ use std::{ borrow::Cow, collections::{HashMap, HashSet}, - ffi::c_int, fs, io, os::fd::{AsFd as _, AsRawFd as _}, path::{Path, PathBuf}, @@ -12,7 +11,6 @@ use aya_obj::{ btf::{Btf, BtfError, BtfFeatures, BtfRelocationError}, generated::{ bpf_map_type::{self, *}, - AYA_PERF_EVENT_IOC_DISABLE, AYA_PERF_EVENT_IOC_ENABLE, AYA_PERF_EVENT_IOC_SET_BPF, BPF_F_SLEEPABLE, BPF_F_XDP_HAS_FRAGS, }, relocation::EbpfRelocationError, @@ -40,10 +38,6 @@ use crate::{ util::{bytes_of, bytes_of_slice, nr_cpus, page_size}, }; -pub(crate) const PERF_EVENT_IOC_ENABLE: c_int = AYA_PERF_EVENT_IOC_ENABLE; -pub(crate) const PERF_EVENT_IOC_DISABLE: c_int = AYA_PERF_EVENT_IOC_DISABLE; -pub(crate) const PERF_EVENT_IOC_SET_BPF: c_int = AYA_PERF_EVENT_IOC_SET_BPF; - /// Marker trait for types that can safely be converted to and from byte slices. pub unsafe trait Pod: Copy + 'static {} diff --git a/aya/src/maps/perf/perf_buffer.rs b/aya/src/maps/perf/perf_buffer.rs index 06b3d333..39996764 100644 --- a/aya/src/maps/perf/perf_buffer.rs +++ b/aya/src/maps/perf/perf_buffer.rs @@ -9,15 +9,13 @@ use std::{ use aya_obj::generated::{ perf_event_header, perf_event_mmap_page, perf_event_type::{PERF_RECORD_LOST, PERF_RECORD_SAMPLE}, + PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE, }; use bytes::BytesMut; use libc::{munmap, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE}; use thiserror::Error; -use crate::{ - sys::{mmap, perf_event_ioctl, perf_event_open_bpf, SysResult}, - PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE, -}; +use crate::sys::{mmap, perf_event_ioctl, perf_event_open_bpf, SysResult}; /// Perf buffer error. #[derive(Error, Debug)] diff --git a/aya/src/programs/perf_attach.rs b/aya/src/programs/perf_attach.rs index c1627e4c..da25fedb 100644 --- a/aya/src/programs/perf_attach.rs +++ b/aya/src/programs/perf_attach.rs @@ -1,7 +1,10 @@ //! Perf attach links. use std::os::fd::{AsFd as _, AsRawFd as _, BorrowedFd, RawFd}; -use aya_obj::generated::bpf_attach_type::BPF_PERF_EVENT; +use aya_obj::generated::{ + bpf_attach_type::BPF_PERF_EVENT, PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE, + PERF_EVENT_IOC_SET_BPF, +}; use crate::{ programs::{ @@ -13,7 +16,7 @@ use crate::{ bpf_link_create, is_bpf_cookie_supported, perf_event_ioctl, BpfLinkCreateArgs, LinkTarget, SysResult, SyscallError, }, - FEATURES, PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE, PERF_EVENT_IOC_SET_BPF, + FEATURES, }; #[derive(Debug, Hash, Eq, PartialEq)] diff --git a/aya/src/sys/mod.rs b/aya/src/sys/mod.rs index dcead532..8eab8acd 100644 --- a/aya/src/sys/mod.rs +++ b/aya/src/sys/mod.rs @@ -40,7 +40,7 @@ pub(crate) enum Syscall<'a> { }, PerfEventIoctl { fd: BorrowedFd<'a>, - request: c_int, + request: u32, arg: c_int, }, } diff --git a/aya/src/sys/perf_event.rs b/aya/src/sys/perf_event.rs index 8ed7b54c..ce7b56c0 100644 --- a/aya/src/sys/perf_event.rs +++ b/aya/src/sys/perf_event.rs @@ -104,11 +104,7 @@ pub(crate) fn perf_event_open_trace_point( perf_event_sys(attr, pid, cpu, PERF_FLAG_FD_CLOEXEC) } -pub(crate) fn perf_event_ioctl( - fd: BorrowedFd<'_>, - request: c_int, - arg: c_int, -) -> SysResult { +pub(crate) fn perf_event_ioctl(fd: BorrowedFd<'_>, request: u32, arg: c_int) -> SysResult { let call = Syscall::PerfEventIoctl { fd, request, arg }; #[cfg(not(test))] return syscall(call); diff --git a/xtask/src/codegen/aya.rs b/xtask/src/codegen/aya.rs index 118e9d53..67e6f67f 100644 --- a/xtask/src/codegen/aya.rs +++ b/xtask/src/codegen/aya.rs @@ -138,8 +138,6 @@ fn codegen_bindings(opts: &SysrootOptions, libbpf_dir: &Path) -> Result<(), anyh "PERF_FLAG_.*", "PERF_EVENT_.*", "PERF_MAX_.*", - // see linux_wrapper.h, these are to workaround the IOC macros - "AYA_PERF_EVENT_.*", // NETLINK "NLMSG_ALIGNTO", "IFLA_XDP_FD",