From e90de090ac481eeeea3e18736517469b7915e36c Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Mon, 6 Mar 2023 17:14:57 +0100 Subject: [PATCH] ebpf, tool: Don't use aya-bpf-cty It's not needed anymore, all C types we need are in `core::ffi`. Signed-off-by: Michal Rostecki --- aya-tool/src/bindgen.rs | 2 +- bpf/aya-bpf/Cargo.toml | 1 - bpf/aya-bpf/src/args.rs | 4 +- bpf/aya-bpf/src/helpers.rs | 56 +++++++++++++++++---------- bpf/aya-bpf/src/lib.rs | 5 +-- bpf/aya-bpf/src/maps/array.rs | 4 +- bpf/aya-bpf/src/maps/bloom_filter.rs | 4 +- bpf/aya-bpf/src/maps/hash_map.rs | 9 ++++- bpf/aya-bpf/src/maps/lpm_trie.rs | 9 ++++- bpf/aya-bpf/src/maps/per_cpu_array.rs | 4 +- bpf/aya-bpf/src/maps/program_array.rs | 7 ++-- bpf/aya-bpf/src/maps/sock_hash.rs | 4 +- bpf/aya-bpf/src/maps/sock_map.rs | 4 +- bpf/aya-bpf/src/programs/fentry.rs | 3 +- bpf/aya-bpf/src/programs/fexit.rs | 3 +- bpf/aya-bpf/src/programs/lsm.rs | 3 +- bpf/aya-bpf/src/programs/probe.rs | 6 ++- bpf/aya-bpf/src/programs/sk_buff.rs | 3 +- bpf/aya-bpf/src/programs/tc.rs | 2 +- bpf/aya-bpf/src/programs/tp_btf.rs | 3 +- xtask/src/codegen/aya_bpf_bindings.rs | 4 +- 21 files changed, 77 insertions(+), 63 deletions(-) diff --git a/aya-tool/src/bindgen.rs b/aya-tool/src/bindgen.rs index eedff6d8..4a3a41c8 100644 --- a/aya-tool/src/bindgen.rs +++ b/aya-tool/src/bindgen.rs @@ -14,7 +14,7 @@ pub fn user_builder() -> Builder { pub fn bpf_builder() -> Builder { bindgen::builder() .use_core() - .ctypes_prefix("::aya_bpf::cty") + .ctypes_prefix("::core::ffi") .layout_tests(false) .generate_comments(false) .clang_arg("-Wno-unknown-attributes") diff --git a/bpf/aya-bpf/Cargo.toml b/bpf/aya-bpf/Cargo.toml index 3e6b390d..f5f2026f 100644 --- a/bpf/aya-bpf/Cargo.toml +++ b/bpf/aya-bpf/Cargo.toml @@ -5,7 +5,6 @@ authors = ["Alessandro Decina "] edition = "2021" [dependencies] -aya-bpf-cty = { path = "../aya-bpf-cty" } aya-bpf-macros = { path = "../../aya-bpf-macros" } aya-bpf-bindings = { path = "../aya-bpf-bindings" } diff --git a/bpf/aya-bpf/src/args.rs b/bpf/aya-bpf/src/args.rs index fea024eb..464f8a17 100644 --- a/bpf/aya-bpf/src/args.rs +++ b/bpf/aya-bpf/src/args.rs @@ -1,4 +1,6 @@ -use crate::{cty::c_void, helpers::bpf_probe_read}; +use core::ffi::c_void; + +use crate::helpers::bpf_probe_read; // aarch64 uses user_pt_regs instead of pt_regs #[cfg(not(bpf_target_arch = "aarch64"))] diff --git a/bpf/aya-bpf/src/helpers.rs b/bpf/aya-bpf/src/helpers.rs index 42a71e52..0cfcd35c 100644 --- a/bpf/aya-bpf/src/helpers.rs +++ b/bpf/aya-bpf/src/helpers.rs @@ -7,14 +7,15 @@ //! also expose bindings to the underlying helpers as a fall-back in case of a missing //! implementation. -use core::mem::{self, MaybeUninit}; +use core::{ + ffi::{c_char, c_long, c_void}, + mem::{self, MaybeUninit}, +}; pub use aya_bpf_bindings::helpers as gen; #[doc(hidden)] pub use gen::*; -use crate::cty::{c_char, c_long, c_void}; - /// Read bytes stored at `src` and store them as a `T`. /// /// Generally speaking, the more specific [`bpf_probe_read_user`] and @@ -27,7 +28,8 @@ use crate::cty::{c_char, c_long, c_void}; /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::{c_int, c_long}, helpers::bpf_probe_read}; +/// # use core::ffi::{c_int, c_long}; +/// # use aya_bpf::helpers::bpf_probe_read; /// # fn try_test() -> Result<(), c_long> { /// # let kernel_ptr: *const c_int = 0 as _; /// let my_int: c_int = unsafe { bpf_probe_read(kernel_ptr)? }; @@ -64,7 +66,8 @@ pub unsafe fn bpf_probe_read(src: *const T) -> Result { /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_buf}; +/// # use core::ffi::{c_int, c_long}; +/// # use aya_bpf::helpers::bpf_probe_read_buf; /// # fn try_test() -> Result<(), c_long> { /// # let ptr: *const u8 = 0 as _; /// let mut buf = [0u8; 16]; @@ -100,7 +103,8 @@ pub unsafe fn bpf_probe_read_buf(src: *const u8, dst: &mut [u8]) -> Result<(), c /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_user}; +/// # use core::ffi::{c_int, c_long}; +/// # use aya_bpf::helpers::bpf_probe_read_user; /// # fn try_test() -> Result<(), c_long> { /// # let user_ptr: *const c_int = 0 as _; /// let my_int: c_int = unsafe { bpf_probe_read_user(user_ptr)? }; @@ -135,7 +139,8 @@ pub unsafe fn bpf_probe_read_user(src: *const T) -> Result { /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_user_buf}; +/// # use core::ffi::{c_int, c_long}; +/// # use aya_bpf::helpers::bpf_probe_read_user_buf; /// # fn try_test() -> Result<(), c_long> { /// # let user_ptr: *const u8 = 0 as _; /// let mut buf = [0u8; 16]; @@ -171,7 +176,8 @@ pub unsafe fn bpf_probe_read_user_buf(src: *const u8, dst: &mut [u8]) -> Result< /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_kernel}; +/// # use core::ffi::{c_int, c_long}; +/// # use aya_bpf::helpers::bpf_probe_read_kernel; /// # fn try_test() -> Result<(), c_long> { /// # let kernel_ptr: *const c_int = 0 as _; /// let my_int: c_int = unsafe { bpf_probe_read_kernel(kernel_ptr)? }; @@ -206,7 +212,8 @@ pub unsafe fn bpf_probe_read_kernel(src: *const T) -> Result { /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_kernel_buf}; +/// # use core::ffi::{c_int, c_long}; +/// # use aya_bpf::helpers::bpf_probe_read_kernel_buf; /// # fn try_test() -> Result<(), c_long> { /// # let kernel_ptr: *const u8 = 0 as _; /// let mut buf = [0u8; 16]; @@ -245,7 +252,8 @@ pub unsafe fn bpf_probe_read_kernel_buf(src: *const u8, dst: &mut [u8]) -> Resul /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::c_long, helpers::bpf_probe_read_str}; +/// # use core::ffi::c_long; +/// # use aya_bpf::helpers::bpf_probe_read_str; /// # fn try_test() -> Result<(), c_long> { /// # let kernel_ptr: *const u8 = 0 as _; /// let mut my_str = [0u8; 16]; @@ -291,7 +299,8 @@ pub unsafe fn bpf_probe_read_str(src: *const u8, dest: &mut [u8]) -> Result Result<(), c_long> { /// # let user_ptr: *const u8 = 0 as _; /// let mut my_str = [0u8; 16]; @@ -340,7 +349,8 @@ pub unsafe fn bpf_probe_read_user_str(src: *const u8, dest: &mut [u8]) -> Result /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::c_long, helpers::bpf_probe_read_user_str_bytes}; +/// # use core::ffi::c_long; +/// # use aya_bpf::helpers::bpf_probe_read_user_str_bytes; /// # fn try_test() -> Result<(), c_long> { /// # let user_ptr: *const u8 = 0 as _; /// let mut buf = [0u8; 16]; @@ -354,7 +364,8 @@ pub unsafe fn bpf_probe_read_user_str(src: *const u8, dest: &mut [u8]) -> Result /// With a `PerCpuArray` (with size defined by us): /// /// ```no_run -/// # use aya_bpf::{cty::c_long, helpers::bpf_probe_read_user_str_bytes}; +/// # use core::ffi::c_long; +/// # use aya_bpf::helpers::bpf_probe_read_user_str_bytes; /// use aya_bpf::{macros::map, maps::PerCpuArray}; /// /// #[repr(C)] @@ -383,8 +394,8 @@ pub unsafe fn bpf_probe_read_user_str(src: *const u8, dest: &mut [u8]) -> Result /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::c_long, helpers::bpf_probe_read_user_str_bytes}; -/// # use aya_bpf::{macros::map, maps::PerCpuArray}; +/// # use core::ffi::c_long; +/// # use aya_bpf::{helpers::bpf_probe_read_user_str_bytes, macros::map, maps::PerCpuArray}; /// # #[repr(C)] /// # pub struct Buf { /// # pub buf: [u8; 4096], @@ -442,7 +453,8 @@ pub unsafe fn bpf_probe_read_user_str_bytes( /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::c_long, helpers::bpf_probe_read_kernel_str}; +/// # use core::ffi::c_long; +/// # use aya_bpf::helpers::bpf_probe_read_kernel_str; /// # fn try_test() -> Result<(), c_long> { /// # let kernel_ptr: *const u8 = 0 as _; /// let mut my_str = [0u8; 16]; @@ -491,7 +503,8 @@ pub unsafe fn bpf_probe_read_kernel_str(src: *const u8, dest: &mut [u8]) -> Resu /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::c_long, helpers::bpf_probe_read_kernel_str_bytes}; +/// # use core::ffi::c_long; +/// # use aya_bpf::helpers::bpf_probe_read_kernel_str_bytes; /// # fn try_test() -> Result<(), c_long> { /// # let kernel_ptr: *const u8 = 0 as _; /// let mut buf = [0u8; 16]; @@ -506,7 +519,8 @@ pub unsafe fn bpf_probe_read_kernel_str(src: *const u8, dest: &mut [u8]) -> Resu /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::c_long, helpers::bpf_probe_read_kernel_str_bytes}; +/// # use core::ffi::c_long; +/// # use aya_bpf::helpers::bpf_probe_read_kernel_str_bytes; /// use aya_bpf::{macros::map, maps::PerCpuArray}; /// /// #[repr(C)] @@ -535,8 +549,8 @@ pub unsafe fn bpf_probe_read_kernel_str(src: *const u8, dest: &mut [u8]) -> Resu /// /// ```no_run /// # #![allow(dead_code)] -/// # use aya_bpf::{cty::c_long, helpers::bpf_probe_read_kernel_str_bytes}; -/// # use aya_bpf::{macros::map, maps::PerCpuArray}; +/// # use core::ffi::c_long; +/// # use aya_bpf::{helpers::bpf_probe_read_kernel_str_bytes, macros::map, maps::PerCpuArray}; /// # #[repr(C)] /// # pub struct Buf { /// # pub buf: [u8; 4096], @@ -591,8 +605,8 @@ pub unsafe fn bpf_probe_read_kernel_str_bytes( /// /// ```no_run /// # #![allow(dead_code)] +/// # use core::ffi::{c_int, c_long} /// # use aya_bpf::{ -/// # cty::{c_int, c_long}, /// # helpers::bpf_probe_write_user, /// # programs::ProbeContext, /// # }; diff --git a/bpf/aya-bpf/src/lib.rs b/bpf/aya-bpf/src/lib.rs index 57e0e372..73cc4b1a 100644 --- a/bpf/aya-bpf/src/lib.rs +++ b/bpf/aya-bpf/src/lib.rs @@ -21,10 +21,7 @@ pub mod helpers; pub mod maps; pub mod programs; -pub use aya_bpf_cty as cty; - -use core::ffi::c_void; -use cty::{c_int, c_long}; +use core::ffi::{c_int, c_long, c_void}; use helpers::{bpf_get_current_comm, bpf_get_current_pid_tgid, bpf_get_current_uid_gid}; pub use aya_bpf_macros as macros; diff --git a/bpf/aya-bpf/src/maps/array.rs b/bpf/aya-bpf/src/maps/array.rs index 2150dd6e..2a97d2c1 100644 --- a/bpf/aya-bpf/src/maps/array.rs +++ b/bpf/aya-bpf/src/maps/array.rs @@ -1,6 +1,4 @@ -use core::{cell::UnsafeCell, marker::PhantomData, mem, ptr::NonNull}; - -use aya_bpf_cty::c_void; +use core::{cell::UnsafeCell, ffi::c_void, marker::PhantomData, mem, ptr::NonNull}; use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_ARRAY}, diff --git a/bpf/aya-bpf/src/maps/bloom_filter.rs b/bpf/aya-bpf/src/maps/bloom_filter.rs index d15d264f..9b3b00a0 100644 --- a/bpf/aya-bpf/src/maps/bloom_filter.rs +++ b/bpf/aya-bpf/src/maps/bloom_filter.rs @@ -1,6 +1,4 @@ -use core::{marker::PhantomData, mem}; - -use aya_bpf_cty::c_void; +use core::{ffi::c_void, marker::PhantomData, mem}; use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_BLOOM_FILTER}, diff --git a/bpf/aya-bpf/src/maps/hash_map.rs b/bpf/aya-bpf/src/maps/hash_map.rs index 5877be90..28c60601 100644 --- a/bpf/aya-bpf/src/maps/hash_map.rs +++ b/bpf/aya-bpf/src/maps/hash_map.rs @@ -1,9 +1,14 @@ -use core::{cell::UnsafeCell, marker::PhantomData, mem, ptr::NonNull}; +use core::{ + cell::UnsafeCell, + ffi::{c_long, c_void}, + marker::PhantomData, + mem, + ptr::NonNull, +}; use aya_bpf_bindings::bindings::bpf_map_type::{ BPF_MAP_TYPE_LRU_HASH, BPF_MAP_TYPE_LRU_PERCPU_HASH, BPF_MAP_TYPE_PERCPU_HASH, }; -use aya_bpf_cty::{c_long, c_void}; use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_HASH}, diff --git a/bpf/aya-bpf/src/maps/lpm_trie.rs b/bpf/aya-bpf/src/maps/lpm_trie.rs index d9314899..55ea8661 100644 --- a/bpf/aya-bpf/src/maps/lpm_trie.rs +++ b/bpf/aya-bpf/src/maps/lpm_trie.rs @@ -1,7 +1,12 @@ -use core::{cell::UnsafeCell, marker::PhantomData, mem, ptr::NonNull}; +use core::{ + cell::UnsafeCell, + ffi::{c_long, c_void}, + marker::PhantomData, + mem, + ptr::NonNull, +}; use aya_bpf_bindings::bindings::BPF_F_NO_PREALLOC; -use aya_bpf_cty::{c_long, c_void}; use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_LPM_TRIE}, diff --git a/bpf/aya-bpf/src/maps/per_cpu_array.rs b/bpf/aya-bpf/src/maps/per_cpu_array.rs index 9a5e388f..4d4b58e4 100644 --- a/bpf/aya-bpf/src/maps/per_cpu_array.rs +++ b/bpf/aya-bpf/src/maps/per_cpu_array.rs @@ -1,6 +1,4 @@ -use core::{cell::UnsafeCell, marker::PhantomData, mem, ptr::NonNull}; - -use aya_bpf_cty::c_void; +use core::{cell::UnsafeCell, ffi::c_void, marker::PhantomData, mem, ptr::NonNull}; use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_PERCPU_ARRAY}, diff --git a/bpf/aya-bpf/src/maps/program_array.rs b/bpf/aya-bpf/src/maps/program_array.rs index b7e54a6c..84ea7b49 100644 --- a/bpf/aya-bpf/src/maps/program_array.rs +++ b/bpf/aya-bpf/src/maps/program_array.rs @@ -1,6 +1,4 @@ -use core::{cell::UnsafeCell, hint::unreachable_unchecked, mem}; - -use aya_bpf_cty::c_long; +use core::{cell::UnsafeCell, ffi::c_long, hint::unreachable_unchecked, mem}; use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_PROG_ARRAY}, @@ -15,7 +13,8 @@ use crate::{ /// /// ```no_run /// # #![allow(dead_code)] -/// use aya_bpf::{macros::map, maps::ProgramArray, cty::c_long}; +/// # use core::ffi::c_long; +/// use aya_bpf::{macros::map, maps::ProgramArray}; /// # use aya_bpf::{programs::LsmContext}; /// /// #[map] diff --git a/bpf/aya-bpf/src/maps/sock_hash.rs b/bpf/aya-bpf/src/maps/sock_hash.rs index 39eedcce..ad0f9e6a 100644 --- a/bpf/aya-bpf/src/maps/sock_hash.rs +++ b/bpf/aya-bpf/src/maps/sock_hash.rs @@ -1,6 +1,4 @@ -use core::{borrow::Borrow, cell::UnsafeCell, marker::PhantomData, mem}; - -use aya_bpf_cty::c_void; +use core::{borrow::Borrow, cell::UnsafeCell, ffi::c_void, marker::PhantomData, mem}; use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_SOCKHASH, bpf_sock_ops}, diff --git a/bpf/aya-bpf/src/maps/sock_map.rs b/bpf/aya-bpf/src/maps/sock_map.rs index 80c6fe7e..884efa89 100644 --- a/bpf/aya-bpf/src/maps/sock_map.rs +++ b/bpf/aya-bpf/src/maps/sock_map.rs @@ -1,6 +1,4 @@ -use core::{cell::UnsafeCell, mem}; - -use aya_bpf_cty::c_void; +use core::{cell::UnsafeCell, ffi::c_void, mem}; use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_SOCKMAP, bpf_sock_ops}, diff --git a/bpf/aya-bpf/src/programs/fentry.rs b/bpf/aya-bpf/src/programs/fentry.rs index 56687539..e26a8b11 100644 --- a/bpf/aya-bpf/src/programs/fentry.rs +++ b/bpf/aya-bpf/src/programs/fentry.rs @@ -18,7 +18,8 @@ impl FEntryContext { /// ```no_run /// # #![allow(non_camel_case_types)] /// # #![allow(dead_code)] - /// # use aya_bpf::{cty::c_int, programs::FEntryContext}; + /// # use core::ffi::c_int; + /// # use aya_bpf::programs::FEntryContext; /// # type pid_t = c_int; /// # struct task_struct { /// # pid: pid_t, diff --git a/bpf/aya-bpf/src/programs/fexit.rs b/bpf/aya-bpf/src/programs/fexit.rs index 1e52d733..fbe77076 100644 --- a/bpf/aya-bpf/src/programs/fexit.rs +++ b/bpf/aya-bpf/src/programs/fexit.rs @@ -18,7 +18,8 @@ impl FExitContext { /// ```no_run /// # #![allow(non_camel_case_types)] /// # #![allow(dead_code)] - /// # use aya_bpf::{cty::c_int, programs::FExitContext}; + /// # use core::ffi::c_int; + /// # use aya_bpf::programs::FExitContext; /// # type pid_t = c_int; /// # struct task_struct { /// # pid: pid_t, diff --git a/bpf/aya-bpf/src/programs/lsm.rs b/bpf/aya-bpf/src/programs/lsm.rs index 4cb76cf4..776dbda1 100644 --- a/bpf/aya-bpf/src/programs/lsm.rs +++ b/bpf/aya-bpf/src/programs/lsm.rs @@ -30,7 +30,8 @@ impl LsmContext { /// /// ```no_run /// # #![allow(dead_code)] - /// # use aya_bpf::{programs::LsmContext, cty::{c_int, c_ulong}}; + /// # use core::ffi::{c_int, c_ulong}; + /// # use aya_bpf::{programs::LsmContext}; /// unsafe fn try_lsm_mmap_addr(ctx: LsmContext) -> Result { /// // In the kernel, this hook is defined as: /// // LSM_HOOK(int, 0, mmap_addr, unsigned long addr) diff --git a/bpf/aya-bpf/src/programs/probe.rs b/bpf/aya-bpf/src/programs/probe.rs index 77d9334b..a4b7e0b1 100644 --- a/bpf/aya-bpf/src/programs/probe.rs +++ b/bpf/aya-bpf/src/programs/probe.rs @@ -26,7 +26,8 @@ impl ProbeContext { /// ```no_run /// # #![allow(non_camel_case_types)] /// # #![allow(dead_code)] - /// # use aya_bpf::{programs::ProbeContext, cty::c_int, helpers::bpf_probe_read}; + /// # use core::ffi::c_int; + /// # use aya_bpf::{programs::ProbeContext, helpers::bpf_probe_read}; /// # type pid_t = c_int; /// # struct task_struct { /// # pid: pid_t, @@ -50,7 +51,8 @@ impl ProbeContext { /// /// ```no_run /// # #![allow(dead_code)] - /// # use aya_bpf::{programs::ProbeContext, cty::c_int}; + /// # use core::ffi::c_int; + /// # use aya_bpf::{programs::ProbeContext}; /// unsafe fn try_kretprobe_try_to_wake_up(ctx: ProbeContext) -> Result { /// let retval: c_int = ctx.ret().ok_or(1u32)?; /// diff --git a/bpf/aya-bpf/src/programs/sk_buff.rs b/bpf/aya-bpf/src/programs/sk_buff.rs index 669c2c95..df825b68 100644 --- a/bpf/aya-bpf/src/programs/sk_buff.rs +++ b/bpf/aya-bpf/src/programs/sk_buff.rs @@ -1,6 +1,6 @@ use core::{ cmp, - ffi::c_void, + ffi::{c_long, c_void}, mem::{self, MaybeUninit}, }; @@ -9,7 +9,6 @@ use aya_bpf_bindings::helpers::{ bpf_skb_adjust_room, bpf_skb_change_type, bpf_skb_load_bytes, bpf_skb_pull_data, bpf_skb_store_bytes, }; -use aya_bpf_cty::c_long; use crate::{bindings::__sk_buff, BpfContext}; diff --git a/bpf/aya-bpf/src/programs/tc.rs b/bpf/aya-bpf/src/programs/tc.rs index 1d3133d5..42e7bded 100644 --- a/bpf/aya-bpf/src/programs/tc.rs +++ b/bpf/aya-bpf/src/programs/tc.rs @@ -1,4 +1,4 @@ -use aya_bpf_cty::{c_long, c_void}; +use core::ffi::{c_long, c_void}; use crate::{bindings::__sk_buff, programs::sk_buff::SkBuff, BpfContext}; diff --git a/bpf/aya-bpf/src/programs/tp_btf.rs b/bpf/aya-bpf/src/programs/tp_btf.rs index f8a1b989..ed289d3f 100644 --- a/bpf/aya-bpf/src/programs/tp_btf.rs +++ b/bpf/aya-bpf/src/programs/tp_btf.rs @@ -24,7 +24,8 @@ impl BtfTracePointContext { /// /// ```no_run /// # #![allow(dead_code)] - /// # use aya_bpf::{programs::BtfTracePointContext, cty::{c_int, c_ulong, c_char}}; + /// # use core::ffi::{c_char, c_int, c_ulong}; + /// # use aya_bpf::programs::BtfTracePointContext; /// unsafe fn try_tp_btf_sched_process_fork(ctx: BtfTracePointContext) -> Result { /// // Grab arguments /// let parent_comm: *const c_char = ctx.arg(0); diff --git a/xtask/src/codegen/aya_bpf_bindings.rs b/xtask/src/codegen/aya_bpf_bindings.rs index bcd7d44c..0f05e24d 100644 --- a/xtask/src/codegen/aya_bpf_bindings.rs +++ b/xtask/src/codegen/aya_bpf_bindings.rs @@ -17,9 +17,7 @@ pub fn codegen(opts: &Options) -> Result<(), anyhow::Error> { let builder = || { let mut bindgen = bindgen::bpf_builder() .header(&*dir.join("include/bindings.h").to_string_lossy()) - // aya-tool uses aya_bpf::cty. We can't use that here since aya-bpf - // depends on aya-bpf-bindings so it would create a circular dep. - .ctypes_prefix("::aya_bpf_cty") + .ctypes_prefix("::core::ffi") .clang_args(&[ "-I", &*opts.libbpf_dir.join("include/uapi").to_string_lossy(),