codegen: remove outdated workaround

bindgen can handle these macros now.
reviewable/pr1170/r1
Tamir Duberstein 2 weeks ago
parent ed92e7eb66
commit 9198335100

@ -7,8 +7,3 @@
#include <linux/pkt_cls.h> #include <linux/pkt_cls.h>
#include <linux/pkt_sched.h> #include <linux/pkt_sched.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
/* 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;

@ -1,7 +1,6 @@
use std::{ use std::{
borrow::Cow, borrow::Cow,
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
ffi::c_int,
fs, io, fs, io,
os::fd::{AsFd as _, AsRawFd as _}, os::fd::{AsFd as _, AsRawFd as _},
path::{Path, PathBuf}, path::{Path, PathBuf},
@ -12,7 +11,6 @@ use aya_obj::{
btf::{Btf, BtfError, BtfFeatures, BtfRelocationError}, btf::{Btf, BtfError, BtfFeatures, BtfRelocationError},
generated::{ generated::{
bpf_map_type::{self, *}, 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, BPF_F_SLEEPABLE, BPF_F_XDP_HAS_FRAGS,
}, },
relocation::EbpfRelocationError, relocation::EbpfRelocationError,
@ -40,10 +38,6 @@ use crate::{
util::{bytes_of, bytes_of_slice, nr_cpus, page_size}, 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. /// Marker trait for types that can safely be converted to and from byte slices.
pub unsafe trait Pod: Copy + 'static {} pub unsafe trait Pod: Copy + 'static {}

@ -9,15 +9,13 @@ use std::{
use aya_obj::generated::{ use aya_obj::generated::{
perf_event_header, perf_event_mmap_page, perf_event_header, perf_event_mmap_page,
perf_event_type::{PERF_RECORD_LOST, PERF_RECORD_SAMPLE}, perf_event_type::{PERF_RECORD_LOST, PERF_RECORD_SAMPLE},
PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE,
}; };
use bytes::BytesMut; use bytes::BytesMut;
use libc::{munmap, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE}; use libc::{munmap, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE};
use thiserror::Error; use thiserror::Error;
use crate::{ use crate::sys::{mmap, perf_event_ioctl, perf_event_open_bpf, SysResult};
sys::{mmap, perf_event_ioctl, perf_event_open_bpf, SysResult},
PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE,
};
/// Perf buffer error. /// Perf buffer error.
#[derive(Error, Debug)] #[derive(Error, Debug)]

@ -1,7 +1,10 @@
//! Perf attach links. //! Perf attach links.
use std::os::fd::{AsFd as _, AsRawFd as _, BorrowedFd, RawFd}; 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::{ use crate::{
programs::{ programs::{
@ -13,7 +16,7 @@ use crate::{
bpf_link_create, is_bpf_cookie_supported, perf_event_ioctl, BpfLinkCreateArgs, LinkTarget, bpf_link_create, is_bpf_cookie_supported, perf_event_ioctl, BpfLinkCreateArgs, LinkTarget,
SysResult, SyscallError, SysResult, SyscallError,
}, },
FEATURES, PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE, PERF_EVENT_IOC_SET_BPF, FEATURES,
}; };
#[derive(Debug, Hash, Eq, PartialEq)] #[derive(Debug, Hash, Eq, PartialEq)]

@ -40,7 +40,7 @@ pub(crate) enum Syscall<'a> {
}, },
PerfEventIoctl { PerfEventIoctl {
fd: BorrowedFd<'a>, fd: BorrowedFd<'a>,
request: c_int, request: u32,
arg: c_int, arg: c_int,
}, },
} }

@ -104,11 +104,7 @@ pub(crate) fn perf_event_open_trace_point(
perf_event_sys(attr, pid, cpu, PERF_FLAG_FD_CLOEXEC) perf_event_sys(attr, pid, cpu, PERF_FLAG_FD_CLOEXEC)
} }
pub(crate) fn perf_event_ioctl( pub(crate) fn perf_event_ioctl(fd: BorrowedFd<'_>, request: u32, arg: c_int) -> SysResult<c_long> {
fd: BorrowedFd<'_>,
request: c_int,
arg: c_int,
) -> SysResult<c_long> {
let call = Syscall::PerfEventIoctl { fd, request, arg }; let call = Syscall::PerfEventIoctl { fd, request, arg };
#[cfg(not(test))] #[cfg(not(test))]
return syscall(call); return syscall(call);

@ -138,8 +138,6 @@ fn codegen_bindings(opts: &SysrootOptions, libbpf_dir: &Path) -> Result<(), anyh
"PERF_FLAG_.*", "PERF_FLAG_.*",
"PERF_EVENT_.*", "PERF_EVENT_.*",
"PERF_MAX_.*", "PERF_MAX_.*",
// see linux_wrapper.h, these are to workaround the IOC macros
"AYA_PERF_EVENT_.*",
// NETLINK // NETLINK
"NLMSG_ALIGNTO", "NLMSG_ALIGNTO",
"IFLA_XDP_FD", "IFLA_XDP_FD",

Loading…
Cancel
Save