aya: fix bindings for PERF_EVENT_IOC_{ENABLE|DISABLE|SET_BPF}

pull/1/head
Alessandro Decina 4 years ago
parent a92bfebf50
commit f9554d6db5

@ -4,3 +4,8 @@
#include <linux/if_link.h>
#include <linux/rtnetlink.h>
#include <asm-generic/socket.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;

@ -2,13 +2,17 @@ use std::{
collections::HashMap,
error::Error,
fs, io,
os::raw::c_int,
path::{Path, PathBuf},
};
use thiserror::Error;
use crate::{
generated::bpf_map_type::BPF_MAP_TYPE_PERF_EVENT_ARRAY,
generated::{
bpf_map_type::BPF_MAP_TYPE_PERF_EVENT_ARRAY, AYA_PERF_EVENT_IOC_DISABLE,
AYA_PERF_EVENT_IOC_ENABLE, AYA_PERF_EVENT_IOC_SET_BPF,
},
maps::{Map, MapError, MapLock, MapRef, MapRefMut},
obj::{
btf::{Btf, BtfError},
@ -24,10 +28,9 @@ use crate::{
pub(crate) const BPF_OBJ_NAME_LEN: usize = 16;
/* FIXME: these are arch dependent */
pub(crate) const PERF_EVENT_IOC_ENABLE: libc::c_ulong = 9216;
pub(crate) const PERF_EVENT_IOC_DISABLE: libc::c_ulong = 9217;
pub(crate) const PERF_EVENT_IOC_SET_BPF: libc::c_ulong = 1074013192;
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;
pub unsafe trait Pod: Copy + 'static {}

@ -1519,3 +1519,6 @@ pub struct ifinfomsg {
pub ifi_flags: ::std::os::raw::c_uint,
pub ifi_change: ::std::os::raw::c_uint,
}
pub const AYA_PERF_EVENT_IOC_ENABLE: ::std::os::raw::c_int = 9216;
pub const AYA_PERF_EVENT_IOC_DISABLE: ::std::os::raw::c_int = 9217;
pub const AYA_PERF_EVENT_IOC_SET_BPF: ::std::os::raw::c_int = 1074013192;

@ -1518,3 +1518,6 @@ pub struct ifinfomsg {
pub ifi_flags: ::std::os::raw::c_uint,
pub ifi_change: ::std::os::raw::c_uint,
}
pub const AYA_PERF_EVENT_IOC_ENABLE: ::std::os::raw::c_int = 9216;
pub const AYA_PERF_EVENT_IOC_DISABLE: ::std::os::raw::c_int = 9217;
pub const AYA_PERF_EVENT_IOC_SET_BPF: ::std::os::raw::c_int = 1074013192;

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

@ -79,7 +79,7 @@ pub(crate) fn perf_event_open_trace_point(id: u32) -> SysResult {
})
}
pub(crate) fn perf_event_ioctl(fd: c_int, request: c_ulong, arg: c_int) -> SysResult {
pub(crate) fn perf_event_ioctl(fd: c_int, request: c_int, arg: c_int) -> SysResult {
let call = Syscall::PerfEventIoctl { fd, request, arg };
#[cfg(not(test))]
return syscall(call);

@ -98,6 +98,8 @@ fn codegen_bindings(opts: &Options) -> Result<(), anyhow::Error> {
// PERF
"PERF_FLAG_.*",
"PERF_EVENT_.*",
// see linux_wrapper.h, these are to workaround the IOC macros
"AYA_PERF_EVENT_.*",
// NETLINK
"NLMSG_ALIGNTO",
"IFLA_XDP_FD",

Loading…
Cancel
Save