diff --git a/aya-gen/src/bindgen.rs b/aya-gen/src/bindgen.rs index d8198da9..98bb80b6 100644 --- a/aya-gen/src/bindgen.rs +++ b/aya-gen/src/bindgen.rs @@ -15,7 +15,7 @@ pub fn bpf_builder() -> Builder { .ctypes_prefix("::aya_bpf_cty") .layout_tests(false) .clang_arg("-Wno-unknown-attributes") - .default_enum_style(EnumVariation::Consts) + .default_enum_style(EnumVariation::ModuleConsts) .prepend_enum_name(false); bindgen diff --git a/bpf/aya-bpf/src/maps/perf_map.rs b/bpf/aya-bpf/src/maps/perf_map.rs index 3801e17a..11979d86 100644 --- a/bpf/aya-bpf/src/maps/perf_map.rs +++ b/bpf/aya-bpf/src/maps/perf_map.rs @@ -1,7 +1,7 @@ use core::{marker::PhantomData, mem}; use crate::{ - bindings::{bpf_map_def, BPF_F_CURRENT_CPU, BPF_MAP_TYPE_PERF_EVENT_ARRAY}, + bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_PERF_EVENT_ARRAY, BPF_F_CURRENT_CPU}, helpers::bpf_perf_event_output, BpfContext, }; diff --git a/xtask/src/codegen/aya_bpf_bindings.rs b/xtask/src/codegen/aya_bpf_bindings.rs index 02eca595..e6306874 100644 --- a/xtask/src/codegen/aya_bpf_bindings.rs +++ b/xtask/src/codegen/aya_bpf_bindings.rs @@ -21,7 +21,21 @@ 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("src").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 + .constified_enum("BPF_F_.*") + .constified_enum("BPF_REG_.*") + .constified_enum("BPF_CSUM_.*") + .constified_enum("BPF_ADJ_.*") + .constified_enum("BPF_SK_.*") + .constified_enum("BPF_RB_.*") + .constified_enum("BPF_RINGBUF_.*") + .constified_enum("BPF_SOCK_.*") + .constified_enum("BPF_TCP_.*") + .constified_enum("BPF_DEVCG_.*") + .constified_enum("BPF_FIB_.*") + .constified_enum("BPF_FLOW_.*"); let types = ["bpf_map_.*"]; let vars = ["BPF_.*", "bpf_.*"];