From 8cd669ca9a15600a18e6529b21d656c6f5b20b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alessandro=C2=A0Decina?= Date: Mon, 28 Jun 2021 08:38:08 +0000 Subject: [PATCH] xtask: fix include paths for kernel headers bundled with libbpf --- bpf/aya-bpf-bindings/include/bindings.h | 4 ++++ bpf/aya-bpf/src/maps/queue.rs | 2 -- xtask/src/codegen/aya.rs | 8 ++++++++ xtask/src/codegen/aya_bpf_bindings.rs | 5 +++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/bpf/aya-bpf-bindings/include/bindings.h b/bpf/aya-bpf-bindings/include/bindings.h index 6dbbbc04..b2f3b072 100644 --- a/bpf/aya-bpf-bindings/include/bindings.h +++ b/bpf/aya-bpf-bindings/include/bindings.h @@ -1,4 +1,8 @@ #include +// __wsum is missing from types.h, see +// https://elixir.bootlin.com/linux/v5.13/source/include/uapi/linux/types.h +typedef __u32 __bitwise __wsum; + #include #include #include diff --git a/bpf/aya-bpf/src/maps/queue.rs b/bpf/aya-bpf/src/maps/queue.rs index 9ef32143..b0d86a40 100644 --- a/bpf/aya-bpf/src/maps/queue.rs +++ b/bpf/aya-bpf/src/maps/queue.rs @@ -1,7 +1,5 @@ use core::{marker::PhantomData, mem}; -use aya_bpf_cty::c_void; - use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_QUEUE}, helpers::{bpf_map_pop_elem, bpf_map_push_elem}, diff --git a/xtask/src/codegen/aya.rs b/xtask/src/codegen/aya.rs index a55b70fb..082beb53 100644 --- a/xtask/src/codegen/aya.rs +++ b/xtask/src/codegen/aya.rs @@ -22,6 +22,14 @@ fn codegen_internal_btf_bindings(opts: &Options) -> Result<(), anyhow::Error> { .unwrap() .to_string_lossy() )) + .clang_arg(format!( + "-I{}", + opts.libbpf_dir + .join("include") + .canonicalize() + .unwrap() + .to_string_lossy() + )) .header( opts.libbpf_dir .join("src/libbpf_internal.h") diff --git a/xtask/src/codegen/aya_bpf_bindings.rs b/xtask/src/codegen/aya_bpf_bindings.rs index 81a0b04d..1daf1e23 100644 --- a/xtask/src/codegen/aya_bpf_bindings.rs +++ b/xtask/src/codegen/aya_bpf_bindings.rs @@ -21,6 +21,11 @@ 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()) + .clang_args(&[ + "-I", + &*opts.libbpf_dir.join("include/uapi").to_string_lossy(), + ]) + .clang_args(&["-I", &*opts.libbpf_dir.join("include").to_string_lossy()]) .clang_args(&["-I", &*opts.libbpf_dir.join("src").to_string_lossy()]) // open aya-bpf-bindings/.../bindings.rs and look for mod // _bindgen, those are anonymous enums