From 12e422b21134e3f4fb1949b248ecfd2afd768e53 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Sun, 1 Jan 2023 09:00:19 +1100 Subject: [PATCH 01/51] btf: fix regression computing pointer sizes Computing pointer sizes was broken in #285 --- aya/src/obj/btf/types.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/aya/src/obj/btf/types.rs b/aya/src/obj/btf/types.rs index f35c1ef1..8f687bb3 100644 --- a/aya/src/obj/btf/types.rs +++ b/aya/src/obj/btf/types.rs @@ -1054,6 +1054,7 @@ impl BtfType { BtfType::Struct(t) => Some(t.size), BtfType::Union(t) => Some(t.size), BtfType::DataSec(t) => Some(t.size), + BtfType::Ptr(_) => Some(mem::size_of::<&()>() as u32), _ => None, } } From 63bbef46da4794ad2b273b5a3f83792cb718e383 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Sun, 1 Jan 2023 09:37:17 +1100 Subject: [PATCH 02/51] Fix lints --- aya-tool/src/generate.rs | 2 +- xtask/src/docs/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aya-tool/src/generate.rs b/aya-tool/src/generate.rs index 6348957f..d8d724d7 100644 --- a/aya-tool/src/generate.rs +++ b/aya-tool/src/generate.rs @@ -76,7 +76,7 @@ pub fn generate>( let output = Command::new("bindgen") .arg(file_path) - .args(&flags) + .args(flags) .output() .map_err(Error::Bindgen)?; diff --git a/xtask/src/docs/mod.rs b/xtask/src/docs/mod.rs index b6779cba..bfeca3a9 100644 --- a/xtask/src/docs/mod.rs +++ b/xtask/src/docs/mod.rs @@ -72,7 +72,7 @@ fn build_docs(working_dir: &PathBuf, abs_header_path: &Path) -> Result<(), anyho abs_header_path.to_str().unwrap() ), ) - .args(&args) + .args(args) .status() .expect("failed to build aya docs"); assert!(status.success()); From aba99ea4b1f5694e115ae49e9dbe058d3e761fd8 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Sat, 31 Dec 2022 19:26:49 +1100 Subject: [PATCH 03/51] btf: make btf::RelocationError private BpfError::RelocationError type erases the inner error so no need to export the type. --- aya/src/obj/btf/mod.rs | 1 - aya/src/obj/btf/relocation.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/aya/src/obj/btf/mod.rs b/aya/src/obj/btf/mod.rs index d5324094..8b3ed606 100644 --- a/aya/src/obj/btf/mod.rs +++ b/aya/src/obj/btf/mod.rs @@ -6,5 +6,4 @@ mod types; pub use btf::*; pub(crate) use info::*; -pub use relocation::RelocationError; pub(crate) use types::*; diff --git a/aya/src/obj/btf/relocation.rs b/aya/src/obj/btf/relocation.rs index e00778fe..eec03ecf 100644 --- a/aya/src/obj/btf/relocation.rs +++ b/aya/src/obj/btf/relocation.rs @@ -18,7 +18,7 @@ use crate::{ }; #[derive(Error, Debug)] -pub enum RelocationError { +enum RelocationError { #[error(transparent)] IOError(#[from] io::Error), From c6f93b177511d3dfb0ab6cce4fa298d13707dedc Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Sat, 31 Dec 2022 19:30:55 +1100 Subject: [PATCH 04/51] btf relocs: don't panic on failed relocation Error out instead of panicing when we can't find a compatible target candidate for a relocation. --- aya/src/obj/btf/relocation.rs | 68 +++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/aya/src/obj/btf/relocation.rs b/aya/src/obj/btf/relocation.rs index eec03ecf..285c5c03 100644 --- a/aya/src/obj/btf/relocation.rs +++ b/aya/src/obj/btf/relocation.rs @@ -71,6 +71,13 @@ enum RelocationError { index: usize, error: String, }, + + #[error("applying relocation `{kind:?}` missing target BTF info for type `{type_id}` at instruction #{ins_index}")] + MissingTargetDefinition { + kind: RelocationKind, + type_id: u32, + ins_index: usize, + }, } fn err_type_name(name: &Option) -> String { @@ -266,7 +273,7 @@ fn relocate_btf_program<'target>( } else { // there are no candidate matches and therefore no target_spec. This might mean // that matching failed, or that the relocation can be applied looking at local - // types only + // types only (eg with EnumVariantExists, FieldExists etc) ComputedRelocation::new(rel, &local_spec, None)? }; @@ -882,18 +889,23 @@ impl ComputedRelocation { spec: Option<&AccessSpec>, ) -> Result { use RelocationKind::*; - let value = match rel.kind { - EnumVariantExists => spec.is_some() as u32, - EnumVariantValue => { - let spec = spec.unwrap(); + let value = match (rel.kind, spec) { + (EnumVariantExists, spec) => spec.is_some() as u32, + (EnumVariantValue, Some(spec)) => { let accessor = &spec.accessors[0]; match spec.btf.type_by_id(accessor.type_id)? { BtfType::Enum(en) => en.variants[accessor.index].value as u32, - _ => panic!("should not be reached"), + // candidate selection ensures that rel_kind == local_kind == target_kind + _ => unreachable!(), } } - // this function is only called for enum relocations - _ => panic!("should not be reached"), + _ => { + return Err(RelocationError::MissingTargetDefinition { + kind: rel.kind, + type_id: rel.type_id, + ins_index: rel.ins_offset / mem::size_of::(), + })?; + } }; Ok(ComputedRelocationValue { @@ -919,7 +931,17 @@ impl ComputedRelocation { }); } - let spec = spec.unwrap(); + let spec = match spec { + Some(spec) => spec, + None => { + return Err(RelocationError::MissingTargetDefinition { + kind: rel.kind, + type_id: rel.type_id, + ins_index: rel.ins_offset / mem::size_of::(), + })?; + } + }; + let accessor = spec.accessors.last().unwrap(); if accessor.name.is_none() { // the last accessor is unnamed, meaning that this is an array access @@ -1035,19 +1057,21 @@ impl ComputedRelocation { target_spec: Option<&AccessSpec>, ) -> Result { use RelocationKind::*; - let value = match rel.kind { - TypeIdLocal => local_spec.root_type_id, - _ => match target_spec { - Some(target_spec) => match rel.kind { - TypeIdTarget => target_spec.root_type_id, - TypeExists => 1, - TypeSize => target_spec.btf.type_size(target_spec.root_type_id)? as u32, - _ => panic!("bug! this should not be reached"), - }, - // FIXME in the case of TypeIdTarget and TypeSize this should probably fail the - // relocation... - None => 0, - }, + + let value = match (rel.kind, target_spec) { + (TypeIdLocal, _) => local_spec.root_type_id, + (TypeIdTarget, Some(target_spec)) => target_spec.root_type_id, + (TypeExists, target_spec) => target_spec.is_some() as u32, + (TypeSize, Some(target_spec)) => { + target_spec.btf.type_size(target_spec.root_type_id)? as u32 + } + _ => { + return Err(RelocationError::MissingTargetDefinition { + kind: rel.kind, + type_id: rel.type_id, + ins_index: rel.ins_offset / mem::size_of::(), + })?; + } }; Ok(ComputedRelocationValue { From 81bc307dce452f0aacbfbe8c304089d11ddd8c5e Mon Sep 17 00:00:00 2001 From: Shenghui Ye Date: Tue, 27 Dec 2022 17:00:20 +0800 Subject: [PATCH 05/51] aya-obj: migrate bindgen destination Aya::obj depends on bindgen generated files, and we start by migrating bindgen generated files. This commit adds the new aya-obj crate to the workplace and migrates generated files into the crate. We use core instead of std in an effort to make the final crate no_std. Bindgen was run against libbpf v1.0.1. Refs: #473 --- Cargo.toml | 4 +- aya-obj/Cargo.toml | 13 + aya-obj/README.md | 1 + {aya => aya-obj}/include/linux_wrapper.h | 0 .../src/generated/btf_internal_bindings.rs | 10 +- .../src/generated/linux_bindings_aarch64.rs | 453 +++++++++--------- .../src/generated/linux_bindings_armv7.rs | 453 +++++++++--------- .../src/generated/linux_bindings_riscv64.rs | 453 +++++++++--------- .../src/generated/linux_bindings_x86_64.rs | 453 +++++++++--------- aya-obj/src/generated/mod.rs | 86 ++++ aya-obj/src/lib.rs | 12 + aya-tool/src/bindgen.rs | 1 + aya/Cargo.toml | 1 + aya/src/bpf.rs | 5 +- aya/src/generated/mod.rs | 31 -- aya/src/lib.rs | 2 +- aya/src/maps/mod.rs | 45 -- xtask/src/codegen/aya.rs | 4 +- 18 files changed, 1036 insertions(+), 991 deletions(-) create mode 100644 aya-obj/Cargo.toml create mode 100644 aya-obj/README.md rename {aya => aya-obj}/include/linux_wrapper.h (100%) rename {aya => aya-obj}/src/generated/btf_internal_bindings.rs (84%) rename {aya => aya-obj}/src/generated/linux_bindings_aarch64.rs (79%) rename {aya => aya-obj}/src/generated/linux_bindings_armv7.rs (79%) rename {aya => aya-obj}/src/generated/linux_bindings_riscv64.rs (79%) rename {aya => aya-obj}/src/generated/linux_bindings_x86_64.rs (79%) create mode 100644 aya-obj/src/generated/mod.rs create mode 100644 aya-obj/src/lib.rs delete mode 100644 aya/src/generated/mod.rs diff --git a/Cargo.toml b/Cargo.toml index cbef1450..9ccb29de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [workspace] members = [ - "aya", "aya-tool", "aya-log", "aya-log-common", "aya-log-parser", "test/integration-test", "test/integration-test-macros", "xtask", + "aya", "aya-obj", "aya-tool", "aya-log", "aya-log-common", "aya-log-parser", "test/integration-test", "test/integration-test-macros", "xtask", # macros "aya-bpf-macros", "aya-log-ebpf-macros", # ebpf crates "bpf/aya-bpf", "bpf/aya-bpf-bindings", "bpf/aya-log-ebpf", "test/integration-ebpf" ] -default-members = ["aya", "aya-tool", "aya-log", "aya-bpf-macros", "aya-log-ebpf-macros"] +default-members = ["aya", "aya-obj", "aya-tool", "aya-log", "aya-bpf-macros", "aya-log-ebpf-macros"] [profile.dev] panic = "abort" diff --git a/aya-obj/Cargo.toml b/aya-obj/Cargo.toml new file mode 100644 index 00000000..79dc47c6 --- /dev/null +++ b/aya-obj/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "aya-obj" +version = "0.11.0" +description = "A library for loading and relocating eBPF object files" +keywords = ["ebpf", "bpf", "linux", "kernel"] +license = "MIT OR Apache-2.0" +authors = ["The Aya Contributors"] +repository = "https://github.com/aya-rs/aya" +readme = "README.md" +documentation = "https://docs.rs/aya-obj" +edition = "2021" + +[dependencies] diff --git a/aya-obj/README.md b/aya-obj/README.md new file mode 100644 index 00000000..40a4c5a9 --- /dev/null +++ b/aya-obj/README.md @@ -0,0 +1 @@ +# aya-obj diff --git a/aya/include/linux_wrapper.h b/aya-obj/include/linux_wrapper.h similarity index 100% rename from aya/include/linux_wrapper.h rename to aya-obj/include/linux_wrapper.h diff --git a/aya/src/generated/btf_internal_bindings.rs b/aya-obj/src/generated/btf_internal_bindings.rs similarity index 84% rename from aya/src/generated/btf_internal_bindings.rs rename to aya-obj/src/generated/btf_internal_bindings.rs index 6e7a7b3e..4613224a 100644 --- a/aya/src/generated/btf_internal_bindings.rs +++ b/aya-obj/src/generated/btf_internal_bindings.rs @@ -1,10 +1,10 @@ -/* automatically generated by rust-bindgen 0.60.1 */ +/* automatically generated by rust-bindgen 0.63.0 */ -pub type __u8 = ::std::os::raw::c_uchar; -pub type __u16 = ::std::os::raw::c_ushort; -pub type __u32 = ::std::os::raw::c_uint; +pub type __u8 = ::core::ffi::c_uchar; +pub type __u16 = ::core::ffi::c_ushort; +pub type __u32 = ::core::ffi::c_uint; pub mod bpf_core_relo_kind { - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; pub const BPF_CORE_FIELD_BYTE_OFFSET: Type = 0; pub const BPF_CORE_FIELD_BYTE_SIZE: Type = 1; pub const BPF_CORE_FIELD_EXISTS: Type = 2; diff --git a/aya/src/generated/linux_bindings_aarch64.rs b/aya-obj/src/generated/linux_bindings_aarch64.rs similarity index 79% rename from aya/src/generated/linux_bindings_aarch64.rs rename to aya-obj/src/generated/linux_bindings_aarch64.rs index 60c5fab6..fab6978c 100644 --- a/aya/src/generated/linux_bindings_aarch64.rs +++ b/aya-obj/src/generated/linux_bindings_aarch64.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.60.1 */ +/* automatically generated by rust-bindgen 0.63.0 */ #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -82,11 +82,11 @@ where } #[repr(C)] #[derive(Default)] -pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); +pub struct __IncompleteArrayField(::core::marker::PhantomData, [T; 0]); impl __IncompleteArrayField { #[inline] pub const fn new() -> Self { - __IncompleteArrayField(::std::marker::PhantomData, []) + __IncompleteArrayField(::core::marker::PhantomData, []) } #[inline] pub fn as_ptr(&self) -> *const T { @@ -98,15 +98,15 @@ impl __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - ::std::slice::from_raw_parts(self.as_ptr(), len) + ::core::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + ::core::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } -impl ::std::fmt::Debug for __IncompleteArrayField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { +impl ::core::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.write_str("__IncompleteArrayField") } } @@ -173,13 +173,13 @@ pub const TC_H_MIN_PRIORITY: u32 = 65504; pub const TC_H_MIN_INGRESS: u32 = 65522; pub const TC_H_MIN_EGRESS: u32 = 65523; pub const TCA_BPF_FLAG_ACT_DIRECT: u32 = 1; -pub type __u8 = ::std::os::raw::c_uchar; -pub type __s16 = ::std::os::raw::c_short; -pub type __u16 = ::std::os::raw::c_ushort; -pub type __s32 = ::std::os::raw::c_int; -pub type __u32 = ::std::os::raw::c_uint; -pub type __s64 = ::std::os::raw::c_longlong; -pub type __u64 = ::std::os::raw::c_ulonglong; +pub type __u8 = ::core::ffi::c_uchar; +pub type __s16 = ::core::ffi::c_short; +pub type __u16 = ::core::ffi::c_ushort; +pub type __s32 = ::core::ffi::c_int; +pub type __u32 = ::core::ffi::c_uint; +pub type __s64 = ::core::ffi::c_longlong; +pub type __u64 = ::core::ffi::c_ulonglong; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_insn { @@ -192,23 +192,23 @@ pub struct bpf_insn { impl bpf_insn { #[inline] pub fn dst_reg(&self) -> __u8 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } } #[inline] pub fn set_dst_reg(&mut self, val: __u8) { unsafe { - let val: u8 = ::std::mem::transmute(val); + let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 4u8, val as u64) } } #[inline] pub fn src_reg(&self) -> __u8 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u8) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u8) } } #[inline] pub fn set_src_reg(&mut self, val: __u8) { unsafe { - let val: u8 = ::std::mem::transmute(val); + let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 4u8, val as u64) } } @@ -216,11 +216,11 @@ impl bpf_insn { pub fn new_bitfield_1(dst_reg: __u8, src_reg: __u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 4u8, { - let dst_reg: u8 = unsafe { ::std::mem::transmute(dst_reg) }; + let dst_reg: u8 = unsafe { ::core::mem::transmute(dst_reg) }; dst_reg as u64 }); __bindgen_bitfield_unit.set(4usize, 4u8, { - let src_reg: u8 = unsafe { ::std::mem::transmute(src_reg) }; + let src_reg: u8 = unsafe { ::core::mem::transmute(src_reg) }; src_reg as u64 }); __bindgen_bitfield_unit @@ -414,7 +414,7 @@ pub const BPF_ANY: _bindgen_ty_2 = 0; pub const BPF_NOEXIST: _bindgen_ty_2 = 1; pub const BPF_EXIST: _bindgen_ty_2 = 2; pub const BPF_F_LOCK: _bindgen_ty_2 = 4; -pub type _bindgen_ty_2 = ::std::os::raw::c_uint; +pub type _bindgen_ty_2 = ::core::ffi::c_uint; pub const BPF_F_NO_PREALLOC: _bindgen_ty_3 = 1; pub const BPF_F_NO_COMMON_LRU: _bindgen_ty_3 = 2; pub const BPF_F_NUMA_NODE: _bindgen_ty_3 = 4; @@ -428,7 +428,7 @@ pub const BPF_F_CLONE: _bindgen_ty_3 = 512; pub const BPF_F_MMAPABLE: _bindgen_ty_3 = 1024; pub const BPF_F_PRESERVE_ELEMS: _bindgen_ty_3 = 2048; pub const BPF_F_INNER_MAP: _bindgen_ty_3 = 4096; -pub type _bindgen_ty_3 = ::std::os::raw::c_uint; +pub type _bindgen_ty_3 = ::core::ffi::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub union bpf_attr { @@ -462,7 +462,7 @@ pub struct bpf_attr__bindgen_ty_1 { pub map_flags: __u32, pub inner_map_fd: __u32, pub numa_node: __u32, - pub map_name: [::std::os::raw::c_char; 16usize], + pub map_name: [::core::ffi::c_char; 16usize], pub map_ifindex: __u32, pub btf_fd: __u32, pub btf_key_type_id: __u32, @@ -508,7 +508,7 @@ pub struct bpf_attr__bindgen_ty_4 { pub log_buf: __u64, pub kern_version: __u32, pub prog_flags: __u32, - pub prog_name: [::std::os::raw::c_char; 16usize], + pub prog_name: [::core::ffi::c_char; 16usize], pub prog_ifindex: __u32, pub expected_attach_type: __u32, pub prog_btf_fd: __u32, @@ -711,33 +711,33 @@ pub struct bpf_attr__bindgen_ty_19 { } pub const BPF_F_RECOMPUTE_CSUM: _bindgen_ty_4 = 1; pub const BPF_F_INVALIDATE_HASH: _bindgen_ty_4 = 2; -pub type _bindgen_ty_4 = ::std::os::raw::c_uint; +pub type _bindgen_ty_4 = ::core::ffi::c_uint; pub const BPF_F_HDR_FIELD_MASK: _bindgen_ty_5 = 15; -pub type _bindgen_ty_5 = ::std::os::raw::c_uint; +pub type _bindgen_ty_5 = ::core::ffi::c_uint; pub const BPF_F_PSEUDO_HDR: _bindgen_ty_6 = 16; pub const BPF_F_MARK_MANGLED_0: _bindgen_ty_6 = 32; pub const BPF_F_MARK_ENFORCE: _bindgen_ty_6 = 64; -pub type _bindgen_ty_6 = ::std::os::raw::c_uint; +pub type _bindgen_ty_6 = ::core::ffi::c_uint; pub const BPF_F_INGRESS: _bindgen_ty_7 = 1; -pub type _bindgen_ty_7 = ::std::os::raw::c_uint; +pub type _bindgen_ty_7 = ::core::ffi::c_uint; pub const BPF_F_TUNINFO_IPV6: _bindgen_ty_8 = 1; -pub type _bindgen_ty_8 = ::std::os::raw::c_uint; +pub type _bindgen_ty_8 = ::core::ffi::c_uint; pub const BPF_F_SKIP_FIELD_MASK: _bindgen_ty_9 = 255; pub const BPF_F_USER_STACK: _bindgen_ty_9 = 256; pub const BPF_F_FAST_STACK_CMP: _bindgen_ty_9 = 512; pub const BPF_F_REUSE_STACKID: _bindgen_ty_9 = 1024; pub const BPF_F_USER_BUILD_ID: _bindgen_ty_9 = 2048; -pub type _bindgen_ty_9 = ::std::os::raw::c_uint; +pub type _bindgen_ty_9 = ::core::ffi::c_uint; pub const BPF_F_ZERO_CSUM_TX: _bindgen_ty_10 = 2; pub const BPF_F_DONT_FRAGMENT: _bindgen_ty_10 = 4; pub const BPF_F_SEQ_NUMBER: _bindgen_ty_10 = 8; -pub type _bindgen_ty_10 = ::std::os::raw::c_uint; +pub type _bindgen_ty_10 = ::core::ffi::c_uint; pub const BPF_F_INDEX_MASK: _bindgen_ty_11 = 4294967295; pub const BPF_F_CURRENT_CPU: _bindgen_ty_11 = 4294967295; pub const BPF_F_CTXLEN_MASK: _bindgen_ty_11 = 4503595332403200; -pub type _bindgen_ty_11 = ::std::os::raw::c_ulong; +pub type _bindgen_ty_11 = ::core::ffi::c_ulong; pub const BPF_F_CURRENT_NETNS: _bindgen_ty_12 = -1; -pub type _bindgen_ty_12 = ::std::os::raw::c_int; +pub type _bindgen_ty_12 = ::core::ffi::c_int; pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_14 = 1; pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_14 = 2; pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_14 = 4; @@ -745,20 +745,20 @@ pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_14 = 8; pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_14 = 16; pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_14 = 32; pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_14 = 64; -pub type _bindgen_ty_14 = ::std::os::raw::c_uint; +pub type _bindgen_ty_14 = ::core::ffi::c_uint; pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_16 = 1; -pub type _bindgen_ty_16 = ::std::os::raw::c_uint; +pub type _bindgen_ty_16 = ::core::ffi::c_uint; pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_18 = 1; -pub type _bindgen_ty_18 = ::std::os::raw::c_uint; +pub type _bindgen_ty_18 = ::core::ffi::c_uint; pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_21 = 2147483648; pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_21 = 1073741824; pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_21 = 8; -pub type _bindgen_ty_21 = ::std::os::raw::c_uint; +pub type _bindgen_ty_21 = ::core::ffi::c_uint; pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_23 = 1; -pub type _bindgen_ty_23 = ::std::os::raw::c_uint; +pub type _bindgen_ty_23 = ::core::ffi::c_uint; pub const BPF_F_BROADCAST: _bindgen_ty_24 = 8; pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_24 = 16; -pub type _bindgen_ty_24 = ::std::os::raw::c_uint; +pub type _bindgen_ty_24 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_prog_info { @@ -773,7 +773,7 @@ pub struct bpf_prog_info { pub created_by_uid: __u32, pub nr_map_ids: __u32, pub map_ids: __u64, - pub name: [::std::os::raw::c_char; 16usize], + pub name: [::core::ffi::c_char; 16usize], pub ifindex: __u32, pub _bitfield_align_1: [u8; 0], pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, @@ -805,12 +805,12 @@ pub struct bpf_prog_info { impl bpf_prog_info { #[inline] pub fn gpl_compatible(&self) -> __u32 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } } #[inline] pub fn set_gpl_compatible(&mut self, val: __u32) { unsafe { - let val: u32 = ::std::mem::transmute(val); + let val: u32 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } @@ -818,7 +818,7 @@ impl bpf_prog_info { pub fn new_bitfield_1(gpl_compatible: __u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let gpl_compatible: u32 = unsafe { ::std::mem::transmute(gpl_compatible) }; + let gpl_compatible: u32 = unsafe { ::core::mem::transmute(gpl_compatible) }; gpl_compatible as u64 }); __bindgen_bitfield_unit @@ -833,7 +833,7 @@ pub struct bpf_map_info { pub value_size: __u32, pub max_entries: __u32, pub map_flags: __u32, - pub name: [::std::os::raw::c_char; 16usize], + pub name: [::core::ffi::c_char; 16usize], pub ifindex: __u32, pub btf_vmlinux_value_type_id: __u32, pub netns_dev: __u64, @@ -988,7 +988,7 @@ pub const BTF_KIND_TYPE_TAG: _bindgen_ty_38 = 18; pub const BTF_KIND_ENUM64: _bindgen_ty_38 = 19; pub const NR_BTF_KINDS: _bindgen_ty_38 = 20; pub const BTF_KIND_MAX: _bindgen_ty_38 = 19; -pub type _bindgen_ty_38 = ::std::os::raw::c_uint; +pub type _bindgen_ty_38 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct btf_enum { @@ -1018,7 +1018,7 @@ pub struct btf_param { pub const BTF_VAR_STATIC: _bindgen_ty_39 = 0; pub const BTF_VAR_GLOBAL_ALLOCATED: _bindgen_ty_39 = 1; pub const BTF_VAR_GLOBAL_EXTERN: _bindgen_ty_39 = 2; -pub type _bindgen_ty_39 = ::std::os::raw::c_uint; +pub type _bindgen_ty_39 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum btf_func_linkage { @@ -1202,419 +1202,419 @@ pub union perf_event_attr__bindgen_ty_4 { impl perf_event_attr { #[inline] pub fn disabled(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } } #[inline] pub fn set_disabled(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } #[inline] pub fn inherit(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } } #[inline] pub fn set_inherit(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(1usize, 1u8, val as u64) } } #[inline] pub fn pinned(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } } #[inline] pub fn set_pinned(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(2usize, 1u8, val as u64) } } #[inline] pub fn exclusive(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } } #[inline] pub fn set_exclusive(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(3usize, 1u8, val as u64) } } #[inline] pub fn exclude_user(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } } #[inline] pub fn set_exclude_user(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] pub fn exclude_kernel(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } } #[inline] pub fn set_exclude_kernel(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(5usize, 1u8, val as u64) } } #[inline] pub fn exclude_hv(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u64) } } #[inline] pub fn set_exclude_hv(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(6usize, 1u8, val as u64) } } #[inline] pub fn exclude_idle(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u64) } } #[inline] pub fn set_exclude_idle(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(7usize, 1u8, val as u64) } } #[inline] pub fn mmap(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u64) } } #[inline] pub fn set_mmap(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(8usize, 1u8, val as u64) } } #[inline] pub fn comm(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u64) } } #[inline] pub fn set_comm(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(9usize, 1u8, val as u64) } } #[inline] pub fn freq(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u64) } } #[inline] pub fn set_freq(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(10usize, 1u8, val as u64) } } #[inline] pub fn inherit_stat(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u64) } } #[inline] pub fn set_inherit_stat(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(11usize, 1u8, val as u64) } } #[inline] pub fn enable_on_exec(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u64) } } #[inline] pub fn set_enable_on_exec(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(12usize, 1u8, val as u64) } } #[inline] pub fn task(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u64) } } #[inline] pub fn set_task(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(13usize, 1u8, val as u64) } } #[inline] pub fn watermark(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u64) } } #[inline] pub fn set_watermark(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(14usize, 1u8, val as u64) } } #[inline] pub fn precise_ip(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 2u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(15usize, 2u8) as u64) } } #[inline] pub fn set_precise_ip(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(15usize, 2u8, val as u64) } } #[inline] pub fn mmap_data(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(17usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(17usize, 1u8) as u64) } } #[inline] pub fn set_mmap_data(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(17usize, 1u8, val as u64) } } #[inline] pub fn sample_id_all(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(18usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(18usize, 1u8) as u64) } } #[inline] pub fn set_sample_id_all(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(18usize, 1u8, val as u64) } } #[inline] pub fn exclude_host(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(19usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(19usize, 1u8) as u64) } } #[inline] pub fn set_exclude_host(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(19usize, 1u8, val as u64) } } #[inline] pub fn exclude_guest(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(20usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(20usize, 1u8) as u64) } } #[inline] pub fn set_exclude_guest(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(20usize, 1u8, val as u64) } } #[inline] pub fn exclude_callchain_kernel(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(21usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(21usize, 1u8) as u64) } } #[inline] pub fn set_exclude_callchain_kernel(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(21usize, 1u8, val as u64) } } #[inline] pub fn exclude_callchain_user(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(22usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(22usize, 1u8) as u64) } } #[inline] pub fn set_exclude_callchain_user(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(22usize, 1u8, val as u64) } } #[inline] pub fn mmap2(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(23usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(23usize, 1u8) as u64) } } #[inline] pub fn set_mmap2(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(23usize, 1u8, val as u64) } } #[inline] pub fn comm_exec(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(24usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(24usize, 1u8) as u64) } } #[inline] pub fn set_comm_exec(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(24usize, 1u8, val as u64) } } #[inline] pub fn use_clockid(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(25usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(25usize, 1u8) as u64) } } #[inline] pub fn set_use_clockid(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(25usize, 1u8, val as u64) } } #[inline] pub fn context_switch(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(26usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(26usize, 1u8) as u64) } } #[inline] pub fn set_context_switch(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(26usize, 1u8, val as u64) } } #[inline] pub fn write_backward(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(27usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(27usize, 1u8) as u64) } } #[inline] pub fn set_write_backward(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(27usize, 1u8, val as u64) } } #[inline] pub fn namespaces(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(28usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(28usize, 1u8) as u64) } } #[inline] pub fn set_namespaces(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(28usize, 1u8, val as u64) } } #[inline] pub fn ksymbol(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(29usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(29usize, 1u8) as u64) } } #[inline] pub fn set_ksymbol(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(29usize, 1u8, val as u64) } } #[inline] pub fn bpf_event(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(30usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(30usize, 1u8) as u64) } } #[inline] pub fn set_bpf_event(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(30usize, 1u8, val as u64) } } #[inline] pub fn aux_output(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(31usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(31usize, 1u8) as u64) } } #[inline] pub fn set_aux_output(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(31usize, 1u8, val as u64) } } #[inline] pub fn cgroup(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(32usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(32usize, 1u8) as u64) } } #[inline] pub fn set_cgroup(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(32usize, 1u8, val as u64) } } #[inline] pub fn text_poke(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(33usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(33usize, 1u8) as u64) } } #[inline] pub fn set_text_poke(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(33usize, 1u8, val as u64) } } #[inline] pub fn build_id(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(34usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(34usize, 1u8) as u64) } } #[inline] pub fn set_build_id(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(34usize, 1u8, val as u64) } } #[inline] pub fn inherit_thread(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(35usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(35usize, 1u8) as u64) } } #[inline] pub fn set_inherit_thread(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(35usize, 1u8, val as u64) } } #[inline] pub fn remove_on_exec(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(36usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(36usize, 1u8) as u64) } } #[inline] pub fn set_remove_on_exec(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(36usize, 1u8, val as u64) } } #[inline] pub fn sigtrap(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(37usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(37usize, 1u8) as u64) } } #[inline] pub fn set_sigtrap(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(37usize, 1u8, val as u64) } } #[inline] pub fn __reserved_1(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(38usize, 26u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(38usize, 26u8) as u64) } } #[inline] pub fn set___reserved_1(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(38usize, 26u8, val as u64) } } @@ -1661,157 +1661,157 @@ impl perf_event_attr { ) -> __BindgenBitfieldUnit<[u8; 8usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let disabled: u64 = unsafe { ::std::mem::transmute(disabled) }; + let disabled: u64 = unsafe { ::core::mem::transmute(disabled) }; disabled as u64 }); __bindgen_bitfield_unit.set(1usize, 1u8, { - let inherit: u64 = unsafe { ::std::mem::transmute(inherit) }; + let inherit: u64 = unsafe { ::core::mem::transmute(inherit) }; inherit as u64 }); __bindgen_bitfield_unit.set(2usize, 1u8, { - let pinned: u64 = unsafe { ::std::mem::transmute(pinned) }; + let pinned: u64 = unsafe { ::core::mem::transmute(pinned) }; pinned as u64 }); __bindgen_bitfield_unit.set(3usize, 1u8, { - let exclusive: u64 = unsafe { ::std::mem::transmute(exclusive) }; + let exclusive: u64 = unsafe { ::core::mem::transmute(exclusive) }; exclusive as u64 }); __bindgen_bitfield_unit.set(4usize, 1u8, { - let exclude_user: u64 = unsafe { ::std::mem::transmute(exclude_user) }; + let exclude_user: u64 = unsafe { ::core::mem::transmute(exclude_user) }; exclude_user as u64 }); __bindgen_bitfield_unit.set(5usize, 1u8, { - let exclude_kernel: u64 = unsafe { ::std::mem::transmute(exclude_kernel) }; + let exclude_kernel: u64 = unsafe { ::core::mem::transmute(exclude_kernel) }; exclude_kernel as u64 }); __bindgen_bitfield_unit.set(6usize, 1u8, { - let exclude_hv: u64 = unsafe { ::std::mem::transmute(exclude_hv) }; + let exclude_hv: u64 = unsafe { ::core::mem::transmute(exclude_hv) }; exclude_hv as u64 }); __bindgen_bitfield_unit.set(7usize, 1u8, { - let exclude_idle: u64 = unsafe { ::std::mem::transmute(exclude_idle) }; + let exclude_idle: u64 = unsafe { ::core::mem::transmute(exclude_idle) }; exclude_idle as u64 }); __bindgen_bitfield_unit.set(8usize, 1u8, { - let mmap: u64 = unsafe { ::std::mem::transmute(mmap) }; + let mmap: u64 = unsafe { ::core::mem::transmute(mmap) }; mmap as u64 }); __bindgen_bitfield_unit.set(9usize, 1u8, { - let comm: u64 = unsafe { ::std::mem::transmute(comm) }; + let comm: u64 = unsafe { ::core::mem::transmute(comm) }; comm as u64 }); __bindgen_bitfield_unit.set(10usize, 1u8, { - let freq: u64 = unsafe { ::std::mem::transmute(freq) }; + let freq: u64 = unsafe { ::core::mem::transmute(freq) }; freq as u64 }); __bindgen_bitfield_unit.set(11usize, 1u8, { - let inherit_stat: u64 = unsafe { ::std::mem::transmute(inherit_stat) }; + let inherit_stat: u64 = unsafe { ::core::mem::transmute(inherit_stat) }; inherit_stat as u64 }); __bindgen_bitfield_unit.set(12usize, 1u8, { - let enable_on_exec: u64 = unsafe { ::std::mem::transmute(enable_on_exec) }; + let enable_on_exec: u64 = unsafe { ::core::mem::transmute(enable_on_exec) }; enable_on_exec as u64 }); __bindgen_bitfield_unit.set(13usize, 1u8, { - let task: u64 = unsafe { ::std::mem::transmute(task) }; + let task: u64 = unsafe { ::core::mem::transmute(task) }; task as u64 }); __bindgen_bitfield_unit.set(14usize, 1u8, { - let watermark: u64 = unsafe { ::std::mem::transmute(watermark) }; + let watermark: u64 = unsafe { ::core::mem::transmute(watermark) }; watermark as u64 }); __bindgen_bitfield_unit.set(15usize, 2u8, { - let precise_ip: u64 = unsafe { ::std::mem::transmute(precise_ip) }; + let precise_ip: u64 = unsafe { ::core::mem::transmute(precise_ip) }; precise_ip as u64 }); __bindgen_bitfield_unit.set(17usize, 1u8, { - let mmap_data: u64 = unsafe { ::std::mem::transmute(mmap_data) }; + let mmap_data: u64 = unsafe { ::core::mem::transmute(mmap_data) }; mmap_data as u64 }); __bindgen_bitfield_unit.set(18usize, 1u8, { - let sample_id_all: u64 = unsafe { ::std::mem::transmute(sample_id_all) }; + let sample_id_all: u64 = unsafe { ::core::mem::transmute(sample_id_all) }; sample_id_all as u64 }); __bindgen_bitfield_unit.set(19usize, 1u8, { - let exclude_host: u64 = unsafe { ::std::mem::transmute(exclude_host) }; + let exclude_host: u64 = unsafe { ::core::mem::transmute(exclude_host) }; exclude_host as u64 }); __bindgen_bitfield_unit.set(20usize, 1u8, { - let exclude_guest: u64 = unsafe { ::std::mem::transmute(exclude_guest) }; + let exclude_guest: u64 = unsafe { ::core::mem::transmute(exclude_guest) }; exclude_guest as u64 }); __bindgen_bitfield_unit.set(21usize, 1u8, { let exclude_callchain_kernel: u64 = - unsafe { ::std::mem::transmute(exclude_callchain_kernel) }; + unsafe { ::core::mem::transmute(exclude_callchain_kernel) }; exclude_callchain_kernel as u64 }); __bindgen_bitfield_unit.set(22usize, 1u8, { let exclude_callchain_user: u64 = - unsafe { ::std::mem::transmute(exclude_callchain_user) }; + unsafe { ::core::mem::transmute(exclude_callchain_user) }; exclude_callchain_user as u64 }); __bindgen_bitfield_unit.set(23usize, 1u8, { - let mmap2: u64 = unsafe { ::std::mem::transmute(mmap2) }; + let mmap2: u64 = unsafe { ::core::mem::transmute(mmap2) }; mmap2 as u64 }); __bindgen_bitfield_unit.set(24usize, 1u8, { - let comm_exec: u64 = unsafe { ::std::mem::transmute(comm_exec) }; + let comm_exec: u64 = unsafe { ::core::mem::transmute(comm_exec) }; comm_exec as u64 }); __bindgen_bitfield_unit.set(25usize, 1u8, { - let use_clockid: u64 = unsafe { ::std::mem::transmute(use_clockid) }; + let use_clockid: u64 = unsafe { ::core::mem::transmute(use_clockid) }; use_clockid as u64 }); __bindgen_bitfield_unit.set(26usize, 1u8, { - let context_switch: u64 = unsafe { ::std::mem::transmute(context_switch) }; + let context_switch: u64 = unsafe { ::core::mem::transmute(context_switch) }; context_switch as u64 }); __bindgen_bitfield_unit.set(27usize, 1u8, { - let write_backward: u64 = unsafe { ::std::mem::transmute(write_backward) }; + let write_backward: u64 = unsafe { ::core::mem::transmute(write_backward) }; write_backward as u64 }); __bindgen_bitfield_unit.set(28usize, 1u8, { - let namespaces: u64 = unsafe { ::std::mem::transmute(namespaces) }; + let namespaces: u64 = unsafe { ::core::mem::transmute(namespaces) }; namespaces as u64 }); __bindgen_bitfield_unit.set(29usize, 1u8, { - let ksymbol: u64 = unsafe { ::std::mem::transmute(ksymbol) }; + let ksymbol: u64 = unsafe { ::core::mem::transmute(ksymbol) }; ksymbol as u64 }); __bindgen_bitfield_unit.set(30usize, 1u8, { - let bpf_event: u64 = unsafe { ::std::mem::transmute(bpf_event) }; + let bpf_event: u64 = unsafe { ::core::mem::transmute(bpf_event) }; bpf_event as u64 }); __bindgen_bitfield_unit.set(31usize, 1u8, { - let aux_output: u64 = unsafe { ::std::mem::transmute(aux_output) }; + let aux_output: u64 = unsafe { ::core::mem::transmute(aux_output) }; aux_output as u64 }); __bindgen_bitfield_unit.set(32usize, 1u8, { - let cgroup: u64 = unsafe { ::std::mem::transmute(cgroup) }; + let cgroup: u64 = unsafe { ::core::mem::transmute(cgroup) }; cgroup as u64 }); __bindgen_bitfield_unit.set(33usize, 1u8, { - let text_poke: u64 = unsafe { ::std::mem::transmute(text_poke) }; + let text_poke: u64 = unsafe { ::core::mem::transmute(text_poke) }; text_poke as u64 }); __bindgen_bitfield_unit.set(34usize, 1u8, { - let build_id: u64 = unsafe { ::std::mem::transmute(build_id) }; + let build_id: u64 = unsafe { ::core::mem::transmute(build_id) }; build_id as u64 }); __bindgen_bitfield_unit.set(35usize, 1u8, { - let inherit_thread: u64 = unsafe { ::std::mem::transmute(inherit_thread) }; + let inherit_thread: u64 = unsafe { ::core::mem::transmute(inherit_thread) }; inherit_thread as u64 }); __bindgen_bitfield_unit.set(36usize, 1u8, { - let remove_on_exec: u64 = unsafe { ::std::mem::transmute(remove_on_exec) }; + let remove_on_exec: u64 = unsafe { ::core::mem::transmute(remove_on_exec) }; remove_on_exec as u64 }); __bindgen_bitfield_unit.set(37usize, 1u8, { - let sigtrap: u64 = unsafe { ::std::mem::transmute(sigtrap) }; + let sigtrap: u64 = unsafe { ::core::mem::transmute(sigtrap) }; sigtrap as u64 }); __bindgen_bitfield_unit.set(38usize, 26u8, { - let __reserved_1: u64 = unsafe { ::std::mem::transmute(__reserved_1) }; + let __reserved_1: u64 = unsafe { ::core::mem::transmute(__reserved_1) }; __reserved_1 as u64 }); __bindgen_bitfield_unit @@ -1863,78 +1863,78 @@ pub struct perf_event_mmap_page__bindgen_ty_1__bindgen_ty_1 { impl perf_event_mmap_page__bindgen_ty_1__bindgen_ty_1 { #[inline] pub fn cap_bit0(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } } #[inline] pub fn set_cap_bit0(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } #[inline] pub fn cap_bit0_is_deprecated(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } } #[inline] pub fn set_cap_bit0_is_deprecated(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(1usize, 1u8, val as u64) } } #[inline] pub fn cap_user_rdpmc(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_rdpmc(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(2usize, 1u8, val as u64) } } #[inline] pub fn cap_user_time(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_time(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(3usize, 1u8, val as u64) } } #[inline] pub fn cap_user_time_zero(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_time_zero(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] pub fn cap_user_time_short(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_time_short(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(5usize, 1u8, val as u64) } } #[inline] pub fn cap_____res(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 58u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(6usize, 58u8) as u64) } } #[inline] pub fn set_cap_____res(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(6usize, 58u8, val as u64) } } @@ -1950,32 +1950,32 @@ impl perf_event_mmap_page__bindgen_ty_1__bindgen_ty_1 { ) -> __BindgenBitfieldUnit<[u8; 8usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let cap_bit0: u64 = unsafe { ::std::mem::transmute(cap_bit0) }; + let cap_bit0: u64 = unsafe { ::core::mem::transmute(cap_bit0) }; cap_bit0 as u64 }); __bindgen_bitfield_unit.set(1usize, 1u8, { let cap_bit0_is_deprecated: u64 = - unsafe { ::std::mem::transmute(cap_bit0_is_deprecated) }; + unsafe { ::core::mem::transmute(cap_bit0_is_deprecated) }; cap_bit0_is_deprecated as u64 }); __bindgen_bitfield_unit.set(2usize, 1u8, { - let cap_user_rdpmc: u64 = unsafe { ::std::mem::transmute(cap_user_rdpmc) }; + let cap_user_rdpmc: u64 = unsafe { ::core::mem::transmute(cap_user_rdpmc) }; cap_user_rdpmc as u64 }); __bindgen_bitfield_unit.set(3usize, 1u8, { - let cap_user_time: u64 = unsafe { ::std::mem::transmute(cap_user_time) }; + let cap_user_time: u64 = unsafe { ::core::mem::transmute(cap_user_time) }; cap_user_time as u64 }); __bindgen_bitfield_unit.set(4usize, 1u8, { - let cap_user_time_zero: u64 = unsafe { ::std::mem::transmute(cap_user_time_zero) }; + let cap_user_time_zero: u64 = unsafe { ::core::mem::transmute(cap_user_time_zero) }; cap_user_time_zero as u64 }); __bindgen_bitfield_unit.set(5usize, 1u8, { - let cap_user_time_short: u64 = unsafe { ::std::mem::transmute(cap_user_time_short) }; + let cap_user_time_short: u64 = unsafe { ::core::mem::transmute(cap_user_time_short) }; cap_user_time_short as u64 }); __bindgen_bitfield_unit.set(6usize, 58u8, { - let cap_____res: u64 = unsafe { ::std::mem::transmute(cap_____res) }; + let cap_____res: u64 = unsafe { ::core::mem::transmute(cap_____res) }; cap_____res as u64 }); __bindgen_bitfield_unit @@ -2024,59 +2024,60 @@ pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_85 = 6; pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_85 = 7; pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_85 = 8; pub const __IFLA_XDP_MAX: _bindgen_ty_85 = 9; -pub type _bindgen_ty_85 = ::std::os::raw::c_uint; +pub type _bindgen_ty_85 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { - pub ifi_family: ::std::os::raw::c_uchar, - pub __ifi_pad: ::std::os::raw::c_uchar, - pub ifi_type: ::std::os::raw::c_ushort, - pub ifi_index: ::std::os::raw::c_int, - pub ifi_flags: ::std::os::raw::c_uint, - pub ifi_change: ::std::os::raw::c_uint, + pub ifi_family: ::core::ffi::c_uchar, + pub __ifi_pad: ::core::ffi::c_uchar, + pub ifi_type: ::core::ffi::c_ushort, + pub ifi_index: ::core::ffi::c_int, + pub ifi_flags: ::core::ffi::c_uint, + pub ifi_change: ::core::ffi::c_uint, } #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct tcmsg { - pub tcm_family: ::std::os::raw::c_uchar, - pub tcm__pad1: ::std::os::raw::c_uchar, - pub tcm__pad2: ::std::os::raw::c_ushort, - pub tcm_ifindex: ::std::os::raw::c_int, + pub tcm_family: ::core::ffi::c_uchar, + pub tcm__pad1: ::core::ffi::c_uchar, + pub tcm__pad2: ::core::ffi::c_ushort, + pub tcm_ifindex: ::core::ffi::c_int, pub tcm_handle: __u32, pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_98 = 0; -pub const TCA_KIND: _bindgen_ty_98 = 1; -pub const TCA_OPTIONS: _bindgen_ty_98 = 2; -pub const TCA_STATS: _bindgen_ty_98 = 3; -pub const TCA_XSTATS: _bindgen_ty_98 = 4; -pub const TCA_RATE: _bindgen_ty_98 = 5; -pub const TCA_FCNT: _bindgen_ty_98 = 6; -pub const TCA_STATS2: _bindgen_ty_98 = 7; -pub const TCA_STAB: _bindgen_ty_98 = 8; -pub const TCA_PAD: _bindgen_ty_98 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_98 = 10; -pub const TCA_CHAIN: _bindgen_ty_98 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_98 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_98 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_98 = 14; -pub const __TCA_MAX: _bindgen_ty_98 = 15; -pub type _bindgen_ty_98 = ::std::os::raw::c_uint; -pub const TCA_BPF_UNSPEC: _bindgen_ty_154 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_154 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_154 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_154 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_154 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_154 = 5; -pub const TCA_BPF_FD: _bindgen_ty_154 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_154 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_154 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_154 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_154 = 10; -pub const TCA_BPF_ID: _bindgen_ty_154 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_154 = 12; -pub type _bindgen_ty_154 = ::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; +pub const TCA_UNSPEC: _bindgen_ty_100 = 0; +pub const TCA_KIND: _bindgen_ty_100 = 1; +pub const TCA_OPTIONS: _bindgen_ty_100 = 2; +pub const TCA_STATS: _bindgen_ty_100 = 3; +pub const TCA_XSTATS: _bindgen_ty_100 = 4; +pub const TCA_RATE: _bindgen_ty_100 = 5; +pub const TCA_FCNT: _bindgen_ty_100 = 6; +pub const TCA_STATS2: _bindgen_ty_100 = 7; +pub const TCA_STAB: _bindgen_ty_100 = 8; +pub const TCA_PAD: _bindgen_ty_100 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_100 = 10; +pub const TCA_CHAIN: _bindgen_ty_100 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_100 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_100 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_100 = 14; +pub const TCA_DUMP_FLAGS: _bindgen_ty_100 = 15; +pub const __TCA_MAX: _bindgen_ty_100 = 16; +pub type _bindgen_ty_100 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; +pub const TCA_BPF_FD: _bindgen_ty_156 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; +pub const TCA_BPF_ID: _bindgen_ty_156 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; +pub type _bindgen_ty_156 = ::core::ffi::c_uint; +pub const AYA_PERF_EVENT_IOC_ENABLE: ::core::ffi::c_int = 9216; +pub const AYA_PERF_EVENT_IOC_DISABLE: ::core::ffi::c_int = 9217; +pub const AYA_PERF_EVENT_IOC_SET_BPF: ::core::ffi::c_int = 1074013192; diff --git a/aya/src/generated/linux_bindings_armv7.rs b/aya-obj/src/generated/linux_bindings_armv7.rs similarity index 79% rename from aya/src/generated/linux_bindings_armv7.rs rename to aya-obj/src/generated/linux_bindings_armv7.rs index 36750363..21355694 100644 --- a/aya/src/generated/linux_bindings_armv7.rs +++ b/aya-obj/src/generated/linux_bindings_armv7.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.60.1 */ +/* automatically generated by rust-bindgen 0.63.0 */ #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -82,11 +82,11 @@ where } #[repr(C)] #[derive(Default)] -pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); +pub struct __IncompleteArrayField(::core::marker::PhantomData, [T; 0]); impl __IncompleteArrayField { #[inline] pub const fn new() -> Self { - __IncompleteArrayField(::std::marker::PhantomData, []) + __IncompleteArrayField(::core::marker::PhantomData, []) } #[inline] pub fn as_ptr(&self) -> *const T { @@ -98,15 +98,15 @@ impl __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - ::std::slice::from_raw_parts(self.as_ptr(), len) + ::core::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + ::core::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } -impl ::std::fmt::Debug for __IncompleteArrayField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { +impl ::core::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.write_str("__IncompleteArrayField") } } @@ -173,13 +173,13 @@ pub const TC_H_MIN_PRIORITY: u32 = 65504; pub const TC_H_MIN_INGRESS: u32 = 65522; pub const TC_H_MIN_EGRESS: u32 = 65523; pub const TCA_BPF_FLAG_ACT_DIRECT: u32 = 1; -pub type __u8 = ::std::os::raw::c_uchar; -pub type __s16 = ::std::os::raw::c_short; -pub type __u16 = ::std::os::raw::c_ushort; -pub type __s32 = ::std::os::raw::c_int; -pub type __u32 = ::std::os::raw::c_uint; -pub type __s64 = ::std::os::raw::c_longlong; -pub type __u64 = ::std::os::raw::c_ulonglong; +pub type __u8 = ::core::ffi::c_uchar; +pub type __s16 = ::core::ffi::c_short; +pub type __u16 = ::core::ffi::c_ushort; +pub type __s32 = ::core::ffi::c_int; +pub type __u32 = ::core::ffi::c_uint; +pub type __s64 = ::core::ffi::c_longlong; +pub type __u64 = ::core::ffi::c_ulonglong; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_insn { @@ -192,23 +192,23 @@ pub struct bpf_insn { impl bpf_insn { #[inline] pub fn dst_reg(&self) -> __u8 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } } #[inline] pub fn set_dst_reg(&mut self, val: __u8) { unsafe { - let val: u8 = ::std::mem::transmute(val); + let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 4u8, val as u64) } } #[inline] pub fn src_reg(&self) -> __u8 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u8) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u8) } } #[inline] pub fn set_src_reg(&mut self, val: __u8) { unsafe { - let val: u8 = ::std::mem::transmute(val); + let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 4u8, val as u64) } } @@ -216,11 +216,11 @@ impl bpf_insn { pub fn new_bitfield_1(dst_reg: __u8, src_reg: __u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 4u8, { - let dst_reg: u8 = unsafe { ::std::mem::transmute(dst_reg) }; + let dst_reg: u8 = unsafe { ::core::mem::transmute(dst_reg) }; dst_reg as u64 }); __bindgen_bitfield_unit.set(4usize, 4u8, { - let src_reg: u8 = unsafe { ::std::mem::transmute(src_reg) }; + let src_reg: u8 = unsafe { ::core::mem::transmute(src_reg) }; src_reg as u64 }); __bindgen_bitfield_unit @@ -414,7 +414,7 @@ pub const BPF_ANY: _bindgen_ty_2 = 0; pub const BPF_NOEXIST: _bindgen_ty_2 = 1; pub const BPF_EXIST: _bindgen_ty_2 = 2; pub const BPF_F_LOCK: _bindgen_ty_2 = 4; -pub type _bindgen_ty_2 = ::std::os::raw::c_uint; +pub type _bindgen_ty_2 = ::core::ffi::c_uint; pub const BPF_F_NO_PREALLOC: _bindgen_ty_3 = 1; pub const BPF_F_NO_COMMON_LRU: _bindgen_ty_3 = 2; pub const BPF_F_NUMA_NODE: _bindgen_ty_3 = 4; @@ -428,7 +428,7 @@ pub const BPF_F_CLONE: _bindgen_ty_3 = 512; pub const BPF_F_MMAPABLE: _bindgen_ty_3 = 1024; pub const BPF_F_PRESERVE_ELEMS: _bindgen_ty_3 = 2048; pub const BPF_F_INNER_MAP: _bindgen_ty_3 = 4096; -pub type _bindgen_ty_3 = ::std::os::raw::c_uint; +pub type _bindgen_ty_3 = ::core::ffi::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub union bpf_attr { @@ -462,7 +462,7 @@ pub struct bpf_attr__bindgen_ty_1 { pub map_flags: __u32, pub inner_map_fd: __u32, pub numa_node: __u32, - pub map_name: [::std::os::raw::c_char; 16usize], + pub map_name: [::core::ffi::c_char; 16usize], pub map_ifindex: __u32, pub btf_fd: __u32, pub btf_key_type_id: __u32, @@ -508,7 +508,7 @@ pub struct bpf_attr__bindgen_ty_4 { pub log_buf: __u64, pub kern_version: __u32, pub prog_flags: __u32, - pub prog_name: [::std::os::raw::c_char; 16usize], + pub prog_name: [::core::ffi::c_char; 16usize], pub prog_ifindex: __u32, pub expected_attach_type: __u32, pub prog_btf_fd: __u32, @@ -711,33 +711,33 @@ pub struct bpf_attr__bindgen_ty_19 { } pub const BPF_F_RECOMPUTE_CSUM: _bindgen_ty_4 = 1; pub const BPF_F_INVALIDATE_HASH: _bindgen_ty_4 = 2; -pub type _bindgen_ty_4 = ::std::os::raw::c_uint; +pub type _bindgen_ty_4 = ::core::ffi::c_uint; pub const BPF_F_HDR_FIELD_MASK: _bindgen_ty_5 = 15; -pub type _bindgen_ty_5 = ::std::os::raw::c_uint; +pub type _bindgen_ty_5 = ::core::ffi::c_uint; pub const BPF_F_PSEUDO_HDR: _bindgen_ty_6 = 16; pub const BPF_F_MARK_MANGLED_0: _bindgen_ty_6 = 32; pub const BPF_F_MARK_ENFORCE: _bindgen_ty_6 = 64; -pub type _bindgen_ty_6 = ::std::os::raw::c_uint; +pub type _bindgen_ty_6 = ::core::ffi::c_uint; pub const BPF_F_INGRESS: _bindgen_ty_7 = 1; -pub type _bindgen_ty_7 = ::std::os::raw::c_uint; +pub type _bindgen_ty_7 = ::core::ffi::c_uint; pub const BPF_F_TUNINFO_IPV6: _bindgen_ty_8 = 1; -pub type _bindgen_ty_8 = ::std::os::raw::c_uint; +pub type _bindgen_ty_8 = ::core::ffi::c_uint; pub const BPF_F_SKIP_FIELD_MASK: _bindgen_ty_9 = 255; pub const BPF_F_USER_STACK: _bindgen_ty_9 = 256; pub const BPF_F_FAST_STACK_CMP: _bindgen_ty_9 = 512; pub const BPF_F_REUSE_STACKID: _bindgen_ty_9 = 1024; pub const BPF_F_USER_BUILD_ID: _bindgen_ty_9 = 2048; -pub type _bindgen_ty_9 = ::std::os::raw::c_uint; +pub type _bindgen_ty_9 = ::core::ffi::c_uint; pub const BPF_F_ZERO_CSUM_TX: _bindgen_ty_10 = 2; pub const BPF_F_DONT_FRAGMENT: _bindgen_ty_10 = 4; pub const BPF_F_SEQ_NUMBER: _bindgen_ty_10 = 8; -pub type _bindgen_ty_10 = ::std::os::raw::c_uint; +pub type _bindgen_ty_10 = ::core::ffi::c_uint; pub const BPF_F_INDEX_MASK: _bindgen_ty_11 = 4294967295; pub const BPF_F_CURRENT_CPU: _bindgen_ty_11 = 4294967295; pub const BPF_F_CTXLEN_MASK: _bindgen_ty_11 = 4503595332403200; -pub type _bindgen_ty_11 = ::std::os::raw::c_ulonglong; +pub type _bindgen_ty_11 = ::core::ffi::c_ulonglong; pub const BPF_F_CURRENT_NETNS: _bindgen_ty_12 = -1; -pub type _bindgen_ty_12 = ::std::os::raw::c_int; +pub type _bindgen_ty_12 = ::core::ffi::c_int; pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_14 = 1; pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_14 = 2; pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_14 = 4; @@ -745,20 +745,20 @@ pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_14 = 8; pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_14 = 16; pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_14 = 32; pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_14 = 64; -pub type _bindgen_ty_14 = ::std::os::raw::c_uint; +pub type _bindgen_ty_14 = ::core::ffi::c_uint; pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_16 = 1; -pub type _bindgen_ty_16 = ::std::os::raw::c_uint; +pub type _bindgen_ty_16 = ::core::ffi::c_uint; pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_18 = 1; -pub type _bindgen_ty_18 = ::std::os::raw::c_uint; +pub type _bindgen_ty_18 = ::core::ffi::c_uint; pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_21 = 2147483648; pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_21 = 1073741824; pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_21 = 8; -pub type _bindgen_ty_21 = ::std::os::raw::c_uint; +pub type _bindgen_ty_21 = ::core::ffi::c_uint; pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_23 = 1; -pub type _bindgen_ty_23 = ::std::os::raw::c_uint; +pub type _bindgen_ty_23 = ::core::ffi::c_uint; pub const BPF_F_BROADCAST: _bindgen_ty_24 = 8; pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_24 = 16; -pub type _bindgen_ty_24 = ::std::os::raw::c_uint; +pub type _bindgen_ty_24 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_prog_info { @@ -773,7 +773,7 @@ pub struct bpf_prog_info { pub created_by_uid: __u32, pub nr_map_ids: __u32, pub map_ids: __u64, - pub name: [::std::os::raw::c_char; 16usize], + pub name: [::core::ffi::c_char; 16usize], pub ifindex: __u32, pub _bitfield_align_1: [u8; 0], pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, @@ -805,12 +805,12 @@ pub struct bpf_prog_info { impl bpf_prog_info { #[inline] pub fn gpl_compatible(&self) -> __u32 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } } #[inline] pub fn set_gpl_compatible(&mut self, val: __u32) { unsafe { - let val: u32 = ::std::mem::transmute(val); + let val: u32 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } @@ -818,7 +818,7 @@ impl bpf_prog_info { pub fn new_bitfield_1(gpl_compatible: __u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let gpl_compatible: u32 = unsafe { ::std::mem::transmute(gpl_compatible) }; + let gpl_compatible: u32 = unsafe { ::core::mem::transmute(gpl_compatible) }; gpl_compatible as u64 }); __bindgen_bitfield_unit @@ -833,7 +833,7 @@ pub struct bpf_map_info { pub value_size: __u32, pub max_entries: __u32, pub map_flags: __u32, - pub name: [::std::os::raw::c_char; 16usize], + pub name: [::core::ffi::c_char; 16usize], pub ifindex: __u32, pub btf_vmlinux_value_type_id: __u32, pub netns_dev: __u64, @@ -988,7 +988,7 @@ pub const BTF_KIND_TYPE_TAG: _bindgen_ty_38 = 18; pub const BTF_KIND_ENUM64: _bindgen_ty_38 = 19; pub const NR_BTF_KINDS: _bindgen_ty_38 = 20; pub const BTF_KIND_MAX: _bindgen_ty_38 = 19; -pub type _bindgen_ty_38 = ::std::os::raw::c_uint; +pub type _bindgen_ty_38 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct btf_enum { @@ -1018,7 +1018,7 @@ pub struct btf_param { pub const BTF_VAR_STATIC: _bindgen_ty_39 = 0; pub const BTF_VAR_GLOBAL_ALLOCATED: _bindgen_ty_39 = 1; pub const BTF_VAR_GLOBAL_EXTERN: _bindgen_ty_39 = 2; -pub type _bindgen_ty_39 = ::std::os::raw::c_uint; +pub type _bindgen_ty_39 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum btf_func_linkage { @@ -1202,419 +1202,419 @@ pub union perf_event_attr__bindgen_ty_4 { impl perf_event_attr { #[inline] pub fn disabled(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } } #[inline] pub fn set_disabled(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } #[inline] pub fn inherit(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } } #[inline] pub fn set_inherit(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(1usize, 1u8, val as u64) } } #[inline] pub fn pinned(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } } #[inline] pub fn set_pinned(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(2usize, 1u8, val as u64) } } #[inline] pub fn exclusive(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } } #[inline] pub fn set_exclusive(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(3usize, 1u8, val as u64) } } #[inline] pub fn exclude_user(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } } #[inline] pub fn set_exclude_user(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] pub fn exclude_kernel(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } } #[inline] pub fn set_exclude_kernel(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(5usize, 1u8, val as u64) } } #[inline] pub fn exclude_hv(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u64) } } #[inline] pub fn set_exclude_hv(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(6usize, 1u8, val as u64) } } #[inline] pub fn exclude_idle(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u64) } } #[inline] pub fn set_exclude_idle(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(7usize, 1u8, val as u64) } } #[inline] pub fn mmap(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u64) } } #[inline] pub fn set_mmap(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(8usize, 1u8, val as u64) } } #[inline] pub fn comm(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u64) } } #[inline] pub fn set_comm(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(9usize, 1u8, val as u64) } } #[inline] pub fn freq(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u64) } } #[inline] pub fn set_freq(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(10usize, 1u8, val as u64) } } #[inline] pub fn inherit_stat(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u64) } } #[inline] pub fn set_inherit_stat(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(11usize, 1u8, val as u64) } } #[inline] pub fn enable_on_exec(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u64) } } #[inline] pub fn set_enable_on_exec(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(12usize, 1u8, val as u64) } } #[inline] pub fn task(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u64) } } #[inline] pub fn set_task(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(13usize, 1u8, val as u64) } } #[inline] pub fn watermark(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u64) } } #[inline] pub fn set_watermark(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(14usize, 1u8, val as u64) } } #[inline] pub fn precise_ip(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 2u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(15usize, 2u8) as u64) } } #[inline] pub fn set_precise_ip(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(15usize, 2u8, val as u64) } } #[inline] pub fn mmap_data(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(17usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(17usize, 1u8) as u64) } } #[inline] pub fn set_mmap_data(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(17usize, 1u8, val as u64) } } #[inline] pub fn sample_id_all(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(18usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(18usize, 1u8) as u64) } } #[inline] pub fn set_sample_id_all(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(18usize, 1u8, val as u64) } } #[inline] pub fn exclude_host(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(19usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(19usize, 1u8) as u64) } } #[inline] pub fn set_exclude_host(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(19usize, 1u8, val as u64) } } #[inline] pub fn exclude_guest(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(20usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(20usize, 1u8) as u64) } } #[inline] pub fn set_exclude_guest(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(20usize, 1u8, val as u64) } } #[inline] pub fn exclude_callchain_kernel(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(21usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(21usize, 1u8) as u64) } } #[inline] pub fn set_exclude_callchain_kernel(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(21usize, 1u8, val as u64) } } #[inline] pub fn exclude_callchain_user(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(22usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(22usize, 1u8) as u64) } } #[inline] pub fn set_exclude_callchain_user(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(22usize, 1u8, val as u64) } } #[inline] pub fn mmap2(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(23usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(23usize, 1u8) as u64) } } #[inline] pub fn set_mmap2(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(23usize, 1u8, val as u64) } } #[inline] pub fn comm_exec(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(24usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(24usize, 1u8) as u64) } } #[inline] pub fn set_comm_exec(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(24usize, 1u8, val as u64) } } #[inline] pub fn use_clockid(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(25usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(25usize, 1u8) as u64) } } #[inline] pub fn set_use_clockid(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(25usize, 1u8, val as u64) } } #[inline] pub fn context_switch(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(26usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(26usize, 1u8) as u64) } } #[inline] pub fn set_context_switch(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(26usize, 1u8, val as u64) } } #[inline] pub fn write_backward(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(27usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(27usize, 1u8) as u64) } } #[inline] pub fn set_write_backward(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(27usize, 1u8, val as u64) } } #[inline] pub fn namespaces(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(28usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(28usize, 1u8) as u64) } } #[inline] pub fn set_namespaces(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(28usize, 1u8, val as u64) } } #[inline] pub fn ksymbol(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(29usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(29usize, 1u8) as u64) } } #[inline] pub fn set_ksymbol(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(29usize, 1u8, val as u64) } } #[inline] pub fn bpf_event(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(30usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(30usize, 1u8) as u64) } } #[inline] pub fn set_bpf_event(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(30usize, 1u8, val as u64) } } #[inline] pub fn aux_output(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(31usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(31usize, 1u8) as u64) } } #[inline] pub fn set_aux_output(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(31usize, 1u8, val as u64) } } #[inline] pub fn cgroup(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(32usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(32usize, 1u8) as u64) } } #[inline] pub fn set_cgroup(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(32usize, 1u8, val as u64) } } #[inline] pub fn text_poke(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(33usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(33usize, 1u8) as u64) } } #[inline] pub fn set_text_poke(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(33usize, 1u8, val as u64) } } #[inline] pub fn build_id(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(34usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(34usize, 1u8) as u64) } } #[inline] pub fn set_build_id(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(34usize, 1u8, val as u64) } } #[inline] pub fn inherit_thread(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(35usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(35usize, 1u8) as u64) } } #[inline] pub fn set_inherit_thread(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(35usize, 1u8, val as u64) } } #[inline] pub fn remove_on_exec(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(36usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(36usize, 1u8) as u64) } } #[inline] pub fn set_remove_on_exec(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(36usize, 1u8, val as u64) } } #[inline] pub fn sigtrap(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(37usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(37usize, 1u8) as u64) } } #[inline] pub fn set_sigtrap(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(37usize, 1u8, val as u64) } } #[inline] pub fn __reserved_1(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(38usize, 26u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(38usize, 26u8) as u64) } } #[inline] pub fn set___reserved_1(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(38usize, 26u8, val as u64) } } @@ -1661,157 +1661,157 @@ impl perf_event_attr { ) -> __BindgenBitfieldUnit<[u8; 8usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let disabled: u64 = unsafe { ::std::mem::transmute(disabled) }; + let disabled: u64 = unsafe { ::core::mem::transmute(disabled) }; disabled as u64 }); __bindgen_bitfield_unit.set(1usize, 1u8, { - let inherit: u64 = unsafe { ::std::mem::transmute(inherit) }; + let inherit: u64 = unsafe { ::core::mem::transmute(inherit) }; inherit as u64 }); __bindgen_bitfield_unit.set(2usize, 1u8, { - let pinned: u64 = unsafe { ::std::mem::transmute(pinned) }; + let pinned: u64 = unsafe { ::core::mem::transmute(pinned) }; pinned as u64 }); __bindgen_bitfield_unit.set(3usize, 1u8, { - let exclusive: u64 = unsafe { ::std::mem::transmute(exclusive) }; + let exclusive: u64 = unsafe { ::core::mem::transmute(exclusive) }; exclusive as u64 }); __bindgen_bitfield_unit.set(4usize, 1u8, { - let exclude_user: u64 = unsafe { ::std::mem::transmute(exclude_user) }; + let exclude_user: u64 = unsafe { ::core::mem::transmute(exclude_user) }; exclude_user as u64 }); __bindgen_bitfield_unit.set(5usize, 1u8, { - let exclude_kernel: u64 = unsafe { ::std::mem::transmute(exclude_kernel) }; + let exclude_kernel: u64 = unsafe { ::core::mem::transmute(exclude_kernel) }; exclude_kernel as u64 }); __bindgen_bitfield_unit.set(6usize, 1u8, { - let exclude_hv: u64 = unsafe { ::std::mem::transmute(exclude_hv) }; + let exclude_hv: u64 = unsafe { ::core::mem::transmute(exclude_hv) }; exclude_hv as u64 }); __bindgen_bitfield_unit.set(7usize, 1u8, { - let exclude_idle: u64 = unsafe { ::std::mem::transmute(exclude_idle) }; + let exclude_idle: u64 = unsafe { ::core::mem::transmute(exclude_idle) }; exclude_idle as u64 }); __bindgen_bitfield_unit.set(8usize, 1u8, { - let mmap: u64 = unsafe { ::std::mem::transmute(mmap) }; + let mmap: u64 = unsafe { ::core::mem::transmute(mmap) }; mmap as u64 }); __bindgen_bitfield_unit.set(9usize, 1u8, { - let comm: u64 = unsafe { ::std::mem::transmute(comm) }; + let comm: u64 = unsafe { ::core::mem::transmute(comm) }; comm as u64 }); __bindgen_bitfield_unit.set(10usize, 1u8, { - let freq: u64 = unsafe { ::std::mem::transmute(freq) }; + let freq: u64 = unsafe { ::core::mem::transmute(freq) }; freq as u64 }); __bindgen_bitfield_unit.set(11usize, 1u8, { - let inherit_stat: u64 = unsafe { ::std::mem::transmute(inherit_stat) }; + let inherit_stat: u64 = unsafe { ::core::mem::transmute(inherit_stat) }; inherit_stat as u64 }); __bindgen_bitfield_unit.set(12usize, 1u8, { - let enable_on_exec: u64 = unsafe { ::std::mem::transmute(enable_on_exec) }; + let enable_on_exec: u64 = unsafe { ::core::mem::transmute(enable_on_exec) }; enable_on_exec as u64 }); __bindgen_bitfield_unit.set(13usize, 1u8, { - let task: u64 = unsafe { ::std::mem::transmute(task) }; + let task: u64 = unsafe { ::core::mem::transmute(task) }; task as u64 }); __bindgen_bitfield_unit.set(14usize, 1u8, { - let watermark: u64 = unsafe { ::std::mem::transmute(watermark) }; + let watermark: u64 = unsafe { ::core::mem::transmute(watermark) }; watermark as u64 }); __bindgen_bitfield_unit.set(15usize, 2u8, { - let precise_ip: u64 = unsafe { ::std::mem::transmute(precise_ip) }; + let precise_ip: u64 = unsafe { ::core::mem::transmute(precise_ip) }; precise_ip as u64 }); __bindgen_bitfield_unit.set(17usize, 1u8, { - let mmap_data: u64 = unsafe { ::std::mem::transmute(mmap_data) }; + let mmap_data: u64 = unsafe { ::core::mem::transmute(mmap_data) }; mmap_data as u64 }); __bindgen_bitfield_unit.set(18usize, 1u8, { - let sample_id_all: u64 = unsafe { ::std::mem::transmute(sample_id_all) }; + let sample_id_all: u64 = unsafe { ::core::mem::transmute(sample_id_all) }; sample_id_all as u64 }); __bindgen_bitfield_unit.set(19usize, 1u8, { - let exclude_host: u64 = unsafe { ::std::mem::transmute(exclude_host) }; + let exclude_host: u64 = unsafe { ::core::mem::transmute(exclude_host) }; exclude_host as u64 }); __bindgen_bitfield_unit.set(20usize, 1u8, { - let exclude_guest: u64 = unsafe { ::std::mem::transmute(exclude_guest) }; + let exclude_guest: u64 = unsafe { ::core::mem::transmute(exclude_guest) }; exclude_guest as u64 }); __bindgen_bitfield_unit.set(21usize, 1u8, { let exclude_callchain_kernel: u64 = - unsafe { ::std::mem::transmute(exclude_callchain_kernel) }; + unsafe { ::core::mem::transmute(exclude_callchain_kernel) }; exclude_callchain_kernel as u64 }); __bindgen_bitfield_unit.set(22usize, 1u8, { let exclude_callchain_user: u64 = - unsafe { ::std::mem::transmute(exclude_callchain_user) }; + unsafe { ::core::mem::transmute(exclude_callchain_user) }; exclude_callchain_user as u64 }); __bindgen_bitfield_unit.set(23usize, 1u8, { - let mmap2: u64 = unsafe { ::std::mem::transmute(mmap2) }; + let mmap2: u64 = unsafe { ::core::mem::transmute(mmap2) }; mmap2 as u64 }); __bindgen_bitfield_unit.set(24usize, 1u8, { - let comm_exec: u64 = unsafe { ::std::mem::transmute(comm_exec) }; + let comm_exec: u64 = unsafe { ::core::mem::transmute(comm_exec) }; comm_exec as u64 }); __bindgen_bitfield_unit.set(25usize, 1u8, { - let use_clockid: u64 = unsafe { ::std::mem::transmute(use_clockid) }; + let use_clockid: u64 = unsafe { ::core::mem::transmute(use_clockid) }; use_clockid as u64 }); __bindgen_bitfield_unit.set(26usize, 1u8, { - let context_switch: u64 = unsafe { ::std::mem::transmute(context_switch) }; + let context_switch: u64 = unsafe { ::core::mem::transmute(context_switch) }; context_switch as u64 }); __bindgen_bitfield_unit.set(27usize, 1u8, { - let write_backward: u64 = unsafe { ::std::mem::transmute(write_backward) }; + let write_backward: u64 = unsafe { ::core::mem::transmute(write_backward) }; write_backward as u64 }); __bindgen_bitfield_unit.set(28usize, 1u8, { - let namespaces: u64 = unsafe { ::std::mem::transmute(namespaces) }; + let namespaces: u64 = unsafe { ::core::mem::transmute(namespaces) }; namespaces as u64 }); __bindgen_bitfield_unit.set(29usize, 1u8, { - let ksymbol: u64 = unsafe { ::std::mem::transmute(ksymbol) }; + let ksymbol: u64 = unsafe { ::core::mem::transmute(ksymbol) }; ksymbol as u64 }); __bindgen_bitfield_unit.set(30usize, 1u8, { - let bpf_event: u64 = unsafe { ::std::mem::transmute(bpf_event) }; + let bpf_event: u64 = unsafe { ::core::mem::transmute(bpf_event) }; bpf_event as u64 }); __bindgen_bitfield_unit.set(31usize, 1u8, { - let aux_output: u64 = unsafe { ::std::mem::transmute(aux_output) }; + let aux_output: u64 = unsafe { ::core::mem::transmute(aux_output) }; aux_output as u64 }); __bindgen_bitfield_unit.set(32usize, 1u8, { - let cgroup: u64 = unsafe { ::std::mem::transmute(cgroup) }; + let cgroup: u64 = unsafe { ::core::mem::transmute(cgroup) }; cgroup as u64 }); __bindgen_bitfield_unit.set(33usize, 1u8, { - let text_poke: u64 = unsafe { ::std::mem::transmute(text_poke) }; + let text_poke: u64 = unsafe { ::core::mem::transmute(text_poke) }; text_poke as u64 }); __bindgen_bitfield_unit.set(34usize, 1u8, { - let build_id: u64 = unsafe { ::std::mem::transmute(build_id) }; + let build_id: u64 = unsafe { ::core::mem::transmute(build_id) }; build_id as u64 }); __bindgen_bitfield_unit.set(35usize, 1u8, { - let inherit_thread: u64 = unsafe { ::std::mem::transmute(inherit_thread) }; + let inherit_thread: u64 = unsafe { ::core::mem::transmute(inherit_thread) }; inherit_thread as u64 }); __bindgen_bitfield_unit.set(36usize, 1u8, { - let remove_on_exec: u64 = unsafe { ::std::mem::transmute(remove_on_exec) }; + let remove_on_exec: u64 = unsafe { ::core::mem::transmute(remove_on_exec) }; remove_on_exec as u64 }); __bindgen_bitfield_unit.set(37usize, 1u8, { - let sigtrap: u64 = unsafe { ::std::mem::transmute(sigtrap) }; + let sigtrap: u64 = unsafe { ::core::mem::transmute(sigtrap) }; sigtrap as u64 }); __bindgen_bitfield_unit.set(38usize, 26u8, { - let __reserved_1: u64 = unsafe { ::std::mem::transmute(__reserved_1) }; + let __reserved_1: u64 = unsafe { ::core::mem::transmute(__reserved_1) }; __reserved_1 as u64 }); __bindgen_bitfield_unit @@ -1863,78 +1863,78 @@ pub struct perf_event_mmap_page__bindgen_ty_1__bindgen_ty_1 { impl perf_event_mmap_page__bindgen_ty_1__bindgen_ty_1 { #[inline] pub fn cap_bit0(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } } #[inline] pub fn set_cap_bit0(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } #[inline] pub fn cap_bit0_is_deprecated(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } } #[inline] pub fn set_cap_bit0_is_deprecated(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(1usize, 1u8, val as u64) } } #[inline] pub fn cap_user_rdpmc(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_rdpmc(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(2usize, 1u8, val as u64) } } #[inline] pub fn cap_user_time(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_time(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(3usize, 1u8, val as u64) } } #[inline] pub fn cap_user_time_zero(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_time_zero(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] pub fn cap_user_time_short(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_time_short(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(5usize, 1u8, val as u64) } } #[inline] pub fn cap_____res(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 58u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(6usize, 58u8) as u64) } } #[inline] pub fn set_cap_____res(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(6usize, 58u8, val as u64) } } @@ -1950,32 +1950,32 @@ impl perf_event_mmap_page__bindgen_ty_1__bindgen_ty_1 { ) -> __BindgenBitfieldUnit<[u8; 8usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let cap_bit0: u64 = unsafe { ::std::mem::transmute(cap_bit0) }; + let cap_bit0: u64 = unsafe { ::core::mem::transmute(cap_bit0) }; cap_bit0 as u64 }); __bindgen_bitfield_unit.set(1usize, 1u8, { let cap_bit0_is_deprecated: u64 = - unsafe { ::std::mem::transmute(cap_bit0_is_deprecated) }; + unsafe { ::core::mem::transmute(cap_bit0_is_deprecated) }; cap_bit0_is_deprecated as u64 }); __bindgen_bitfield_unit.set(2usize, 1u8, { - let cap_user_rdpmc: u64 = unsafe { ::std::mem::transmute(cap_user_rdpmc) }; + let cap_user_rdpmc: u64 = unsafe { ::core::mem::transmute(cap_user_rdpmc) }; cap_user_rdpmc as u64 }); __bindgen_bitfield_unit.set(3usize, 1u8, { - let cap_user_time: u64 = unsafe { ::std::mem::transmute(cap_user_time) }; + let cap_user_time: u64 = unsafe { ::core::mem::transmute(cap_user_time) }; cap_user_time as u64 }); __bindgen_bitfield_unit.set(4usize, 1u8, { - let cap_user_time_zero: u64 = unsafe { ::std::mem::transmute(cap_user_time_zero) }; + let cap_user_time_zero: u64 = unsafe { ::core::mem::transmute(cap_user_time_zero) }; cap_user_time_zero as u64 }); __bindgen_bitfield_unit.set(5usize, 1u8, { - let cap_user_time_short: u64 = unsafe { ::std::mem::transmute(cap_user_time_short) }; + let cap_user_time_short: u64 = unsafe { ::core::mem::transmute(cap_user_time_short) }; cap_user_time_short as u64 }); __bindgen_bitfield_unit.set(6usize, 58u8, { - let cap_____res: u64 = unsafe { ::std::mem::transmute(cap_____res) }; + let cap_____res: u64 = unsafe { ::core::mem::transmute(cap_____res) }; cap_____res as u64 }); __bindgen_bitfield_unit @@ -2024,59 +2024,60 @@ pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_85 = 6; pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_85 = 7; pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_85 = 8; pub const __IFLA_XDP_MAX: _bindgen_ty_85 = 9; -pub type _bindgen_ty_85 = ::std::os::raw::c_uint; +pub type _bindgen_ty_85 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { - pub ifi_family: ::std::os::raw::c_uchar, - pub __ifi_pad: ::std::os::raw::c_uchar, - pub ifi_type: ::std::os::raw::c_ushort, - pub ifi_index: ::std::os::raw::c_int, - pub ifi_flags: ::std::os::raw::c_uint, - pub ifi_change: ::std::os::raw::c_uint, + pub ifi_family: ::core::ffi::c_uchar, + pub __ifi_pad: ::core::ffi::c_uchar, + pub ifi_type: ::core::ffi::c_ushort, + pub ifi_index: ::core::ffi::c_int, + pub ifi_flags: ::core::ffi::c_uint, + pub ifi_change: ::core::ffi::c_uint, } #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct tcmsg { - pub tcm_family: ::std::os::raw::c_uchar, - pub tcm__pad1: ::std::os::raw::c_uchar, - pub tcm__pad2: ::std::os::raw::c_ushort, - pub tcm_ifindex: ::std::os::raw::c_int, + pub tcm_family: ::core::ffi::c_uchar, + pub tcm__pad1: ::core::ffi::c_uchar, + pub tcm__pad2: ::core::ffi::c_ushort, + pub tcm_ifindex: ::core::ffi::c_int, pub tcm_handle: __u32, pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_98 = 0; -pub const TCA_KIND: _bindgen_ty_98 = 1; -pub const TCA_OPTIONS: _bindgen_ty_98 = 2; -pub const TCA_STATS: _bindgen_ty_98 = 3; -pub const TCA_XSTATS: _bindgen_ty_98 = 4; -pub const TCA_RATE: _bindgen_ty_98 = 5; -pub const TCA_FCNT: _bindgen_ty_98 = 6; -pub const TCA_STATS2: _bindgen_ty_98 = 7; -pub const TCA_STAB: _bindgen_ty_98 = 8; -pub const TCA_PAD: _bindgen_ty_98 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_98 = 10; -pub const TCA_CHAIN: _bindgen_ty_98 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_98 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_98 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_98 = 14; -pub const __TCA_MAX: _bindgen_ty_98 = 15; -pub type _bindgen_ty_98 = ::std::os::raw::c_uint; -pub const TCA_BPF_UNSPEC: _bindgen_ty_154 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_154 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_154 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_154 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_154 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_154 = 5; -pub const TCA_BPF_FD: _bindgen_ty_154 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_154 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_154 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_154 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_154 = 10; -pub const TCA_BPF_ID: _bindgen_ty_154 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_154 = 12; -pub type _bindgen_ty_154 = ::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; +pub const TCA_UNSPEC: _bindgen_ty_100 = 0; +pub const TCA_KIND: _bindgen_ty_100 = 1; +pub const TCA_OPTIONS: _bindgen_ty_100 = 2; +pub const TCA_STATS: _bindgen_ty_100 = 3; +pub const TCA_XSTATS: _bindgen_ty_100 = 4; +pub const TCA_RATE: _bindgen_ty_100 = 5; +pub const TCA_FCNT: _bindgen_ty_100 = 6; +pub const TCA_STATS2: _bindgen_ty_100 = 7; +pub const TCA_STAB: _bindgen_ty_100 = 8; +pub const TCA_PAD: _bindgen_ty_100 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_100 = 10; +pub const TCA_CHAIN: _bindgen_ty_100 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_100 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_100 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_100 = 14; +pub const TCA_DUMP_FLAGS: _bindgen_ty_100 = 15; +pub const __TCA_MAX: _bindgen_ty_100 = 16; +pub type _bindgen_ty_100 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; +pub const TCA_BPF_FD: _bindgen_ty_156 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; +pub const TCA_BPF_ID: _bindgen_ty_156 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; +pub type _bindgen_ty_156 = ::core::ffi::c_uint; +pub const AYA_PERF_EVENT_IOC_ENABLE: ::core::ffi::c_int = 9216; +pub const AYA_PERF_EVENT_IOC_DISABLE: ::core::ffi::c_int = 9217; +pub const AYA_PERF_EVENT_IOC_SET_BPF: ::core::ffi::c_int = 1074013192; diff --git a/aya/src/generated/linux_bindings_riscv64.rs b/aya-obj/src/generated/linux_bindings_riscv64.rs similarity index 79% rename from aya/src/generated/linux_bindings_riscv64.rs rename to aya-obj/src/generated/linux_bindings_riscv64.rs index 60c5fab6..fab6978c 100644 --- a/aya/src/generated/linux_bindings_riscv64.rs +++ b/aya-obj/src/generated/linux_bindings_riscv64.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.60.1 */ +/* automatically generated by rust-bindgen 0.63.0 */ #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -82,11 +82,11 @@ where } #[repr(C)] #[derive(Default)] -pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); +pub struct __IncompleteArrayField(::core::marker::PhantomData, [T; 0]); impl __IncompleteArrayField { #[inline] pub const fn new() -> Self { - __IncompleteArrayField(::std::marker::PhantomData, []) + __IncompleteArrayField(::core::marker::PhantomData, []) } #[inline] pub fn as_ptr(&self) -> *const T { @@ -98,15 +98,15 @@ impl __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - ::std::slice::from_raw_parts(self.as_ptr(), len) + ::core::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + ::core::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } -impl ::std::fmt::Debug for __IncompleteArrayField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { +impl ::core::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.write_str("__IncompleteArrayField") } } @@ -173,13 +173,13 @@ pub const TC_H_MIN_PRIORITY: u32 = 65504; pub const TC_H_MIN_INGRESS: u32 = 65522; pub const TC_H_MIN_EGRESS: u32 = 65523; pub const TCA_BPF_FLAG_ACT_DIRECT: u32 = 1; -pub type __u8 = ::std::os::raw::c_uchar; -pub type __s16 = ::std::os::raw::c_short; -pub type __u16 = ::std::os::raw::c_ushort; -pub type __s32 = ::std::os::raw::c_int; -pub type __u32 = ::std::os::raw::c_uint; -pub type __s64 = ::std::os::raw::c_longlong; -pub type __u64 = ::std::os::raw::c_ulonglong; +pub type __u8 = ::core::ffi::c_uchar; +pub type __s16 = ::core::ffi::c_short; +pub type __u16 = ::core::ffi::c_ushort; +pub type __s32 = ::core::ffi::c_int; +pub type __u32 = ::core::ffi::c_uint; +pub type __s64 = ::core::ffi::c_longlong; +pub type __u64 = ::core::ffi::c_ulonglong; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_insn { @@ -192,23 +192,23 @@ pub struct bpf_insn { impl bpf_insn { #[inline] pub fn dst_reg(&self) -> __u8 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } } #[inline] pub fn set_dst_reg(&mut self, val: __u8) { unsafe { - let val: u8 = ::std::mem::transmute(val); + let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 4u8, val as u64) } } #[inline] pub fn src_reg(&self) -> __u8 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u8) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u8) } } #[inline] pub fn set_src_reg(&mut self, val: __u8) { unsafe { - let val: u8 = ::std::mem::transmute(val); + let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 4u8, val as u64) } } @@ -216,11 +216,11 @@ impl bpf_insn { pub fn new_bitfield_1(dst_reg: __u8, src_reg: __u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 4u8, { - let dst_reg: u8 = unsafe { ::std::mem::transmute(dst_reg) }; + let dst_reg: u8 = unsafe { ::core::mem::transmute(dst_reg) }; dst_reg as u64 }); __bindgen_bitfield_unit.set(4usize, 4u8, { - let src_reg: u8 = unsafe { ::std::mem::transmute(src_reg) }; + let src_reg: u8 = unsafe { ::core::mem::transmute(src_reg) }; src_reg as u64 }); __bindgen_bitfield_unit @@ -414,7 +414,7 @@ pub const BPF_ANY: _bindgen_ty_2 = 0; pub const BPF_NOEXIST: _bindgen_ty_2 = 1; pub const BPF_EXIST: _bindgen_ty_2 = 2; pub const BPF_F_LOCK: _bindgen_ty_2 = 4; -pub type _bindgen_ty_2 = ::std::os::raw::c_uint; +pub type _bindgen_ty_2 = ::core::ffi::c_uint; pub const BPF_F_NO_PREALLOC: _bindgen_ty_3 = 1; pub const BPF_F_NO_COMMON_LRU: _bindgen_ty_3 = 2; pub const BPF_F_NUMA_NODE: _bindgen_ty_3 = 4; @@ -428,7 +428,7 @@ pub const BPF_F_CLONE: _bindgen_ty_3 = 512; pub const BPF_F_MMAPABLE: _bindgen_ty_3 = 1024; pub const BPF_F_PRESERVE_ELEMS: _bindgen_ty_3 = 2048; pub const BPF_F_INNER_MAP: _bindgen_ty_3 = 4096; -pub type _bindgen_ty_3 = ::std::os::raw::c_uint; +pub type _bindgen_ty_3 = ::core::ffi::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub union bpf_attr { @@ -462,7 +462,7 @@ pub struct bpf_attr__bindgen_ty_1 { pub map_flags: __u32, pub inner_map_fd: __u32, pub numa_node: __u32, - pub map_name: [::std::os::raw::c_char; 16usize], + pub map_name: [::core::ffi::c_char; 16usize], pub map_ifindex: __u32, pub btf_fd: __u32, pub btf_key_type_id: __u32, @@ -508,7 +508,7 @@ pub struct bpf_attr__bindgen_ty_4 { pub log_buf: __u64, pub kern_version: __u32, pub prog_flags: __u32, - pub prog_name: [::std::os::raw::c_char; 16usize], + pub prog_name: [::core::ffi::c_char; 16usize], pub prog_ifindex: __u32, pub expected_attach_type: __u32, pub prog_btf_fd: __u32, @@ -711,33 +711,33 @@ pub struct bpf_attr__bindgen_ty_19 { } pub const BPF_F_RECOMPUTE_CSUM: _bindgen_ty_4 = 1; pub const BPF_F_INVALIDATE_HASH: _bindgen_ty_4 = 2; -pub type _bindgen_ty_4 = ::std::os::raw::c_uint; +pub type _bindgen_ty_4 = ::core::ffi::c_uint; pub const BPF_F_HDR_FIELD_MASK: _bindgen_ty_5 = 15; -pub type _bindgen_ty_5 = ::std::os::raw::c_uint; +pub type _bindgen_ty_5 = ::core::ffi::c_uint; pub const BPF_F_PSEUDO_HDR: _bindgen_ty_6 = 16; pub const BPF_F_MARK_MANGLED_0: _bindgen_ty_6 = 32; pub const BPF_F_MARK_ENFORCE: _bindgen_ty_6 = 64; -pub type _bindgen_ty_6 = ::std::os::raw::c_uint; +pub type _bindgen_ty_6 = ::core::ffi::c_uint; pub const BPF_F_INGRESS: _bindgen_ty_7 = 1; -pub type _bindgen_ty_7 = ::std::os::raw::c_uint; +pub type _bindgen_ty_7 = ::core::ffi::c_uint; pub const BPF_F_TUNINFO_IPV6: _bindgen_ty_8 = 1; -pub type _bindgen_ty_8 = ::std::os::raw::c_uint; +pub type _bindgen_ty_8 = ::core::ffi::c_uint; pub const BPF_F_SKIP_FIELD_MASK: _bindgen_ty_9 = 255; pub const BPF_F_USER_STACK: _bindgen_ty_9 = 256; pub const BPF_F_FAST_STACK_CMP: _bindgen_ty_9 = 512; pub const BPF_F_REUSE_STACKID: _bindgen_ty_9 = 1024; pub const BPF_F_USER_BUILD_ID: _bindgen_ty_9 = 2048; -pub type _bindgen_ty_9 = ::std::os::raw::c_uint; +pub type _bindgen_ty_9 = ::core::ffi::c_uint; pub const BPF_F_ZERO_CSUM_TX: _bindgen_ty_10 = 2; pub const BPF_F_DONT_FRAGMENT: _bindgen_ty_10 = 4; pub const BPF_F_SEQ_NUMBER: _bindgen_ty_10 = 8; -pub type _bindgen_ty_10 = ::std::os::raw::c_uint; +pub type _bindgen_ty_10 = ::core::ffi::c_uint; pub const BPF_F_INDEX_MASK: _bindgen_ty_11 = 4294967295; pub const BPF_F_CURRENT_CPU: _bindgen_ty_11 = 4294967295; pub const BPF_F_CTXLEN_MASK: _bindgen_ty_11 = 4503595332403200; -pub type _bindgen_ty_11 = ::std::os::raw::c_ulong; +pub type _bindgen_ty_11 = ::core::ffi::c_ulong; pub const BPF_F_CURRENT_NETNS: _bindgen_ty_12 = -1; -pub type _bindgen_ty_12 = ::std::os::raw::c_int; +pub type _bindgen_ty_12 = ::core::ffi::c_int; pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_14 = 1; pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_14 = 2; pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_14 = 4; @@ -745,20 +745,20 @@ pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_14 = 8; pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_14 = 16; pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_14 = 32; pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_14 = 64; -pub type _bindgen_ty_14 = ::std::os::raw::c_uint; +pub type _bindgen_ty_14 = ::core::ffi::c_uint; pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_16 = 1; -pub type _bindgen_ty_16 = ::std::os::raw::c_uint; +pub type _bindgen_ty_16 = ::core::ffi::c_uint; pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_18 = 1; -pub type _bindgen_ty_18 = ::std::os::raw::c_uint; +pub type _bindgen_ty_18 = ::core::ffi::c_uint; pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_21 = 2147483648; pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_21 = 1073741824; pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_21 = 8; -pub type _bindgen_ty_21 = ::std::os::raw::c_uint; +pub type _bindgen_ty_21 = ::core::ffi::c_uint; pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_23 = 1; -pub type _bindgen_ty_23 = ::std::os::raw::c_uint; +pub type _bindgen_ty_23 = ::core::ffi::c_uint; pub const BPF_F_BROADCAST: _bindgen_ty_24 = 8; pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_24 = 16; -pub type _bindgen_ty_24 = ::std::os::raw::c_uint; +pub type _bindgen_ty_24 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_prog_info { @@ -773,7 +773,7 @@ pub struct bpf_prog_info { pub created_by_uid: __u32, pub nr_map_ids: __u32, pub map_ids: __u64, - pub name: [::std::os::raw::c_char; 16usize], + pub name: [::core::ffi::c_char; 16usize], pub ifindex: __u32, pub _bitfield_align_1: [u8; 0], pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, @@ -805,12 +805,12 @@ pub struct bpf_prog_info { impl bpf_prog_info { #[inline] pub fn gpl_compatible(&self) -> __u32 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } } #[inline] pub fn set_gpl_compatible(&mut self, val: __u32) { unsafe { - let val: u32 = ::std::mem::transmute(val); + let val: u32 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } @@ -818,7 +818,7 @@ impl bpf_prog_info { pub fn new_bitfield_1(gpl_compatible: __u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let gpl_compatible: u32 = unsafe { ::std::mem::transmute(gpl_compatible) }; + let gpl_compatible: u32 = unsafe { ::core::mem::transmute(gpl_compatible) }; gpl_compatible as u64 }); __bindgen_bitfield_unit @@ -833,7 +833,7 @@ pub struct bpf_map_info { pub value_size: __u32, pub max_entries: __u32, pub map_flags: __u32, - pub name: [::std::os::raw::c_char; 16usize], + pub name: [::core::ffi::c_char; 16usize], pub ifindex: __u32, pub btf_vmlinux_value_type_id: __u32, pub netns_dev: __u64, @@ -988,7 +988,7 @@ pub const BTF_KIND_TYPE_TAG: _bindgen_ty_38 = 18; pub const BTF_KIND_ENUM64: _bindgen_ty_38 = 19; pub const NR_BTF_KINDS: _bindgen_ty_38 = 20; pub const BTF_KIND_MAX: _bindgen_ty_38 = 19; -pub type _bindgen_ty_38 = ::std::os::raw::c_uint; +pub type _bindgen_ty_38 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct btf_enum { @@ -1018,7 +1018,7 @@ pub struct btf_param { pub const BTF_VAR_STATIC: _bindgen_ty_39 = 0; pub const BTF_VAR_GLOBAL_ALLOCATED: _bindgen_ty_39 = 1; pub const BTF_VAR_GLOBAL_EXTERN: _bindgen_ty_39 = 2; -pub type _bindgen_ty_39 = ::std::os::raw::c_uint; +pub type _bindgen_ty_39 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum btf_func_linkage { @@ -1202,419 +1202,419 @@ pub union perf_event_attr__bindgen_ty_4 { impl perf_event_attr { #[inline] pub fn disabled(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } } #[inline] pub fn set_disabled(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } #[inline] pub fn inherit(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } } #[inline] pub fn set_inherit(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(1usize, 1u8, val as u64) } } #[inline] pub fn pinned(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } } #[inline] pub fn set_pinned(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(2usize, 1u8, val as u64) } } #[inline] pub fn exclusive(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } } #[inline] pub fn set_exclusive(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(3usize, 1u8, val as u64) } } #[inline] pub fn exclude_user(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } } #[inline] pub fn set_exclude_user(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] pub fn exclude_kernel(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } } #[inline] pub fn set_exclude_kernel(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(5usize, 1u8, val as u64) } } #[inline] pub fn exclude_hv(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u64) } } #[inline] pub fn set_exclude_hv(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(6usize, 1u8, val as u64) } } #[inline] pub fn exclude_idle(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u64) } } #[inline] pub fn set_exclude_idle(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(7usize, 1u8, val as u64) } } #[inline] pub fn mmap(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u64) } } #[inline] pub fn set_mmap(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(8usize, 1u8, val as u64) } } #[inline] pub fn comm(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u64) } } #[inline] pub fn set_comm(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(9usize, 1u8, val as u64) } } #[inline] pub fn freq(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u64) } } #[inline] pub fn set_freq(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(10usize, 1u8, val as u64) } } #[inline] pub fn inherit_stat(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u64) } } #[inline] pub fn set_inherit_stat(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(11usize, 1u8, val as u64) } } #[inline] pub fn enable_on_exec(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u64) } } #[inline] pub fn set_enable_on_exec(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(12usize, 1u8, val as u64) } } #[inline] pub fn task(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u64) } } #[inline] pub fn set_task(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(13usize, 1u8, val as u64) } } #[inline] pub fn watermark(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u64) } } #[inline] pub fn set_watermark(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(14usize, 1u8, val as u64) } } #[inline] pub fn precise_ip(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 2u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(15usize, 2u8) as u64) } } #[inline] pub fn set_precise_ip(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(15usize, 2u8, val as u64) } } #[inline] pub fn mmap_data(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(17usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(17usize, 1u8) as u64) } } #[inline] pub fn set_mmap_data(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(17usize, 1u8, val as u64) } } #[inline] pub fn sample_id_all(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(18usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(18usize, 1u8) as u64) } } #[inline] pub fn set_sample_id_all(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(18usize, 1u8, val as u64) } } #[inline] pub fn exclude_host(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(19usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(19usize, 1u8) as u64) } } #[inline] pub fn set_exclude_host(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(19usize, 1u8, val as u64) } } #[inline] pub fn exclude_guest(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(20usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(20usize, 1u8) as u64) } } #[inline] pub fn set_exclude_guest(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(20usize, 1u8, val as u64) } } #[inline] pub fn exclude_callchain_kernel(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(21usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(21usize, 1u8) as u64) } } #[inline] pub fn set_exclude_callchain_kernel(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(21usize, 1u8, val as u64) } } #[inline] pub fn exclude_callchain_user(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(22usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(22usize, 1u8) as u64) } } #[inline] pub fn set_exclude_callchain_user(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(22usize, 1u8, val as u64) } } #[inline] pub fn mmap2(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(23usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(23usize, 1u8) as u64) } } #[inline] pub fn set_mmap2(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(23usize, 1u8, val as u64) } } #[inline] pub fn comm_exec(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(24usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(24usize, 1u8) as u64) } } #[inline] pub fn set_comm_exec(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(24usize, 1u8, val as u64) } } #[inline] pub fn use_clockid(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(25usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(25usize, 1u8) as u64) } } #[inline] pub fn set_use_clockid(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(25usize, 1u8, val as u64) } } #[inline] pub fn context_switch(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(26usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(26usize, 1u8) as u64) } } #[inline] pub fn set_context_switch(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(26usize, 1u8, val as u64) } } #[inline] pub fn write_backward(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(27usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(27usize, 1u8) as u64) } } #[inline] pub fn set_write_backward(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(27usize, 1u8, val as u64) } } #[inline] pub fn namespaces(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(28usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(28usize, 1u8) as u64) } } #[inline] pub fn set_namespaces(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(28usize, 1u8, val as u64) } } #[inline] pub fn ksymbol(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(29usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(29usize, 1u8) as u64) } } #[inline] pub fn set_ksymbol(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(29usize, 1u8, val as u64) } } #[inline] pub fn bpf_event(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(30usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(30usize, 1u8) as u64) } } #[inline] pub fn set_bpf_event(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(30usize, 1u8, val as u64) } } #[inline] pub fn aux_output(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(31usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(31usize, 1u8) as u64) } } #[inline] pub fn set_aux_output(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(31usize, 1u8, val as u64) } } #[inline] pub fn cgroup(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(32usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(32usize, 1u8) as u64) } } #[inline] pub fn set_cgroup(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(32usize, 1u8, val as u64) } } #[inline] pub fn text_poke(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(33usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(33usize, 1u8) as u64) } } #[inline] pub fn set_text_poke(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(33usize, 1u8, val as u64) } } #[inline] pub fn build_id(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(34usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(34usize, 1u8) as u64) } } #[inline] pub fn set_build_id(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(34usize, 1u8, val as u64) } } #[inline] pub fn inherit_thread(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(35usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(35usize, 1u8) as u64) } } #[inline] pub fn set_inherit_thread(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(35usize, 1u8, val as u64) } } #[inline] pub fn remove_on_exec(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(36usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(36usize, 1u8) as u64) } } #[inline] pub fn set_remove_on_exec(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(36usize, 1u8, val as u64) } } #[inline] pub fn sigtrap(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(37usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(37usize, 1u8) as u64) } } #[inline] pub fn set_sigtrap(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(37usize, 1u8, val as u64) } } #[inline] pub fn __reserved_1(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(38usize, 26u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(38usize, 26u8) as u64) } } #[inline] pub fn set___reserved_1(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(38usize, 26u8, val as u64) } } @@ -1661,157 +1661,157 @@ impl perf_event_attr { ) -> __BindgenBitfieldUnit<[u8; 8usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let disabled: u64 = unsafe { ::std::mem::transmute(disabled) }; + let disabled: u64 = unsafe { ::core::mem::transmute(disabled) }; disabled as u64 }); __bindgen_bitfield_unit.set(1usize, 1u8, { - let inherit: u64 = unsafe { ::std::mem::transmute(inherit) }; + let inherit: u64 = unsafe { ::core::mem::transmute(inherit) }; inherit as u64 }); __bindgen_bitfield_unit.set(2usize, 1u8, { - let pinned: u64 = unsafe { ::std::mem::transmute(pinned) }; + let pinned: u64 = unsafe { ::core::mem::transmute(pinned) }; pinned as u64 }); __bindgen_bitfield_unit.set(3usize, 1u8, { - let exclusive: u64 = unsafe { ::std::mem::transmute(exclusive) }; + let exclusive: u64 = unsafe { ::core::mem::transmute(exclusive) }; exclusive as u64 }); __bindgen_bitfield_unit.set(4usize, 1u8, { - let exclude_user: u64 = unsafe { ::std::mem::transmute(exclude_user) }; + let exclude_user: u64 = unsafe { ::core::mem::transmute(exclude_user) }; exclude_user as u64 }); __bindgen_bitfield_unit.set(5usize, 1u8, { - let exclude_kernel: u64 = unsafe { ::std::mem::transmute(exclude_kernel) }; + let exclude_kernel: u64 = unsafe { ::core::mem::transmute(exclude_kernel) }; exclude_kernel as u64 }); __bindgen_bitfield_unit.set(6usize, 1u8, { - let exclude_hv: u64 = unsafe { ::std::mem::transmute(exclude_hv) }; + let exclude_hv: u64 = unsafe { ::core::mem::transmute(exclude_hv) }; exclude_hv as u64 }); __bindgen_bitfield_unit.set(7usize, 1u8, { - let exclude_idle: u64 = unsafe { ::std::mem::transmute(exclude_idle) }; + let exclude_idle: u64 = unsafe { ::core::mem::transmute(exclude_idle) }; exclude_idle as u64 }); __bindgen_bitfield_unit.set(8usize, 1u8, { - let mmap: u64 = unsafe { ::std::mem::transmute(mmap) }; + let mmap: u64 = unsafe { ::core::mem::transmute(mmap) }; mmap as u64 }); __bindgen_bitfield_unit.set(9usize, 1u8, { - let comm: u64 = unsafe { ::std::mem::transmute(comm) }; + let comm: u64 = unsafe { ::core::mem::transmute(comm) }; comm as u64 }); __bindgen_bitfield_unit.set(10usize, 1u8, { - let freq: u64 = unsafe { ::std::mem::transmute(freq) }; + let freq: u64 = unsafe { ::core::mem::transmute(freq) }; freq as u64 }); __bindgen_bitfield_unit.set(11usize, 1u8, { - let inherit_stat: u64 = unsafe { ::std::mem::transmute(inherit_stat) }; + let inherit_stat: u64 = unsafe { ::core::mem::transmute(inherit_stat) }; inherit_stat as u64 }); __bindgen_bitfield_unit.set(12usize, 1u8, { - let enable_on_exec: u64 = unsafe { ::std::mem::transmute(enable_on_exec) }; + let enable_on_exec: u64 = unsafe { ::core::mem::transmute(enable_on_exec) }; enable_on_exec as u64 }); __bindgen_bitfield_unit.set(13usize, 1u8, { - let task: u64 = unsafe { ::std::mem::transmute(task) }; + let task: u64 = unsafe { ::core::mem::transmute(task) }; task as u64 }); __bindgen_bitfield_unit.set(14usize, 1u8, { - let watermark: u64 = unsafe { ::std::mem::transmute(watermark) }; + let watermark: u64 = unsafe { ::core::mem::transmute(watermark) }; watermark as u64 }); __bindgen_bitfield_unit.set(15usize, 2u8, { - let precise_ip: u64 = unsafe { ::std::mem::transmute(precise_ip) }; + let precise_ip: u64 = unsafe { ::core::mem::transmute(precise_ip) }; precise_ip as u64 }); __bindgen_bitfield_unit.set(17usize, 1u8, { - let mmap_data: u64 = unsafe { ::std::mem::transmute(mmap_data) }; + let mmap_data: u64 = unsafe { ::core::mem::transmute(mmap_data) }; mmap_data as u64 }); __bindgen_bitfield_unit.set(18usize, 1u8, { - let sample_id_all: u64 = unsafe { ::std::mem::transmute(sample_id_all) }; + let sample_id_all: u64 = unsafe { ::core::mem::transmute(sample_id_all) }; sample_id_all as u64 }); __bindgen_bitfield_unit.set(19usize, 1u8, { - let exclude_host: u64 = unsafe { ::std::mem::transmute(exclude_host) }; + let exclude_host: u64 = unsafe { ::core::mem::transmute(exclude_host) }; exclude_host as u64 }); __bindgen_bitfield_unit.set(20usize, 1u8, { - let exclude_guest: u64 = unsafe { ::std::mem::transmute(exclude_guest) }; + let exclude_guest: u64 = unsafe { ::core::mem::transmute(exclude_guest) }; exclude_guest as u64 }); __bindgen_bitfield_unit.set(21usize, 1u8, { let exclude_callchain_kernel: u64 = - unsafe { ::std::mem::transmute(exclude_callchain_kernel) }; + unsafe { ::core::mem::transmute(exclude_callchain_kernel) }; exclude_callchain_kernel as u64 }); __bindgen_bitfield_unit.set(22usize, 1u8, { let exclude_callchain_user: u64 = - unsafe { ::std::mem::transmute(exclude_callchain_user) }; + unsafe { ::core::mem::transmute(exclude_callchain_user) }; exclude_callchain_user as u64 }); __bindgen_bitfield_unit.set(23usize, 1u8, { - let mmap2: u64 = unsafe { ::std::mem::transmute(mmap2) }; + let mmap2: u64 = unsafe { ::core::mem::transmute(mmap2) }; mmap2 as u64 }); __bindgen_bitfield_unit.set(24usize, 1u8, { - let comm_exec: u64 = unsafe { ::std::mem::transmute(comm_exec) }; + let comm_exec: u64 = unsafe { ::core::mem::transmute(comm_exec) }; comm_exec as u64 }); __bindgen_bitfield_unit.set(25usize, 1u8, { - let use_clockid: u64 = unsafe { ::std::mem::transmute(use_clockid) }; + let use_clockid: u64 = unsafe { ::core::mem::transmute(use_clockid) }; use_clockid as u64 }); __bindgen_bitfield_unit.set(26usize, 1u8, { - let context_switch: u64 = unsafe { ::std::mem::transmute(context_switch) }; + let context_switch: u64 = unsafe { ::core::mem::transmute(context_switch) }; context_switch as u64 }); __bindgen_bitfield_unit.set(27usize, 1u8, { - let write_backward: u64 = unsafe { ::std::mem::transmute(write_backward) }; + let write_backward: u64 = unsafe { ::core::mem::transmute(write_backward) }; write_backward as u64 }); __bindgen_bitfield_unit.set(28usize, 1u8, { - let namespaces: u64 = unsafe { ::std::mem::transmute(namespaces) }; + let namespaces: u64 = unsafe { ::core::mem::transmute(namespaces) }; namespaces as u64 }); __bindgen_bitfield_unit.set(29usize, 1u8, { - let ksymbol: u64 = unsafe { ::std::mem::transmute(ksymbol) }; + let ksymbol: u64 = unsafe { ::core::mem::transmute(ksymbol) }; ksymbol as u64 }); __bindgen_bitfield_unit.set(30usize, 1u8, { - let bpf_event: u64 = unsafe { ::std::mem::transmute(bpf_event) }; + let bpf_event: u64 = unsafe { ::core::mem::transmute(bpf_event) }; bpf_event as u64 }); __bindgen_bitfield_unit.set(31usize, 1u8, { - let aux_output: u64 = unsafe { ::std::mem::transmute(aux_output) }; + let aux_output: u64 = unsafe { ::core::mem::transmute(aux_output) }; aux_output as u64 }); __bindgen_bitfield_unit.set(32usize, 1u8, { - let cgroup: u64 = unsafe { ::std::mem::transmute(cgroup) }; + let cgroup: u64 = unsafe { ::core::mem::transmute(cgroup) }; cgroup as u64 }); __bindgen_bitfield_unit.set(33usize, 1u8, { - let text_poke: u64 = unsafe { ::std::mem::transmute(text_poke) }; + let text_poke: u64 = unsafe { ::core::mem::transmute(text_poke) }; text_poke as u64 }); __bindgen_bitfield_unit.set(34usize, 1u8, { - let build_id: u64 = unsafe { ::std::mem::transmute(build_id) }; + let build_id: u64 = unsafe { ::core::mem::transmute(build_id) }; build_id as u64 }); __bindgen_bitfield_unit.set(35usize, 1u8, { - let inherit_thread: u64 = unsafe { ::std::mem::transmute(inherit_thread) }; + let inherit_thread: u64 = unsafe { ::core::mem::transmute(inherit_thread) }; inherit_thread as u64 }); __bindgen_bitfield_unit.set(36usize, 1u8, { - let remove_on_exec: u64 = unsafe { ::std::mem::transmute(remove_on_exec) }; + let remove_on_exec: u64 = unsafe { ::core::mem::transmute(remove_on_exec) }; remove_on_exec as u64 }); __bindgen_bitfield_unit.set(37usize, 1u8, { - let sigtrap: u64 = unsafe { ::std::mem::transmute(sigtrap) }; + let sigtrap: u64 = unsafe { ::core::mem::transmute(sigtrap) }; sigtrap as u64 }); __bindgen_bitfield_unit.set(38usize, 26u8, { - let __reserved_1: u64 = unsafe { ::std::mem::transmute(__reserved_1) }; + let __reserved_1: u64 = unsafe { ::core::mem::transmute(__reserved_1) }; __reserved_1 as u64 }); __bindgen_bitfield_unit @@ -1863,78 +1863,78 @@ pub struct perf_event_mmap_page__bindgen_ty_1__bindgen_ty_1 { impl perf_event_mmap_page__bindgen_ty_1__bindgen_ty_1 { #[inline] pub fn cap_bit0(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } } #[inline] pub fn set_cap_bit0(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } #[inline] pub fn cap_bit0_is_deprecated(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } } #[inline] pub fn set_cap_bit0_is_deprecated(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(1usize, 1u8, val as u64) } } #[inline] pub fn cap_user_rdpmc(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_rdpmc(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(2usize, 1u8, val as u64) } } #[inline] pub fn cap_user_time(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_time(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(3usize, 1u8, val as u64) } } #[inline] pub fn cap_user_time_zero(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_time_zero(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] pub fn cap_user_time_short(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_time_short(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(5usize, 1u8, val as u64) } } #[inline] pub fn cap_____res(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 58u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(6usize, 58u8) as u64) } } #[inline] pub fn set_cap_____res(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(6usize, 58u8, val as u64) } } @@ -1950,32 +1950,32 @@ impl perf_event_mmap_page__bindgen_ty_1__bindgen_ty_1 { ) -> __BindgenBitfieldUnit<[u8; 8usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let cap_bit0: u64 = unsafe { ::std::mem::transmute(cap_bit0) }; + let cap_bit0: u64 = unsafe { ::core::mem::transmute(cap_bit0) }; cap_bit0 as u64 }); __bindgen_bitfield_unit.set(1usize, 1u8, { let cap_bit0_is_deprecated: u64 = - unsafe { ::std::mem::transmute(cap_bit0_is_deprecated) }; + unsafe { ::core::mem::transmute(cap_bit0_is_deprecated) }; cap_bit0_is_deprecated as u64 }); __bindgen_bitfield_unit.set(2usize, 1u8, { - let cap_user_rdpmc: u64 = unsafe { ::std::mem::transmute(cap_user_rdpmc) }; + let cap_user_rdpmc: u64 = unsafe { ::core::mem::transmute(cap_user_rdpmc) }; cap_user_rdpmc as u64 }); __bindgen_bitfield_unit.set(3usize, 1u8, { - let cap_user_time: u64 = unsafe { ::std::mem::transmute(cap_user_time) }; + let cap_user_time: u64 = unsafe { ::core::mem::transmute(cap_user_time) }; cap_user_time as u64 }); __bindgen_bitfield_unit.set(4usize, 1u8, { - let cap_user_time_zero: u64 = unsafe { ::std::mem::transmute(cap_user_time_zero) }; + let cap_user_time_zero: u64 = unsafe { ::core::mem::transmute(cap_user_time_zero) }; cap_user_time_zero as u64 }); __bindgen_bitfield_unit.set(5usize, 1u8, { - let cap_user_time_short: u64 = unsafe { ::std::mem::transmute(cap_user_time_short) }; + let cap_user_time_short: u64 = unsafe { ::core::mem::transmute(cap_user_time_short) }; cap_user_time_short as u64 }); __bindgen_bitfield_unit.set(6usize, 58u8, { - let cap_____res: u64 = unsafe { ::std::mem::transmute(cap_____res) }; + let cap_____res: u64 = unsafe { ::core::mem::transmute(cap_____res) }; cap_____res as u64 }); __bindgen_bitfield_unit @@ -2024,59 +2024,60 @@ pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_85 = 6; pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_85 = 7; pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_85 = 8; pub const __IFLA_XDP_MAX: _bindgen_ty_85 = 9; -pub type _bindgen_ty_85 = ::std::os::raw::c_uint; +pub type _bindgen_ty_85 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { - pub ifi_family: ::std::os::raw::c_uchar, - pub __ifi_pad: ::std::os::raw::c_uchar, - pub ifi_type: ::std::os::raw::c_ushort, - pub ifi_index: ::std::os::raw::c_int, - pub ifi_flags: ::std::os::raw::c_uint, - pub ifi_change: ::std::os::raw::c_uint, + pub ifi_family: ::core::ffi::c_uchar, + pub __ifi_pad: ::core::ffi::c_uchar, + pub ifi_type: ::core::ffi::c_ushort, + pub ifi_index: ::core::ffi::c_int, + pub ifi_flags: ::core::ffi::c_uint, + pub ifi_change: ::core::ffi::c_uint, } #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct tcmsg { - pub tcm_family: ::std::os::raw::c_uchar, - pub tcm__pad1: ::std::os::raw::c_uchar, - pub tcm__pad2: ::std::os::raw::c_ushort, - pub tcm_ifindex: ::std::os::raw::c_int, + pub tcm_family: ::core::ffi::c_uchar, + pub tcm__pad1: ::core::ffi::c_uchar, + pub tcm__pad2: ::core::ffi::c_ushort, + pub tcm_ifindex: ::core::ffi::c_int, pub tcm_handle: __u32, pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_98 = 0; -pub const TCA_KIND: _bindgen_ty_98 = 1; -pub const TCA_OPTIONS: _bindgen_ty_98 = 2; -pub const TCA_STATS: _bindgen_ty_98 = 3; -pub const TCA_XSTATS: _bindgen_ty_98 = 4; -pub const TCA_RATE: _bindgen_ty_98 = 5; -pub const TCA_FCNT: _bindgen_ty_98 = 6; -pub const TCA_STATS2: _bindgen_ty_98 = 7; -pub const TCA_STAB: _bindgen_ty_98 = 8; -pub const TCA_PAD: _bindgen_ty_98 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_98 = 10; -pub const TCA_CHAIN: _bindgen_ty_98 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_98 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_98 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_98 = 14; -pub const __TCA_MAX: _bindgen_ty_98 = 15; -pub type _bindgen_ty_98 = ::std::os::raw::c_uint; -pub const TCA_BPF_UNSPEC: _bindgen_ty_154 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_154 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_154 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_154 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_154 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_154 = 5; -pub const TCA_BPF_FD: _bindgen_ty_154 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_154 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_154 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_154 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_154 = 10; -pub const TCA_BPF_ID: _bindgen_ty_154 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_154 = 12; -pub type _bindgen_ty_154 = ::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; +pub const TCA_UNSPEC: _bindgen_ty_100 = 0; +pub const TCA_KIND: _bindgen_ty_100 = 1; +pub const TCA_OPTIONS: _bindgen_ty_100 = 2; +pub const TCA_STATS: _bindgen_ty_100 = 3; +pub const TCA_XSTATS: _bindgen_ty_100 = 4; +pub const TCA_RATE: _bindgen_ty_100 = 5; +pub const TCA_FCNT: _bindgen_ty_100 = 6; +pub const TCA_STATS2: _bindgen_ty_100 = 7; +pub const TCA_STAB: _bindgen_ty_100 = 8; +pub const TCA_PAD: _bindgen_ty_100 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_100 = 10; +pub const TCA_CHAIN: _bindgen_ty_100 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_100 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_100 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_100 = 14; +pub const TCA_DUMP_FLAGS: _bindgen_ty_100 = 15; +pub const __TCA_MAX: _bindgen_ty_100 = 16; +pub type _bindgen_ty_100 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; +pub const TCA_BPF_FD: _bindgen_ty_156 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; +pub const TCA_BPF_ID: _bindgen_ty_156 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; +pub type _bindgen_ty_156 = ::core::ffi::c_uint; +pub const AYA_PERF_EVENT_IOC_ENABLE: ::core::ffi::c_int = 9216; +pub const AYA_PERF_EVENT_IOC_DISABLE: ::core::ffi::c_int = 9217; +pub const AYA_PERF_EVENT_IOC_SET_BPF: ::core::ffi::c_int = 1074013192; diff --git a/aya/src/generated/linux_bindings_x86_64.rs b/aya-obj/src/generated/linux_bindings_x86_64.rs similarity index 79% rename from aya/src/generated/linux_bindings_x86_64.rs rename to aya-obj/src/generated/linux_bindings_x86_64.rs index 60c5fab6..fab6978c 100644 --- a/aya/src/generated/linux_bindings_x86_64.rs +++ b/aya-obj/src/generated/linux_bindings_x86_64.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.60.1 */ +/* automatically generated by rust-bindgen 0.63.0 */ #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -82,11 +82,11 @@ where } #[repr(C)] #[derive(Default)] -pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); +pub struct __IncompleteArrayField(::core::marker::PhantomData, [T; 0]); impl __IncompleteArrayField { #[inline] pub const fn new() -> Self { - __IncompleteArrayField(::std::marker::PhantomData, []) + __IncompleteArrayField(::core::marker::PhantomData, []) } #[inline] pub fn as_ptr(&self) -> *const T { @@ -98,15 +98,15 @@ impl __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - ::std::slice::from_raw_parts(self.as_ptr(), len) + ::core::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + ::core::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } -impl ::std::fmt::Debug for __IncompleteArrayField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { +impl ::core::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.write_str("__IncompleteArrayField") } } @@ -173,13 +173,13 @@ pub const TC_H_MIN_PRIORITY: u32 = 65504; pub const TC_H_MIN_INGRESS: u32 = 65522; pub const TC_H_MIN_EGRESS: u32 = 65523; pub const TCA_BPF_FLAG_ACT_DIRECT: u32 = 1; -pub type __u8 = ::std::os::raw::c_uchar; -pub type __s16 = ::std::os::raw::c_short; -pub type __u16 = ::std::os::raw::c_ushort; -pub type __s32 = ::std::os::raw::c_int; -pub type __u32 = ::std::os::raw::c_uint; -pub type __s64 = ::std::os::raw::c_longlong; -pub type __u64 = ::std::os::raw::c_ulonglong; +pub type __u8 = ::core::ffi::c_uchar; +pub type __s16 = ::core::ffi::c_short; +pub type __u16 = ::core::ffi::c_ushort; +pub type __s32 = ::core::ffi::c_int; +pub type __u32 = ::core::ffi::c_uint; +pub type __s64 = ::core::ffi::c_longlong; +pub type __u64 = ::core::ffi::c_ulonglong; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_insn { @@ -192,23 +192,23 @@ pub struct bpf_insn { impl bpf_insn { #[inline] pub fn dst_reg(&self) -> __u8 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } } #[inline] pub fn set_dst_reg(&mut self, val: __u8) { unsafe { - let val: u8 = ::std::mem::transmute(val); + let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 4u8, val as u64) } } #[inline] pub fn src_reg(&self) -> __u8 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u8) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u8) } } #[inline] pub fn set_src_reg(&mut self, val: __u8) { unsafe { - let val: u8 = ::std::mem::transmute(val); + let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 4u8, val as u64) } } @@ -216,11 +216,11 @@ impl bpf_insn { pub fn new_bitfield_1(dst_reg: __u8, src_reg: __u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 4u8, { - let dst_reg: u8 = unsafe { ::std::mem::transmute(dst_reg) }; + let dst_reg: u8 = unsafe { ::core::mem::transmute(dst_reg) }; dst_reg as u64 }); __bindgen_bitfield_unit.set(4usize, 4u8, { - let src_reg: u8 = unsafe { ::std::mem::transmute(src_reg) }; + let src_reg: u8 = unsafe { ::core::mem::transmute(src_reg) }; src_reg as u64 }); __bindgen_bitfield_unit @@ -414,7 +414,7 @@ pub const BPF_ANY: _bindgen_ty_2 = 0; pub const BPF_NOEXIST: _bindgen_ty_2 = 1; pub const BPF_EXIST: _bindgen_ty_2 = 2; pub const BPF_F_LOCK: _bindgen_ty_2 = 4; -pub type _bindgen_ty_2 = ::std::os::raw::c_uint; +pub type _bindgen_ty_2 = ::core::ffi::c_uint; pub const BPF_F_NO_PREALLOC: _bindgen_ty_3 = 1; pub const BPF_F_NO_COMMON_LRU: _bindgen_ty_3 = 2; pub const BPF_F_NUMA_NODE: _bindgen_ty_3 = 4; @@ -428,7 +428,7 @@ pub const BPF_F_CLONE: _bindgen_ty_3 = 512; pub const BPF_F_MMAPABLE: _bindgen_ty_3 = 1024; pub const BPF_F_PRESERVE_ELEMS: _bindgen_ty_3 = 2048; pub const BPF_F_INNER_MAP: _bindgen_ty_3 = 4096; -pub type _bindgen_ty_3 = ::std::os::raw::c_uint; +pub type _bindgen_ty_3 = ::core::ffi::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub union bpf_attr { @@ -462,7 +462,7 @@ pub struct bpf_attr__bindgen_ty_1 { pub map_flags: __u32, pub inner_map_fd: __u32, pub numa_node: __u32, - pub map_name: [::std::os::raw::c_char; 16usize], + pub map_name: [::core::ffi::c_char; 16usize], pub map_ifindex: __u32, pub btf_fd: __u32, pub btf_key_type_id: __u32, @@ -508,7 +508,7 @@ pub struct bpf_attr__bindgen_ty_4 { pub log_buf: __u64, pub kern_version: __u32, pub prog_flags: __u32, - pub prog_name: [::std::os::raw::c_char; 16usize], + pub prog_name: [::core::ffi::c_char; 16usize], pub prog_ifindex: __u32, pub expected_attach_type: __u32, pub prog_btf_fd: __u32, @@ -711,33 +711,33 @@ pub struct bpf_attr__bindgen_ty_19 { } pub const BPF_F_RECOMPUTE_CSUM: _bindgen_ty_4 = 1; pub const BPF_F_INVALIDATE_HASH: _bindgen_ty_4 = 2; -pub type _bindgen_ty_4 = ::std::os::raw::c_uint; +pub type _bindgen_ty_4 = ::core::ffi::c_uint; pub const BPF_F_HDR_FIELD_MASK: _bindgen_ty_5 = 15; -pub type _bindgen_ty_5 = ::std::os::raw::c_uint; +pub type _bindgen_ty_5 = ::core::ffi::c_uint; pub const BPF_F_PSEUDO_HDR: _bindgen_ty_6 = 16; pub const BPF_F_MARK_MANGLED_0: _bindgen_ty_6 = 32; pub const BPF_F_MARK_ENFORCE: _bindgen_ty_6 = 64; -pub type _bindgen_ty_6 = ::std::os::raw::c_uint; +pub type _bindgen_ty_6 = ::core::ffi::c_uint; pub const BPF_F_INGRESS: _bindgen_ty_7 = 1; -pub type _bindgen_ty_7 = ::std::os::raw::c_uint; +pub type _bindgen_ty_7 = ::core::ffi::c_uint; pub const BPF_F_TUNINFO_IPV6: _bindgen_ty_8 = 1; -pub type _bindgen_ty_8 = ::std::os::raw::c_uint; +pub type _bindgen_ty_8 = ::core::ffi::c_uint; pub const BPF_F_SKIP_FIELD_MASK: _bindgen_ty_9 = 255; pub const BPF_F_USER_STACK: _bindgen_ty_9 = 256; pub const BPF_F_FAST_STACK_CMP: _bindgen_ty_9 = 512; pub const BPF_F_REUSE_STACKID: _bindgen_ty_9 = 1024; pub const BPF_F_USER_BUILD_ID: _bindgen_ty_9 = 2048; -pub type _bindgen_ty_9 = ::std::os::raw::c_uint; +pub type _bindgen_ty_9 = ::core::ffi::c_uint; pub const BPF_F_ZERO_CSUM_TX: _bindgen_ty_10 = 2; pub const BPF_F_DONT_FRAGMENT: _bindgen_ty_10 = 4; pub const BPF_F_SEQ_NUMBER: _bindgen_ty_10 = 8; -pub type _bindgen_ty_10 = ::std::os::raw::c_uint; +pub type _bindgen_ty_10 = ::core::ffi::c_uint; pub const BPF_F_INDEX_MASK: _bindgen_ty_11 = 4294967295; pub const BPF_F_CURRENT_CPU: _bindgen_ty_11 = 4294967295; pub const BPF_F_CTXLEN_MASK: _bindgen_ty_11 = 4503595332403200; -pub type _bindgen_ty_11 = ::std::os::raw::c_ulong; +pub type _bindgen_ty_11 = ::core::ffi::c_ulong; pub const BPF_F_CURRENT_NETNS: _bindgen_ty_12 = -1; -pub type _bindgen_ty_12 = ::std::os::raw::c_int; +pub type _bindgen_ty_12 = ::core::ffi::c_int; pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_14 = 1; pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_14 = 2; pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_14 = 4; @@ -745,20 +745,20 @@ pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_14 = 8; pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_14 = 16; pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_14 = 32; pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_14 = 64; -pub type _bindgen_ty_14 = ::std::os::raw::c_uint; +pub type _bindgen_ty_14 = ::core::ffi::c_uint; pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_16 = 1; -pub type _bindgen_ty_16 = ::std::os::raw::c_uint; +pub type _bindgen_ty_16 = ::core::ffi::c_uint; pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_18 = 1; -pub type _bindgen_ty_18 = ::std::os::raw::c_uint; +pub type _bindgen_ty_18 = ::core::ffi::c_uint; pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_21 = 2147483648; pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_21 = 1073741824; pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_21 = 8; -pub type _bindgen_ty_21 = ::std::os::raw::c_uint; +pub type _bindgen_ty_21 = ::core::ffi::c_uint; pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_23 = 1; -pub type _bindgen_ty_23 = ::std::os::raw::c_uint; +pub type _bindgen_ty_23 = ::core::ffi::c_uint; pub const BPF_F_BROADCAST: _bindgen_ty_24 = 8; pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_24 = 16; -pub type _bindgen_ty_24 = ::std::os::raw::c_uint; +pub type _bindgen_ty_24 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_prog_info { @@ -773,7 +773,7 @@ pub struct bpf_prog_info { pub created_by_uid: __u32, pub nr_map_ids: __u32, pub map_ids: __u64, - pub name: [::std::os::raw::c_char; 16usize], + pub name: [::core::ffi::c_char; 16usize], pub ifindex: __u32, pub _bitfield_align_1: [u8; 0], pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, @@ -805,12 +805,12 @@ pub struct bpf_prog_info { impl bpf_prog_info { #[inline] pub fn gpl_compatible(&self) -> __u32 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } } #[inline] pub fn set_gpl_compatible(&mut self, val: __u32) { unsafe { - let val: u32 = ::std::mem::transmute(val); + let val: u32 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } @@ -818,7 +818,7 @@ impl bpf_prog_info { pub fn new_bitfield_1(gpl_compatible: __u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let gpl_compatible: u32 = unsafe { ::std::mem::transmute(gpl_compatible) }; + let gpl_compatible: u32 = unsafe { ::core::mem::transmute(gpl_compatible) }; gpl_compatible as u64 }); __bindgen_bitfield_unit @@ -833,7 +833,7 @@ pub struct bpf_map_info { pub value_size: __u32, pub max_entries: __u32, pub map_flags: __u32, - pub name: [::std::os::raw::c_char; 16usize], + pub name: [::core::ffi::c_char; 16usize], pub ifindex: __u32, pub btf_vmlinux_value_type_id: __u32, pub netns_dev: __u64, @@ -988,7 +988,7 @@ pub const BTF_KIND_TYPE_TAG: _bindgen_ty_38 = 18; pub const BTF_KIND_ENUM64: _bindgen_ty_38 = 19; pub const NR_BTF_KINDS: _bindgen_ty_38 = 20; pub const BTF_KIND_MAX: _bindgen_ty_38 = 19; -pub type _bindgen_ty_38 = ::std::os::raw::c_uint; +pub type _bindgen_ty_38 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct btf_enum { @@ -1018,7 +1018,7 @@ pub struct btf_param { pub const BTF_VAR_STATIC: _bindgen_ty_39 = 0; pub const BTF_VAR_GLOBAL_ALLOCATED: _bindgen_ty_39 = 1; pub const BTF_VAR_GLOBAL_EXTERN: _bindgen_ty_39 = 2; -pub type _bindgen_ty_39 = ::std::os::raw::c_uint; +pub type _bindgen_ty_39 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum btf_func_linkage { @@ -1202,419 +1202,419 @@ pub union perf_event_attr__bindgen_ty_4 { impl perf_event_attr { #[inline] pub fn disabled(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } } #[inline] pub fn set_disabled(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } #[inline] pub fn inherit(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } } #[inline] pub fn set_inherit(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(1usize, 1u8, val as u64) } } #[inline] pub fn pinned(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } } #[inline] pub fn set_pinned(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(2usize, 1u8, val as u64) } } #[inline] pub fn exclusive(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } } #[inline] pub fn set_exclusive(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(3usize, 1u8, val as u64) } } #[inline] pub fn exclude_user(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } } #[inline] pub fn set_exclude_user(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] pub fn exclude_kernel(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } } #[inline] pub fn set_exclude_kernel(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(5usize, 1u8, val as u64) } } #[inline] pub fn exclude_hv(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u64) } } #[inline] pub fn set_exclude_hv(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(6usize, 1u8, val as u64) } } #[inline] pub fn exclude_idle(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u64) } } #[inline] pub fn set_exclude_idle(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(7usize, 1u8, val as u64) } } #[inline] pub fn mmap(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u64) } } #[inline] pub fn set_mmap(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(8usize, 1u8, val as u64) } } #[inline] pub fn comm(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u64) } } #[inline] pub fn set_comm(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(9usize, 1u8, val as u64) } } #[inline] pub fn freq(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u64) } } #[inline] pub fn set_freq(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(10usize, 1u8, val as u64) } } #[inline] pub fn inherit_stat(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u64) } } #[inline] pub fn set_inherit_stat(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(11usize, 1u8, val as u64) } } #[inline] pub fn enable_on_exec(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u64) } } #[inline] pub fn set_enable_on_exec(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(12usize, 1u8, val as u64) } } #[inline] pub fn task(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u64) } } #[inline] pub fn set_task(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(13usize, 1u8, val as u64) } } #[inline] pub fn watermark(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u64) } } #[inline] pub fn set_watermark(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(14usize, 1u8, val as u64) } } #[inline] pub fn precise_ip(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 2u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(15usize, 2u8) as u64) } } #[inline] pub fn set_precise_ip(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(15usize, 2u8, val as u64) } } #[inline] pub fn mmap_data(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(17usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(17usize, 1u8) as u64) } } #[inline] pub fn set_mmap_data(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(17usize, 1u8, val as u64) } } #[inline] pub fn sample_id_all(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(18usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(18usize, 1u8) as u64) } } #[inline] pub fn set_sample_id_all(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(18usize, 1u8, val as u64) } } #[inline] pub fn exclude_host(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(19usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(19usize, 1u8) as u64) } } #[inline] pub fn set_exclude_host(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(19usize, 1u8, val as u64) } } #[inline] pub fn exclude_guest(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(20usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(20usize, 1u8) as u64) } } #[inline] pub fn set_exclude_guest(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(20usize, 1u8, val as u64) } } #[inline] pub fn exclude_callchain_kernel(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(21usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(21usize, 1u8) as u64) } } #[inline] pub fn set_exclude_callchain_kernel(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(21usize, 1u8, val as u64) } } #[inline] pub fn exclude_callchain_user(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(22usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(22usize, 1u8) as u64) } } #[inline] pub fn set_exclude_callchain_user(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(22usize, 1u8, val as u64) } } #[inline] pub fn mmap2(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(23usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(23usize, 1u8) as u64) } } #[inline] pub fn set_mmap2(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(23usize, 1u8, val as u64) } } #[inline] pub fn comm_exec(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(24usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(24usize, 1u8) as u64) } } #[inline] pub fn set_comm_exec(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(24usize, 1u8, val as u64) } } #[inline] pub fn use_clockid(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(25usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(25usize, 1u8) as u64) } } #[inline] pub fn set_use_clockid(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(25usize, 1u8, val as u64) } } #[inline] pub fn context_switch(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(26usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(26usize, 1u8) as u64) } } #[inline] pub fn set_context_switch(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(26usize, 1u8, val as u64) } } #[inline] pub fn write_backward(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(27usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(27usize, 1u8) as u64) } } #[inline] pub fn set_write_backward(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(27usize, 1u8, val as u64) } } #[inline] pub fn namespaces(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(28usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(28usize, 1u8) as u64) } } #[inline] pub fn set_namespaces(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(28usize, 1u8, val as u64) } } #[inline] pub fn ksymbol(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(29usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(29usize, 1u8) as u64) } } #[inline] pub fn set_ksymbol(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(29usize, 1u8, val as u64) } } #[inline] pub fn bpf_event(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(30usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(30usize, 1u8) as u64) } } #[inline] pub fn set_bpf_event(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(30usize, 1u8, val as u64) } } #[inline] pub fn aux_output(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(31usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(31usize, 1u8) as u64) } } #[inline] pub fn set_aux_output(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(31usize, 1u8, val as u64) } } #[inline] pub fn cgroup(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(32usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(32usize, 1u8) as u64) } } #[inline] pub fn set_cgroup(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(32usize, 1u8, val as u64) } } #[inline] pub fn text_poke(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(33usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(33usize, 1u8) as u64) } } #[inline] pub fn set_text_poke(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(33usize, 1u8, val as u64) } } #[inline] pub fn build_id(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(34usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(34usize, 1u8) as u64) } } #[inline] pub fn set_build_id(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(34usize, 1u8, val as u64) } } #[inline] pub fn inherit_thread(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(35usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(35usize, 1u8) as u64) } } #[inline] pub fn set_inherit_thread(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(35usize, 1u8, val as u64) } } #[inline] pub fn remove_on_exec(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(36usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(36usize, 1u8) as u64) } } #[inline] pub fn set_remove_on_exec(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(36usize, 1u8, val as u64) } } #[inline] pub fn sigtrap(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(37usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(37usize, 1u8) as u64) } } #[inline] pub fn set_sigtrap(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(37usize, 1u8, val as u64) } } #[inline] pub fn __reserved_1(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(38usize, 26u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(38usize, 26u8) as u64) } } #[inline] pub fn set___reserved_1(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(38usize, 26u8, val as u64) } } @@ -1661,157 +1661,157 @@ impl perf_event_attr { ) -> __BindgenBitfieldUnit<[u8; 8usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let disabled: u64 = unsafe { ::std::mem::transmute(disabled) }; + let disabled: u64 = unsafe { ::core::mem::transmute(disabled) }; disabled as u64 }); __bindgen_bitfield_unit.set(1usize, 1u8, { - let inherit: u64 = unsafe { ::std::mem::transmute(inherit) }; + let inherit: u64 = unsafe { ::core::mem::transmute(inherit) }; inherit as u64 }); __bindgen_bitfield_unit.set(2usize, 1u8, { - let pinned: u64 = unsafe { ::std::mem::transmute(pinned) }; + let pinned: u64 = unsafe { ::core::mem::transmute(pinned) }; pinned as u64 }); __bindgen_bitfield_unit.set(3usize, 1u8, { - let exclusive: u64 = unsafe { ::std::mem::transmute(exclusive) }; + let exclusive: u64 = unsafe { ::core::mem::transmute(exclusive) }; exclusive as u64 }); __bindgen_bitfield_unit.set(4usize, 1u8, { - let exclude_user: u64 = unsafe { ::std::mem::transmute(exclude_user) }; + let exclude_user: u64 = unsafe { ::core::mem::transmute(exclude_user) }; exclude_user as u64 }); __bindgen_bitfield_unit.set(5usize, 1u8, { - let exclude_kernel: u64 = unsafe { ::std::mem::transmute(exclude_kernel) }; + let exclude_kernel: u64 = unsafe { ::core::mem::transmute(exclude_kernel) }; exclude_kernel as u64 }); __bindgen_bitfield_unit.set(6usize, 1u8, { - let exclude_hv: u64 = unsafe { ::std::mem::transmute(exclude_hv) }; + let exclude_hv: u64 = unsafe { ::core::mem::transmute(exclude_hv) }; exclude_hv as u64 }); __bindgen_bitfield_unit.set(7usize, 1u8, { - let exclude_idle: u64 = unsafe { ::std::mem::transmute(exclude_idle) }; + let exclude_idle: u64 = unsafe { ::core::mem::transmute(exclude_idle) }; exclude_idle as u64 }); __bindgen_bitfield_unit.set(8usize, 1u8, { - let mmap: u64 = unsafe { ::std::mem::transmute(mmap) }; + let mmap: u64 = unsafe { ::core::mem::transmute(mmap) }; mmap as u64 }); __bindgen_bitfield_unit.set(9usize, 1u8, { - let comm: u64 = unsafe { ::std::mem::transmute(comm) }; + let comm: u64 = unsafe { ::core::mem::transmute(comm) }; comm as u64 }); __bindgen_bitfield_unit.set(10usize, 1u8, { - let freq: u64 = unsafe { ::std::mem::transmute(freq) }; + let freq: u64 = unsafe { ::core::mem::transmute(freq) }; freq as u64 }); __bindgen_bitfield_unit.set(11usize, 1u8, { - let inherit_stat: u64 = unsafe { ::std::mem::transmute(inherit_stat) }; + let inherit_stat: u64 = unsafe { ::core::mem::transmute(inherit_stat) }; inherit_stat as u64 }); __bindgen_bitfield_unit.set(12usize, 1u8, { - let enable_on_exec: u64 = unsafe { ::std::mem::transmute(enable_on_exec) }; + let enable_on_exec: u64 = unsafe { ::core::mem::transmute(enable_on_exec) }; enable_on_exec as u64 }); __bindgen_bitfield_unit.set(13usize, 1u8, { - let task: u64 = unsafe { ::std::mem::transmute(task) }; + let task: u64 = unsafe { ::core::mem::transmute(task) }; task as u64 }); __bindgen_bitfield_unit.set(14usize, 1u8, { - let watermark: u64 = unsafe { ::std::mem::transmute(watermark) }; + let watermark: u64 = unsafe { ::core::mem::transmute(watermark) }; watermark as u64 }); __bindgen_bitfield_unit.set(15usize, 2u8, { - let precise_ip: u64 = unsafe { ::std::mem::transmute(precise_ip) }; + let precise_ip: u64 = unsafe { ::core::mem::transmute(precise_ip) }; precise_ip as u64 }); __bindgen_bitfield_unit.set(17usize, 1u8, { - let mmap_data: u64 = unsafe { ::std::mem::transmute(mmap_data) }; + let mmap_data: u64 = unsafe { ::core::mem::transmute(mmap_data) }; mmap_data as u64 }); __bindgen_bitfield_unit.set(18usize, 1u8, { - let sample_id_all: u64 = unsafe { ::std::mem::transmute(sample_id_all) }; + let sample_id_all: u64 = unsafe { ::core::mem::transmute(sample_id_all) }; sample_id_all as u64 }); __bindgen_bitfield_unit.set(19usize, 1u8, { - let exclude_host: u64 = unsafe { ::std::mem::transmute(exclude_host) }; + let exclude_host: u64 = unsafe { ::core::mem::transmute(exclude_host) }; exclude_host as u64 }); __bindgen_bitfield_unit.set(20usize, 1u8, { - let exclude_guest: u64 = unsafe { ::std::mem::transmute(exclude_guest) }; + let exclude_guest: u64 = unsafe { ::core::mem::transmute(exclude_guest) }; exclude_guest as u64 }); __bindgen_bitfield_unit.set(21usize, 1u8, { let exclude_callchain_kernel: u64 = - unsafe { ::std::mem::transmute(exclude_callchain_kernel) }; + unsafe { ::core::mem::transmute(exclude_callchain_kernel) }; exclude_callchain_kernel as u64 }); __bindgen_bitfield_unit.set(22usize, 1u8, { let exclude_callchain_user: u64 = - unsafe { ::std::mem::transmute(exclude_callchain_user) }; + unsafe { ::core::mem::transmute(exclude_callchain_user) }; exclude_callchain_user as u64 }); __bindgen_bitfield_unit.set(23usize, 1u8, { - let mmap2: u64 = unsafe { ::std::mem::transmute(mmap2) }; + let mmap2: u64 = unsafe { ::core::mem::transmute(mmap2) }; mmap2 as u64 }); __bindgen_bitfield_unit.set(24usize, 1u8, { - let comm_exec: u64 = unsafe { ::std::mem::transmute(comm_exec) }; + let comm_exec: u64 = unsafe { ::core::mem::transmute(comm_exec) }; comm_exec as u64 }); __bindgen_bitfield_unit.set(25usize, 1u8, { - let use_clockid: u64 = unsafe { ::std::mem::transmute(use_clockid) }; + let use_clockid: u64 = unsafe { ::core::mem::transmute(use_clockid) }; use_clockid as u64 }); __bindgen_bitfield_unit.set(26usize, 1u8, { - let context_switch: u64 = unsafe { ::std::mem::transmute(context_switch) }; + let context_switch: u64 = unsafe { ::core::mem::transmute(context_switch) }; context_switch as u64 }); __bindgen_bitfield_unit.set(27usize, 1u8, { - let write_backward: u64 = unsafe { ::std::mem::transmute(write_backward) }; + let write_backward: u64 = unsafe { ::core::mem::transmute(write_backward) }; write_backward as u64 }); __bindgen_bitfield_unit.set(28usize, 1u8, { - let namespaces: u64 = unsafe { ::std::mem::transmute(namespaces) }; + let namespaces: u64 = unsafe { ::core::mem::transmute(namespaces) }; namespaces as u64 }); __bindgen_bitfield_unit.set(29usize, 1u8, { - let ksymbol: u64 = unsafe { ::std::mem::transmute(ksymbol) }; + let ksymbol: u64 = unsafe { ::core::mem::transmute(ksymbol) }; ksymbol as u64 }); __bindgen_bitfield_unit.set(30usize, 1u8, { - let bpf_event: u64 = unsafe { ::std::mem::transmute(bpf_event) }; + let bpf_event: u64 = unsafe { ::core::mem::transmute(bpf_event) }; bpf_event as u64 }); __bindgen_bitfield_unit.set(31usize, 1u8, { - let aux_output: u64 = unsafe { ::std::mem::transmute(aux_output) }; + let aux_output: u64 = unsafe { ::core::mem::transmute(aux_output) }; aux_output as u64 }); __bindgen_bitfield_unit.set(32usize, 1u8, { - let cgroup: u64 = unsafe { ::std::mem::transmute(cgroup) }; + let cgroup: u64 = unsafe { ::core::mem::transmute(cgroup) }; cgroup as u64 }); __bindgen_bitfield_unit.set(33usize, 1u8, { - let text_poke: u64 = unsafe { ::std::mem::transmute(text_poke) }; + let text_poke: u64 = unsafe { ::core::mem::transmute(text_poke) }; text_poke as u64 }); __bindgen_bitfield_unit.set(34usize, 1u8, { - let build_id: u64 = unsafe { ::std::mem::transmute(build_id) }; + let build_id: u64 = unsafe { ::core::mem::transmute(build_id) }; build_id as u64 }); __bindgen_bitfield_unit.set(35usize, 1u8, { - let inherit_thread: u64 = unsafe { ::std::mem::transmute(inherit_thread) }; + let inherit_thread: u64 = unsafe { ::core::mem::transmute(inherit_thread) }; inherit_thread as u64 }); __bindgen_bitfield_unit.set(36usize, 1u8, { - let remove_on_exec: u64 = unsafe { ::std::mem::transmute(remove_on_exec) }; + let remove_on_exec: u64 = unsafe { ::core::mem::transmute(remove_on_exec) }; remove_on_exec as u64 }); __bindgen_bitfield_unit.set(37usize, 1u8, { - let sigtrap: u64 = unsafe { ::std::mem::transmute(sigtrap) }; + let sigtrap: u64 = unsafe { ::core::mem::transmute(sigtrap) }; sigtrap as u64 }); __bindgen_bitfield_unit.set(38usize, 26u8, { - let __reserved_1: u64 = unsafe { ::std::mem::transmute(__reserved_1) }; + let __reserved_1: u64 = unsafe { ::core::mem::transmute(__reserved_1) }; __reserved_1 as u64 }); __bindgen_bitfield_unit @@ -1863,78 +1863,78 @@ pub struct perf_event_mmap_page__bindgen_ty_1__bindgen_ty_1 { impl perf_event_mmap_page__bindgen_ty_1__bindgen_ty_1 { #[inline] pub fn cap_bit0(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u64) } } #[inline] pub fn set_cap_bit0(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } #[inline] pub fn cap_bit0_is_deprecated(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u64) } } #[inline] pub fn set_cap_bit0_is_deprecated(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(1usize, 1u8, val as u64) } } #[inline] pub fn cap_user_rdpmc(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_rdpmc(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(2usize, 1u8, val as u64) } } #[inline] pub fn cap_user_time(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_time(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(3usize, 1u8, val as u64) } } #[inline] pub fn cap_user_time_zero(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_time_zero(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] pub fn cap_user_time_short(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u64) } } #[inline] pub fn set_cap_user_time_short(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(5usize, 1u8, val as u64) } } #[inline] pub fn cap_____res(&self) -> __u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 58u8) as u64) } + unsafe { ::core::mem::transmute(self._bitfield_1.get(6usize, 58u8) as u64) } } #[inline] pub fn set_cap_____res(&mut self, val: __u64) { unsafe { - let val: u64 = ::std::mem::transmute(val); + let val: u64 = ::core::mem::transmute(val); self._bitfield_1.set(6usize, 58u8, val as u64) } } @@ -1950,32 +1950,32 @@ impl perf_event_mmap_page__bindgen_ty_1__bindgen_ty_1 { ) -> __BindgenBitfieldUnit<[u8; 8usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let cap_bit0: u64 = unsafe { ::std::mem::transmute(cap_bit0) }; + let cap_bit0: u64 = unsafe { ::core::mem::transmute(cap_bit0) }; cap_bit0 as u64 }); __bindgen_bitfield_unit.set(1usize, 1u8, { let cap_bit0_is_deprecated: u64 = - unsafe { ::std::mem::transmute(cap_bit0_is_deprecated) }; + unsafe { ::core::mem::transmute(cap_bit0_is_deprecated) }; cap_bit0_is_deprecated as u64 }); __bindgen_bitfield_unit.set(2usize, 1u8, { - let cap_user_rdpmc: u64 = unsafe { ::std::mem::transmute(cap_user_rdpmc) }; + let cap_user_rdpmc: u64 = unsafe { ::core::mem::transmute(cap_user_rdpmc) }; cap_user_rdpmc as u64 }); __bindgen_bitfield_unit.set(3usize, 1u8, { - let cap_user_time: u64 = unsafe { ::std::mem::transmute(cap_user_time) }; + let cap_user_time: u64 = unsafe { ::core::mem::transmute(cap_user_time) }; cap_user_time as u64 }); __bindgen_bitfield_unit.set(4usize, 1u8, { - let cap_user_time_zero: u64 = unsafe { ::std::mem::transmute(cap_user_time_zero) }; + let cap_user_time_zero: u64 = unsafe { ::core::mem::transmute(cap_user_time_zero) }; cap_user_time_zero as u64 }); __bindgen_bitfield_unit.set(5usize, 1u8, { - let cap_user_time_short: u64 = unsafe { ::std::mem::transmute(cap_user_time_short) }; + let cap_user_time_short: u64 = unsafe { ::core::mem::transmute(cap_user_time_short) }; cap_user_time_short as u64 }); __bindgen_bitfield_unit.set(6usize, 58u8, { - let cap_____res: u64 = unsafe { ::std::mem::transmute(cap_____res) }; + let cap_____res: u64 = unsafe { ::core::mem::transmute(cap_____res) }; cap_____res as u64 }); __bindgen_bitfield_unit @@ -2024,59 +2024,60 @@ pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_85 = 6; pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_85 = 7; pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_85 = 8; pub const __IFLA_XDP_MAX: _bindgen_ty_85 = 9; -pub type _bindgen_ty_85 = ::std::os::raw::c_uint; +pub type _bindgen_ty_85 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { - pub ifi_family: ::std::os::raw::c_uchar, - pub __ifi_pad: ::std::os::raw::c_uchar, - pub ifi_type: ::std::os::raw::c_ushort, - pub ifi_index: ::std::os::raw::c_int, - pub ifi_flags: ::std::os::raw::c_uint, - pub ifi_change: ::std::os::raw::c_uint, + pub ifi_family: ::core::ffi::c_uchar, + pub __ifi_pad: ::core::ffi::c_uchar, + pub ifi_type: ::core::ffi::c_ushort, + pub ifi_index: ::core::ffi::c_int, + pub ifi_flags: ::core::ffi::c_uint, + pub ifi_change: ::core::ffi::c_uint, } #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct tcmsg { - pub tcm_family: ::std::os::raw::c_uchar, - pub tcm__pad1: ::std::os::raw::c_uchar, - pub tcm__pad2: ::std::os::raw::c_ushort, - pub tcm_ifindex: ::std::os::raw::c_int, + pub tcm_family: ::core::ffi::c_uchar, + pub tcm__pad1: ::core::ffi::c_uchar, + pub tcm__pad2: ::core::ffi::c_ushort, + pub tcm_ifindex: ::core::ffi::c_int, pub tcm_handle: __u32, pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_98 = 0; -pub const TCA_KIND: _bindgen_ty_98 = 1; -pub const TCA_OPTIONS: _bindgen_ty_98 = 2; -pub const TCA_STATS: _bindgen_ty_98 = 3; -pub const TCA_XSTATS: _bindgen_ty_98 = 4; -pub const TCA_RATE: _bindgen_ty_98 = 5; -pub const TCA_FCNT: _bindgen_ty_98 = 6; -pub const TCA_STATS2: _bindgen_ty_98 = 7; -pub const TCA_STAB: _bindgen_ty_98 = 8; -pub const TCA_PAD: _bindgen_ty_98 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_98 = 10; -pub const TCA_CHAIN: _bindgen_ty_98 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_98 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_98 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_98 = 14; -pub const __TCA_MAX: _bindgen_ty_98 = 15; -pub type _bindgen_ty_98 = ::std::os::raw::c_uint; -pub const TCA_BPF_UNSPEC: _bindgen_ty_154 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_154 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_154 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_154 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_154 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_154 = 5; -pub const TCA_BPF_FD: _bindgen_ty_154 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_154 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_154 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_154 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_154 = 10; -pub const TCA_BPF_ID: _bindgen_ty_154 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_154 = 12; -pub type _bindgen_ty_154 = ::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; +pub const TCA_UNSPEC: _bindgen_ty_100 = 0; +pub const TCA_KIND: _bindgen_ty_100 = 1; +pub const TCA_OPTIONS: _bindgen_ty_100 = 2; +pub const TCA_STATS: _bindgen_ty_100 = 3; +pub const TCA_XSTATS: _bindgen_ty_100 = 4; +pub const TCA_RATE: _bindgen_ty_100 = 5; +pub const TCA_FCNT: _bindgen_ty_100 = 6; +pub const TCA_STATS2: _bindgen_ty_100 = 7; +pub const TCA_STAB: _bindgen_ty_100 = 8; +pub const TCA_PAD: _bindgen_ty_100 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_100 = 10; +pub const TCA_CHAIN: _bindgen_ty_100 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_100 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_100 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_100 = 14; +pub const TCA_DUMP_FLAGS: _bindgen_ty_100 = 15; +pub const __TCA_MAX: _bindgen_ty_100 = 16; +pub type _bindgen_ty_100 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; +pub const TCA_BPF_FD: _bindgen_ty_156 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; +pub const TCA_BPF_ID: _bindgen_ty_156 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; +pub type _bindgen_ty_156 = ::core::ffi::c_uint; +pub const AYA_PERF_EVENT_IOC_ENABLE: ::core::ffi::c_int = 9216; +pub const AYA_PERF_EVENT_IOC_DISABLE: ::core::ffi::c_int = 9217; +pub const AYA_PERF_EVENT_IOC_SET_BPF: ::core::ffi::c_int = 1074013192; diff --git a/aya-obj/src/generated/mod.rs b/aya-obj/src/generated/mod.rs new file mode 100644 index 00000000..4153c2e8 --- /dev/null +++ b/aya-obj/src/generated/mod.rs @@ -0,0 +1,86 @@ +//! eBPF bindings generated by rust-bindgen + +#![allow( + dead_code, + non_camel_case_types, + non_snake_case, + clippy::all, + missing_docs +)] + +mod btf_internal_bindings; +#[cfg(target_arch = "aarch64")] +mod linux_bindings_aarch64; +#[cfg(target_arch = "arm")] +mod linux_bindings_armv7; +#[cfg(target_arch = "riscv64")] +mod linux_bindings_riscv64; +#[cfg(target_arch = "x86_64")] +mod linux_bindings_x86_64; + +pub use btf_internal_bindings::*; + +#[cfg(target_arch = "x86_64")] +pub use linux_bindings_x86_64::*; + +#[cfg(target_arch = "arm")] +pub use linux_bindings_armv7::*; + +#[cfg(target_arch = "aarch64")] +pub use linux_bindings_aarch64::*; + +#[cfg(target_arch = "riscv64")] +pub use linux_bindings_riscv64::*; + +pub mod maps { + /// Invalid map type encontered + pub struct InvalidMapTypeError { + /// The map type + pub map_type: u32, + } + + impl TryFrom for super::bpf_map_type { + type Error = InvalidMapTypeError; + + fn try_from(map_type: u32) -> Result { + use super::bpf_map_type::*; + Ok(match map_type { + x if x == BPF_MAP_TYPE_UNSPEC as u32 => BPF_MAP_TYPE_UNSPEC, + x if x == BPF_MAP_TYPE_HASH as u32 => BPF_MAP_TYPE_HASH, + x if x == BPF_MAP_TYPE_ARRAY as u32 => BPF_MAP_TYPE_ARRAY, + x if x == BPF_MAP_TYPE_PROG_ARRAY as u32 => BPF_MAP_TYPE_PROG_ARRAY, + x if x == BPF_MAP_TYPE_PERF_EVENT_ARRAY as u32 => BPF_MAP_TYPE_PERF_EVENT_ARRAY, + x if x == BPF_MAP_TYPE_PERCPU_HASH as u32 => BPF_MAP_TYPE_PERCPU_HASH, + x if x == BPF_MAP_TYPE_PERCPU_ARRAY as u32 => BPF_MAP_TYPE_PERCPU_ARRAY, + x if x == BPF_MAP_TYPE_STACK_TRACE as u32 => BPF_MAP_TYPE_STACK_TRACE, + x if x == BPF_MAP_TYPE_CGROUP_ARRAY as u32 => BPF_MAP_TYPE_CGROUP_ARRAY, + x if x == BPF_MAP_TYPE_LRU_HASH as u32 => BPF_MAP_TYPE_LRU_HASH, + x if x == BPF_MAP_TYPE_LRU_PERCPU_HASH as u32 => BPF_MAP_TYPE_LRU_PERCPU_HASH, + x if x == BPF_MAP_TYPE_LPM_TRIE as u32 => BPF_MAP_TYPE_LPM_TRIE, + x if x == BPF_MAP_TYPE_BLOOM_FILTER as u32 => BPF_MAP_TYPE_BLOOM_FILTER, + x if x == BPF_MAP_TYPE_ARRAY_OF_MAPS as u32 => BPF_MAP_TYPE_ARRAY_OF_MAPS, + x if x == BPF_MAP_TYPE_HASH_OF_MAPS as u32 => BPF_MAP_TYPE_HASH_OF_MAPS, + x if x == BPF_MAP_TYPE_DEVMAP as u32 => BPF_MAP_TYPE_DEVMAP, + x if x == BPF_MAP_TYPE_SOCKMAP as u32 => BPF_MAP_TYPE_SOCKMAP, + x if x == BPF_MAP_TYPE_CPUMAP as u32 => BPF_MAP_TYPE_CPUMAP, + x if x == BPF_MAP_TYPE_XSKMAP as u32 => BPF_MAP_TYPE_XSKMAP, + x if x == BPF_MAP_TYPE_SOCKHASH as u32 => BPF_MAP_TYPE_SOCKHASH, + x if x == BPF_MAP_TYPE_CGROUP_STORAGE as u32 => BPF_MAP_TYPE_CGROUP_STORAGE, + x if x == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY as u32 => BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, + x if x == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE as u32 => { + BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE + } + x if x == BPF_MAP_TYPE_QUEUE as u32 => BPF_MAP_TYPE_QUEUE, + x if x == BPF_MAP_TYPE_STACK as u32 => BPF_MAP_TYPE_STACK, + x if x == BPF_MAP_TYPE_SK_STORAGE as u32 => BPF_MAP_TYPE_SK_STORAGE, + x if x == BPF_MAP_TYPE_DEVMAP_HASH as u32 => BPF_MAP_TYPE_DEVMAP_HASH, + x if x == BPF_MAP_TYPE_STRUCT_OPS as u32 => BPF_MAP_TYPE_STRUCT_OPS, + x if x == BPF_MAP_TYPE_RINGBUF as u32 => BPF_MAP_TYPE_RINGBUF, + x if x == BPF_MAP_TYPE_INODE_STORAGE as u32 => BPF_MAP_TYPE_INODE_STORAGE, + x if x == BPF_MAP_TYPE_TASK_STORAGE as u32 => BPF_MAP_TYPE_TASK_STORAGE, + _ => return Err(InvalidMapTypeError { map_type }), + }) + } + } +} + diff --git a/aya-obj/src/lib.rs b/aya-obj/src/lib.rs new file mode 100644 index 00000000..5302fbe6 --- /dev/null +++ b/aya-obj/src/lib.rs @@ -0,0 +1,12 @@ +//! A library for loading and relocating eBPF object files. + +#![no_std] +#![doc( + html_logo_url = "https://aya-rs.dev/assets/images/crabby.svg", + html_favicon_url = "https://aya-rs.dev/assets/images/crabby.svg" +)] +#![cfg_attr(docsrs, feature(doc_cfg))] +#![deny(clippy::all, missing_docs)] +#![allow(clippy::missing_safety_doc, clippy::len_without_is_empty)] + +pub mod generated; diff --git a/aya-tool/src/bindgen.rs b/aya-tool/src/bindgen.rs index 45a6062f..2d710534 100644 --- a/aya-tool/src/bindgen.rs +++ b/aya-tool/src/bindgen.rs @@ -2,6 +2,7 @@ use bindgen::{self, Builder, EnumVariation}; pub fn user_builder() -> Builder { bindgen::builder() + .use_core() .layout_tests(false) .generate_comments(false) .prepend_enum_name(false) diff --git a/aya/Cargo.toml b/aya/Cargo.toml index 996948a7..ed413621 100644 --- a/aya/Cargo.toml +++ b/aya/Cargo.toml @@ -12,6 +12,7 @@ edition = "2021" [dependencies] libc = { version = "0.2.105" } +aya-obj = { path = "../aya-obj", version = "0.11.0" } thiserror = "1" object = { version = "0.30", default-features = false, features = ["std", "read_core", "elf"] } bitflags = "1.2.1" diff --git a/aya/src/bpf.rs b/aya/src/bpf.rs index d81ff9fd..f9e209c6 100644 --- a/aya/src/bpf.rs +++ b/aya/src/bpf.rs @@ -655,7 +655,10 @@ impl<'a> BpfLoader<'a> { fn parse_map(data: (String, MapData)) -> Result<(String, Map), BpfError> { let name = data.0; let map = data.1; - let map_type = bpf_map_type::try_from(map.obj.map_type())?; + let map_type = + bpf_map_type::try_from(map.obj.map_type()).map_err(|e| MapError::InvalidMapType { + map_type: e.map_type, + })?; let map = match map_type { BPF_MAP_TYPE_ARRAY => Ok(Map::Array(map)), BPF_MAP_TYPE_PERCPU_ARRAY => Ok(Map::PerCpuArray(map)), diff --git a/aya/src/generated/mod.rs b/aya/src/generated/mod.rs deleted file mode 100644 index 54a99ffc..00000000 --- a/aya/src/generated/mod.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![allow( - dead_code, - non_camel_case_types, - non_snake_case, - clippy::all, - missing_docs -)] - -mod btf_internal_bindings; -#[cfg(target_arch = "aarch64")] -mod linux_bindings_aarch64; -#[cfg(target_arch = "arm")] -mod linux_bindings_armv7; -#[cfg(target_arch = "riscv64")] -mod linux_bindings_riscv64; -#[cfg(target_arch = "x86_64")] -mod linux_bindings_x86_64; - -pub use btf_internal_bindings::*; - -#[cfg(target_arch = "x86_64")] -pub use linux_bindings_x86_64::*; - -#[cfg(target_arch = "arm")] -pub use linux_bindings_armv7::*; - -#[cfg(target_arch = "aarch64")] -pub use linux_bindings_aarch64::*; - -#[cfg(target_arch = "riscv64")] -pub use linux_bindings_riscv64::*; diff --git a/aya/src/lib.rs b/aya/src/lib.rs index 14f3eb2d..8d235095 100644 --- a/aya/src/lib.rs +++ b/aya/src/lib.rs @@ -46,7 +46,7 @@ extern crate lazy_static; extern crate bitflags; mod bpf; -mod generated; +use aya_obj::generated as generated; pub mod maps; mod obj; pub mod pin; diff --git a/aya/src/maps/mod.rs b/aya/src/maps/mod.rs index 0b8c2865..783cc3db 100644 --- a/aya/src/maps/mod.rs +++ b/aya/src/maps/mod.rs @@ -53,7 +53,6 @@ use log::warn; use thiserror::Error; use crate::{ - generated::bpf_map_type, obj::{self, parse_map_info}, pin::PinError, sys::{ @@ -739,50 +738,6 @@ impl> Iterator for MapIter<'_, K, V, I> { } } -impl TryFrom for bpf_map_type { - type Error = MapError; - - fn try_from(map_type: u32) -> Result { - use bpf_map_type::*; - Ok(match map_type { - x if x == BPF_MAP_TYPE_UNSPEC as u32 => BPF_MAP_TYPE_UNSPEC, - x if x == BPF_MAP_TYPE_HASH as u32 => BPF_MAP_TYPE_HASH, - x if x == BPF_MAP_TYPE_ARRAY as u32 => BPF_MAP_TYPE_ARRAY, - x if x == BPF_MAP_TYPE_PROG_ARRAY as u32 => BPF_MAP_TYPE_PROG_ARRAY, - x if x == BPF_MAP_TYPE_PERF_EVENT_ARRAY as u32 => BPF_MAP_TYPE_PERF_EVENT_ARRAY, - x if x == BPF_MAP_TYPE_PERCPU_HASH as u32 => BPF_MAP_TYPE_PERCPU_HASH, - x if x == BPF_MAP_TYPE_PERCPU_ARRAY as u32 => BPF_MAP_TYPE_PERCPU_ARRAY, - x if x == BPF_MAP_TYPE_STACK_TRACE as u32 => BPF_MAP_TYPE_STACK_TRACE, - x if x == BPF_MAP_TYPE_CGROUP_ARRAY as u32 => BPF_MAP_TYPE_CGROUP_ARRAY, - x if x == BPF_MAP_TYPE_LRU_HASH as u32 => BPF_MAP_TYPE_LRU_HASH, - x if x == BPF_MAP_TYPE_LRU_PERCPU_HASH as u32 => BPF_MAP_TYPE_LRU_PERCPU_HASH, - x if x == BPF_MAP_TYPE_LPM_TRIE as u32 => BPF_MAP_TYPE_LPM_TRIE, - x if x == BPF_MAP_TYPE_BLOOM_FILTER as u32 => BPF_MAP_TYPE_BLOOM_FILTER, - x if x == BPF_MAP_TYPE_ARRAY_OF_MAPS as u32 => BPF_MAP_TYPE_ARRAY_OF_MAPS, - x if x == BPF_MAP_TYPE_HASH_OF_MAPS as u32 => BPF_MAP_TYPE_HASH_OF_MAPS, - x if x == BPF_MAP_TYPE_DEVMAP as u32 => BPF_MAP_TYPE_DEVMAP, - x if x == BPF_MAP_TYPE_SOCKMAP as u32 => BPF_MAP_TYPE_SOCKMAP, - x if x == BPF_MAP_TYPE_CPUMAP as u32 => BPF_MAP_TYPE_CPUMAP, - x if x == BPF_MAP_TYPE_XSKMAP as u32 => BPF_MAP_TYPE_XSKMAP, - x if x == BPF_MAP_TYPE_SOCKHASH as u32 => BPF_MAP_TYPE_SOCKHASH, - x if x == BPF_MAP_TYPE_CGROUP_STORAGE as u32 => BPF_MAP_TYPE_CGROUP_STORAGE, - x if x == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY as u32 => BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, - x if x == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE as u32 => { - BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE - } - x if x == BPF_MAP_TYPE_QUEUE as u32 => BPF_MAP_TYPE_QUEUE, - x if x == BPF_MAP_TYPE_STACK as u32 => BPF_MAP_TYPE_STACK, - x if x == BPF_MAP_TYPE_SK_STORAGE as u32 => BPF_MAP_TYPE_SK_STORAGE, - x if x == BPF_MAP_TYPE_DEVMAP_HASH as u32 => BPF_MAP_TYPE_DEVMAP_HASH, - x if x == BPF_MAP_TYPE_STRUCT_OPS as u32 => BPF_MAP_TYPE_STRUCT_OPS, - x if x == BPF_MAP_TYPE_RINGBUF as u32 => BPF_MAP_TYPE_RINGBUF, - x if x == BPF_MAP_TYPE_INODE_STORAGE as u32 => BPF_MAP_TYPE_INODE_STORAGE, - x if x == BPF_MAP_TYPE_TASK_STORAGE as u32 => BPF_MAP_TYPE_TASK_STORAGE, - _ => return Err(MapError::InvalidMapType { map_type }), - }) - } -} - pub(crate) struct PerCpuKernelMem { bytes: Vec, } diff --git a/xtask/src/codegen/aya.rs b/xtask/src/codegen/aya.rs index 5a870516..6628e772 100644 --- a/xtask/src/codegen/aya.rs +++ b/xtask/src/codegen/aya.rs @@ -11,7 +11,7 @@ pub fn codegen(opts: &Options) -> Result<(), anyhow::Error> { } fn codegen_internal_btf_bindings(opts: &Options) -> Result<(), anyhow::Error> { - let dir = PathBuf::from("aya"); + let dir = PathBuf::from("aya-obj"); let generated = dir.join("src/generated"); let mut bindgen = bindgen::user_builder() .clang_arg(format!( @@ -154,7 +154,7 @@ fn codegen_bindings(opts: &Options) -> Result<(), anyhow::Error> { "BPF_RINGBUF_.*", ]; - let dir = PathBuf::from("aya"); + let dir = PathBuf::from("aya-obj"); let generated = dir.join("src/generated"); let builder = || { From ac49827e204801079be2b87160a795ef412bd6cb Mon Sep 17 00:00:00 2001 From: Shenghui Ye Date: Tue, 27 Dec 2022 23:20:46 +0800 Subject: [PATCH 06/51] aya-obj: migrate aya::obj into a separate crate To split the crate into two, several changes were made: 1. Most `pub(crate)` are now `pub` to allow access from Aya; 2. Parts of BpfError are merged into, for example, RelocationError; 3. BTF part of Features is moved into the new crate; 4. `#![deny(missing_docs)]` is removed temporarily; 5. Some other code gets moved into the new crate, mainly: - aya::{bpf_map_def, BtfMapDef, PinningType}, - aya::programs::{CgroupSock*AttachType}, The new crate is currenly allowing missing_docs. Member visibility will be adjusted later to minimize exposure of implementation details. Refs: #473 --- aya-obj/Cargo.toml | 7 + {aya/src/obj => aya-obj/src}/btf/btf.rs | 51 ++++--- {aya/src/obj => aya-obj/src}/btf/info.rs | 16 +- {aya/src/obj => aya-obj/src}/btf/mod.rs | 2 + .../src/obj => aya-obj/src}/btf/relocation.rs | 133 +++++++---------- {aya/src/obj => aya-obj/src}/btf/types.rs | 80 +++++----- aya-obj/src/generated/mod.rs | 53 ------- aya-obj/src/lib.rs | 11 +- aya-obj/src/maps.rs | 111 ++++++++++++++ aya/src/obj/mod.rs => aya-obj/src/obj.rs | 139 +++++++++--------- aya-obj/src/programs/cgroup_sock.rs | 52 +++++++ aya-obj/src/programs/cgroup_sock_addr.rs | 76 ++++++++++ aya-obj/src/programs/cgroup_sockopt.rs | 36 +++++ aya-obj/src/programs/mod.rs | 9 ++ {aya/src/obj => aya-obj/src}/relocation.rs | 137 +++++++++-------- aya-obj/src/util.rs | 7 + aya/src/bpf.rs | 124 +++++----------- aya/src/lib.rs | 4 +- aya/src/programs/cgroup_sock.rs | 51 +------ aya/src/programs/cgroup_sock_addr.rs | 75 +--------- aya/src/programs/cgroup_sockopt.rs | 36 +---- 21 files changed, 621 insertions(+), 589 deletions(-) rename {aya/src/obj => aya-obj/src}/btf/btf.rs (97%) rename {aya/src/obj => aya-obj/src}/btf/info.rs (94%) rename {aya/src/obj => aya-obj/src}/btf/mod.rs (77%) rename {aya/src/obj => aya-obj/src}/btf/relocation.rs (94%) rename {aya/src/obj => aya-obj/src}/btf/types.rs (96%) create mode 100644 aya-obj/src/maps.rs rename aya/src/obj/mod.rs => aya-obj/src/obj.rs (96%) create mode 100644 aya-obj/src/programs/cgroup_sock.rs create mode 100644 aya-obj/src/programs/cgroup_sock_addr.rs create mode 100644 aya-obj/src/programs/cgroup_sockopt.rs create mode 100644 aya-obj/src/programs/mod.rs rename {aya/src/obj => aya-obj/src}/relocation.rs (87%) create mode 100644 aya-obj/src/util.rs diff --git a/aya-obj/Cargo.toml b/aya-obj/Cargo.toml index 79dc47c6..0dc1e2b6 100644 --- a/aya-obj/Cargo.toml +++ b/aya-obj/Cargo.toml @@ -11,3 +11,10 @@ documentation = "https://docs.rs/aya-obj" edition = "2021" [dependencies] +bytes = "1" +log = "0.4" +object = { version = "0.30", default-features = false, features = ["std", "read_core", "elf"] } +thiserror = "1" + +[dev-dependencies] +matches = "0.1.8" diff --git a/aya/src/obj/btf/btf.rs b/aya-obj/src/btf/btf.rs similarity index 97% rename from aya/src/obj/btf/btf.rs rename to aya-obj/src/btf/btf.rs index dc1563f8..e8da97e1 100644 --- a/aya/src/obj/btf/btf.rs +++ b/aya-obj/src/btf/btf.rs @@ -16,14 +16,13 @@ use thiserror::Error; use crate::{ generated::{btf_ext_header, btf_header}, - obj::btf::{ + btf::{ info::{FuncSecInfo, LineSecInfo}, relocation::Relocation, Array, BtfEnum, BtfKind, BtfMember, BtfType, Const, Enum, FuncInfo, FuncLinkage, Int, IntEncoding, LineInfo, Struct, Typedef, VarLinkage, }, util::bytes_of, - Features, }; pub(crate) const MAX_RESOLVE_DEPTH: u8 = 32; @@ -158,6 +157,16 @@ pub enum BtfError { InvalidSymbolName, } +#[derive(Default, Debug)] +pub struct BtfFeatures { + pub btf_func: bool, + pub btf_func_global: bool, + pub btf_datasec: bool, + pub btf_float: bool, + pub btf_decl_tag: bool, + pub btf_type_tag: bool, +} + /// Bpf Type Format metadata. /// /// BTF is a kind of debug metadata that allows eBPF programs compiled against one kernel version @@ -175,7 +184,7 @@ pub struct Btf { } impl Btf { - pub(crate) fn new() -> Btf { + pub fn new() -> Btf { Btf { header: btf_header { magic: 0xeb9f, @@ -197,7 +206,7 @@ impl Btf { self.types.types.iter() } - pub(crate) fn add_string(&mut self, name: String) -> u32 { + pub fn add_string(&mut self, name: String) -> u32 { let str = CString::new(name).unwrap(); let name_offset = self.strings.len(); self.strings.extend(str.as_c_str().to_bytes_with_nul()); @@ -205,7 +214,7 @@ impl Btf { name_offset as u32 } - pub(crate) fn add_type(&mut self, btf_type: BtfType) -> u32 { + pub fn add_type(&mut self, btf_type: BtfType) -> u32 { let size = btf_type.type_info_size() as u32; let type_id = self.types.len(); self.types.push(btf_type); @@ -231,7 +240,7 @@ impl Btf { ) } - pub(crate) fn parse(data: &[u8], endianness: Endianness) -> Result { + pub fn parse(data: &[u8], endianness: Endianness) -> Result { if data.len() < mem::size_of::() { return Err(BtfError::InvalidHeader); } @@ -324,7 +333,7 @@ impl Btf { self.string_at(ty.name_offset()).ok().map(String::from) } - pub(crate) fn id_by_type_name_kind(&self, name: &str, kind: BtfKind) -> Result { + pub fn id_by_type_name_kind(&self, name: &str, kind: BtfKind) -> Result { for (type_id, ty) in self.types().enumerate() { if ty.kind() != kind { continue; @@ -370,7 +379,7 @@ impl Btf { }) } - pub(crate) fn to_bytes(&self) -> Vec { + pub fn to_bytes(&self) -> Vec { // Safety: btf_header is POD let mut buf = unsafe { bytes_of::(&self.header).to_vec() }; // Skip the first type since it's always BtfType::Unknown for type_by_id to work @@ -379,11 +388,11 @@ impl Btf { buf } - pub(crate) fn fixup_and_sanitize( + pub fn fixup_and_sanitize( &mut self, section_sizes: &HashMap, symbol_offsets: &HashMap, - features: &Features, + features: &BtfFeatures, ) -> Result<(), BtfError> { let mut types = mem::take(&mut self.types); for i in 0..types.types.len() { @@ -863,7 +872,7 @@ pub(crate) struct SecInfo<'a> { #[cfg(test)] mod tests { - use crate::obj::btf::{ + use crate::btf::{ BtfParam, DataSec, DataSecEntry, DeclTag, Float, Func, FuncProto, Ptr, TypeTag, Var, }; @@ -996,7 +1005,7 @@ mod tests { let name_offset = btf.add_string("&mut int".to_string()); let ptr_type_id = btf.add_type(BtfType::Ptr(Ptr::new(name_offset, int_type_id))); - let features = Features { + let features = BtfFeatures { ..Default::default() }; @@ -1034,7 +1043,7 @@ mod tests { VarLinkage::Static, ))); - let features = Features { + let features = BtfFeatures { btf_datasec: false, ..Default::default() }; @@ -1078,7 +1087,7 @@ mod tests { let datasec_type_id = btf.add_type(BtfType::DataSec(DataSec::new(name_offset, variables, 0))); - let features = Features { + let features = BtfFeatures { btf_datasec: false, ..Default::default() }; @@ -1125,7 +1134,7 @@ mod tests { let datasec_type_id = btf.add_type(BtfType::DataSec(DataSec::new(name_offset, variables, 0))); - let features = Features { + let features = BtfFeatures { btf_datasec: true, ..Default::default() }; @@ -1186,7 +1195,7 @@ mod tests { FuncLinkage::Static, ))); - let features = Features { + let features = BtfFeatures { btf_func: false, ..Default::default() }; @@ -1235,7 +1244,7 @@ mod tests { let func_proto = BtfType::FuncProto(FuncProto::new(params, int_type_id)); let func_proto_type_id = btf.add_type(func_proto); - let features = Features { + let features = BtfFeatures { btf_func: true, ..Default::default() }; @@ -1284,7 +1293,7 @@ mod tests { FuncLinkage::Global, ))); - let features = Features { + let features = BtfFeatures { btf_func: true, btf_func_global: false, ..Default::default() @@ -1309,7 +1318,7 @@ mod tests { let name_offset = btf.add_string("float".to_string()); let float_type_id = btf.add_type(BtfType::Float(Float::new(name_offset, 16))); - let features = Features { + let features = BtfFeatures { btf_float: false, ..Default::default() }; @@ -1349,7 +1358,7 @@ mod tests { let decl_tag_type_id = btf.add_type(BtfType::DeclTag(DeclTag::new(name_offset, var_type_id, -1))); - let features = Features { + let features = BtfFeatures { btf_decl_tag: false, ..Default::default() }; @@ -1377,7 +1386,7 @@ mod tests { let type_tag_type = btf.add_type(BtfType::TypeTag(TypeTag::new(name_offset, int_type_id))); btf.add_type(BtfType::Ptr(Ptr::new(0, type_tag_type))); - let features = Features { + let features = BtfFeatures { btf_type_tag: false, ..Default::default() }; diff --git a/aya/src/obj/btf/info.rs b/aya-obj/src/btf/info.rs similarity index 94% rename from aya/src/obj/btf/info.rs rename to aya-obj/src/btf/info.rs index 2e6139ce..d265a3a9 100644 --- a/aya/src/obj/btf/info.rs +++ b/aya-obj/src/btf/info.rs @@ -5,7 +5,7 @@ use object::Endianness; use crate::{ generated::{bpf_func_info, bpf_line_info}, - obj::relocation::INS_SIZE, + relocation::INS_SIZE, util::bytes_of, }; @@ -20,7 +20,7 @@ use crate::{ * ...... */ #[derive(Debug, Clone, Default)] -pub(crate) struct FuncSecInfo { +pub struct FuncSecInfo { pub _sec_name_offset: u32, pub num_info: u32, pub func_info: Vec, @@ -64,7 +64,7 @@ impl FuncSecInfo { } } - pub(crate) fn func_info_bytes(&self) -> Vec { + pub fn func_info_bytes(&self) -> Vec { let mut buf = vec![]; for l in &self.func_info { // Safety: bpf_func_info is POD @@ -73,13 +73,13 @@ impl FuncSecInfo { buf } - pub(crate) fn len(&self) -> usize { + pub fn len(&self) -> usize { self.func_info.len() } } #[derive(Debug, Clone)] -pub(crate) struct FuncInfo { +pub struct FuncInfo { pub data: HashMap, } @@ -99,7 +99,7 @@ impl FuncInfo { } #[derive(Debug, Clone, Default)] -pub(crate) struct LineSecInfo { +pub struct LineSecInfo { // each line info section has a header pub _sec_name_offset: u32, pub num_info: u32, @@ -154,7 +154,7 @@ impl LineSecInfo { } } - pub(crate) fn line_info_bytes(&self) -> Vec { + pub fn line_info_bytes(&self) -> Vec { let mut buf = vec![]; for l in &self.line_info { // Safety: bpf_func_info is POD @@ -163,7 +163,7 @@ impl LineSecInfo { buf } - pub(crate) fn len(&self) -> usize { + pub fn len(&self) -> usize { self.line_info.len() } } diff --git a/aya/src/obj/btf/mod.rs b/aya-obj/src/btf/mod.rs similarity index 77% rename from aya/src/obj/btf/mod.rs rename to aya-obj/src/btf/mod.rs index 8b3ed606..44bf123f 100644 --- a/aya/src/obj/btf/mod.rs +++ b/aya-obj/src/btf/mod.rs @@ -1,3 +1,5 @@ +//! BTF loading, parsing and relocation. + #[allow(clippy::module_inception)] mod btf; mod info; diff --git a/aya/src/obj/btf/relocation.rs b/aya-obj/src/btf/relocation.rs similarity index 94% rename from aya/src/obj/btf/relocation.rs rename to aya-obj/src/btf/relocation.rs index 285c5c03..b3e89d93 100644 --- a/aya/src/obj/btf/relocation.rs +++ b/aya-obj/src/btf/relocation.rs @@ -3,20 +3,27 @@ use std::{collections::HashMap, io, mem, ptr, str::FromStr}; use thiserror::Error; use crate::{ + btf::{ + fields_are_compatible, types_are_compatible, Array, Btf, BtfError, BtfMember, BtfType, + IntEncoding, Struct, Union, MAX_SPEC_LEN, + }, generated::{ bpf_core_relo, bpf_core_relo_kind::*, bpf_insn, BPF_ALU, BPF_ALU64, BPF_B, BPF_DW, BPF_H, BPF_K, BPF_LD, BPF_LDX, BPF_ST, BPF_STX, BPF_W, BTF_INT_SIGNED, }, - obj::{ - btf::{ - fields_are_compatible, types_are_compatible, Array, BtfMember, BtfType, IntEncoding, - Struct, Union, MAX_SPEC_LEN, - }, - Btf, BtfError, Object, Program, ProgramSection, - }, - BpfError, + Object, Program, ProgramSection, }; +#[derive(Error, Debug)] +#[error("error relocating `{section}`")] +pub struct BtfRelocationError { + /// The function name + pub section: String, + #[source] + /// The original error + error: RelocationError, +} + #[derive(Error, Debug)] enum RelocationError { #[error(transparent)] @@ -78,6 +85,9 @@ enum RelocationError { type_id: u32, ins_index: usize, }, + + #[error("invalid BTF")] + BtfError(#[from] BtfError), } fn err_type_name(name: &Option) -> String { @@ -154,7 +164,7 @@ impl Relocation { } impl Object { - pub fn relocate_btf(&mut self, target_btf: &Btf) -> Result<(), BpfError> { + pub fn relocate_btf(&mut self, target_btf: &Btf) -> Result<(), BtfRelocationError> { let (local_btf, btf_ext) = match (&self.btf, &self.btf_ext) { (Some(btf), Some(btf_ext)) => (btf, btf_ext), _ => return Ok(()), @@ -162,7 +172,10 @@ impl Object { let mut candidates_cache = HashMap::>::new(); for (sec_name_off, relos) in btf_ext.relocations() { - let section_name = local_btf.string_at(*sec_name_off)?; + let section_name = local_btf.string_at(*sec_name_off).map_err(|e| BtfRelocationError { + section: format!("section@{sec_name_off}"), + error: RelocationError::BtfError(e), + })?; let program_section = match ProgramSection::from_str(§ion_name) { Ok(program) => program, @@ -173,20 +186,17 @@ impl Object { let program = self .programs .get_mut(section_name) - .ok_or(BpfError::RelocationError { - function: section_name.to_owned(), - error: Box::new(RelocationError::ProgramNotFound), + .ok_or(BtfRelocationError { + section: section_name.to_owned(), + error: RelocationError::ProgramNotFound, })?; match relocate_btf_program(program, relos, local_btf, target_btf, &mut candidates_cache) { Ok(_) => {} - Err(ErrorWrapper::BtfError(e)) => return Err(e.into()), - Err(ErrorWrapper::RelocationError(error)) => { - return Err(BpfError::RelocationError { - function: section_name.to_owned(), - error: Box::new(error), - }) - } + Err(error) => return Err(BtfRelocationError { + section: section_name.to_owned(), + error, + }), } } @@ -200,7 +210,7 @@ fn relocate_btf_program<'target>( local_btf: &Btf, target_btf: &'target Btf, candidates_cache: &mut HashMap>>, -) -> Result<(), ErrorWrapper> { +) -> Result<(), RelocationError> { for rel in relos { let instructions = &mut program.function.instructions; let ins_index = rel.ins_offset / std::mem::size_of::(); @@ -209,8 +219,7 @@ fn relocate_btf_program<'target>( index: ins_index, num_instructions: instructions.len(), relocation_number: rel.number, - } - .into()); + }); } let local_ty = local_btf.type_by_id(rel.type_id)?; @@ -266,8 +275,7 @@ fn relocate_btf_program<'target>( return Err(RelocationError::ConflictingCandidates { type_name: local_name.to_string(), candidates: conflicts, - } - .into()); + }); } target_comp_rel } else { @@ -317,7 +325,7 @@ fn find_candidates<'target>( fn match_candidate<'target>( local_spec: &AccessSpec, candidate: &'target Candidate, -) -> Result>, ErrorWrapper> { +) -> Result>, RelocationError> { let mut target_spec = AccessSpec { btf: candidate.btf, root_type_id: candidate.type_id, @@ -419,8 +427,7 @@ fn match_candidate<'target>( if target_spec.parts.len() == MAX_SPEC_LEN { return Err(RelocationError::MaximumNestingLevelReached { type_name: Some(candidate.name.clone()), - } - .into()); + }); } target_spec.parts.push(accessor.index); @@ -446,7 +453,7 @@ fn match_member<'target>( target_btf: &'target Btf, target_id: u32, target_spec: &mut AccessSpec<'target>, -) -> Result, ErrorWrapper> { +) -> Result, RelocationError> { let local_ty = local_btf.type_by_id(local_accessor.type_id)?; let local_member = match local_ty { // this won't panic, bounds are checked when local_spec is built in AccessSpec::new @@ -470,8 +477,7 @@ fn match_member<'target>( let root_ty = target_spec.btf.type_by_id(target_spec.root_type_id)?; return Err(RelocationError::MaximumNestingLevelReached { type_name: target_spec.btf.err_type_name(root_ty), - } - .into()); + }); } // this will not panic as we've already established these are fields types @@ -532,7 +538,7 @@ impl<'a> AccessSpec<'a> { root_type_id: u32, spec: &str, relocation: Relocation, - ) -> Result, ErrorWrapper> { + ) -> Result, RelocationError> { let parts = spec .split(':') .map(|s| s.parse::()) @@ -552,8 +558,7 @@ impl<'a> AccessSpec<'a> { if parts != [0] { return Err(RelocationError::InvalidAccessString { access_str: spec.to_string(), - } - .into()); + }); } AccessSpec { btf, @@ -569,8 +574,7 @@ impl<'a> AccessSpec<'a> { if parts.len() != 1 { return Err(RelocationError::InvalidAccessString { access_str: spec.to_string(), - } - .into()); + }); } let index = parts[0]; if index >= en.variants.len() { @@ -580,8 +584,7 @@ impl<'a> AccessSpec<'a> { index, max_index: en.variants.len(), error: "tried to access nonexistant enum variant".to_string(), - } - .into()); + }); } let accessors = vec![Accessor { type_id, @@ -607,8 +610,7 @@ impl<'a> AccessSpec<'a> { relocation_kind: format!("{:?}", relocation.kind), type_kind: format!("{:?}", ty.kind()), error: "enum relocation on non-enum type".to_string(), - } - .into()) + }) } }, @@ -638,8 +640,7 @@ impl<'a> AccessSpec<'a> { index, max_index: members.len(), error: "out of bounds struct or union access".to_string(), - } - .into()); + }); } let member = &members[index]; @@ -675,8 +676,7 @@ impl<'a> AccessSpec<'a> { index, max_index: array.len as usize, error: "array index out of bounds".to_string(), - } - .into()); + }); } accessors.push(Accessor { type_id, @@ -693,8 +693,7 @@ impl<'a> AccessSpec<'a> { type_kind: format!("{:?}", ty.kind()), error: "field relocation on a type that doesn't have fields" .to_string(), - } - .into()); + }); } }; } @@ -747,7 +746,7 @@ impl ComputedRelocation { rel: &Relocation, local_spec: &AccessSpec, target_spec: Option<&AccessSpec>, - ) -> Result { + ) -> Result { use RelocationKind::*; let ret = match rel.kind { FieldByteOffset | FieldByteSize | FieldExists | FieldSigned | FieldLShift64 @@ -774,7 +773,7 @@ impl ComputedRelocation { rel: &Relocation, local_btf: &Btf, target_btf: &Btf, - ) -> Result<(), ErrorWrapper> { + ) -> Result<(), RelocationError> { let instructions = &mut program.function.instructions; let num_instructions = instructions.len(); let ins_index = rel.ins_offset / std::mem::size_of::(); @@ -799,8 +798,7 @@ impl ComputedRelocation { relocation_number: rel.number, index: ins_index, error: format!("invalid src_reg={src_reg:x} expected {BPF_K:x}"), - } - .into()); + }); } ins.imm = target_value as i32; @@ -811,8 +809,7 @@ impl ComputedRelocation { relocation_number: rel.number, index: ins_index, error: format!("value `{target_value}` overflows 16 bits offset field"), - } - .into()); + }); } ins.off = target_value as i16; @@ -837,8 +834,7 @@ impl ComputedRelocation { err_type_name(&target_btf.err_type_name(target_ty)), self.target.size, ), - } - .into()) + }) } } @@ -852,8 +848,7 @@ impl ComputedRelocation { relocation_number: rel.number, index: ins_index, error: format!("invalid target size {size}"), - } - .into()) + }) } } as u8; ins.code = ins.code & 0xE0 | size | ins.code & 0x07; @@ -876,8 +871,7 @@ impl ComputedRelocation { relocation_number: rel.number, index: ins_index, error: format!("invalid instruction class {class:x}"), - } - .into()) + }) } }; @@ -887,7 +881,7 @@ impl ComputedRelocation { fn compute_enum_relocation( rel: &Relocation, spec: Option<&AccessSpec>, - ) -> Result { + ) -> Result { use RelocationKind::*; let value = match (rel.kind, spec) { (EnumVariantExists, spec) => spec.is_some() as u32, @@ -918,7 +912,7 @@ impl ComputedRelocation { fn compute_field_relocation( rel: &Relocation, spec: Option<&AccessSpec>, - ) -> Result { + ) -> Result { use RelocationKind::*; if let FieldExists = rel.kind { @@ -963,8 +957,7 @@ impl ComputedRelocation { relocation_kind: format!("{rel_kind:?}"), type_kind: format!("{:?}", ty.kind()), error: "invalid relocation kind for array type".to_string(), - } - .into()); + }); } }; } @@ -979,8 +972,7 @@ impl ComputedRelocation { relocation_kind: format!("{:?}", rel.kind), type_kind: format!("{:?}", ty.kind()), error: "field relocation on a type that doesn't have fields".to_string(), - } - .into()); + }); } }; @@ -1055,7 +1047,7 @@ impl ComputedRelocation { rel: &Relocation, local_spec: &AccessSpec, target_spec: Option<&AccessSpec>, - ) -> Result { + ) -> Result { use RelocationKind::*; let value = match (rel.kind, target_spec) { @@ -1081,14 +1073,3 @@ impl ComputedRelocation { }) } } - -// this exists only to simplify propagating errors from relocate_btf() and to associate -// RelocationError(s) with their respective program name -#[derive(Error, Debug)] -enum ErrorWrapper { - #[error(transparent)] - BtfError(#[from] BtfError), - - #[error(transparent)] - RelocationError(#[from] RelocationError), -} diff --git a/aya/src/obj/btf/types.rs b/aya-obj/src/btf/types.rs similarity index 96% rename from aya/src/obj/btf/types.rs rename to aya-obj/src/btf/types.rs index 8f687bb3..f50b6d07 100644 --- a/aya/src/obj/btf/types.rs +++ b/aya-obj/src/btf/types.rs @@ -2,10 +2,10 @@ use std::{fmt::Display, mem, ptr}; use object::Endianness; -use crate::obj::btf::{Btf, BtfError, MAX_RESOLVE_DEPTH}; +use crate::btf::{Btf, BtfError, MAX_RESOLVE_DEPTH}; #[derive(Clone, Debug)] -pub(crate) enum BtfType { +pub enum BtfType { Unknown, Fwd(Fwd), Const(Const), @@ -29,7 +29,7 @@ pub(crate) enum BtfType { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Fwd { +pub struct Fwd { pub(crate) name_offset: u32, info: u32, _unused: u32, @@ -51,7 +51,7 @@ impl Fwd { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Const { +pub struct Const { pub(crate) name_offset: u32, info: u32, pub(crate) btf_type: u32, @@ -82,7 +82,7 @@ impl Const { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Volatile { +pub struct Volatile { pub(crate) name_offset: u32, info: u32, pub(crate) btf_type: u32, @@ -103,7 +103,7 @@ impl Volatile { } #[derive(Clone, Debug)] -pub(crate) struct Restrict { +pub struct Restrict { pub(crate) name_offset: u32, _info: u32, pub(crate) btf_type: u32, @@ -125,7 +125,7 @@ impl Restrict { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Ptr { +pub struct Ptr { pub(crate) name_offset: u32, info: u32, pub(crate) btf_type: u32, @@ -144,7 +144,7 @@ impl Ptr { mem::size_of::() } - pub(crate) fn new(name_offset: u32, btf_type: u32) -> Self { + pub fn new(name_offset: u32, btf_type: u32) -> Self { let info = (BtfKind::Ptr as u32) << 24; Ptr { name_offset, @@ -156,7 +156,7 @@ impl Ptr { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Typedef { +pub struct Typedef { pub(crate) name_offset: u32, info: u32, pub(crate) btf_type: u32, @@ -187,7 +187,7 @@ impl Typedef { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Float { +pub struct Float { pub(crate) name_offset: u32, info: u32, pub(crate) size: u32, @@ -205,7 +205,7 @@ impl Float { mem::size_of::() } - pub(crate) fn new(name_offset: u32, size: u32) -> Self { + pub fn new(name_offset: u32, size: u32) -> Self { let info = (BtfKind::Float as u32) << 24; Float { name_offset, @@ -217,7 +217,7 @@ impl Float { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Func { +pub struct Func { pub(crate) name_offset: u32, info: u32, pub(crate) btf_type: u32, @@ -225,7 +225,7 @@ pub(crate) struct Func { #[repr(u32)] #[derive(Clone, Debug, PartialEq, Eq)] -pub(crate) enum FuncLinkage { +pub enum FuncLinkage { Static = 0, Global = 1, Extern = 2, @@ -255,7 +255,7 @@ impl Func { mem::size_of::() } - pub(crate) fn new(name_offset: u32, proto: u32, linkage: FuncLinkage) -> Self { + pub fn new(name_offset: u32, proto: u32, linkage: FuncLinkage) -> Self { let mut info = (BtfKind::Func as u32) << 24; info |= (linkage as u32) & 0xFFFF; Func { @@ -276,7 +276,7 @@ impl Func { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct TypeTag { +pub struct TypeTag { pub(crate) name_offset: u32, info: u32, pub(crate) btf_type: u32, @@ -295,7 +295,7 @@ impl TypeTag { mem::size_of::() } - pub(crate) fn new(name_offset: u32, btf_type: u32) -> Self { + pub fn new(name_offset: u32, btf_type: u32) -> Self { let info = (BtfKind::TypeTag as u32) << 24; TypeTag { name_offset, @@ -307,7 +307,7 @@ impl TypeTag { #[repr(u32)] #[derive(Clone, Debug, Eq, PartialEq)] -pub(crate) enum IntEncoding { +pub enum IntEncoding { None, Signed = 1, Char = 2, @@ -329,7 +329,7 @@ impl From for IntEncoding { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Int { +pub struct Int { pub(crate) name_offset: u32, info: u32, pub(crate) size: u32, @@ -353,7 +353,7 @@ impl Int { mem::size_of::() } - pub(crate) fn new(name_offset: u32, size: u32, encoding: IntEncoding, offset: u32) -> Self { + pub fn new(name_offset: u32, size: u32, encoding: IntEncoding, offset: u32) -> Self { let info = (BtfKind::Int as u32) << 24; let mut data = 0u32; data |= (encoding as u32 & 0x0f) << 24; @@ -391,7 +391,7 @@ pub(crate) struct BtfEnum { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Enum { +pub struct Enum { pub(crate) name_offset: u32, info: u32, pub(crate) size: u32, @@ -441,7 +441,7 @@ pub(crate) struct BtfMember { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Struct { +pub struct Struct { pub(crate) name_offset: u32, info: u32, pub(crate) size: u32, @@ -502,7 +502,7 @@ impl Struct { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Union { +pub struct Union { pub(crate) name_offset: u32, info: u32, pub(crate) size: u32, @@ -559,7 +559,7 @@ pub(crate) struct BtfArray { } #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Array { +pub struct Array { pub(crate) name_offset: u32, info: u32, _unused: u32, @@ -602,14 +602,14 @@ impl Array { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct BtfParam { - pub(crate) name_offset: u32, - pub(crate) btf_type: u32, +pub struct BtfParam { + pub name_offset: u32, + pub btf_type: u32, } #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct FuncProto { +pub struct FuncProto { pub(crate) name_offset: u32, info: u32, pub(crate) return_type: u32, @@ -637,7 +637,7 @@ impl FuncProto { mem::size_of::() + mem::size_of::() * self.params.len() } - pub(crate) fn new(params: Vec, return_type: u32) -> Self { + pub fn new(params: Vec, return_type: u32) -> Self { let mut info = (BtfKind::FuncProto as u32) << 24; info |= (params.len() as u32) & 0xFFFF; FuncProto { @@ -651,7 +651,7 @@ impl FuncProto { #[repr(u32)] #[derive(Clone, Debug, PartialEq, Eq)] -pub(crate) enum VarLinkage { +pub enum VarLinkage { Static, Global, Extern, @@ -671,7 +671,7 @@ impl From for VarLinkage { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct Var { +pub struct Var { pub(crate) name_offset: u32, info: u32, pub(crate) btf_type: u32, @@ -696,7 +696,7 @@ impl Var { mem::size_of::() } - pub(crate) fn new(name_offset: u32, btf_type: u32, linkage: VarLinkage) -> Self { + pub fn new(name_offset: u32, btf_type: u32, linkage: VarLinkage) -> Self { let info = (BtfKind::Var as u32) << 24; Var { name_offset, @@ -709,15 +709,15 @@ impl Var { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct DataSecEntry { - pub(crate) btf_type: u32, - pub(crate) offset: u32, - pub(crate) size: u32, +pub struct DataSecEntry { + pub btf_type: u32, + pub offset: u32, + pub size: u32, } #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct DataSec { +pub struct DataSec { pub(crate) name_offset: u32, info: u32, pub(crate) size: u32, @@ -746,7 +746,7 @@ impl DataSec { mem::size_of::() + mem::size_of::() * self.entries.len() } - pub(crate) fn new(name_offset: u32, entries: Vec, size: u32) -> Self { + pub fn new(name_offset: u32, entries: Vec, size: u32) -> Self { let mut info = (BtfKind::DataSec as u32) << 24; info |= (entries.len() as u32) & 0xFFFF; DataSec { @@ -760,7 +760,7 @@ impl DataSec { #[repr(C)] #[derive(Clone, Debug)] -pub(crate) struct DeclTag { +pub struct DeclTag { pub(crate) name_offset: u32, info: u32, pub(crate) btf_type: u32, @@ -785,7 +785,7 @@ impl DeclTag { mem::size_of::() } - pub(crate) fn new(name_offset: u32, btf_type: u32, component_index: i32) -> Self { + pub fn new(name_offset: u32, btf_type: u32, component_index: i32) -> Self { let info = (BtfKind::DeclTag as u32) << 24; DeclTag { name_offset, @@ -798,7 +798,7 @@ impl DeclTag { #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[repr(u32)] -pub(crate) enum BtfKind { +pub enum BtfKind { Unknown = 0, Int = 1, Ptr = 2, diff --git a/aya-obj/src/generated/mod.rs b/aya-obj/src/generated/mod.rs index 4153c2e8..0a64f088 100644 --- a/aya-obj/src/generated/mod.rs +++ b/aya-obj/src/generated/mod.rs @@ -31,56 +31,3 @@ pub use linux_bindings_aarch64::*; #[cfg(target_arch = "riscv64")] pub use linux_bindings_riscv64::*; - -pub mod maps { - /// Invalid map type encontered - pub struct InvalidMapTypeError { - /// The map type - pub map_type: u32, - } - - impl TryFrom for super::bpf_map_type { - type Error = InvalidMapTypeError; - - fn try_from(map_type: u32) -> Result { - use super::bpf_map_type::*; - Ok(match map_type { - x if x == BPF_MAP_TYPE_UNSPEC as u32 => BPF_MAP_TYPE_UNSPEC, - x if x == BPF_MAP_TYPE_HASH as u32 => BPF_MAP_TYPE_HASH, - x if x == BPF_MAP_TYPE_ARRAY as u32 => BPF_MAP_TYPE_ARRAY, - x if x == BPF_MAP_TYPE_PROG_ARRAY as u32 => BPF_MAP_TYPE_PROG_ARRAY, - x if x == BPF_MAP_TYPE_PERF_EVENT_ARRAY as u32 => BPF_MAP_TYPE_PERF_EVENT_ARRAY, - x if x == BPF_MAP_TYPE_PERCPU_HASH as u32 => BPF_MAP_TYPE_PERCPU_HASH, - x if x == BPF_MAP_TYPE_PERCPU_ARRAY as u32 => BPF_MAP_TYPE_PERCPU_ARRAY, - x if x == BPF_MAP_TYPE_STACK_TRACE as u32 => BPF_MAP_TYPE_STACK_TRACE, - x if x == BPF_MAP_TYPE_CGROUP_ARRAY as u32 => BPF_MAP_TYPE_CGROUP_ARRAY, - x if x == BPF_MAP_TYPE_LRU_HASH as u32 => BPF_MAP_TYPE_LRU_HASH, - x if x == BPF_MAP_TYPE_LRU_PERCPU_HASH as u32 => BPF_MAP_TYPE_LRU_PERCPU_HASH, - x if x == BPF_MAP_TYPE_LPM_TRIE as u32 => BPF_MAP_TYPE_LPM_TRIE, - x if x == BPF_MAP_TYPE_BLOOM_FILTER as u32 => BPF_MAP_TYPE_BLOOM_FILTER, - x if x == BPF_MAP_TYPE_ARRAY_OF_MAPS as u32 => BPF_MAP_TYPE_ARRAY_OF_MAPS, - x if x == BPF_MAP_TYPE_HASH_OF_MAPS as u32 => BPF_MAP_TYPE_HASH_OF_MAPS, - x if x == BPF_MAP_TYPE_DEVMAP as u32 => BPF_MAP_TYPE_DEVMAP, - x if x == BPF_MAP_TYPE_SOCKMAP as u32 => BPF_MAP_TYPE_SOCKMAP, - x if x == BPF_MAP_TYPE_CPUMAP as u32 => BPF_MAP_TYPE_CPUMAP, - x if x == BPF_MAP_TYPE_XSKMAP as u32 => BPF_MAP_TYPE_XSKMAP, - x if x == BPF_MAP_TYPE_SOCKHASH as u32 => BPF_MAP_TYPE_SOCKHASH, - x if x == BPF_MAP_TYPE_CGROUP_STORAGE as u32 => BPF_MAP_TYPE_CGROUP_STORAGE, - x if x == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY as u32 => BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, - x if x == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE as u32 => { - BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE - } - x if x == BPF_MAP_TYPE_QUEUE as u32 => BPF_MAP_TYPE_QUEUE, - x if x == BPF_MAP_TYPE_STACK as u32 => BPF_MAP_TYPE_STACK, - x if x == BPF_MAP_TYPE_SK_STORAGE as u32 => BPF_MAP_TYPE_SK_STORAGE, - x if x == BPF_MAP_TYPE_DEVMAP_HASH as u32 => BPF_MAP_TYPE_DEVMAP_HASH, - x if x == BPF_MAP_TYPE_STRUCT_OPS as u32 => BPF_MAP_TYPE_STRUCT_OPS, - x if x == BPF_MAP_TYPE_RINGBUF as u32 => BPF_MAP_TYPE_RINGBUF, - x if x == BPF_MAP_TYPE_INODE_STORAGE as u32 => BPF_MAP_TYPE_INODE_STORAGE, - x if x == BPF_MAP_TYPE_TASK_STORAGE as u32 => BPF_MAP_TYPE_TASK_STORAGE, - _ => return Err(InvalidMapTypeError { map_type }), - }) - } - } -} - diff --git a/aya-obj/src/lib.rs b/aya-obj/src/lib.rs index 5302fbe6..d145d2aa 100644 --- a/aya-obj/src/lib.rs +++ b/aya-obj/src/lib.rs @@ -1,12 +1,19 @@ //! A library for loading and relocating eBPF object files. -#![no_std] #![doc( html_logo_url = "https://aya-rs.dev/assets/images/crabby.svg", html_favicon_url = "https://aya-rs.dev/assets/images/crabby.svg" )] #![cfg_attr(docsrs, feature(doc_cfg))] -#![deny(clippy::all, missing_docs)] +#![deny(clippy::all)] #![allow(clippy::missing_safety_doc, clippy::len_without_is_empty)] +pub mod btf; pub mod generated; +pub mod maps; +pub mod obj; +pub mod programs; +pub mod relocation; +mod util; + +pub use obj::*; diff --git a/aya-obj/src/maps.rs b/aya-obj/src/maps.rs new file mode 100644 index 00000000..94d0b590 --- /dev/null +++ b/aya-obj/src/maps.rs @@ -0,0 +1,111 @@ +//! Map struct and type bindings. + +use thiserror::Error; + +/// Invalid map type encontered +pub struct InvalidMapTypeError { + /// The map type + pub map_type: u32, +} + +impl TryFrom for crate::generated::bpf_map_type { + type Error = InvalidMapTypeError; + + fn try_from(map_type: u32) -> Result { + use crate::generated::bpf_map_type::*; + Ok(match map_type { + x if x == BPF_MAP_TYPE_UNSPEC as u32 => BPF_MAP_TYPE_UNSPEC, + x if x == BPF_MAP_TYPE_HASH as u32 => BPF_MAP_TYPE_HASH, + x if x == BPF_MAP_TYPE_ARRAY as u32 => BPF_MAP_TYPE_ARRAY, + x if x == BPF_MAP_TYPE_PROG_ARRAY as u32 => BPF_MAP_TYPE_PROG_ARRAY, + x if x == BPF_MAP_TYPE_PERF_EVENT_ARRAY as u32 => BPF_MAP_TYPE_PERF_EVENT_ARRAY, + x if x == BPF_MAP_TYPE_PERCPU_HASH as u32 => BPF_MAP_TYPE_PERCPU_HASH, + x if x == BPF_MAP_TYPE_PERCPU_ARRAY as u32 => BPF_MAP_TYPE_PERCPU_ARRAY, + x if x == BPF_MAP_TYPE_STACK_TRACE as u32 => BPF_MAP_TYPE_STACK_TRACE, + x if x == BPF_MAP_TYPE_CGROUP_ARRAY as u32 => BPF_MAP_TYPE_CGROUP_ARRAY, + x if x == BPF_MAP_TYPE_LRU_HASH as u32 => BPF_MAP_TYPE_LRU_HASH, + x if x == BPF_MAP_TYPE_LRU_PERCPU_HASH as u32 => BPF_MAP_TYPE_LRU_PERCPU_HASH, + x if x == BPF_MAP_TYPE_LPM_TRIE as u32 => BPF_MAP_TYPE_LPM_TRIE, + x if x == BPF_MAP_TYPE_BLOOM_FILTER as u32 => BPF_MAP_TYPE_BLOOM_FILTER, + x if x == BPF_MAP_TYPE_ARRAY_OF_MAPS as u32 => BPF_MAP_TYPE_ARRAY_OF_MAPS, + x if x == BPF_MAP_TYPE_HASH_OF_MAPS as u32 => BPF_MAP_TYPE_HASH_OF_MAPS, + x if x == BPF_MAP_TYPE_DEVMAP as u32 => BPF_MAP_TYPE_DEVMAP, + x if x == BPF_MAP_TYPE_SOCKMAP as u32 => BPF_MAP_TYPE_SOCKMAP, + x if x == BPF_MAP_TYPE_CPUMAP as u32 => BPF_MAP_TYPE_CPUMAP, + x if x == BPF_MAP_TYPE_XSKMAP as u32 => BPF_MAP_TYPE_XSKMAP, + x if x == BPF_MAP_TYPE_SOCKHASH as u32 => BPF_MAP_TYPE_SOCKHASH, + x if x == BPF_MAP_TYPE_CGROUP_STORAGE as u32 => BPF_MAP_TYPE_CGROUP_STORAGE, + x if x == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY as u32 => BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, + x if x == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE as u32 => { + BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE + } + x if x == BPF_MAP_TYPE_QUEUE as u32 => BPF_MAP_TYPE_QUEUE, + x if x == BPF_MAP_TYPE_STACK as u32 => BPF_MAP_TYPE_STACK, + x if x == BPF_MAP_TYPE_SK_STORAGE as u32 => BPF_MAP_TYPE_SK_STORAGE, + x if x == BPF_MAP_TYPE_DEVMAP_HASH as u32 => BPF_MAP_TYPE_DEVMAP_HASH, + x if x == BPF_MAP_TYPE_STRUCT_OPS as u32 => BPF_MAP_TYPE_STRUCT_OPS, + x if x == BPF_MAP_TYPE_RINGBUF as u32 => BPF_MAP_TYPE_RINGBUF, + x if x == BPF_MAP_TYPE_INODE_STORAGE as u32 => BPF_MAP_TYPE_INODE_STORAGE, + x if x == BPF_MAP_TYPE_TASK_STORAGE as u32 => BPF_MAP_TYPE_TASK_STORAGE, + _ => return Err(InvalidMapTypeError { map_type }), + }) + } +} + +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] +pub struct BtfMapDef { + pub(crate) map_type: u32, + pub(crate) key_size: u32, + pub(crate) value_size: u32, + pub(crate) max_entries: u32, + pub(crate) map_flags: u32, + pub(crate) pinning: PinningType, + pub btf_key_type_id: u32, + pub btf_value_type_id: u32, +} + +#[repr(u32)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum PinningType { + None = 0, + ByName = 1, +} + +#[derive(Debug, Error)] +pub enum PinningError { + #[error("unsupported pinning type")] + Unsupported, +} + +impl TryFrom for PinningType { + type Error = PinningError; + + fn try_from(value: u32) -> Result { + match value { + 0 => Ok(PinningType::None), + 1 => Ok(PinningType::ByName), + _ => Err(PinningError::Unsupported), + } + } +} + +impl Default for PinningType { + fn default() -> Self { + PinningType::None + } +} + +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] +pub struct bpf_map_def { + // minimum features required by old BPF programs + pub map_type: u32, + pub key_size: u32, + pub value_size: u32, + pub max_entries: u32, + pub map_flags: u32, + // optional features + pub id: u32, + pub pinning: PinningType, +} diff --git a/aya/src/obj/mod.rs b/aya-obj/src/obj.rs similarity index 96% rename from aya/src/obj/mod.rs rename to aya-obj/src/obj.rs index 7dd90d53..46e6b1bf 100644 --- a/aya/src/obj/mod.rs +++ b/aya-obj/src/obj.rs @@ -1,5 +1,4 @@ -pub(crate) mod btf; -mod relocation; +//! Object file loading, parsing, and relocation. use log::debug; use object::{ @@ -15,18 +14,18 @@ use std::{ }; use thiserror::Error; -use relocation::*; +use crate::relocation::*; use crate::{ - bpf_map_def, + maps::bpf_map_def, + btf::{Btf, BtfError, BtfExt, BtfType}, generated::{bpf_insn, bpf_map_info, bpf_map_type::BPF_MAP_TYPE_ARRAY, BPF_F_RDONLY_PROG}, - obj::btf::{Btf, BtfError, BtfExt, BtfType}, programs::{CgroupSockAddrAttachType, CgroupSockAttachType, CgroupSockoptAttachType}, - BpfError, BtfMapDef, PinningType, + maps::BtfMapDef, maps::PinningType, }; use std::slice::from_raw_parts_mut; -use self::btf::{Array, DataSecEntry, FuncSecInfo, LineSecInfo}; +use crate::btf::{Array, DataSecEntry, FuncSecInfo, LineSecInfo}; const KERNEL_VERSION_ANY: u32 = 0xFFFF_FFFE; /// The first five __u32 of `bpf_map_def` must be defined. @@ -34,25 +33,25 @@ const MINIMUM_MAP_SIZE: usize = mem::size_of::() * 5; #[derive(Clone)] pub struct Object { - pub(crate) endianness: Endianness, + pub endianness: Endianness, pub license: CString, pub kernel_version: KernelVersion, pub btf: Option, pub btf_ext: Option, - pub(crate) maps: HashMap, - pub(crate) programs: HashMap, - pub(crate) functions: HashMap, - pub(crate) relocations: HashMap>, - pub(crate) symbols_by_index: HashMap, - pub(crate) section_sizes: HashMap, + pub maps: HashMap, + pub programs: HashMap, + pub functions: HashMap, + pub relocations: HashMap>, + pub symbols_by_index: HashMap, + pub section_sizes: HashMap, // symbol_offset_by_name caches symbols that could be referenced from a // BTF VAR type so the offsets can be fixed up - pub(crate) symbol_offset_by_name: HashMap, - pub(crate) text_section_index: Option, + pub symbol_offset_by_name: HashMap, + pub text_section_index: Option, } #[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub(crate) enum MapKind { +pub enum MapKind { Bss, Data, Rodata, @@ -80,84 +79,84 @@ pub enum Map { } impl Map { - pub(crate) fn map_type(&self) -> u32 { + pub fn map_type(&self) -> u32 { match self { Map::Legacy(m) => m.def.map_type, Map::Btf(m) => m.def.map_type, } } - pub(crate) fn key_size(&self) -> u32 { + pub fn key_size(&self) -> u32 { match self { Map::Legacy(m) => m.def.key_size, Map::Btf(m) => m.def.key_size, } } - pub(crate) fn value_size(&self) -> u32 { + pub fn value_size(&self) -> u32 { match self { Map::Legacy(m) => m.def.value_size, Map::Btf(m) => m.def.value_size, } } - pub(crate) fn max_entries(&self) -> u32 { + pub fn max_entries(&self) -> u32 { match self { Map::Legacy(m) => m.def.max_entries, Map::Btf(m) => m.def.max_entries, } } - pub(crate) fn set_max_entries(&mut self, v: u32) { + pub fn set_max_entries(&mut self, v: u32) { match self { Map::Legacy(m) => m.def.max_entries = v, Map::Btf(m) => m.def.max_entries = v, } } - pub(crate) fn map_flags(&self) -> u32 { + pub fn map_flags(&self) -> u32 { match self { Map::Legacy(m) => m.def.map_flags, Map::Btf(m) => m.def.map_flags, } } - pub(crate) fn pinning(&self) -> PinningType { + pub fn pinning(&self) -> PinningType { match self { Map::Legacy(m) => m.def.pinning, Map::Btf(m) => m.def.pinning, } } - pub(crate) fn data(&self) -> &[u8] { + pub fn data(&self) -> &[u8] { match self { Map::Legacy(m) => &m.data, Map::Btf(m) => &m.data, } } - pub(crate) fn data_mut(&mut self) -> &mut Vec { + pub fn data_mut(&mut self) -> &mut Vec { match self { Map::Legacy(m) => m.data.as_mut(), Map::Btf(m) => m.data.as_mut(), } } - pub(crate) fn kind(&self) -> MapKind { + pub fn kind(&self) -> MapKind { match self { Map::Legacy(m) => m.kind, Map::Btf(m) => m.kind, } } - pub(crate) fn section_index(&self) -> usize { + pub fn section_index(&self) -> usize { match self { Map::Legacy(m) => m.section_index, Map::Btf(m) => m.section_index, } } - pub(crate) fn symbol_index(&self) -> usize { + pub fn symbol_index(&self) -> usize { match self { Map::Legacy(m) => m.symbol_index, Map::Btf(m) => m.symbol_index, @@ -167,41 +166,41 @@ impl Map { #[derive(Debug, Clone)] pub struct LegacyMap { - pub(crate) def: bpf_map_def, - pub(crate) section_index: usize, - pub(crate) symbol_index: usize, - pub(crate) data: Vec, - pub(crate) kind: MapKind, + pub def: bpf_map_def, + pub section_index: usize, + pub symbol_index: usize, + pub data: Vec, + pub kind: MapKind, } #[derive(Debug, Clone)] pub struct BtfMap { - pub(crate) def: BtfMapDef, - pub(crate) section_index: usize, - pub(crate) symbol_index: usize, - pub(crate) kind: MapKind, - pub(crate) data: Vec, + pub def: BtfMapDef, + pub section_index: usize, + pub symbol_index: usize, + pub kind: MapKind, + pub data: Vec, } #[derive(Debug, Clone)] -pub(crate) struct Program { - pub(crate) license: CString, - pub(crate) kernel_version: KernelVersion, - pub(crate) section: ProgramSection, - pub(crate) function: Function, +pub struct Program { + pub license: CString, + pub kernel_version: KernelVersion, + pub section: ProgramSection, + pub function: Function, } #[derive(Debug, Clone)] -pub(crate) struct Function { - pub(crate) address: u64, - pub(crate) name: String, - pub(crate) section_index: SectionIndex, - pub(crate) section_offset: usize, - pub(crate) instructions: Vec, - pub(crate) func_info: FuncSecInfo, - pub(crate) line_info: LineSecInfo, - pub(crate) func_info_rec_size: usize, - pub(crate) line_info_rec_size: usize, +pub struct Function { + pub address: u64, + pub name: String, + pub section_index: SectionIndex, + pub section_offset: usize, + pub instructions: Vec, + pub func_info: FuncSecInfo, + pub line_info: LineSecInfo, + pub func_info_rec_size: usize, + pub line_info_rec_size: usize, } #[derive(Debug, Clone)] @@ -299,7 +298,7 @@ pub enum ProgramSection { } impl ProgramSection { - fn name(&self) -> &str { + pub fn name(&self) -> &str { match self { ProgramSection::KRetProbe { name } => name, ProgramSection::KProbe { name } => name, @@ -521,7 +520,7 @@ impl FromStr for ProgramSection { } impl Object { - pub(crate) fn parse(data: &[u8]) -> Result { + pub fn parse(data: &[u8]) -> Result { let obj = object::read::File::parse(data).map_err(ParseError::ElfError)?; let endianness = obj.endianness(); @@ -829,9 +828,9 @@ impl Object { &mut self, section: &Section, symbols: HashMap, - ) -> Result<(), BpfError> { + ) -> Result<(), ParseError> { if self.btf.is_none() { - return Err(BpfError::NoBTF); + return Err(ParseError::NoBTF); } let btf = self.btf.as_ref().unwrap(); @@ -847,10 +846,8 @@ impl Object { let (map_name, def) = parse_btf_map_def(btf, info)?; let symbol_index = symbols .get(&map_name) - .ok_or_else(|| { - BpfError::ParseError(ParseError::SymbolNotFound { - name: map_name.to_string(), - }) + .ok_or_else(|| ParseError::SymbolNotFound { + name: map_name.to_string(), })? .index; self.maps.insert( @@ -870,7 +867,7 @@ impl Object { Ok(()) } - fn parse_section(&mut self, mut section: Section) -> Result<(), BpfError> { + fn parse_section(&mut self, mut section: Section) -> Result<(), ParseError> { let mut parts = section.name.rsplitn(2, '/').collect::>(); parts.reverse(); @@ -945,11 +942,14 @@ impl Object { } } -#[derive(Debug, Clone, Error)] +#[derive(Debug, Error)] pub enum ParseError { #[error("error parsing ELF data")] ElfError(#[from] object::read::Error), + #[error("BTF error")] + BtfError(#[from] BtfError), + #[error("invalid license `{data:?}`: missing NULL terminator")] MissingLicenseNullTerminator { data: Vec }, @@ -1005,6 +1005,9 @@ pub enum ParseError { #[error("no symbols found for the maps included in the maps section")] NoSymbolsInMapSection {}, + + #[error("no BTF parsed for object")] + NoBTF, } #[derive(Debug)] @@ -1311,7 +1314,7 @@ fn parse_btf_map_def(btf: &Btf, info: &DataSecEntry) -> Result<(String, BtfMapDe Ok((map_name.to_string(), map_def)) } -pub(crate) fn parse_map_info(info: bpf_map_info, pinned: PinningType) -> Map { +pub fn parse_map_info(info: bpf_map_info, pinned: PinningType) -> Map { if info.btf_key_type_id != 0 { Map::Btf(BtfMap { def: BtfMapDef { @@ -1350,7 +1353,7 @@ pub(crate) fn parse_map_info(info: bpf_map_info, pinned: PinningType) -> Map { } } -pub(crate) fn copy_instructions(data: &[u8]) -> Result, ParseError> { +pub fn copy_instructions(data: &[u8]) -> Result, ParseError> { if data.len() % mem::size_of::() > 0 { return Err(ParseError::InvalidProgramCode); } @@ -1367,7 +1370,7 @@ mod tests { use object::Endianness; use super::*; - use crate::PinningType; + use crate::maps::PinningType; fn fake_section<'a>(kind: BpfSectionKind, name: &'a str, data: &'a [u8]) -> Section<'a> { Section { @@ -1416,7 +1419,7 @@ mod tests { fn test_parse_generic_error() { assert!(matches!( Object::parse(&b"foo"[..]), - Err(BpfError::ParseError(ParseError::ElfError(_))) + Err(ParseError::ElfError(_)) )) } diff --git a/aya-obj/src/programs/cgroup_sock.rs b/aya-obj/src/programs/cgroup_sock.rs new file mode 100644 index 00000000..d30d269b --- /dev/null +++ b/aya-obj/src/programs/cgroup_sock.rs @@ -0,0 +1,52 @@ +//! Cgroup socket programs. +use thiserror::Error; + +use crate::generated::bpf_attach_type; + +/// Defines where to attach a [`CgroupSock`] program. +#[derive(Copy, Clone, Debug)] +pub enum CgroupSockAttachType { + /// Called after the IPv4 bind events. + PostBind4, + /// Called after the IPv6 bind events. + PostBind6, + /// Attach to IPv4 connect events. + SockCreate, + /// Attach to IPv6 connect events. + SockRelease, +} + +impl Default for CgroupSockAttachType { + // The kernel checks for a 0 attach_type and sets it to sock_create + // We may as well do that here also + fn default() -> Self { + CgroupSockAttachType::SockCreate + } +} + +impl From for bpf_attach_type { + fn from(s: CgroupSockAttachType) -> bpf_attach_type { + match s { + CgroupSockAttachType::PostBind4 => bpf_attach_type::BPF_CGROUP_INET4_POST_BIND, + CgroupSockAttachType::PostBind6 => bpf_attach_type::BPF_CGROUP_INET6_POST_BIND, + CgroupSockAttachType::SockCreate => bpf_attach_type::BPF_CGROUP_INET_SOCK_CREATE, + CgroupSockAttachType::SockRelease => bpf_attach_type::BPF_CGROUP_INET_SOCK_RELEASE, + } + } +} + +#[derive(Debug, Error)] +#[error("{0} is not a valid attach type for a CGROUP_SOCK program")] +pub(crate) struct InvalidAttachType(String); + +impl CgroupSockAttachType { + pub(crate) fn try_from(value: &str) -> Result { + match value { + "post_bind4" => Ok(CgroupSockAttachType::PostBind4), + "post_bind6" => Ok(CgroupSockAttachType::PostBind6), + "sock_create" => Ok(CgroupSockAttachType::SockCreate), + "sock_release" => Ok(CgroupSockAttachType::SockRelease), + _ => Err(InvalidAttachType(value.to_owned())), + } + } +} diff --git a/aya-obj/src/programs/cgroup_sock_addr.rs b/aya-obj/src/programs/cgroup_sock_addr.rs new file mode 100644 index 00000000..61cb33c5 --- /dev/null +++ b/aya-obj/src/programs/cgroup_sock_addr.rs @@ -0,0 +1,76 @@ +//! Cgroup socket address programs. +use thiserror::Error; + +use crate::generated::bpf_attach_type; + +/// Defines where to attach a [`CgroupSockAddr`] program. +#[derive(Copy, Clone, Debug)] +pub enum CgroupSockAddrAttachType { + /// Attach to IPv4 bind events. + Bind4, + /// Attach to IPv6 bind events. + Bind6, + /// Attach to IPv4 connect events. + Connect4, + /// Attach to IPv6 connect events. + Connect6, + /// Attach to IPv4 getpeername events. + GetPeerName4, + /// Attach to IPv6 getpeername events. + GetPeerName6, + /// Attach to IPv4 getsockname events. + GetSockName4, + /// Attach to IPv6 getsockname events. + GetSockName6, + /// Attach to IPv4 udp_sendmsg events. + UDPSendMsg4, + /// Attach to IPv6 udp_sendmsg events. + UDPSendMsg6, + /// Attach to IPv4 udp_recvmsg events. + UDPRecvMsg4, + /// Attach to IPv6 udp_recvmsg events. + UDPRecvMsg6, +} + +impl From for bpf_attach_type { + fn from(s: CgroupSockAddrAttachType) -> bpf_attach_type { + match s { + CgroupSockAddrAttachType::Bind4 => bpf_attach_type::BPF_CGROUP_INET4_BIND, + CgroupSockAddrAttachType::Bind6 => bpf_attach_type::BPF_CGROUP_INET6_BIND, + CgroupSockAddrAttachType::Connect4 => bpf_attach_type::BPF_CGROUP_INET4_CONNECT, + CgroupSockAddrAttachType::Connect6 => bpf_attach_type::BPF_CGROUP_INET6_CONNECT, + CgroupSockAddrAttachType::GetPeerName4 => bpf_attach_type::BPF_CGROUP_INET4_GETPEERNAME, + CgroupSockAddrAttachType::GetPeerName6 => bpf_attach_type::BPF_CGROUP_INET6_GETPEERNAME, + CgroupSockAddrAttachType::GetSockName4 => bpf_attach_type::BPF_CGROUP_INET4_GETSOCKNAME, + CgroupSockAddrAttachType::GetSockName6 => bpf_attach_type::BPF_CGROUP_INET6_GETSOCKNAME, + CgroupSockAddrAttachType::UDPSendMsg4 => bpf_attach_type::BPF_CGROUP_UDP4_SENDMSG, + CgroupSockAddrAttachType::UDPSendMsg6 => bpf_attach_type::BPF_CGROUP_UDP6_SENDMSG, + CgroupSockAddrAttachType::UDPRecvMsg4 => bpf_attach_type::BPF_CGROUP_UDP4_RECVMSG, + CgroupSockAddrAttachType::UDPRecvMsg6 => bpf_attach_type::BPF_CGROUP_UDP6_RECVMSG, + } + } +} + +#[derive(Debug, Error)] +#[error("{0} is not a valid attach type for a CGROUP_SOCK_ADDR program")] +pub(crate) struct InvalidAttachType(String); + +impl CgroupSockAddrAttachType { + pub(crate) fn try_from(value: &str) -> Result { + match value { + "bind4" => Ok(CgroupSockAddrAttachType::Bind4), + "bind6" => Ok(CgroupSockAddrAttachType::Bind6), + "connect4" => Ok(CgroupSockAddrAttachType::Connect4), + "connect6" => Ok(CgroupSockAddrAttachType::Connect6), + "getpeername4" => Ok(CgroupSockAddrAttachType::GetPeerName4), + "getpeername6" => Ok(CgroupSockAddrAttachType::GetPeerName6), + "getsockname4" => Ok(CgroupSockAddrAttachType::GetSockName4), + "getsockname6" => Ok(CgroupSockAddrAttachType::GetSockName6), + "sendmsg4" => Ok(CgroupSockAddrAttachType::UDPSendMsg4), + "sendmsg6" => Ok(CgroupSockAddrAttachType::UDPSendMsg6), + "recvmsg4" => Ok(CgroupSockAddrAttachType::UDPRecvMsg4), + "recvmsg6" => Ok(CgroupSockAddrAttachType::UDPRecvMsg6), + _ => Err(InvalidAttachType(value.to_owned())), + } + } +} diff --git a/aya-obj/src/programs/cgroup_sockopt.rs b/aya-obj/src/programs/cgroup_sockopt.rs new file mode 100644 index 00000000..daa4b250 --- /dev/null +++ b/aya-obj/src/programs/cgroup_sockopt.rs @@ -0,0 +1,36 @@ +//! Cgroup socket option programs. +use thiserror::Error; + +use crate::generated::bpf_attach_type; + +/// Defines where to attach a [`CgroupSockopt`] program. +#[derive(Copy, Clone, Debug)] +pub enum CgroupSockoptAttachType { + /// Attach to GetSockopt. + Get, + /// Attach to SetSockopt. + Set, +} + +impl From for bpf_attach_type { + fn from(s: CgroupSockoptAttachType) -> bpf_attach_type { + match s { + CgroupSockoptAttachType::Get => bpf_attach_type::BPF_CGROUP_GETSOCKOPT, + CgroupSockoptAttachType::Set => bpf_attach_type::BPF_CGROUP_SETSOCKOPT, + } + } +} + +#[derive(Debug, Error)] +#[error("{0} is not a valid attach type for a CGROUP_SOCKOPT program")] +pub(crate) struct InvalidAttachType(String); + +impl CgroupSockoptAttachType { + pub(crate) fn try_from(value: &str) -> Result { + match value { + "getsockopt" => Ok(CgroupSockoptAttachType::Get), + "setsockopt" => Ok(CgroupSockoptAttachType::Set), + _ => Err(InvalidAttachType(value.to_owned())), + } + } +} diff --git a/aya-obj/src/programs/mod.rs b/aya-obj/src/programs/mod.rs new file mode 100644 index 00000000..4f76211a --- /dev/null +++ b/aya-obj/src/programs/mod.rs @@ -0,0 +1,9 @@ +//! Program struct and type bindings. + +pub mod cgroup_sock; +pub mod cgroup_sock_addr; +pub mod cgroup_sockopt; + +pub use cgroup_sock::CgroupSockAttachType; +pub use cgroup_sock_addr::CgroupSockAddrAttachType; +pub use cgroup_sockopt::CgroupSockoptAttachType; diff --git a/aya/src/obj/relocation.rs b/aya-obj/src/relocation.rs similarity index 87% rename from aya/src/obj/relocation.rs rename to aya-obj/src/relocation.rs index 1564084a..6f56eb60 100644 --- a/aya/src/obj/relocation.rs +++ b/aya-obj/src/relocation.rs @@ -9,15 +9,23 @@ use crate::{ bpf_insn, BPF_CALL, BPF_JMP, BPF_K, BPF_PSEUDO_CALL, BPF_PSEUDO_FUNC, BPF_PSEUDO_MAP_FD, BPF_PSEUDO_MAP_VALUE, }, - maps::MapData, - obj::{Function, Object, Program}, - BpfError, + obj::{Function, Object, Program}, Map, }; pub(crate) const INS_SIZE: usize = mem::size_of::(); +#[derive(Error, Debug)] +#[error("error relocating `{function}`")] +pub struct BpfRelocationError { + /// The function name + function: String, + #[source] + /// The original error + error: RelocationError, +} + #[derive(Debug, Error)] -enum RelocationError { +pub enum RelocationError { #[error("unknown symbol, index `{index}`")] UnknownSymbol { index: usize }, @@ -43,7 +51,7 @@ enum RelocationError { } #[derive(Debug, Copy, Clone)] -pub(crate) struct Relocation { +pub struct Relocation { // byte offset of the instruction to be relocated pub(crate) offset: u64, // index of the symbol to relocate to @@ -51,7 +59,7 @@ pub(crate) struct Relocation { } #[derive(Debug, Clone)] -pub(crate) struct Symbol { +pub struct Symbol { pub(crate) index: usize, pub(crate) section_index: Option, pub(crate) name: Option, @@ -62,16 +70,16 @@ pub(crate) struct Symbol { } impl Object { - pub fn relocate_maps(&mut self, maps: &HashMap) -> Result<(), BpfError> { - let maps_by_section = maps - .iter() - .map(|(name, map)| (map.obj.section_index(), (name.as_str(), map))) - .collect::>(); - - let maps_by_symbol = maps - .iter() - .map(|(name, map)| (map.obj.symbol_index(), (name.as_str(), map))) - .collect::>(); + pub fn relocate_maps<'a, I: Iterator, &'a Map)>>( + &mut self, + maps: I, + ) -> Result<(), BpfRelocationError> { + let mut maps_by_section = HashMap::new(); + let mut maps_by_symbol = HashMap::new(); + for (name, fd, map) in maps { + maps_by_section.insert(map.section_index(), (name, fd, map)); + maps_by_symbol.insert(map.symbol_index(), (name, fd, map)); + } let functions = self .programs @@ -89,9 +97,9 @@ impl Object { &self.symbols_by_index, self.text_section_index, ) - .map_err(|error| BpfError::RelocationError { + .map_err(|error| BpfRelocationError { function: function.name.clone(), - error: Box::new(error), + error, })?; } } @@ -99,7 +107,7 @@ impl Object { Ok(()) } - pub fn relocate_calls(&mut self) -> Result<(), BpfError> { + pub fn relocate_calls(&mut self) -> Result<(), BpfRelocationError> { for (name, program) in self.programs.iter_mut() { let linker = FunctionLinker::new( self.text_section_index, @@ -109,9 +117,9 @@ impl Object { ); linker .link(program) - .map_err(|error| BpfError::RelocationError { - function: name.clone(), - error: Box::new(error), + .map_err(|error| BpfRelocationError{ + function: name.to_owned(), + error, })?; } @@ -122,8 +130,8 @@ impl Object { fn relocate_maps<'a, I: Iterator>( fun: &mut Function, relocations: I, - maps_by_section: &HashMap, - maps_by_symbol: &HashMap, + maps_by_section: &HashMap, &Map)>, + maps_by_symbol: &HashMap, &Map)>, symbol_table: &HashMap, text_section_index: Option, ) -> Result<(), RelocationError> { @@ -166,7 +174,7 @@ fn relocate_maps<'a, I: Iterator>( continue; } - let (name, map) = if maps_by_symbol.contains_key(&rel.symbol_index) { + let (name, fd, map) = if maps_by_symbol.contains_key(&rel.symbol_index) { maps_by_symbol .get(&rel.symbol_index) .ok_or(RelocationError::SectionNotFound { @@ -184,12 +192,12 @@ fn relocate_maps<'a, I: Iterator>( })? }; - let map_fd = map.fd.ok_or_else(|| RelocationError::MapNotCreated { + let map_fd = fd.ok_or_else(|| RelocationError::MapNotCreated { name: (*name).into(), section_index, })?; - if !map.obj.data().is_empty() { + if !map.data().is_empty() { instructions[ins_index].set_src_reg(BPF_PSEUDO_MAP_VALUE as u8); instructions[ins_index + 1].imm = instructions[ins_index].imm + sym.address as i32; } else { @@ -437,10 +445,9 @@ fn insn_is_call(ins: &bpf_insn) -> bool { #[cfg(test)] mod test { use crate::{ - bpf_map_def, - maps::MapData, + maps::bpf_map_def, obj::{self, BtfMap, LegacyMap, MapKind}, - BtfMapDef, + maps::BtfMapDef, }; use super::*; @@ -461,38 +468,28 @@ mod test { unsafe { std::ptr::read_unaligned(bytes.as_ptr() as *const _) } } - fn fake_legacy_map(fd: i32, symbol_index: usize) -> MapData { - MapData { - obj: obj::Map::Legacy(LegacyMap { - def: bpf_map_def { - ..Default::default() - }, - section_index: 0, - symbol_index, - data: Vec::new(), - kind: MapKind::Other, - }), - fd: Some(fd), - btf_fd: None, - pinned: false, - } + fn fake_legacy_map(symbol_index: usize) -> Map { + obj::Map::Legacy(LegacyMap { + def: bpf_map_def { + ..Default::default() + }, + section_index: 0, + symbol_index, + data: Vec::new(), + kind: MapKind::Other, + }) } - fn fake_btf_map(fd: i32, symbol_index: usize) -> MapData { - MapData { - obj: obj::Map::Btf(BtfMap { - def: BtfMapDef { - ..Default::default() - }, - section_index: 0, - symbol_index, - data: Vec::new(), - kind: MapKind::Other, - }), - fd: Some(fd), - btf_fd: None, - pinned: false, - } + fn fake_btf_map(symbol_index: usize) -> Map { + obj::Map::Btf(BtfMap { + def: BtfMapDef { + ..Default::default() + }, + section_index: 0, + symbol_index, + data: Vec::new(), + kind: MapKind::Other, + }) } fn fake_func(name: &str, instructions: Vec) -> Function { @@ -527,8 +524,8 @@ mod test { }]; let maps_by_section = HashMap::new(); - let map = fake_legacy_map(1, 1); - let maps_by_symbol = HashMap::from([(1, ("test_map", &map))]); + let map = fake_legacy_map(1); + let maps_by_symbol = HashMap::from([(1, ("test_map", Some(1), &map))]); relocate_maps( &mut fun, @@ -579,10 +576,10 @@ mod test { ]; let maps_by_section = HashMap::new(); - let map_1 = fake_legacy_map(1, 1); - let map_2 = fake_legacy_map(2, 2); + let map_1 = fake_legacy_map(1); + let map_2 = fake_legacy_map(2); let maps_by_symbol = - HashMap::from([(1, ("test_map_1", &map_1)), (2, ("test_map_2", &map_2))]); + HashMap::from([(1, ("test_map_1", Some(1), &map_1)), (2, ("test_map_2", Some(2), &map_2))]); relocate_maps( &mut fun, @@ -622,8 +619,8 @@ mod test { }]; let maps_by_section = HashMap::new(); - let map = fake_btf_map(1, 1); - let maps_by_symbol = HashMap::from([(1, ("test_map", &map))]); + let map = fake_btf_map(1); + let maps_by_symbol = HashMap::from([(1, ("test_map", Some(1), &map))]); relocate_maps( &mut fun, @@ -674,10 +671,10 @@ mod test { ]; let maps_by_section = HashMap::new(); - let map_1 = fake_btf_map(1, 1); - let map_2 = fake_btf_map(2, 2); + let map_1 = fake_btf_map(1); + let map_2 = fake_btf_map(2); let maps_by_symbol = - HashMap::from([(1, ("test_map_1", &map_1)), (2, ("test_map_2", &map_2))]); + HashMap::from([(1, ("test_map_1", Some(1), &map_1)), (2, ("test_map_2", Some(2), &map_2))]); relocate_maps( &mut fun, diff --git a/aya-obj/src/util.rs b/aya-obj/src/util.rs new file mode 100644 index 00000000..6c208ec9 --- /dev/null +++ b/aya-obj/src/util.rs @@ -0,0 +1,7 @@ +use core::{mem, slice}; + +/// bytes_of converts a to a byte slice +pub(crate) unsafe fn bytes_of(val: &T) -> &[u8] { + let size = mem::size_of::(); + slice::from_raw_parts(slice::from_ref(val).as_ptr().cast(), size) +} \ No newline at end of file diff --git a/aya/src/bpf.rs b/aya/src/bpf.rs index f9e209c6..d1988f67 100644 --- a/aya/src/bpf.rs +++ b/aya/src/bpf.rs @@ -1,13 +1,13 @@ use std::{ borrow::Cow, collections::{HashMap, HashSet}, - error::Error, ffi::CString, fs, io, os::{raw::c_int, unix::io::RawFd}, path::{Path, PathBuf}, }; +use aya_obj::{btf::{BtfFeatures, BtfRelocationError}, relocation::BpfRelocationError}; use log::debug; use thiserror::Error; @@ -58,75 +58,15 @@ unsafe_impl_pod!(i8, u8, i16, u16, i32, u32, i64, u64, u128, i128); // It only makes sense that an array of POD types is itself POD unsafe impl Pod for [T; N] {} -#[allow(non_camel_case_types)] -#[repr(C)] -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] -pub(crate) struct bpf_map_def { - // minimum features required by old BPF programs - pub(crate) map_type: u32, - pub(crate) key_size: u32, - pub(crate) value_size: u32, - pub(crate) max_entries: u32, - pub(crate) map_flags: u32, - // optional features - pub(crate) id: u32, - pub(crate) pinning: PinningType, -} - -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] -pub(crate) struct BtfMapDef { - pub(crate) map_type: u32, - pub(crate) key_size: u32, - pub(crate) value_size: u32, - pub(crate) max_entries: u32, - pub(crate) map_flags: u32, - pub(crate) pinning: PinningType, - pub(crate) btf_key_type_id: u32, - pub(crate) btf_value_type_id: u32, -} - -#[repr(u32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub(crate) enum PinningType { - None = 0, - ByName = 1, -} - -#[derive(Debug, Error)] -pub(crate) enum PinningError { - #[error("unsupported pinning type")] - Unsupported, -} - -impl TryFrom for PinningType { - type Error = PinningError; - - fn try_from(value: u32) -> Result { - match value { - 0 => Ok(PinningType::None), - 1 => Ok(PinningType::ByName), - _ => Err(PinningError::Unsupported), - } - } -} - -impl Default for PinningType { - fn default() -> Self { - PinningType::None - } -} +pub use aya_obj::maps::bpf_map_def; +pub use aya_obj::maps::BtfMapDef; +pub use aya_obj::maps::PinningType; // Features implements BPF and BTF feature detection #[derive(Default, Debug)] pub(crate) struct Features { pub bpf_name: bool, - pub btf: bool, - pub btf_func: bool, - pub btf_func_global: bool, - pub btf_datasec: bool, - pub btf_float: bool, - pub btf_decl_tag: bool, - pub btf_type_tag: bool, + pub btf: Option, } impl Features { @@ -134,33 +74,37 @@ impl Features { self.bpf_name = is_prog_name_supported(); debug!("[FEAT PROBE] BPF program name support: {}", self.bpf_name); - self.btf = is_btf_supported(); - debug!("[FEAT PROBE] BTF support: {}", self.btf); + self.btf = if is_btf_supported() { + Some(BtfFeatures::default()) + } else { + None + }; + debug!("[FEAT PROBE] BTF support: {}", self.btf.is_some()); - if self.btf { - self.btf_func = is_btf_func_supported(); - debug!("[FEAT PROBE] BTF func support: {}", self.btf_func); + if let Some(ref mut btf) = self.btf { + btf.btf_func = is_btf_func_supported(); + debug!("[FEAT PROBE] BTF func support: {}", btf.btf_func); - self.btf_func_global = is_btf_func_global_supported(); + btf.btf_func_global = is_btf_func_global_supported(); debug!( "[FEAT PROBE] BTF global func support: {}", - self.btf_func_global + btf.btf_func_global ); - self.btf_datasec = is_btf_datasec_supported(); + btf.btf_datasec = is_btf_datasec_supported(); debug!( "[FEAT PROBE] BTF var and datasec support: {}", - self.btf_datasec + btf.btf_datasec ); - self.btf_float = is_btf_float_supported(); - debug!("[FEAT PROBE] BTF float support: {}", self.btf_float); + btf.btf_float = is_btf_float_supported(); + debug!("[FEAT PROBE] BTF float support: {}", btf.btf_float); - self.btf_decl_tag = is_btf_decl_tag_supported(); - debug!("[FEAT PROBE] BTF decl_tag support: {}", self.btf_decl_tag); + btf.btf_decl_tag = is_btf_decl_tag_supported(); + debug!("[FEAT PROBE] BTF decl_tag support: {}", btf.btf_decl_tag); - self.btf_type_tag = is_btf_type_tag_supported(); - debug!("[FEAT PROBE] BTF type_tag support: {}", self.btf_type_tag); + btf.btf_type_tag = is_btf_type_tag_supported(); + debug!("[FEAT PROBE] BTF type_tag support: {}", btf.btf_type_tag); } } } @@ -413,12 +357,12 @@ impl<'a> BpfLoader<'a> { let mut obj = Object::parse(data)?; obj.patch_map_data(self.globals.clone())?; - let btf_fd = if self.features.btf { + let btf_fd = if let Some(ref btf) = self.features.btf { if let Some(ref mut obj_btf) = obj.btf { // fixup btf let section_data = obj.section_sizes.clone(); let symbol_offsets = obj.symbol_offset_by_name.clone(); - obj_btf.fixup_and_sanitize(§ion_data, &symbol_offsets, &self.features)?; + obj_btf.fixup_and_sanitize(§ion_data, &symbol_offsets, btf)?; // load btf to the kernel let raw_btf = obj_btf.to_bytes(); Some(load_btf(raw_btf)?) @@ -497,7 +441,7 @@ impl<'a> BpfLoader<'a> { maps.insert(name, map); } - obj.relocate_maps(&maps)?; + obj.relocate_maps(maps.iter().map(|(s, data)| (s.as_str(), data.fd, &data.obj)))?; obj.relocate_calls()?; let programs = obj @@ -921,14 +865,12 @@ pub enum BpfError { BtfError(#[from] BtfError), /// Error performing relocations - #[error("error relocating `{function}`")] - RelocationError { - /// The function name - function: String, - #[source] - /// The original error - error: Box, - }, + #[error("error relocating function")] + RelocationError(#[from] BpfRelocationError), + + /// Error performing relocations + #[error("error relocating section")] + BtfRelocationError(#[from] BtfRelocationError), /// No BTF parsed for object #[error("no BTF parsed for object")] diff --git a/aya/src/lib.rs b/aya/src/lib.rs index 8d235095..8d5be4d9 100644 --- a/aya/src/lib.rs +++ b/aya/src/lib.rs @@ -46,9 +46,9 @@ extern crate lazy_static; extern crate bitflags; mod bpf; -use aya_obj::generated as generated; +use aya_obj::generated; pub mod maps; -mod obj; +use aya_obj as obj; pub mod pin; pub mod programs; mod sys; diff --git a/aya/src/programs/cgroup_sock.rs b/aya/src/programs/cgroup_sock.rs index 2a87a91d..4463116c 100644 --- a/aya/src/programs/cgroup_sock.rs +++ b/aya/src/programs/cgroup_sock.rs @@ -1,7 +1,6 @@ //! Cgroup socket programs. -use thiserror::Error; +pub use aya_obj::programs::CgroupSockAttachType; -use crate::generated::bpf_attach_type; use std::{ hash::Hash, os::unix::prelude::{AsRawFd, RawFd}, @@ -154,51 +153,3 @@ define_link_wrapper!( CgroupSockLinkInner, CgroupSockLinkIdInner ); - -/// Defines where to attach a [`CgroupSock`] program. -#[derive(Copy, Clone, Debug)] -pub enum CgroupSockAttachType { - /// Called after the IPv4 bind events. - PostBind4, - /// Called after the IPv6 bind events. - PostBind6, - /// Attach to IPv4 connect events. - SockCreate, - /// Attach to IPv6 connect events. - SockRelease, -} - -impl Default for CgroupSockAttachType { - // The kernel checks for a 0 attach_type and sets it to sock_create - // We may as well do that here also - fn default() -> Self { - CgroupSockAttachType::SockCreate - } -} - -impl From for bpf_attach_type { - fn from(s: CgroupSockAttachType) -> bpf_attach_type { - match s { - CgroupSockAttachType::PostBind4 => bpf_attach_type::BPF_CGROUP_INET4_POST_BIND, - CgroupSockAttachType::PostBind6 => bpf_attach_type::BPF_CGROUP_INET6_POST_BIND, - CgroupSockAttachType::SockCreate => bpf_attach_type::BPF_CGROUP_INET_SOCK_CREATE, - CgroupSockAttachType::SockRelease => bpf_attach_type::BPF_CGROUP_INET_SOCK_RELEASE, - } - } -} - -#[derive(Debug, Error)] -#[error("{0} is not a valid attach type for a CGROUP_SOCK program")] -pub(crate) struct InvalidAttachType(String); - -impl CgroupSockAttachType { - pub(crate) fn try_from(value: &str) -> Result { - match value { - "post_bind4" => Ok(CgroupSockAttachType::PostBind4), - "post_bind6" => Ok(CgroupSockAttachType::PostBind6), - "sock_create" => Ok(CgroupSockAttachType::SockCreate), - "sock_release" => Ok(CgroupSockAttachType::SockRelease), - _ => Err(InvalidAttachType(value.to_owned())), - } - } -} diff --git a/aya/src/programs/cgroup_sock_addr.rs b/aya/src/programs/cgroup_sock_addr.rs index 2f8aac7d..12345b5e 100644 --- a/aya/src/programs/cgroup_sock_addr.rs +++ b/aya/src/programs/cgroup_sock_addr.rs @@ -1,7 +1,6 @@ //! Cgroup socket address programs. -use thiserror::Error; +pub use aya_obj::programs::CgroupSockAddrAttachType; -use crate::generated::bpf_attach_type; use std::{ hash::Hash, os::unix::prelude::{AsRawFd, RawFd}, @@ -160,75 +159,3 @@ define_link_wrapper!( CgroupSockAddrLinkInner, CgroupSockAddrLinkIdInner ); - -/// Defines where to attach a [`CgroupSockAddr`] program. -#[derive(Copy, Clone, Debug)] -pub enum CgroupSockAddrAttachType { - /// Attach to IPv4 bind events. - Bind4, - /// Attach to IPv6 bind events. - Bind6, - /// Attach to IPv4 connect events. - Connect4, - /// Attach to IPv6 connect events. - Connect6, - /// Attach to IPv4 getpeername events. - GetPeerName4, - /// Attach to IPv6 getpeername events. - GetPeerName6, - /// Attach to IPv4 getsockname events. - GetSockName4, - /// Attach to IPv6 getsockname events. - GetSockName6, - /// Attach to IPv4 udp_sendmsg events. - UDPSendMsg4, - /// Attach to IPv6 udp_sendmsg events. - UDPSendMsg6, - /// Attach to IPv4 udp_recvmsg events. - UDPRecvMsg4, - /// Attach to IPv6 udp_recvmsg events. - UDPRecvMsg6, -} - -impl From for bpf_attach_type { - fn from(s: CgroupSockAddrAttachType) -> bpf_attach_type { - match s { - CgroupSockAddrAttachType::Bind4 => bpf_attach_type::BPF_CGROUP_INET4_BIND, - CgroupSockAddrAttachType::Bind6 => bpf_attach_type::BPF_CGROUP_INET6_BIND, - CgroupSockAddrAttachType::Connect4 => bpf_attach_type::BPF_CGROUP_INET4_CONNECT, - CgroupSockAddrAttachType::Connect6 => bpf_attach_type::BPF_CGROUP_INET6_CONNECT, - CgroupSockAddrAttachType::GetPeerName4 => bpf_attach_type::BPF_CGROUP_INET4_GETPEERNAME, - CgroupSockAddrAttachType::GetPeerName6 => bpf_attach_type::BPF_CGROUP_INET6_GETPEERNAME, - CgroupSockAddrAttachType::GetSockName4 => bpf_attach_type::BPF_CGROUP_INET4_GETSOCKNAME, - CgroupSockAddrAttachType::GetSockName6 => bpf_attach_type::BPF_CGROUP_INET6_GETSOCKNAME, - CgroupSockAddrAttachType::UDPSendMsg4 => bpf_attach_type::BPF_CGROUP_UDP4_SENDMSG, - CgroupSockAddrAttachType::UDPSendMsg6 => bpf_attach_type::BPF_CGROUP_UDP6_SENDMSG, - CgroupSockAddrAttachType::UDPRecvMsg4 => bpf_attach_type::BPF_CGROUP_UDP4_RECVMSG, - CgroupSockAddrAttachType::UDPRecvMsg6 => bpf_attach_type::BPF_CGROUP_UDP6_RECVMSG, - } - } -} - -#[derive(Debug, Error)] -#[error("{0} is not a valid attach type for a CGROUP_SOCK_ADDR program")] -pub(crate) struct InvalidAttachType(String); - -impl CgroupSockAddrAttachType { - pub(crate) fn try_from(value: &str) -> Result { - match value { - "bind4" => Ok(CgroupSockAddrAttachType::Bind4), - "bind6" => Ok(CgroupSockAddrAttachType::Bind6), - "connect4" => Ok(CgroupSockAddrAttachType::Connect4), - "connect6" => Ok(CgroupSockAddrAttachType::Connect6), - "getpeername4" => Ok(CgroupSockAddrAttachType::GetPeerName4), - "getpeername6" => Ok(CgroupSockAddrAttachType::GetPeerName6), - "getsockname4" => Ok(CgroupSockAddrAttachType::GetSockName4), - "getsockname6" => Ok(CgroupSockAddrAttachType::GetSockName6), - "sendmsg4" => Ok(CgroupSockAddrAttachType::UDPSendMsg4), - "sendmsg6" => Ok(CgroupSockAddrAttachType::UDPSendMsg6), - "recvmsg4" => Ok(CgroupSockAddrAttachType::UDPRecvMsg4), - "recvmsg6" => Ok(CgroupSockAddrAttachType::UDPRecvMsg6), - _ => Err(InvalidAttachType(value.to_owned())), - } - } -} diff --git a/aya/src/programs/cgroup_sockopt.rs b/aya/src/programs/cgroup_sockopt.rs index 669e4f99..de4c1f43 100644 --- a/aya/src/programs/cgroup_sockopt.rs +++ b/aya/src/programs/cgroup_sockopt.rs @@ -1,5 +1,5 @@ //! Cgroup socket option programs. -use thiserror::Error; +pub use aya_obj::programs::CgroupSockoptAttachType; use std::{ hash::Hash, @@ -9,7 +9,7 @@ use std::{ use crate::{ generated::bpf_prog_type::BPF_PROG_TYPE_CGROUP_SOCKOPT, programs::{ - bpf_attach_type, define_link_wrapper, load_program, FdLink, Link, ProgAttachLink, + define_link_wrapper, load_program, FdLink, Link, ProgAttachLink, ProgramData, ProgramError, }, sys::{bpf_link_create, bpf_prog_attach, kernel_version}, @@ -155,35 +155,3 @@ define_link_wrapper!( CgroupSockoptLinkInner, CgroupSockoptLinkIdInner ); - -/// Defines where to attach a [`CgroupSockopt`] program. -#[derive(Copy, Clone, Debug)] -pub enum CgroupSockoptAttachType { - /// Attach to GetSockopt. - Get, - /// Attach to SetSockopt. - Set, -} - -impl From for bpf_attach_type { - fn from(s: CgroupSockoptAttachType) -> bpf_attach_type { - match s { - CgroupSockoptAttachType::Get => bpf_attach_type::BPF_CGROUP_GETSOCKOPT, - CgroupSockoptAttachType::Set => bpf_attach_type::BPF_CGROUP_SETSOCKOPT, - } - } -} - -#[derive(Debug, Error)] -#[error("{0} is not a valid attach type for a CGROUP_SOCKOPT program")] -pub(crate) struct InvalidAttachType(String); - -impl CgroupSockoptAttachType { - pub(crate) fn try_from(value: &str) -> Result { - match value { - "getsockopt" => Ok(CgroupSockoptAttachType::Get), - "setsockopt" => Ok(CgroupSockoptAttachType::Set), - _ => Err(InvalidAttachType(value.to_owned())), - } - } -} From e52497cb9c02123ae450ca36fb6f898d24b25c4b Mon Sep 17 00:00:00 2001 From: Shenghui Ye Date: Wed, 28 Dec 2022 10:15:29 +0800 Subject: [PATCH 07/51] aya-obj: add basic documentation to public members Types relevant to maps are moved into aya_obj::maps. Some members are marked `pub(crate)` again. Refs: #473 --- aya-obj/src/btf/btf.rs | 40 ++++- aya-obj/src/btf/info.rs | 29 +++- aya-obj/src/btf/mod.rs | 5 +- aya-obj/src/btf/relocation.rs | 63 ++++++-- aya-obj/src/btf/types.rs | 2 + aya-obj/src/lib.rs | 3 +- aya-obj/src/maps.rs | 196 ++++++++++++++++++++++- aya-obj/src/obj.rs | 190 ++++++---------------- aya-obj/src/programs/cgroup_sock.rs | 2 +- aya-obj/src/programs/cgroup_sock_addr.rs | 2 +- aya-obj/src/programs/cgroup_sockopt.rs | 2 +- aya-obj/src/relocation.rs | 74 ++++++--- aya-obj/src/util.rs | 2 +- aya/src/bpf.rs | 26 +-- aya/src/maps/bloom_filter.rs | 13 +- aya/src/maps/hash_map/hash_map.rs | 13 +- aya/src/maps/lpm_trie.rs | 13 +- aya/src/maps/mod.rs | 4 +- aya/src/programs/cgroup_sockopt.rs | 3 +- 19 files changed, 458 insertions(+), 224 deletions(-) diff --git a/aya-obj/src/btf/btf.rs b/aya-obj/src/btf/btf.rs index e8da97e1..193e9528 100644 --- a/aya-obj/src/btf/btf.rs +++ b/aya-obj/src/btf/btf.rs @@ -15,14 +15,15 @@ use object::Endianness; use thiserror::Error; use crate::{ - generated::{btf_ext_header, btf_header}, btf::{ info::{FuncSecInfo, LineSecInfo}, relocation::Relocation, Array, BtfEnum, BtfKind, BtfMember, BtfType, Const, Enum, FuncInfo, FuncLinkage, Int, IntEncoding, LineInfo, Struct, Typedef, VarLinkage, }, + generated::{btf_ext_header, btf_header}, util::bytes_of, + Object, }; pub(crate) const MAX_RESOLVE_DEPTH: u8 = 32; @@ -157,7 +158,9 @@ pub enum BtfError { InvalidSymbolName, } +/// Available BTF features #[derive(Default, Debug)] +#[allow(missing_docs)] pub struct BtfFeatures { pub btf_func: bool, pub btf_func_global: bool, @@ -172,9 +175,9 @@ pub struct BtfFeatures { /// BTF is a kind of debug metadata that allows eBPF programs compiled against one kernel version /// to be loaded into different kernel versions. /// -/// Aya automatically loads BTF metadata if you use [`Bpf::load_file`](crate::Bpf::load_file). You +/// Aya automatically loads BTF metadata if you use `Bpf::load_file`. You /// only need to explicitly use this type if you want to load BTF from a non-standard -/// location or if you are using [`Bpf::load`](crate::Bpf::load). +/// location or if you are using `Bpf::load`. #[derive(Clone, Debug)] pub struct Btf { header: btf_header, @@ -184,6 +187,7 @@ pub struct Btf { } impl Btf { + /// Creates a new empty instance with its header initialized pub fn new() -> Btf { Btf { header: btf_header { @@ -206,6 +210,7 @@ impl Btf { self.types.types.iter() } + /// Adds a string to BTF metadata, returning an offset pub fn add_string(&mut self, name: String) -> u32 { let str = CString::new(name).unwrap(); let name_offset = self.strings.len(); @@ -214,6 +219,7 @@ impl Btf { name_offset as u32 } + /// Adds a type to BTF metadata, returning a type id pub fn add_type(&mut self, btf_type: BtfType) -> u32 { let size = btf_type.type_info_size() as u32; let type_id = self.types.len(); @@ -240,6 +246,7 @@ impl Btf { ) } + /// Parses BTF from binary data of the given endianness pub fn parse(data: &[u8], endianness: Endianness) -> Result { if data.len() < mem::size_of::() { return Err(BtfError::InvalidHeader); @@ -333,6 +340,7 @@ impl Btf { self.string_at(ty.name_offset()).ok().map(String::from) } + /// Returns a type id matching the type name and [BtfKind] pub fn id_by_type_name_kind(&self, name: &str, kind: BtfKind) -> Result { for (type_id, ty) in self.types().enumerate() { if ty.kind() != kind { @@ -379,6 +387,7 @@ impl Btf { }) } + /// Encodes the metadata as BTF format pub fn to_bytes(&self) -> Vec { // Safety: btf_header is POD let mut buf = unsafe { bytes_of::(&self.header).to_vec() }; @@ -388,7 +397,7 @@ impl Btf { buf } - pub fn fixup_and_sanitize( + pub(crate) fn fixup_and_sanitize( &mut self, section_sizes: &HashMap, symbol_offsets: &HashMap, @@ -569,11 +578,34 @@ impl Default for Btf { } } +impl Object { + /// Fixes up and sanitizes BTF data. + /// + /// Mostly, it removes unsupported types and works around LLVM behaviours. + pub fn fixup_and_sanitize_btf( + &mut self, + features: &BtfFeatures, + ) -> Result, BtfError> { + if let Some(ref mut obj_btf) = self.btf { + // fixup btf + obj_btf.fixup_and_sanitize( + &self.section_sizes, + &self.symbol_offset_by_name, + features, + )?; + Ok(Some(obj_btf)) + } else { + Ok(None) + } + } +} + unsafe fn read_btf_header(data: &[u8]) -> btf_header { // safety: btf_header is POD so read_unaligned is safe ptr::read_unaligned(data.as_ptr() as *const btf_header) } +/// Data in .BTF.ext section #[derive(Debug, Clone)] pub struct BtfExt { data: Vec, diff --git a/aya-obj/src/btf/info.rs b/aya-obj/src/btf/info.rs index d265a3a9..5d1652c4 100644 --- a/aya-obj/src/btf/info.rs +++ b/aya-obj/src/btf/info.rs @@ -19,10 +19,18 @@ use crate::{ * a list of bpf_func_info records for section #2 * ...... */ + +/// A collection of [bpf_func_info] collected from the `btf_ext_info_sec` struct +/// inside the [FuncInfo] subsection. +/// +/// See [BPF Type Format (BTF) — The Linux Kernel documentation](https://docs.kernel.org/bpf/btf.html) +/// for more information. #[derive(Debug, Clone, Default)] pub struct FuncSecInfo { - pub _sec_name_offset: u32, + pub(crate) _sec_name_offset: u32, + /// The number of info entries pub num_info: u32, + /// Info entries pub func_info: Vec, } @@ -64,6 +72,7 @@ impl FuncSecInfo { } } + /// Encodes the [bpf_func_info] entries pub fn func_info_bytes(&self) -> Vec { let mut buf = vec![]; for l in &self.func_info { @@ -73,13 +82,20 @@ impl FuncSecInfo { buf } + /// Returns the number of [bpf_func_info] entries pub fn len(&self) -> usize { self.func_info.len() } } +/// A collection of [FuncSecInfo] collected from the `func_info` subsection +/// in the `.BTF.ext` section. +/// +/// See [BPF Type Format (BTF) — The Linux Kernel documentation](https://docs.kernel.org/bpf/btf.html) +/// for more information. #[derive(Debug, Clone)] pub struct FuncInfo { + /// The [FuncSecInfo] subsections for some sections, referenced by section names pub data: HashMap, } @@ -98,12 +114,19 @@ impl FuncInfo { } } +/// A collection of [bpf_line_info] collected from the `btf_ext_info_sec` struct +/// inside the `line_info` subsection. +/// +/// See [BPF Type Format (BTF) — The Linux Kernel documentation](https://docs.kernel.org/bpf/btf.html) +/// for more information. #[derive(Debug, Clone, Default)] pub struct LineSecInfo { // each line info section has a header - pub _sec_name_offset: u32, + pub(crate) _sec_name_offset: u32, + /// The number of entries pub num_info: u32, // followed by one or more bpf_line_info structs + /// The [bpf_line_info] entries pub line_info: Vec, } @@ -154,6 +177,7 @@ impl LineSecInfo { } } + /// Encode the entries pub fn line_info_bytes(&self) -> Vec { let mut buf = vec![]; for l in &self.line_info { @@ -163,6 +187,7 @@ impl LineSecInfo { buf } + /// Returns the number of entries pub fn len(&self) -> usize { self.line_info.len() } diff --git a/aya-obj/src/btf/mod.rs b/aya-obj/src/btf/mod.rs index 44bf123f..a5606e5e 100644 --- a/aya-obj/src/btf/mod.rs +++ b/aya-obj/src/btf/mod.rs @@ -7,5 +7,6 @@ mod relocation; mod types; pub use btf::*; -pub(crate) use info::*; -pub(crate) use types::*; +pub use info::*; +pub use relocation::BtfRelocationError; +pub use types::*; diff --git a/aya-obj/src/btf/relocation.rs b/aya-obj/src/btf/relocation.rs index b3e89d93..641e7265 100644 --- a/aya-obj/src/btf/relocation.rs +++ b/aya-obj/src/btf/relocation.rs @@ -14,6 +14,7 @@ use crate::{ Object, Program, ProgramSection, }; +/// The error type returned by [`Object::relocate_btf`]. #[derive(Error, Debug)] #[error("error relocating `{section}`")] pub struct BtfRelocationError { @@ -24,58 +25,91 @@ pub struct BtfRelocationError { error: RelocationError, } +/// Relocation failures #[derive(Error, Debug)] enum RelocationError { + /// I/O error #[error(transparent)] IOError(#[from] io::Error), + /// Program not found #[error("program not found")] ProgramNotFound, + /// Invalid relocation access string #[error("invalid relocation access string {access_str}")] - InvalidAccessString { access_str: String }, + InvalidAccessString { + /// The access string + access_str: String, + }, + /// Invalid instruction index referenced by relocation #[error("invalid instruction index #{index} referenced by relocation #{relocation_number}, the program contains {num_instructions} instructions")] InvalidInstructionIndex { + /// The invalid instruction index index: usize, + /// Number of instructions in the program num_instructions: usize, + /// The relocation number relocation_number: usize, }, + /// Multiple candidate target types found with different memory layouts #[error("error relocating {type_name}, multiple candidate target types found with different memory layouts: {candidates:?}")] ConflictingCandidates { + /// The type name type_name: String, + /// The candidates candidates: Vec, }, + /// Maximum nesting level reached evaluating candidate type #[error("maximum nesting level reached evaluating candidate type `{}`", err_type_name(.type_name))] - MaximumNestingLevelReached { type_name: Option }, + MaximumNestingLevelReached { + /// The type name + type_name: Option, + }, + /// Invalid access string #[error("invalid access string `{spec}` for type `{}`: {error}", err_type_name(.type_name))] InvalidAccessIndex { + /// The type name type_name: Option, + /// The access string spec: String, + /// The index index: usize, + /// The max index max_index: usize, + /// The error message error: String, }, + /// Relocation not valid for type #[error( "relocation #{relocation_number} of kind `{relocation_kind}` not valid for type `{type_kind}`: {error}" )] InvalidRelocationKindForType { + /// The relocation number relocation_number: usize, + /// The relocation kind relocation_kind: String, + /// The type kind type_kind: String, + /// The error message error: String, }, + /// Invalid instruction referenced by relocation #[error( "instruction #{index} referenced by relocation #{relocation_number} is invalid: {error}" )] InvalidInstruction { + /// The relocation number relocation_number: usize, + /// The instruction index index: usize, + /// The error message error: String, }, @@ -86,6 +120,7 @@ enum RelocationError { ins_index: usize, }, + /// BTF error #[error("invalid BTF")] BtfError(#[from] BtfError), } @@ -136,7 +171,7 @@ impl TryFrom for RelocationKind { } #[derive(Debug, Copy, Clone)] -pub struct Relocation { +pub(crate) struct Relocation { kind: RelocationKind, ins_offset: usize, type_id: u32, @@ -164,6 +199,7 @@ impl Relocation { } impl Object { + /// Relocate programs inside this object file with loaded BTF info. pub fn relocate_btf(&mut self, target_btf: &Btf) -> Result<(), BtfRelocationError> { let (local_btf, btf_ext) = match (&self.btf, &self.btf_ext) { (Some(btf), Some(btf_ext)) => (btf, btf_ext), @@ -172,10 +208,13 @@ impl Object { let mut candidates_cache = HashMap::>::new(); for (sec_name_off, relos) in btf_ext.relocations() { - let section_name = local_btf.string_at(*sec_name_off).map_err(|e| BtfRelocationError { - section: format!("section@{sec_name_off}"), - error: RelocationError::BtfError(e), - })?; + let section_name = + local_btf + .string_at(*sec_name_off) + .map_err(|e| BtfRelocationError { + section: format!("section@{sec_name_off}"), + error: RelocationError::BtfError(e), + })?; let program_section = match ProgramSection::from_str(§ion_name) { Ok(program) => program, @@ -193,10 +232,12 @@ impl Object { match relocate_btf_program(program, relos, local_btf, target_btf, &mut candidates_cache) { Ok(_) => {} - Err(error) => return Err(BtfRelocationError { - section: section_name.to_owned(), - error, - }), + Err(error) => { + return Err(BtfRelocationError { + section: section_name.to_owned(), + error, + }) + } } } diff --git a/aya-obj/src/btf/types.rs b/aya-obj/src/btf/types.rs index f50b6d07..2f5cfc1e 100644 --- a/aya-obj/src/btf/types.rs +++ b/aya-obj/src/btf/types.rs @@ -1,3 +1,5 @@ +#![allow(missing_docs)] + use std::{fmt::Display, mem, ptr}; use object::Endianness; diff --git a/aya-obj/src/lib.rs b/aya-obj/src/lib.rs index d145d2aa..22ceb1cc 100644 --- a/aya-obj/src/lib.rs +++ b/aya-obj/src/lib.rs @@ -5,7 +5,7 @@ html_favicon_url = "https://aya-rs.dev/assets/images/crabby.svg" )] #![cfg_attr(docsrs, feature(doc_cfg))] -#![deny(clippy::all)] +#![deny(clippy::all, missing_docs)] #![allow(clippy::missing_safety_doc, clippy::len_without_is_empty)] pub mod btf; @@ -16,4 +16,5 @@ pub mod programs; pub mod relocation; mod util; +pub use maps::Map; pub use obj::*; diff --git a/aya-obj/src/maps.rs b/aya-obj/src/maps.rs index 94d0b590..b54f3bbb 100644 --- a/aya-obj/src/maps.rs +++ b/aya-obj/src/maps.rs @@ -1,5 +1,7 @@ //! Map struct and type bindings. +use core::mem; + use thiserror::Error; /// Invalid map type encontered @@ -52,6 +54,7 @@ impl TryFrom for crate::generated::bpf_map_type { } } +/// BTF definition of a map #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] pub struct BtfMapDef { pub(crate) map_type: u32, @@ -60,21 +63,34 @@ pub struct BtfMapDef { pub(crate) max_entries: u32, pub(crate) map_flags: u32, pub(crate) pinning: PinningType, + /// BTF type id of the map key pub btf_key_type_id: u32, + /// BTF type id of the map value pub btf_value_type_id: u32, } +/// The pinning type +/// +/// Upon pinning a map, a file representation is created for the map, +/// so that the map can be alive and retrievable across sessions. #[repr(u32)] #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum PinningType { + /// No pinning None = 0, + /// Pin by the name ByName = 1, } +/// The error type returned when failing to parse a [PinningType] #[derive(Debug, Error)] pub enum PinningError { - #[error("unsupported pinning type")] - Unsupported, + /// Unsupported pinning type + #[error("unsupported pinning type `{pinning_type}`")] + Unsupported { + /// The unsupported pinning type + pinning_type: u32, + }, } impl TryFrom for PinningType { @@ -84,7 +100,7 @@ impl TryFrom for PinningType { match value { 0 => Ok(PinningType::None), 1 => Ok(PinningType::ByName), - _ => Err(PinningError::Unsupported), + pinning_type => Err(PinningError::Unsupported { pinning_type }), } } } @@ -95,17 +111,191 @@ impl Default for PinningType { } } +/// Map definition in legacy BPF map declaration style #[allow(non_camel_case_types)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] pub struct bpf_map_def { // minimum features required by old BPF programs + /// The map type pub map_type: u32, + /// The key_size pub key_size: u32, + /// The value size pub value_size: u32, + /// Max entry number pub max_entries: u32, + /// Map flags pub map_flags: u32, // optional features + /// Id pub id: u32, + /// Pinning type pub pinning: PinningType, } + +/// The first five __u32 of `bpf_map_def` must be defined. +pub(crate) const MINIMUM_MAP_SIZE: usize = mem::size_of::() * 5; + +/// Kinds of maps +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum MapKind { + /// A map holding `.bss` section data + Bss, + /// A map holding `.data` section data + Data, + /// A map holding `.rodata` section data + Rodata, + /// Other maps + Other, +} + +impl From<&str> for MapKind { + fn from(s: &str) -> Self { + if s == ".bss" { + MapKind::Bss + } else if s.starts_with(".data") { + MapKind::Data + } else if s.starts_with(".rodata") { + MapKind::Rodata + } else { + MapKind::Other + } + } +} + +/// Map data defined in `maps` or `.maps` sections +#[derive(Debug, Clone)] +pub enum Map { + /// A map defined in the `maps` section + Legacy(LegacyMap), + /// A map defined in the `.maps` section + Btf(BtfMap), +} + +impl Map { + /// Returns the map type + pub fn map_type(&self) -> u32 { + match self { + Map::Legacy(m) => m.def.map_type, + Map::Btf(m) => m.def.map_type, + } + } + + /// Returns the key size in bytes + pub fn key_size(&self) -> u32 { + match self { + Map::Legacy(m) => m.def.key_size, + Map::Btf(m) => m.def.key_size, + } + } + + /// Returns the value size in bytes + pub fn value_size(&self) -> u32 { + match self { + Map::Legacy(m) => m.def.value_size, + Map::Btf(m) => m.def.value_size, + } + } + + /// Returns the max entry number + pub fn max_entries(&self) -> u32 { + match self { + Map::Legacy(m) => m.def.max_entries, + Map::Btf(m) => m.def.max_entries, + } + } + + /// Sets the max entry number + pub fn set_max_entries(&mut self, v: u32) { + match self { + Map::Legacy(m) => m.def.max_entries = v, + Map::Btf(m) => m.def.max_entries = v, + } + } + + /// Returns the map flags + pub fn map_flags(&self) -> u32 { + match self { + Map::Legacy(m) => m.def.map_flags, + Map::Btf(m) => m.def.map_flags, + } + } + + /// Returns the pinning type of the map + pub fn pinning(&self) -> PinningType { + match self { + Map::Legacy(m) => m.def.pinning, + Map::Btf(m) => m.def.pinning, + } + } + + /// Returns the map data + pub fn data(&self) -> &[u8] { + match self { + Map::Legacy(m) => &m.data, + Map::Btf(m) => &m.data, + } + } + + /// Returns the map data as mutable + pub fn data_mut(&mut self) -> &mut Vec { + match self { + Map::Legacy(m) => m.data.as_mut(), + Map::Btf(m) => m.data.as_mut(), + } + } + + /// Returns the map kind + pub fn kind(&self) -> MapKind { + match self { + Map::Legacy(m) => m.kind, + Map::Btf(m) => m.kind, + } + } + + /// Returns the section index + pub fn section_index(&self) -> usize { + match self { + Map::Legacy(m) => m.section_index, + Map::Btf(m) => m.section_index, + } + } + + /// Returns the symbol index + pub fn symbol_index(&self) -> usize { + match self { + Map::Legacy(m) => m.symbol_index, + Map::Btf(m) => m.symbol_index, + } + } +} + +/// A map declared with legacy BPF map declaration style, most likely from a `maps` section. +/// +/// See [Drop support for legacy BPF map declaration syntax - Libbpf: the road to v1.0](https://github.com/libbpf/libbpf/wiki/Libbpf:-the-road-to-v1.0#drop-support-for-legacy-bpf-map-declaration-syntax) +/// for more info. +#[derive(Debug, Clone)] +pub struct LegacyMap { + /// The definition of the map + pub def: bpf_map_def, + /// The section index + pub section_index: usize, + /// The symbol index + pub symbol_index: usize, + /// The map data + pub data: Vec, + /// The map kind + pub kind: MapKind, +} + +/// A BTF-defined map, most likely from a `.maps` section. +#[derive(Debug, Clone)] +pub struct BtfMap { + /// The definition of the map + pub def: BtfMapDef, + pub(crate) section_index: usize, + pub(crate) symbol_index: usize, + pub(crate) kind: MapKind, + pub(crate) data: Vec, +} diff --git a/aya-obj/src/obj.rs b/aya-obj/src/obj.rs index 46e6b1bf..cf4cb7a7 100644 --- a/aya-obj/src/obj.rs +++ b/aya-obj/src/obj.rs @@ -14,196 +14,90 @@ use std::{ }; use thiserror::Error; -use crate::relocation::*; +use crate::{ + maps::{BtfMap, LegacyMap, Map, MapKind, MINIMUM_MAP_SIZE}, + relocation::*, +}; use crate::{ - maps::bpf_map_def, btf::{Btf, BtfError, BtfExt, BtfType}, generated::{bpf_insn, bpf_map_info, bpf_map_type::BPF_MAP_TYPE_ARRAY, BPF_F_RDONLY_PROG}, + maps::{bpf_map_def, BtfMapDef, PinningType}, programs::{CgroupSockAddrAttachType, CgroupSockAttachType, CgroupSockoptAttachType}, - maps::BtfMapDef, maps::PinningType, }; use std::slice::from_raw_parts_mut; use crate::btf::{Array, DataSecEntry, FuncSecInfo, LineSecInfo}; const KERNEL_VERSION_ANY: u32 = 0xFFFF_FFFE; -/// The first five __u32 of `bpf_map_def` must be defined. -const MINIMUM_MAP_SIZE: usize = mem::size_of::() * 5; +/// The loaded object file representation #[derive(Clone)] pub struct Object { + /// The endianness pub endianness: Endianness, + /// Program license pub license: CString, + /// Kernel version pub kernel_version: KernelVersion, + /// Program BTF pub btf: Option, + /// Program BTF.ext pub btf_ext: Option, + /// Referenced maps pub maps: HashMap, + /// Programs pub programs: HashMap, + /// Functions pub functions: HashMap, - pub relocations: HashMap>, - pub symbols_by_index: HashMap, - pub section_sizes: HashMap, + pub(crate) relocations: HashMap>, + pub(crate) symbols_by_index: HashMap, + pub(crate) section_sizes: HashMap, // symbol_offset_by_name caches symbols that could be referenced from a // BTF VAR type so the offsets can be fixed up - pub symbol_offset_by_name: HashMap, - pub text_section_index: Option, -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub enum MapKind { - Bss, - Data, - Rodata, - Other, -} - -impl From<&str> for MapKind { - fn from(s: &str) -> Self { - if s == ".bss" { - MapKind::Bss - } else if s.starts_with(".data") { - MapKind::Data - } else if s.starts_with(".rodata") { - MapKind::Rodata - } else { - MapKind::Other - } - } -} - -#[derive(Debug, Clone)] -pub enum Map { - Legacy(LegacyMap), - Btf(BtfMap), -} - -impl Map { - pub fn map_type(&self) -> u32 { - match self { - Map::Legacy(m) => m.def.map_type, - Map::Btf(m) => m.def.map_type, - } - } - - pub fn key_size(&self) -> u32 { - match self { - Map::Legacy(m) => m.def.key_size, - Map::Btf(m) => m.def.key_size, - } - } - - pub fn value_size(&self) -> u32 { - match self { - Map::Legacy(m) => m.def.value_size, - Map::Btf(m) => m.def.value_size, - } - } - - pub fn max_entries(&self) -> u32 { - match self { - Map::Legacy(m) => m.def.max_entries, - Map::Btf(m) => m.def.max_entries, - } - } - - pub fn set_max_entries(&mut self, v: u32) { - match self { - Map::Legacy(m) => m.def.max_entries = v, - Map::Btf(m) => m.def.max_entries = v, - } - } - - pub fn map_flags(&self) -> u32 { - match self { - Map::Legacy(m) => m.def.map_flags, - Map::Btf(m) => m.def.map_flags, - } - } - - pub fn pinning(&self) -> PinningType { - match self { - Map::Legacy(m) => m.def.pinning, - Map::Btf(m) => m.def.pinning, - } - } - - pub fn data(&self) -> &[u8] { - match self { - Map::Legacy(m) => &m.data, - Map::Btf(m) => &m.data, - } - } - - pub fn data_mut(&mut self) -> &mut Vec { - match self { - Map::Legacy(m) => m.data.as_mut(), - Map::Btf(m) => m.data.as_mut(), - } - } - - pub fn kind(&self) -> MapKind { - match self { - Map::Legacy(m) => m.kind, - Map::Btf(m) => m.kind, - } - } - - pub fn section_index(&self) -> usize { - match self { - Map::Legacy(m) => m.section_index, - Map::Btf(m) => m.section_index, - } - } - - pub fn symbol_index(&self) -> usize { - match self { - Map::Legacy(m) => m.symbol_index, - Map::Btf(m) => m.symbol_index, - } - } -} - -#[derive(Debug, Clone)] -pub struct LegacyMap { - pub def: bpf_map_def, - pub section_index: usize, - pub symbol_index: usize, - pub data: Vec, - pub kind: MapKind, -} - -#[derive(Debug, Clone)] -pub struct BtfMap { - pub def: BtfMapDef, - pub section_index: usize, - pub symbol_index: usize, - pub kind: MapKind, - pub data: Vec, + pub(crate) symbol_offset_by_name: HashMap, + pub(crate) text_section_index: Option, } +/// An eBPF program #[derive(Debug, Clone)] pub struct Program { + /// The license pub license: CString, + /// The kernel version pub kernel_version: KernelVersion, + /// The section containing the program pub section: ProgramSection, + /// The function pub function: Function, } +/// An eBPF function #[derive(Debug, Clone)] pub struct Function { + /// The address pub address: u64, + /// The function name pub name: String, + /// The section index pub section_index: SectionIndex, + /// The section offset pub section_offset: usize, + /// The eBPF byte code instructions pub instructions: Vec, + /// The function info pub func_info: FuncSecInfo, + /// The line info pub line_info: LineSecInfo, + /// Function info record size pub func_info_rec_size: usize, + /// Line info record size pub line_info_rec_size: usize, } +/// Sections containing eBPF programs #[derive(Debug, Clone)] +#[allow(missing_docs)] pub enum ProgramSection { KRetProbe { name: String, @@ -298,6 +192,7 @@ pub enum ProgramSection { } impl ProgramSection { + /// Returns the program name pub fn name(&self) -> &str { match self { ProgramSection::KRetProbe { name } => name, @@ -520,6 +415,7 @@ impl FromStr for ProgramSection { } impl Object { + /// Parses the binary data as an object file into an [Object] pub fn parse(data: &[u8]) -> Result { let obj = object::read::File::parse(data).map_err(ParseError::ElfError)?; let endianness = obj.endianness(); @@ -603,6 +499,7 @@ impl Object { } } + /// Patches map data pub fn patch_map_data(&mut self, globals: HashMap<&str, &[u8]>) -> Result<(), ParseError> { let symbols: HashMap = self .symbols_by_index @@ -942,11 +839,14 @@ impl Object { } } +/// Errors caught during parsing the object file #[derive(Debug, Error)] +#[allow(missing_docs)] pub enum ParseError { #[error("error parsing ELF data")] ElfError(#[from] object::read::Error), + /// Error parsing BTF object #[error("BTF error")] BtfError(#[from] BtfError), @@ -1006,6 +906,7 @@ pub enum ParseError { #[error("no symbols found for the maps included in the maps section")] NoSymbolsInMapSection {}, + /// No BTF parsed for object #[error("no BTF parsed for object")] NoBTF, } @@ -1169,9 +1070,12 @@ fn get_map_field(btf: &Btf, type_id: u32) -> Result { Ok(arr.len) } +/// The parsed kernel version #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum KernelVersion { + /// Specified version Version(u32), + /// Any version Any, } @@ -1314,6 +1218,7 @@ fn parse_btf_map_def(btf: &Btf, info: &DataSecEntry) -> Result<(String, BtfMapDe Ok((map_name.to_string(), map_def)) } +/// Parses a [bpf_map_info] into a [Map]. pub fn parse_map_info(info: bpf_map_info, pinned: PinningType) -> Map { if info.btf_key_type_id != 0 { Map::Btf(BtfMap { @@ -1353,6 +1258,7 @@ pub fn parse_map_info(info: bpf_map_info, pinned: PinningType) -> Map { } } +/// Copies a block of eBPF instructions pub fn copy_instructions(data: &[u8]) -> Result, ParseError> { if data.len() % mem::size_of::() > 0 { return Err(ParseError::InvalidProgramCode); diff --git a/aya-obj/src/programs/cgroup_sock.rs b/aya-obj/src/programs/cgroup_sock.rs index d30d269b..59cc254e 100644 --- a/aya-obj/src/programs/cgroup_sock.rs +++ b/aya-obj/src/programs/cgroup_sock.rs @@ -3,7 +3,7 @@ use thiserror::Error; use crate::generated::bpf_attach_type; -/// Defines where to attach a [`CgroupSock`] program. +/// Defines where to attach a `CgroupSock` program. #[derive(Copy, Clone, Debug)] pub enum CgroupSockAttachType { /// Called after the IPv4 bind events. diff --git a/aya-obj/src/programs/cgroup_sock_addr.rs b/aya-obj/src/programs/cgroup_sock_addr.rs index 61cb33c5..73ee00a2 100644 --- a/aya-obj/src/programs/cgroup_sock_addr.rs +++ b/aya-obj/src/programs/cgroup_sock_addr.rs @@ -3,7 +3,7 @@ use thiserror::Error; use crate::generated::bpf_attach_type; -/// Defines where to attach a [`CgroupSockAddr`] program. +/// Defines where to attach a `CgroupSockAddr` program. #[derive(Copy, Clone, Debug)] pub enum CgroupSockAddrAttachType { /// Attach to IPv4 bind events. diff --git a/aya-obj/src/programs/cgroup_sockopt.rs b/aya-obj/src/programs/cgroup_sockopt.rs index daa4b250..f85f52f1 100644 --- a/aya-obj/src/programs/cgroup_sockopt.rs +++ b/aya-obj/src/programs/cgroup_sockopt.rs @@ -3,7 +3,7 @@ use thiserror::Error; use crate::generated::bpf_attach_type; -/// Defines where to attach a [`CgroupSockopt`] program. +/// Defines where to attach a `CgroupSockopt` program. #[derive(Copy, Clone, Debug)] pub enum CgroupSockoptAttachType { /// Attach to GetSockopt. diff --git a/aya-obj/src/relocation.rs b/aya-obj/src/relocation.rs index 6f56eb60..25d5c1f9 100644 --- a/aya-obj/src/relocation.rs +++ b/aya-obj/src/relocation.rs @@ -1,3 +1,5 @@ +//! Program relocation handling. + use std::{collections::HashMap, mem}; use log::debug; @@ -9,11 +11,13 @@ use crate::{ bpf_insn, BPF_CALL, BPF_JMP, BPF_K, BPF_PSEUDO_CALL, BPF_PSEUDO_FUNC, BPF_PSEUDO_MAP_FD, BPF_PSEUDO_MAP_VALUE, }, - obj::{Function, Object, Program}, Map, + maps::Map, + obj::{Function, Object, Program}, }; pub(crate) const INS_SIZE: usize = mem::size_of::(); +/// The error type returned by [`Object::relocate_maps`] and [`Object::relocate_calls`] #[derive(Error, Debug)] #[error("error relocating `{function}`")] pub struct BpfRelocationError { @@ -24,34 +28,58 @@ pub struct BpfRelocationError { error: RelocationError, } +/// Relocation failures #[derive(Debug, Error)] pub enum RelocationError { + /// Unknown symbol #[error("unknown symbol, index `{index}`")] - UnknownSymbol { index: usize }, + UnknownSymbol { + /// The symbol index + index: usize, + }, + /// Section not found #[error("section `{section_index}` not found, referenced by symbol `{}` #{symbol_index}", .symbol_name.clone().unwrap_or_default())] SectionNotFound { + /// The section index section_index: usize, + /// The symbol index symbol_index: usize, + /// The symbol name symbol_name: Option, }, + /// Unknown function #[error("function {address:#x} not found while relocating `{caller_name}`")] - UnknownFunction { address: u64, caller_name: String }, + UnknownFunction { + /// The function address + address: u64, + /// The caller name + caller_name: String, + }, + /// Referenced map not created yet #[error("the map `{name}` at section `{section_index}` has not been created")] - MapNotCreated { section_index: usize, name: String }, + MapNotCreated { + /// The section index + section_index: usize, + /// The map name + name: String, + }, + /// Invalid relocation offset #[error("invalid offset `{offset}` applying relocation #{relocation_number}")] InvalidRelocationOffset { + /// The relocation offset offset: u64, + /// The relocation number relocation_number: usize, }, } #[derive(Debug, Copy, Clone)] -pub struct Relocation { +pub(crate) struct Relocation { // byte offset of the instruction to be relocated pub(crate) offset: u64, // index of the symbol to relocate to @@ -59,7 +87,7 @@ pub struct Relocation { } #[derive(Debug, Clone)] -pub struct Symbol { +pub(crate) struct Symbol { pub(crate) index: usize, pub(crate) section_index: Option, pub(crate) name: Option, @@ -70,6 +98,7 @@ pub struct Symbol { } impl Object { + /// Relocates the map references pub fn relocate_maps<'a, I: Iterator, &'a Map)>>( &mut self, maps: I, @@ -107,6 +136,7 @@ impl Object { Ok(()) } + /// Relocates function calls pub fn relocate_calls(&mut self) -> Result<(), BpfRelocationError> { for (name, program) in self.programs.iter_mut() { let linker = FunctionLinker::new( @@ -115,12 +145,10 @@ impl Object { &self.relocations, &self.symbols_by_index, ); - linker - .link(program) - .map_err(|error| BpfRelocationError{ - function: name.to_owned(), - error, - })?; + linker.link(program).map_err(|error| BpfRelocationError { + function: name.to_owned(), + error, + })?; } Ok(()) @@ -444,11 +472,7 @@ fn insn_is_call(ins: &bpf_insn) -> bool { #[cfg(test)] mod test { - use crate::{ - maps::bpf_map_def, - obj::{self, BtfMap, LegacyMap, MapKind}, - maps::BtfMapDef, - }; + use crate::maps::{bpf_map_def, BtfMap, BtfMapDef, LegacyMap, Map, MapKind}; use super::*; @@ -469,7 +493,7 @@ mod test { } fn fake_legacy_map(symbol_index: usize) -> Map { - obj::Map::Legacy(LegacyMap { + Map::Legacy(LegacyMap { def: bpf_map_def { ..Default::default() }, @@ -481,7 +505,7 @@ mod test { } fn fake_btf_map(symbol_index: usize) -> Map { - obj::Map::Btf(BtfMap { + Map::Btf(BtfMap { def: BtfMapDef { ..Default::default() }, @@ -578,8 +602,10 @@ mod test { let map_1 = fake_legacy_map(1); let map_2 = fake_legacy_map(2); - let maps_by_symbol = - HashMap::from([(1, ("test_map_1", Some(1), &map_1)), (2, ("test_map_2", Some(2), &map_2))]); + let maps_by_symbol = HashMap::from([ + (1, ("test_map_1", Some(1), &map_1)), + (2, ("test_map_2", Some(2), &map_2)), + ]); relocate_maps( &mut fun, @@ -673,8 +699,10 @@ mod test { let map_1 = fake_btf_map(1); let map_2 = fake_btf_map(2); - let maps_by_symbol = - HashMap::from([(1, ("test_map_1", Some(1), &map_1)), (2, ("test_map_2", Some(2), &map_2))]); + let maps_by_symbol = HashMap::from([ + (1, ("test_map_1", Some(1), &map_1)), + (2, ("test_map_2", Some(2), &map_2)), + ]); relocate_maps( &mut fun, diff --git a/aya-obj/src/util.rs b/aya-obj/src/util.rs index 6c208ec9..4aa177bb 100644 --- a/aya-obj/src/util.rs +++ b/aya-obj/src/util.rs @@ -4,4 +4,4 @@ use core::{mem, slice}; pub(crate) unsafe fn bytes_of(val: &T) -> &[u8] { let size = mem::size_of::(); slice::from_raw_parts(slice::from_ref(val).as_ptr().cast(), size) -} \ No newline at end of file +} diff --git a/aya/src/bpf.rs b/aya/src/bpf.rs index d1988f67..3f765b9a 100644 --- a/aya/src/bpf.rs +++ b/aya/src/bpf.rs @@ -7,7 +7,10 @@ use std::{ path::{Path, PathBuf}, }; -use aya_obj::{btf::{BtfFeatures, BtfRelocationError}, relocation::BpfRelocationError}; +use aya_obj::{ + btf::{BtfFeatures, BtfRelocationError}, + relocation::BpfRelocationError, +}; use log::debug; use thiserror::Error; @@ -19,7 +22,8 @@ use crate::{ maps::{Map, MapData, MapError}, obj::{ btf::{Btf, BtfError}, - MapKind, Object, ParseError, ProgramSection, + maps::MapKind, + Object, ParseError, ProgramSection, }, programs::{ BtfTracePoint, CgroupDevice, CgroupSkb, CgroupSkbAttachType, CgroupSock, CgroupSockAddr, @@ -58,9 +62,7 @@ unsafe_impl_pod!(i8, u8, i16, u16, i32, u32, i64, u64, u128, i128); // It only makes sense that an array of POD types is itself POD unsafe impl Pod for [T; N] {} -pub use aya_obj::maps::bpf_map_def; -pub use aya_obj::maps::BtfMapDef; -pub use aya_obj::maps::PinningType; +pub use aya_obj::maps::{bpf_map_def, PinningType}; // Features implements BPF and BTF feature detection #[derive(Default, Debug)] @@ -358,14 +360,9 @@ impl<'a> BpfLoader<'a> { obj.patch_map_data(self.globals.clone())?; let btf_fd = if let Some(ref btf) = self.features.btf { - if let Some(ref mut obj_btf) = obj.btf { - // fixup btf - let section_data = obj.section_sizes.clone(); - let symbol_offsets = obj.symbol_offset_by_name.clone(); - obj_btf.fixup_and_sanitize(§ion_data, &symbol_offsets, btf)?; + if let Some(btf) = obj.fixup_and_sanitize_btf(btf)? { // load btf to the kernel - let raw_btf = obj_btf.to_bytes(); - Some(load_btf(raw_btf)?) + Some(load_btf(btf.to_bytes())?) } else { None } @@ -441,7 +438,10 @@ impl<'a> BpfLoader<'a> { maps.insert(name, map); } - obj.relocate_maps(maps.iter().map(|(s, data)| (s.as_str(), data.fd, &data.obj)))?; + obj.relocate_maps( + maps.iter() + .map(|(s, data)| (s.as_str(), data.fd, &data.obj)), + )?; obj.relocate_calls()?; let programs = obj diff --git a/aya/src/maps/bloom_filter.rs b/aya/src/maps/bloom_filter.rs index 615e64c7..16eb1aa3 100644 --- a/aya/src/maps/bloom_filter.rs +++ b/aya/src/maps/bloom_filter.rs @@ -84,14 +84,17 @@ mod tests { bpf_map_type::{BPF_MAP_TYPE_BLOOM_FILTER, BPF_MAP_TYPE_PERF_EVENT_ARRAY}, }, maps::{Map, MapData}, - obj, + obj::{ + self, + maps::{LegacyMap, MapKind}, + }, sys::{override_syscall, SysResult, Syscall}, }; use libc::{EFAULT, ENOENT}; use std::io; fn new_obj_map() -> obj::Map { - obj::Map::Legacy(obj::LegacyMap { + obj::Map::Legacy(LegacyMap { def: bpf_map_def { map_type: BPF_MAP_TYPE_BLOOM_FILTER as u32, key_size: 4, @@ -102,7 +105,7 @@ mod tests { section_index: 0, symbol_index: 0, data: Vec::new(), - kind: obj::MapKind::Other, + kind: MapKind::Other, }) } @@ -130,7 +133,7 @@ mod tests { #[test] fn test_try_from_wrong_map() { let map_data = MapData { - obj: obj::Map::Legacy(obj::LegacyMap { + obj: obj::Map::Legacy(LegacyMap { def: bpf_map_def { map_type: BPF_MAP_TYPE_PERF_EVENT_ARRAY as u32, key_size: 4, @@ -141,7 +144,7 @@ mod tests { section_index: 0, symbol_index: 0, data: Vec::new(), - kind: obj::MapKind::Other, + kind: MapKind::Other, }), fd: None, pinned: false, diff --git a/aya/src/maps/hash_map/hash_map.rs b/aya/src/maps/hash_map/hash_map.rs index e7045466..a67cdead 100644 --- a/aya/src/maps/hash_map/hash_map.rs +++ b/aya/src/maps/hash_map/hash_map.rs @@ -117,14 +117,17 @@ mod tests { bpf_map_type::{BPF_MAP_TYPE_HASH, BPF_MAP_TYPE_LRU_HASH}, }, maps::{Map, MapData}, - obj, + obj::{ + self, + maps::{LegacyMap, MapKind}, + }, sys::{override_syscall, SysResult, Syscall}, }; use super::*; fn new_obj_map() -> obj::Map { - obj::Map::Legacy(obj::LegacyMap { + obj::Map::Legacy(LegacyMap { def: bpf_map_def { map_type: BPF_MAP_TYPE_HASH as u32, key_size: 4, @@ -134,7 +137,7 @@ mod tests { }, section_index: 0, data: Vec::new(), - kind: obj::MapKind::Other, + kind: MapKind::Other, symbol_index: 0, }) } @@ -255,7 +258,7 @@ mod tests { #[test] fn test_try_from_ok_lru() { let map_data = MapData { - obj: obj::Map::Legacy(obj::LegacyMap { + obj: obj::Map::Legacy(LegacyMap { def: bpf_map_def { map_type: BPF_MAP_TYPE_LRU_HASH as u32, key_size: 4, @@ -266,7 +269,7 @@ mod tests { section_index: 0, symbol_index: 0, data: Vec::new(), - kind: obj::MapKind::Other, + kind: MapKind::Other, }), fd: Some(42), pinned: false, diff --git a/aya/src/maps/lpm_trie.rs b/aya/src/maps/lpm_trie.rs index a7d43703..4a6cc94f 100644 --- a/aya/src/maps/lpm_trie.rs +++ b/aya/src/maps/lpm_trie.rs @@ -247,14 +247,17 @@ mod tests { bpf_map_type::{BPF_MAP_TYPE_LPM_TRIE, BPF_MAP_TYPE_PERF_EVENT_ARRAY}, }, maps::{Map, MapData}, - obj, + obj::{ + self, + maps::{LegacyMap, MapKind}, + }, sys::{override_syscall, SysResult, Syscall}, }; use libc::{EFAULT, ENOENT}; use std::{io, mem, net::Ipv4Addr}; fn new_obj_map() -> obj::Map { - obj::Map::Legacy(obj::LegacyMap { + obj::Map::Legacy(LegacyMap { def: bpf_map_def { map_type: BPF_MAP_TYPE_LPM_TRIE as u32, key_size: mem::size_of::>() as u32, @@ -265,7 +268,7 @@ mod tests { section_index: 0, symbol_index: 0, data: Vec::new(), - kind: obj::MapKind::Other, + kind: MapKind::Other, }) } @@ -310,7 +313,7 @@ mod tests { #[test] fn test_try_from_wrong_map() { let map_data = MapData { - obj: obj::Map::Legacy(obj::LegacyMap { + obj: obj::Map::Legacy(LegacyMap { def: bpf_map_def { map_type: BPF_MAP_TYPE_PERF_EVENT_ARRAY as u32, key_size: 4, @@ -321,7 +324,7 @@ mod tests { section_index: 0, symbol_index: 0, data: Vec::new(), - kind: obj::MapKind::Other, + kind: MapKind::Other, }), fd: None, btf_fd: None, diff --git a/aya/src/maps/mod.rs b/aya/src/maps/mod.rs index 783cc3db..e9d3009b 100644 --- a/aya/src/maps/mod.rs +++ b/aya/src/maps/mod.rs @@ -844,14 +844,14 @@ mod tests { bpf_map_def, generated::{bpf_cmd, bpf_map_type::BPF_MAP_TYPE_HASH}, maps::MapData, - obj::MapKind, + obj::maps::{LegacyMap, MapKind}, sys::{override_syscall, Syscall}, }; use super::*; fn new_obj_map() -> obj::Map { - obj::Map::Legacy(obj::LegacyMap { + obj::Map::Legacy(LegacyMap { def: bpf_map_def { map_type: BPF_MAP_TYPE_HASH as u32, key_size: 4, diff --git a/aya/src/programs/cgroup_sockopt.rs b/aya/src/programs/cgroup_sockopt.rs index de4c1f43..97231f17 100644 --- a/aya/src/programs/cgroup_sockopt.rs +++ b/aya/src/programs/cgroup_sockopt.rs @@ -9,8 +9,7 @@ use std::{ use crate::{ generated::bpf_prog_type::BPF_PROG_TYPE_CGROUP_SOCKOPT, programs::{ - define_link_wrapper, load_program, FdLink, Link, ProgAttachLink, - ProgramData, ProgramError, + define_link_wrapper, load_program, FdLink, Link, ProgAttachLink, ProgramData, ProgramError, }, sys::{bpf_link_create, bpf_prog_attach, kernel_version}, }; From 311ead6760ce53e9503af00391e6631f7387ab4a Mon Sep 17 00:00:00 2001 From: Shenghui Ye Date: Wed, 28 Dec 2022 12:19:51 +0800 Subject: [PATCH 08/51] aya-obj: add integration tests against rbpf --- aya-obj/README.md | 43 ++++++++++- aya-obj/src/lib.rs | 41 ++++++++++ test/integration-test/Cargo.toml | 2 + test/integration-test/src/tests/mod.rs | 1 + test/integration-test/src/tests/rbpf.rs | 99 +++++++++++++++++++++++++ 5 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 test/integration-test/src/tests/rbpf.rs diff --git a/aya-obj/README.md b/aya-obj/README.md index 40a4c5a9..29037565 100644 --- a/aya-obj/README.md +++ b/aya-obj/README.md @@ -1 +1,42 @@ -# aya-obj +# aya-obj - an eBPF object file loading library + +## Overview + +eBPF programs written with [libbpf] or [aya-bpf] are usually compiled +into an ELF object file, using various section to store information +about the eBPF programs. + +`aya-obj` is a library that loads, parses and processes such eBPF +object files. + +[libbpf]: https://github.com/libbpf/libbpf +[aya-bpf]: https://github.com/aya-rs/aya + +## Example + +This example loads a simple eBPF program and runs it with [rbpf]. + +```rust +use aya_bpf::Object; + +// Parse the object file +let bytes = std::fs::read("program.o").unwrap(); +let mut object = Object::parse(bytes).unwrap(); +// Relocate the programs +object.relocate_calls().unwrap(); +object.relocate_maps(std::iter::empty()).unwrap(); + +// Run with rbpf +let program = object.programs.iter().next().unwrap().1; +let instructions = &program.function.instructions; +let data = unsafe { + from_raw_parts( + instructions.as_ptr() as *const u8, + instructions.len() * size_of::(), + ) +}; +let vm = rbpf::EbpfVmNoData::new(Some(data)).unwrap(); +let _return = vm.execute_program().unwrap(); +``` + +[rbpf]: https://github.com/qmonnet/rbpf diff --git a/aya-obj/src/lib.rs b/aya-obj/src/lib.rs index 22ceb1cc..45a781a1 100644 --- a/aya-obj/src/lib.rs +++ b/aya-obj/src/lib.rs @@ -1,4 +1,45 @@ //! A library for loading and relocating eBPF object files. +//! +//! ## Overview +//! +//! eBPF programs written with [libbpf] or [aya-bpf] are usually compiled +//! into an ELF object file, using various section to store information +//! about the eBPF programs. +//! +//! `aya-obj` is a library that loads, parses and processes such eBPF +//! object files. +//! +//! [libbpf]: https://github.com/libbpf/libbpf +//! [aya-bpf]: https://github.com/aya-rs/aya +//! +//! ## Example +//! +//! This example loads a simple eBPF program and runs it with [rbpf]. +//! +//! ```no_run +//! use aya_bpf::Object; +//! +//! // Parse the object file +//! let bytes = std::fs::read("program.o").unwrap(); +//! let mut object = Object::parse(bytes).unwrap(); +//! // Relocate the programs +//! object.relocate_calls().unwrap(); +//! object.relocate_maps(std::iter::empty()).unwrap(); +//! +//! // Run with rbpf +//! let program = object.programs.iter().next().unwrap().1; +//! let instructions = &program.function.instructions; +//! let data = unsafe { +//! from_raw_parts( +//! instructions.as_ptr() as *const u8, +//! instructions.len() * size_of::(), +//! ) +//! }; +//! let vm = rbpf::EbpfVmNoData::new(Some(data)).unwrap(); +//! let _return = vm.execute_program().unwrap(); +//! ``` +//! +//! [rbpf]: https://github.com/qmonnet/rbpf #![doc( html_logo_url = "https://aya-rs.dev/assets/images/crabby.svg", diff --git a/test/integration-test/Cargo.toml b/test/integration-test/Cargo.toml index 94c05cf1..1f1bdf13 100644 --- a/test/integration-test/Cargo.toml +++ b/test/integration-test/Cargo.toml @@ -7,6 +7,7 @@ publish = false [dependencies] anyhow = "1" aya = { path = "../../aya" } +aya-obj = { path = "../../aya-obj" } clap = { version = "4", features = ["derive"] } env_logger = "0.10" inventory = "0.2" @@ -15,4 +16,5 @@ lazy_static = "1" libc = { version = "0.2.105" } log = "0.4" object = { version = "0.30", default-features = false, features = ["std", "read_core", "elf"] } +rbpf = "0.1.0" regex = "1" diff --git a/test/integration-test/src/tests/mod.rs b/test/integration-test/src/tests/mod.rs index 53a98abe..0b3e9e95 100644 --- a/test/integration-test/src/tests/mod.rs +++ b/test/integration-test/src/tests/mod.rs @@ -6,6 +6,7 @@ use std::{ffi::CStr, mem}; pub mod elf; pub mod load; +pub mod rbpf; pub mod smoke; pub use integration_test_macros::integration_test; diff --git a/test/integration-test/src/tests/rbpf.rs b/test/integration-test/src/tests/rbpf.rs new file mode 100644 index 00000000..a76bb162 --- /dev/null +++ b/test/integration-test/src/tests/rbpf.rs @@ -0,0 +1,99 @@ +use core::{mem::size_of, ptr::null_mut, slice::from_raw_parts}; +use std::collections::HashMap; + +use aya::include_bytes_aligned; +use aya_obj::{generated::bpf_insn, Object}; + +use super::{integration_test, IntegrationTest}; + +#[integration_test] +fn run_with_rbpf() { + let bytes = include_bytes_aligned!("../../../../target/bpfel-unknown-none/debug/pass"); + let object = Object::parse(bytes).unwrap(); + assert_eq!(object.programs.len(), 1); + let instructions = &object.programs["pass"].function.instructions; + let data = unsafe { + from_raw_parts( + instructions.as_ptr() as *const u8, + instructions.len() * size_of::(), + ) + }; + // Use rbpf interpreter instead of JIT compiler to ensure platform compatibility. + let vm = rbpf::EbpfVmNoData::new(Some(data)).unwrap(); + const XDP_PASS: u64 = 2; + assert_eq!(vm.execute_program().unwrap(), XDP_PASS); +} + +static mut MULTIMAP_MAPS: [*mut Vec; 2] = [null_mut(), null_mut()]; + +#[integration_test] +fn use_map_with_rbpf() { + let bytes = + include_bytes_aligned!("../../../../target/bpfel-unknown-none/debug/multimap-btf.bpf.o"); + let mut object = Object::parse(bytes).unwrap(); + let mut maps = HashMap::new(); + + // Initializes maps: + // - fd: 0xCAFE00 or 0xCAFE01, + // - Note that rbpf does not convert fds into real pointers, + // so we keeps the pointers to our maps in MULTIMAP_MAPS, to be used in helpers. + let mut map_instances = Vec::new(); + for (map_id, (name, map)) in object.maps.iter().enumerate() { + maps.insert(name.to_owned(), (map_id as i32 | 0xCAFE00, map.clone())); + assert_eq!(map.key_size(), size_of::() as u32); + assert_eq!(map.value_size(), size_of::() as u32); + assert_eq!( + map.map_type(), + aya_obj::generated::bpf_map_type::BPF_MAP_TYPE_ARRAY as u32 + ); + map_instances.push(vec![0u64]); + + unsafe { + MULTIMAP_MAPS[if name == "map_1" { 0 } else { 1 }] = + &mut map_instances[map_id] as *mut _; + } + } + + object + .relocate_maps( + maps.iter() + .map(|(s, (fd, map))| (s.as_ref() as &str, Some(*fd), map)), + ) + .expect("Relocation failed"); + // Actually there is no call involved. + object.relocate_calls().unwrap(); + + // Executes the program + assert_eq!(object.programs.len(), 1); + let instructions = &object.programs["tracepoint"].function.instructions; + let data = unsafe { + from_raw_parts( + instructions.as_ptr() as *const u8, + instructions.len() * size_of::(), + ) + }; + let mut vm = rbpf::EbpfVmNoData::new(Some(data)).unwrap(); + vm.register_helper(2, bpf_map_update_elem_multimap) + .expect("Helper failed"); + assert_eq!(vm.execute_program().unwrap(), 0); + + assert_eq!(map_instances[0][0], 24); + assert_eq!(map_instances[1][0], 42); + + unsafe { + MULTIMAP_MAPS[0] = null_mut(); + MULTIMAP_MAPS[1] = null_mut(); + } +} + +fn bpf_map_update_elem_multimap(map: u64, key: u64, value: u64, _: u64, _: u64) -> u64 { + assert!(map == 0xCAFE00 || map == 0xCAFE01); + let key = *unsafe { (key as usize as *const u32).as_ref().unwrap() }; + let value = *unsafe { (value as usize as *const u64).as_ref().unwrap() }; + assert_eq!(key, 0); + unsafe { + let map_instance = MULTIMAP_MAPS[map as usize & 0xFF].as_mut().unwrap(); + map_instance[0] = value; + } + 0 +} From 30f1fabc05654e8d11dd2648767895123c141c3b Mon Sep 17 00:00:00 2001 From: Shenghui Ye Date: Wed, 28 Dec 2022 15:29:00 +0800 Subject: [PATCH 09/51] aya-obj: add no_std feature The crate has few libstd dependencies. Since it should be platform- independent in principle, making it no_std like the object crate would seem reasonable. However, the feature `error_in_core` is not yet stabilized, and the thiserror crate currently offers no no_std support. When the feature no_std is selected, we enable the `error_in_core` feature, switch to thiserror-core and replace the HashMap with the one in hashbrown. --- aya-obj/Cargo.toml | 11 +++++-- aya-obj/README.md | 8 ++--- aya-obj/src/btf/btf.rs | 37 +++++++++++++++--------- aya-obj/src/btf/info.rs | 5 ++-- aya-obj/src/btf/relocation.rs | 23 ++++++++++----- aya-obj/src/btf/types.rs | 5 ++-- aya-obj/src/lib.rs | 20 ++++++++++--- aya-obj/src/maps.rs | 3 +- aya-obj/src/obj.rs | 28 +++++++++--------- aya-obj/src/programs/cgroup_sock.rs | 7 +++-- aya-obj/src/programs/cgroup_sock_addr.rs | 7 +++-- aya-obj/src/programs/cgroup_sockopt.rs | 7 +++-- aya-obj/src/relocation.rs | 10 +++++-- aya-obj/src/util.rs | 5 ++++ 14 files changed, 117 insertions(+), 59 deletions(-) diff --git a/aya-obj/Cargo.toml b/aya-obj/Cargo.toml index 0dc1e2b6..f1bf4e9c 100644 --- a/aya-obj/Cargo.toml +++ b/aya-obj/Cargo.toml @@ -13,8 +13,15 @@ edition = "2021" [dependencies] bytes = "1" log = "0.4" -object = { version = "0.30", default-features = false, features = ["std", "read_core", "elf"] } -thiserror = "1" +object = { version = "0.30", default-features = false, features = ["read_core", "elf"] } +hashbrown = { version = "0.13", optional = true } +thiserror-std = { package = "thiserror", version = "1" } +thiserror-core = { version = "1", default-features = false, features = [], optional = true } [dev-dependencies] matches = "0.1.8" +rbpf = "0.1.0" + +[features] +default = [] +no_std = ["hashbrown", "thiserror-core"] diff --git a/aya-obj/README.md b/aya-obj/README.md index 29037565..62450ff8 100644 --- a/aya-obj/README.md +++ b/aya-obj/README.md @@ -17,11 +17,11 @@ object files. This example loads a simple eBPF program and runs it with [rbpf]. ```rust -use aya_bpf::Object; +use aya_obj::{generated::bpf_insn, Object}; // Parse the object file let bytes = std::fs::read("program.o").unwrap(); -let mut object = Object::parse(bytes).unwrap(); +let mut object = Object::parse(&bytes).unwrap(); // Relocate the programs object.relocate_calls().unwrap(); object.relocate_maps(std::iter::empty()).unwrap(); @@ -30,9 +30,9 @@ object.relocate_maps(std::iter::empty()).unwrap(); let program = object.programs.iter().next().unwrap().1; let instructions = &program.function.instructions; let data = unsafe { - from_raw_parts( + core::slice::from_raw_parts( instructions.as_ptr() as *const u8, - instructions.len() * size_of::(), + instructions.len() * core::mem::size_of::(), ) }; let vm = rbpf::EbpfVmNoData::new(Some(data)).unwrap(); diff --git a/aya-obj/src/btf/btf.rs b/aya-obj/src/btf/btf.rs index 193e9528..a5fbcd1a 100644 --- a/aya-obj/src/btf/btf.rs +++ b/aya-obj/src/btf/btf.rs @@ -1,18 +1,17 @@ -use std::{ +use core::{ffi::CStr, mem, ptr}; + +use alloc::{ borrow::Cow, - collections::HashMap, - convert::TryInto, - ffi::{CStr, CString}, - fs, io, mem, - path::{Path, PathBuf}, - ptr, + ffi::CString, + format, + string::{String, ToString}, + vec, + vec::Vec, }; - use bytes::BufMut; use log::debug; use object::Endianness; -use thiserror::Error; use crate::{ btf::{ @@ -22,7 +21,8 @@ use crate::{ IntEncoding, LineInfo, Struct, Typedef, VarLinkage, }, generated::{btf_ext_header, btf_header}, - util::bytes_of, + thiserror::{self, Error}, + util::{bytes_of, HashMap}, Object, }; @@ -32,14 +32,15 @@ pub(crate) const MAX_SPEC_LEN: usize = 64; /// The error type returned when `BTF` operations fail. #[derive(Error, Debug)] pub enum BtfError { + #[cfg(not(feature = "no_std"))] /// Error parsing file #[error("error parsing {path}")] FileError { /// file path - path: PathBuf, + path: std::path::PathBuf, /// source of the error #[source] - error: io::Error, + error: std::io::Error, }, /// Error parsing BTF header @@ -125,12 +126,13 @@ pub enum BtfError { type_id: u32, }, + #[cfg(not(feature = "no_std"))] /// Loading the btf failed #[error("the BPF_BTF_LOAD syscall failed. Verifier output: {verifier_log}")] LoadError { /// The [`io::Error`] returned by the `BPF_BTF_LOAD` syscall. #[source] - io_error: io::Error, + io_error: std::io::Error, /// The error log produced by the kernel verifier. verifier_log: String, }, @@ -230,12 +232,18 @@ impl Btf { } /// Loads BTF metadata from `/sys/kernel/btf/vmlinux`. + #[cfg(not(feature = "no_std"))] pub fn from_sys_fs() -> Result { Btf::parse_file("/sys/kernel/btf/vmlinux", Endianness::default()) } /// Loads BTF metadata from the given `path`. - pub fn parse_file>(path: P, endianness: Endianness) -> Result { + #[cfg(not(feature = "no_std"))] + pub fn parse_file>( + path: P, + endianness: Endianness, + ) -> Result { + use std::{borrow::ToOwned, fs}; let path = path.as_ref(); Btf::parse( &fs::read(path).map_err(|error| BtfError::FileError { @@ -1436,6 +1444,7 @@ mod tests { } #[test] + #[cfg(not(feature = "no_std"))] #[cfg_attr(miri, ignore)] fn test_read_btf_from_sys_fs() { let btf = Btf::parse_file("/sys/kernel/btf/vmlinux", Endianness::default()).unwrap(); diff --git a/aya-obj/src/btf/info.rs b/aya-obj/src/btf/info.rs index 5d1652c4..97f5b866 100644 --- a/aya-obj/src/btf/info.rs +++ b/aya-obj/src/btf/info.rs @@ -1,12 +1,11 @@ -use std::collections::HashMap; - +use alloc::{string::String, vec, vec::Vec}; use bytes::BufMut; use object::Endianness; use crate::{ generated::{bpf_func_info, bpf_line_info}, relocation::INS_SIZE, - util::bytes_of, + util::{bytes_of, HashMap}, }; /* The func_info subsection layout: diff --git a/aya-obj/src/btf/relocation.rs b/aya-obj/src/btf/relocation.rs index 641e7265..ec1bcde7 100644 --- a/aya-obj/src/btf/relocation.rs +++ b/aya-obj/src/btf/relocation.rs @@ -1,6 +1,12 @@ -use std::{collections::HashMap, io, mem, ptr, str::FromStr}; - -use thiserror::Error; +use core::{mem, ptr, str::FromStr}; + +use alloc::{ + borrow::ToOwned, + format, + string::{String, ToString}, + vec, + vec::Vec, +}; use crate::{ btf::{ @@ -11,6 +17,8 @@ use crate::{ bpf_core_relo, bpf_core_relo_kind::*, bpf_insn, BPF_ALU, BPF_ALU64, BPF_B, BPF_DW, BPF_H, BPF_K, BPF_LD, BPF_LDX, BPF_ST, BPF_STX, BPF_W, BTF_INT_SIGNED, }, + thiserror::{self, Error}, + util::HashMap, Object, Program, ProgramSection, }; @@ -28,9 +36,10 @@ pub struct BtfRelocationError { /// Relocation failures #[derive(Error, Debug)] enum RelocationError { + #[cfg(not(feature = "no_std"))] /// I/O error #[error(transparent)] - IOError(#[from] io::Error), + IOError(#[from] std::io::Error), /// Program not found #[error("program not found")] @@ -254,7 +263,7 @@ fn relocate_btf_program<'target>( ) -> Result<(), RelocationError> { for rel in relos { let instructions = &mut program.function.instructions; - let ins_index = rel.ins_offset / std::mem::size_of::(); + let ins_index = rel.ins_offset / mem::size_of::(); if ins_index >= instructions.len() { return Err(RelocationError::InvalidInstructionIndex { index: ins_index, @@ -817,7 +826,7 @@ impl ComputedRelocation { ) -> Result<(), RelocationError> { let instructions = &mut program.function.instructions; let num_instructions = instructions.len(); - let ins_index = rel.ins_offset / std::mem::size_of::(); + let ins_index = rel.ins_offset / mem::size_of::(); let mut ins = instructions .get_mut(ins_index) @@ -845,7 +854,7 @@ impl ComputedRelocation { ins.imm = target_value as i32; } BPF_LDX | BPF_ST | BPF_STX => { - if target_value > std::i16::MAX as u32 { + if target_value > i16::MAX as u32 { return Err(RelocationError::InvalidInstruction { relocation_number: rel.number, index: ins_index, diff --git a/aya-obj/src/btf/types.rs b/aya-obj/src/btf/types.rs index 2f5cfc1e..177b97a5 100644 --- a/aya-obj/src/btf/types.rs +++ b/aya-obj/src/btf/types.rs @@ -1,7 +1,8 @@ #![allow(missing_docs)] -use std::{fmt::Display, mem, ptr}; +use core::{fmt::Display, mem, ptr}; +use alloc::{string::ToString, vec, vec::Vec}; use object::Endianness; use crate::btf::{Btf, BtfError, MAX_RESOLVE_DEPTH}; @@ -853,7 +854,7 @@ impl TryFrom for BtfKind { } impl Display for BtfKind { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { BtfKind::Unknown => write!(f, "[UNKNOWN]"), BtfKind::Int => write!(f, "[INT]"), diff --git a/aya-obj/src/lib.rs b/aya-obj/src/lib.rs index 45a781a1..120ae047 100644 --- a/aya-obj/src/lib.rs +++ b/aya-obj/src/lib.rs @@ -17,11 +17,11 @@ //! This example loads a simple eBPF program and runs it with [rbpf]. //! //! ```no_run -//! use aya_bpf::Object; +//! use aya_obj::{generated::bpf_insn, Object}; //! //! // Parse the object file //! let bytes = std::fs::read("program.o").unwrap(); -//! let mut object = Object::parse(bytes).unwrap(); +//! let mut object = Object::parse(&bytes).unwrap(); //! // Relocate the programs //! object.relocate_calls().unwrap(); //! object.relocate_maps(std::iter::empty()).unwrap(); @@ -30,9 +30,9 @@ //! let program = object.programs.iter().next().unwrap().1; //! let instructions = &program.function.instructions; //! let data = unsafe { -//! from_raw_parts( +//! core::slice::from_raw_parts( //! instructions.as_ptr() as *const u8, -//! instructions.len() * size_of::(), +//! instructions.len() * core::mem::size_of::(), //! ) //! }; //! let vm = rbpf::EbpfVmNoData::new(Some(data)).unwrap(); @@ -41,6 +41,7 @@ //! //! [rbpf]: https://github.com/qmonnet/rbpf +#![no_std] #![doc( html_logo_url = "https://aya-rs.dev/assets/images/crabby.svg", html_favicon_url = "https://aya-rs.dev/assets/images/crabby.svg" @@ -49,6 +50,17 @@ #![deny(clippy::all, missing_docs)] #![allow(clippy::missing_safety_doc, clippy::len_without_is_empty)] +#![cfg_attr(feature = "no_std", feature(error_in_core))] + +#[cfg(not(feature = "no_std"))] +pub(crate) use thiserror_std as thiserror; +#[cfg(feature = "no_std")] +pub(crate) use thiserror_core as thiserror; + +extern crate alloc; +#[cfg(not(feature = "no_std"))] +extern crate std; + pub mod btf; pub mod generated; pub mod maps; diff --git a/aya-obj/src/maps.rs b/aya-obj/src/maps.rs index b54f3bbb..b6467d94 100644 --- a/aya-obj/src/maps.rs +++ b/aya-obj/src/maps.rs @@ -2,7 +2,8 @@ use core::mem; -use thiserror::Error; +use crate::thiserror::{self, Error}; +use alloc::vec::Vec; /// Invalid map type encontered pub struct InvalidMapTypeError { diff --git a/aya-obj/src/obj.rs b/aya-obj/src/obj.rs index cf4cb7a7..5c01c815 100644 --- a/aya-obj/src/obj.rs +++ b/aya-obj/src/obj.rs @@ -1,22 +1,24 @@ //! Object file loading, parsing, and relocation. +use alloc::{ + borrow::ToOwned, + ffi::CString, + string::{String, ToString}, + vec::Vec, +}; +use core::{ffi::CStr, mem, ptr, str::FromStr}; use log::debug; use object::{ read::{Object as ElfObject, ObjectSection, Section as ObjSection}, Endianness, ObjectSymbol, ObjectSymbolTable, RelocationTarget, SectionIndex, SectionKind, SymbolKind, }; -use std::{ - collections::HashMap, - ffi::{CStr, CString}, - mem, ptr, - str::FromStr, -}; -use thiserror::Error; use crate::{ maps::{BtfMap, LegacyMap, Map, MapKind, MINIMUM_MAP_SIZE}, relocation::*, + thiserror::{self, Error}, + util::HashMap, }; use crate::{ @@ -25,7 +27,7 @@ use crate::{ maps::{bpf_map_def, BtfMapDef, PinningType}, programs::{CgroupSockAddrAttachType, CgroupSockAttachType, CgroupSockoptAttachType}, }; -use std::slice::from_raw_parts_mut; +use core::slice::from_raw_parts_mut; use crate::btf::{Array, DataSecEntry, FuncSecInfo, LineSecInfo}; @@ -844,7 +846,7 @@ impl Object { #[allow(missing_docs)] pub enum ParseError { #[error("error parsing ELF data")] - ElfError(#[from] object::read::Error), + ElfError(object::read::Error), /// Error parsing BTF object #[error("BTF error")] @@ -862,8 +864,7 @@ pub enum ParseError { #[error("error parsing section with index {index}")] SectionError { index: usize, - #[source] - source: object::read::Error, + error: object::read::Error, }, #[error("unsupported relocation target")] @@ -968,9 +969,9 @@ impl<'data, 'file, 'a> TryFrom<&'a ObjSection<'data, 'file>> for Section<'a> { fn try_from(section: &'a ObjSection) -> Result, ParseError> { let index = section.index(); - let map_err = |source| ParseError::SectionError { + let map_err = |error| ParseError::SectionError { index: index.0, - source, + error, }; let name = section.name().map_err(map_err)?; let kind = match BpfSectionKind::from_name(name) { @@ -1272,6 +1273,7 @@ pub fn copy_instructions(data: &[u8]) -> Result, ParseError> { #[cfg(test)] mod tests { + use alloc::vec; use matches::assert_matches; use object::Endianness; diff --git a/aya-obj/src/programs/cgroup_sock.rs b/aya-obj/src/programs/cgroup_sock.rs index 59cc254e..ed470f8a 100644 --- a/aya-obj/src/programs/cgroup_sock.rs +++ b/aya-obj/src/programs/cgroup_sock.rs @@ -1,7 +1,10 @@ //! Cgroup socket programs. -use thiserror::Error; +use alloc::{borrow::ToOwned, string::String}; -use crate::generated::bpf_attach_type; +use crate::{ + generated::bpf_attach_type, + thiserror::{self, Error}, +}; /// Defines where to attach a `CgroupSock` program. #[derive(Copy, Clone, Debug)] diff --git a/aya-obj/src/programs/cgroup_sock_addr.rs b/aya-obj/src/programs/cgroup_sock_addr.rs index 73ee00a2..39db0ae3 100644 --- a/aya-obj/src/programs/cgroup_sock_addr.rs +++ b/aya-obj/src/programs/cgroup_sock_addr.rs @@ -1,7 +1,10 @@ //! Cgroup socket address programs. -use thiserror::Error; +use alloc::{borrow::ToOwned, string::String}; -use crate::generated::bpf_attach_type; +use crate::{ + generated::bpf_attach_type, + thiserror::{self, Error}, +}; /// Defines where to attach a `CgroupSockAddr` program. #[derive(Copy, Clone, Debug)] diff --git a/aya-obj/src/programs/cgroup_sockopt.rs b/aya-obj/src/programs/cgroup_sockopt.rs index f85f52f1..b48e984a 100644 --- a/aya-obj/src/programs/cgroup_sockopt.rs +++ b/aya-obj/src/programs/cgroup_sockopt.rs @@ -1,7 +1,10 @@ //! Cgroup socket option programs. -use thiserror::Error; +use alloc::{borrow::ToOwned, string::String}; -use crate::generated::bpf_attach_type; +use crate::{ + generated::bpf_attach_type, + thiserror::{self, Error}, +}; /// Defines where to attach a `CgroupSockopt` program. #[derive(Copy, Clone, Debug)] diff --git a/aya-obj/src/relocation.rs b/aya-obj/src/relocation.rs index 25d5c1f9..8b0b9170 100644 --- a/aya-obj/src/relocation.rs +++ b/aya-obj/src/relocation.rs @@ -1,10 +1,10 @@ //! Program relocation handling. -use std::{collections::HashMap, mem}; +use core::mem; +use alloc::{borrow::ToOwned, string::String}; use log::debug; use object::{SectionIndex, SymbolKind}; -use thiserror::Error; use crate::{ generated::{ @@ -13,6 +13,8 @@ use crate::{ }, maps::Map, obj::{Function, Object, Program}, + thiserror::{self, Error}, + util::HashMap, }; pub(crate) const INS_SIZE: usize = mem::size_of::(); @@ -472,6 +474,8 @@ fn insn_is_call(ins: &bpf_insn) -> bool { #[cfg(test)] mod test { + use alloc::{string::ToString, vec, vec::Vec}; + use crate::maps::{bpf_map_def, BtfMap, BtfMapDef, LegacyMap, Map, MapKind}; use super::*; @@ -489,7 +493,7 @@ mod test { } fn ins(bytes: &[u8]) -> bpf_insn { - unsafe { std::ptr::read_unaligned(bytes.as_ptr() as *const _) } + unsafe { core::ptr::read_unaligned(bytes.as_ptr() as *const _) } } fn fake_legacy_map(symbol_index: usize) -> Map { diff --git a/aya-obj/src/util.rs b/aya-obj/src/util.rs index 4aa177bb..36355a18 100644 --- a/aya-obj/src/util.rs +++ b/aya-obj/src/util.rs @@ -1,5 +1,10 @@ use core::{mem, slice}; +#[cfg(feature = "no_std")] +pub(crate) use hashbrown::HashMap; +#[cfg(not(feature = "no_std"))] +pub(crate) use std::collections::HashMap; + /// bytes_of converts a to a byte slice pub(crate) unsafe fn bytes_of(val: &T) -> &[u8] { let size = mem::size_of::(); From 9ec3447e891ca770a65f8ff9b71884f25530f515 Mon Sep 17 00:00:00 2001 From: Shenghui Ye Date: Wed, 28 Dec 2022 17:15:46 +0800 Subject: [PATCH 10/51] aya-obj: fix rustfmt diffs and typos --- aya-obj/README.md | 2 +- aya-obj/src/btf/btf.rs | 4 ++-- aya-obj/src/btf/info.rs | 8 ++++---- aya-obj/src/btf/relocation.rs | 2 +- aya-obj/src/lib.rs | 7 +++---- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/aya-obj/README.md b/aya-obj/README.md index 62450ff8..cfc4cfae 100644 --- a/aya-obj/README.md +++ b/aya-obj/README.md @@ -3,7 +3,7 @@ ## Overview eBPF programs written with [libbpf] or [aya-bpf] are usually compiled -into an ELF object file, using various section to store information +into an ELF object file, using various sections to store information about the eBPF programs. `aya-obj` is a library that loads, parses and processes such eBPF diff --git a/aya-obj/src/btf/btf.rs b/aya-obj/src/btf/btf.rs index a5fbcd1a..61fa6a52 100644 --- a/aya-obj/src/btf/btf.rs +++ b/aya-obj/src/btf/btf.rs @@ -130,7 +130,7 @@ pub enum BtfError { /// Loading the btf failed #[error("the BPF_BTF_LOAD syscall failed. Verifier output: {verifier_log}")] LoadError { - /// The [`io::Error`] returned by the `BPF_BTF_LOAD` syscall. + /// The [`std::io::Error`] returned by the `BPF_BTF_LOAD` syscall. #[source] io_error: std::io::Error, /// The error log produced by the kernel verifier. @@ -613,7 +613,7 @@ unsafe fn read_btf_header(data: &[u8]) -> btf_header { ptr::read_unaligned(data.as_ptr() as *const btf_header) } -/// Data in .BTF.ext section +/// Data in the `.BTF.ext` section #[derive(Debug, Clone)] pub struct BtfExt { data: Vec, diff --git a/aya-obj/src/btf/info.rs b/aya-obj/src/btf/info.rs index 97f5b866..27982807 100644 --- a/aya-obj/src/btf/info.rs +++ b/aya-obj/src/btf/info.rs @@ -71,7 +71,7 @@ impl FuncSecInfo { } } - /// Encodes the [bpf_func_info] entries + /// Encodes the [bpf_func_info] entries. pub fn func_info_bytes(&self) -> Vec { let mut buf = vec![]; for l in &self.func_info { @@ -81,7 +81,7 @@ impl FuncSecInfo { buf } - /// Returns the number of [bpf_func_info] entries + /// Returns the number of [bpf_func_info] entries. pub fn len(&self) -> usize { self.func_info.len() } @@ -176,7 +176,7 @@ impl LineSecInfo { } } - /// Encode the entries + /// Encodes the entries. pub fn line_info_bytes(&self) -> Vec { let mut buf = vec![]; for l in &self.line_info { @@ -186,7 +186,7 @@ impl LineSecInfo { buf } - /// Returns the number of entries + /// Returns the number of entries. pub fn len(&self) -> usize { self.line_info.len() } diff --git a/aya-obj/src/btf/relocation.rs b/aya-obj/src/btf/relocation.rs index ec1bcde7..f70502b0 100644 --- a/aya-obj/src/btf/relocation.rs +++ b/aya-obj/src/btf/relocation.rs @@ -208,7 +208,7 @@ impl Relocation { } impl Object { - /// Relocate programs inside this object file with loaded BTF info. + /// Relocates programs inside this object file with loaded BTF info. pub fn relocate_btf(&mut self, target_btf: &Btf) -> Result<(), BtfRelocationError> { let (local_btf, btf_ext) = match (&self.btf, &self.btf_ext) { (Some(btf), Some(btf_ext)) => (btf, btf_ext), diff --git a/aya-obj/src/lib.rs b/aya-obj/src/lib.rs index 120ae047..4044eea3 100644 --- a/aya-obj/src/lib.rs +++ b/aya-obj/src/lib.rs @@ -3,7 +3,7 @@ //! ## Overview //! //! eBPF programs written with [libbpf] or [aya-bpf] are usually compiled -//! into an ELF object file, using various section to store information +//! into an ELF object file, using various sections to store information //! about the eBPF programs. //! //! `aya-obj` is a library that loads, parses and processes such eBPF @@ -49,13 +49,12 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![deny(clippy::all, missing_docs)] #![allow(clippy::missing_safety_doc, clippy::len_without_is_empty)] - #![cfg_attr(feature = "no_std", feature(error_in_core))] -#[cfg(not(feature = "no_std"))] -pub(crate) use thiserror_std as thiserror; #[cfg(feature = "no_std")] pub(crate) use thiserror_core as thiserror; +#[cfg(not(feature = "no_std"))] +pub(crate) use thiserror_std as thiserror; extern crate alloc; #[cfg(not(feature = "no_std"))] From 772af170aea2feccb5e98cc84125e9e31b9fbe9a Mon Sep 17 00:00:00 2001 From: Shenghui Ye Date: Thu, 29 Dec 2022 14:01:50 +0800 Subject: [PATCH 11/51] aya-obj: add documentation on program names This commit adds documentation on how program names are parsed from section names, as is used by `aya_obj::Object.programs` as HashMap keys, and updates the examples into using program names. --- aya-obj/README.md | 3 +- aya-obj/src/lib.rs | 3 +- aya-obj/src/obj.rs | 67 ++++++++++++++++++++++++- test/integration-test/src/tests/rbpf.rs | 37 ++++++++++---- 4 files changed, 93 insertions(+), 17 deletions(-) diff --git a/aya-obj/README.md b/aya-obj/README.md index cfc4cfae..3bb23916 100644 --- a/aya-obj/README.md +++ b/aya-obj/README.md @@ -27,8 +27,7 @@ object.relocate_calls().unwrap(); object.relocate_maps(std::iter::empty()).unwrap(); // Run with rbpf -let program = object.programs.iter().next().unwrap().1; -let instructions = &program.function.instructions; +let instructions = &object.programs["prog_name"].function.instructions; let data = unsafe { core::slice::from_raw_parts( instructions.as_ptr() as *const u8, diff --git a/aya-obj/src/lib.rs b/aya-obj/src/lib.rs index 4044eea3..f9d04d6e 100644 --- a/aya-obj/src/lib.rs +++ b/aya-obj/src/lib.rs @@ -27,8 +27,7 @@ //! object.relocate_maps(std::iter::empty()).unwrap(); //! //! // Run with rbpf -//! let program = object.programs.iter().next().unwrap().1; -//! let instructions = &program.function.instructions; +//! let instructions = &object.programs["prog_name"].function.instructions; //! let data = unsafe { //! core::slice::from_raw_parts( //! instructions.as_ptr() as *const u8, diff --git a/aya-obj/src/obj.rs b/aya-obj/src/obj.rs index 5c01c815..6a859190 100644 --- a/aya-obj/src/obj.rs +++ b/aya-obj/src/obj.rs @@ -48,7 +48,8 @@ pub struct Object { pub btf_ext: Option, /// Referenced maps pub maps: HashMap, - /// Programs + /// A hash map of programs, using the program names parsed + /// in [ProgramSection]s as keys. pub programs: HashMap, /// Functions pub functions: HashMap, @@ -97,7 +98,69 @@ pub struct Function { pub line_info_rec_size: usize, } -/// Sections containing eBPF programs +/// Section types containing eBPF programs +/// +/// # Section Name Parsing +/// +/// Section types are parsed from the section name strings. +/// +/// In order for Aya to treat a section as a [ProgramSection], +/// there are a few requirements: +/// - The section must be an executable code section. +/// - The section name must conform to [Program Types and ELF Sections]. +/// +/// [Program Types and ELF Sections]: https://docs.kernel.org/bpf/libbpf/program_types.html +/// +/// ## Program Name +/// +/// Each section name is parsed into a section type and a program name. +/// +/// Generally speaking, +/// - if the section name does not contain any slashes, +/// then the program name is just that section name; +/// - if there are some slashes, the name is `section_name.rsplitn(2, '/')[0]`, +/// - except for tracepoint programs, for which the name is +/// `section_name.splitn(2, '/')[1]`. +/// +/// ```rust +/// use aya_obj::ProgramSection; +/// use std::str::FromStr; +/// +/// assert_eq!( +/// ProgramSection::from_str("kprobe/do_unlinkat") +/// .unwrap().name(), +/// "do_unlinkat", +/// ); +/// assert_eq!( +/// ProgramSection::from_str("tracepoint/syscalls/sys_enter_openat") +/// .unwrap().name(), +/// "syscalls/sys_enter_openat", +/// ); +/// ``` +/// +/// The program name will be used in [Object] as references to each program. +/// +/// ## Unsupported Sections +/// +/// Currently, the following section names are not supported yet: +/// - `flow_dissector`: `BPF_PROG_TYPE_FLOW_DISSECTOR` +/// - `ksyscall+` or `kretsyscall+` +/// - `uprobe.s+` or `uretprobe.s+` +/// - `usdt+` +/// - `kprobe.multi+` or `kretprobe.multi+`: `BPF_TRACE_KPROBE_MULTI` +/// - `lsm_cgroup+` or `lsm.s+` +/// - `lwt_in`, `lwt_out`, `lwt_seg6local`, `lwt_xmit` +/// - `raw_tp.w+`, `raw_tracepoint.w+` +/// - `action` +/// - `sk_reuseport/migrate`, `sk_reuseport` +/// - `syscall` +/// - `struct_ops+` +/// - `fmod_ret+`, `fmod_ret.s+` +/// - `fentry.s+`, `fexit.s+` +/// - `iter+`, `iter.s+` +/// - `xdp.frags/cpumap`, `xdp/cpumap` +/// - `xdp.frags/devmap`, `xdp/devmap` +/// - `xdp.frags` #[derive(Debug, Clone)] #[allow(missing_docs)] pub enum ProgramSection { diff --git a/test/integration-test/src/tests/rbpf.rs b/test/integration-test/src/tests/rbpf.rs index a76bb162..92dfac74 100644 --- a/test/integration-test/src/tests/rbpf.rs +++ b/test/integration-test/src/tests/rbpf.rs @@ -2,7 +2,7 @@ use core::{mem::size_of, ptr::null_mut, slice::from_raw_parts}; use std::collections::HashMap; use aya::include_bytes_aligned; -use aya_obj::{generated::bpf_insn, Object}; +use aya_obj::{generated::bpf_insn, Object, ProgramSection}; use super::{integration_test, IntegrationTest}; @@ -10,7 +10,14 @@ use super::{integration_test, IntegrationTest}; fn run_with_rbpf() { let bytes = include_bytes_aligned!("../../../../target/bpfel-unknown-none/debug/pass"); let object = Object::parse(bytes).unwrap(); + assert_eq!(object.programs.len(), 1); + assert!(matches!( + object.programs["pass"].section, + ProgramSection::Xdp { .. } + )); + assert_eq!(object.programs["pass"].section.name(), "pass"); + let instructions = &object.programs["pass"].function.instructions; let data = unsafe { from_raw_parts( @@ -31,26 +38,34 @@ fn use_map_with_rbpf() { let bytes = include_bytes_aligned!("../../../../target/bpfel-unknown-none/debug/multimap-btf.bpf.o"); let mut object = Object::parse(bytes).unwrap(); - let mut maps = HashMap::new(); - // Initializes maps: - // - fd: 0xCAFE00 or 0xCAFE01, + assert_eq!(object.programs.len(), 1); + assert!(matches!( + object.programs["tracepoint"].section, + ProgramSection::TracePoint { .. } + )); + assert_eq!(object.programs["tracepoint"].section.name(), "tracepoint"); + + // Initialize maps: + // - fd: 0xCAFE00 or 0xCAFE01 (the 0xCAFE00 part is used to distinguish fds from indices), // - Note that rbpf does not convert fds into real pointers, // so we keeps the pointers to our maps in MULTIMAP_MAPS, to be used in helpers. - let mut map_instances = Vec::new(); - for (map_id, (name, map)) in object.maps.iter().enumerate() { - maps.insert(name.to_owned(), (map_id as i32 | 0xCAFE00, map.clone())); + let mut maps = HashMap::new(); + let mut map_instances = vec![vec![0u64], vec![0u64]]; + for (name, map) in object.maps.iter() { assert_eq!(map.key_size(), size_of::() as u32); assert_eq!(map.value_size(), size_of::() as u32); assert_eq!( map.map_type(), aya_obj::generated::bpf_map_type::BPF_MAP_TYPE_ARRAY as u32 ); - map_instances.push(vec![0u64]); + + let map_id = if name == "map_1" { 0 } else { 1 }; + let fd = map_id as i32 | 0xCAFE00; + maps.insert(name.to_owned(), (fd, map.clone())); unsafe { - MULTIMAP_MAPS[if name == "map_1" { 0 } else { 1 }] = - &mut map_instances[map_id] as *mut _; + MULTIMAP_MAPS[map_id] = &mut map_instances[map_id] as *mut _; } } @@ -60,7 +75,7 @@ fn use_map_with_rbpf() { .map(|(s, (fd, map))| (s.as_ref() as &str, Some(*fd), map)), ) .expect("Relocation failed"); - // Actually there is no call involved. + // Actually there is no local function call involved. object.relocate_calls().unwrap(); // Executes the program From 9c451a3357317405dd8e2e4df7d006cee943adcc Mon Sep 17 00:00:00 2001 From: Shenghui Ye Date: Mon, 2 Jan 2023 11:07:08 +0800 Subject: [PATCH 12/51] aya-obj: update documentation and versioning info - Set the version number of `aya-obj` to `0.1.0`. - Update the description of the `aya-obj` crate. - Add a section in README and rustdoc warning about the unstable API. --- aya-obj/Cargo.toml | 6 +++--- aya-obj/README.md | 20 +++++++++++++++++--- aya-obj/src/lib.rs | 24 +++++++++++++++++++----- aya-obj/src/obj.rs | 2 +- aya/Cargo.toml | 2 +- 5 files changed, 41 insertions(+), 13 deletions(-) diff --git a/aya-obj/Cargo.toml b/aya-obj/Cargo.toml index f1bf4e9c..9ede2431 100644 --- a/aya-obj/Cargo.toml +++ b/aya-obj/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "aya-obj" -version = "0.11.0" -description = "A library for loading and relocating eBPF object files" -keywords = ["ebpf", "bpf", "linux", "kernel"] +version = "0.1.0" +description = "An eBPF object file parsing library with BTF and relocation support." +keywords = ["ebpf", "bpf", "btf", "elf", "object"] license = "MIT OR Apache-2.0" authors = ["The Aya Contributors"] repository = "https://github.com/aya-rs/aya" diff --git a/aya-obj/README.md b/aya-obj/README.md index 3bb23916..1530ca03 100644 --- a/aya-obj/README.md +++ b/aya-obj/README.md @@ -1,4 +1,18 @@ -# aya-obj - an eBPF object file loading library +# aya-obj + +## Status + +This crate includes code that started as internal API used by +the [aya] crate. It has been split out so that it can be used by +other projects that deal with eBPF object files. Unless you're writing +low level eBPF plumbing tools, you should not need to use this crate +but see the [aya] crate instead. + +The API as it is today has a few rough edges and is generally not as +polished nor stable as the main [aya] crate API. As always, +improvements welcome! + +[aya]: https://github.com/aya-rs/aya ## Overview @@ -6,8 +20,8 @@ eBPF programs written with [libbpf] or [aya-bpf] are usually compiled into an ELF object file, using various sections to store information about the eBPF programs. -`aya-obj` is a library that loads, parses and processes such eBPF -object files. +`aya-obj` is a library for parsing such eBPF object files, with BTF and +relocation support. [libbpf]: https://github.com/libbpf/libbpf [aya-bpf]: https://github.com/aya-rs/aya diff --git a/aya-obj/src/lib.rs b/aya-obj/src/lib.rs index f9d04d6e..438e38f2 100644 --- a/aya-obj/src/lib.rs +++ b/aya-obj/src/lib.rs @@ -1,18 +1,32 @@ -//! A library for loading and relocating eBPF object files. +//! An eBPF object file parsing library with BTF and relocation support. //! -//! ## Overview +//! # Status +//! +//! This crate includes code that started as internal API used by +//! the [aya] crate. It has been split out so that it can be used by +//! other projects that deal with eBPF object files. Unless you're writing +//! low level eBPF plumbing tools, you should not need to use this crate +//! but see the [aya] crate instead. +//! +//! The API as it is today has a few rough edges and is generally not as +//! polished nor stable as the main [aya] crate API. As always, +//! improvements welcome! +//! +//! [aya]: https://github.com/aya-rs/aya +//! +//! # Overview //! //! eBPF programs written with [libbpf] or [aya-bpf] are usually compiled //! into an ELF object file, using various sections to store information //! about the eBPF programs. //! -//! `aya-obj` is a library that loads, parses and processes such eBPF -//! object files. +//! `aya-obj` is a library for parsing such eBPF object files, with BTF and +//! relocation support. //! //! [libbpf]: https://github.com/libbpf/libbpf //! [aya-bpf]: https://github.com/aya-rs/aya //! -//! ## Example +//! # Example //! //! This example loads a simple eBPF program and runs it with [rbpf]. //! diff --git a/aya-obj/src/obj.rs b/aya-obj/src/obj.rs index 6a859190..23943236 100644 --- a/aya-obj/src/obj.rs +++ b/aya-obj/src/obj.rs @@ -140,7 +140,7 @@ pub struct Function { /// /// The program name will be used in [Object] as references to each program. /// -/// ## Unsupported Sections +/// # Unsupported Sections /// /// Currently, the following section names are not supported yet: /// - `flow_dissector`: `BPF_PROG_TYPE_FLOW_DISSECTOR` diff --git a/aya/Cargo.toml b/aya/Cargo.toml index ed413621..341bdac0 100644 --- a/aya/Cargo.toml +++ b/aya/Cargo.toml @@ -12,7 +12,7 @@ edition = "2021" [dependencies] libc = { version = "0.2.105" } -aya-obj = { path = "../aya-obj", version = "0.11.0" } +aya-obj = { path = "../aya-obj", version = "0.1.0" } thiserror = "1" object = { version = "0.30", default-features = false, features = ["std", "read_core", "elf"] } bitflags = "1.2.1" From 7e6a7d9005618affe6a796d3681d1107abdea380 Mon Sep 17 00:00:00 2001 From: Matteo Nardi Date: Fri, 16 Dec 2022 12:10:35 +0100 Subject: [PATCH 13/51] btf: add integration tests for relocations Add new integrations tests for BTF relocations. --- test/integration-test/Cargo.toml | 1 + test/integration-test/src/tests/mod.rs | 1 + .../integration-test/src/tests/relocations.rs | 226 ++++++++++++++++++ xtask/src/build_ebpf.rs | 1 + 4 files changed, 229 insertions(+) create mode 100644 test/integration-test/src/tests/relocations.rs diff --git a/test/integration-test/Cargo.toml b/test/integration-test/Cargo.toml index 1f1bdf13..5851e414 100644 --- a/test/integration-test/Cargo.toml +++ b/test/integration-test/Cargo.toml @@ -18,3 +18,4 @@ log = "0.4" object = { version = "0.30", default-features = false, features = ["std", "read_core", "elf"] } rbpf = "0.1.0" regex = "1" +tempfile = "3.3.0" diff --git a/test/integration-test/src/tests/mod.rs b/test/integration-test/src/tests/mod.rs index 0b3e9e95..ddb1b504 100644 --- a/test/integration-test/src/tests/mod.rs +++ b/test/integration-test/src/tests/mod.rs @@ -7,6 +7,7 @@ use std::{ffi::CStr, mem}; pub mod elf; pub mod load; pub mod rbpf; +pub mod relocations; pub mod smoke; pub use integration_test_macros::integration_test; diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs new file mode 100644 index 00000000..4778f14f --- /dev/null +++ b/test/integration-test/src/tests/relocations.rs @@ -0,0 +1,226 @@ +use anyhow::{Context, Result}; +use std::{process::Command, thread::sleep, time::Duration}; + +use aya::{maps::Array, programs::TracePoint, BpfLoader, Btf, Endianness}; + +use super::{integration_test, IntegrationTest}; + +#[integration_test] +fn relocate_field() { + let test = RelocationTest { + local_definition: r#" + struct foo { + __u8 a; + __u8 b; + __u8 c; + __u8 d; + } __attribute__((preserve_access_index)); + "#, + target_btf: r#" + struct foo { + __u8 a; + __u8 c; + __u8 b; + __u8 d; + } s1; + "#, + relocation_code: r#" + __u8 memory[] = {1, 2, 3, 4}; + __u32 value = BPF_CORE_READ((struct foo *)&memory, c); + "#, + } + .build() + .unwrap(); + assert_eq!(test.run().unwrap(), 2); + assert_eq!(test.run_no_btf().unwrap(), 3); +} + +#[integration_test] +fn relocate_enum() { + let test = RelocationTest { + local_definition: r#" + enum foo { D = 1 }; + "#, + target_btf: r#" + enum foo { D = 4 } e1; + "#, + relocation_code: r#" + __u32 value = bpf_core_enum_value(enum foo, D); + "#, + } + .build() + .unwrap(); + assert_eq!(test.run().unwrap(), 4); + assert_eq!(test.run_no_btf().unwrap(), 0); +} + +/// Utility code for running relocation tests: +/// - Generates the eBPF program using probided local definition and relocation code +/// - Generates the BTF from the target btf code +struct RelocationTest { + /// Data structure definition, local to the eBPF program and embedded in the eBPF bytecode + local_definition: &'static str, + /// Target data structure definition. What the vmlinux would actually contain. + target_btf: &'static str, + /// Code executed by the eBPF program to test the relocation. + /// The format should be: + // __u8 memory[] = { ... }; + // __u32 value = BPF_CORE_READ((struct foo *)&memory, ...); + // + // The generated code will be executed by attaching a tracepoint to sched_switch + // and emitting `__u32 value` an a map. See the code template below for more details. + relocation_code: &'static str, +} + +impl RelocationTest { + /// Build a RelocationTestRunner + fn build(&self) -> Result { + Ok(RelocationTestRunner { + ebpf: self.build_ebpf()?, + btf: self.build_btf()?, + }) + } + + /// - Generate the source eBPF filling a template + /// - Compile it with clang + fn build_ebpf(&self) -> Result> { + let local_definition = self.local_definition; + let relocation_code = self.relocation_code; + let tmp_dir = tempfile::tempdir().context("Error making temp dir")?; + let ebpf_file = tmp_dir.path().join("ebpf_program.c"); + std::fs::write( + &ebpf_file, + format!( + r#" + #include + + #include + #include + #include + + {local_definition} + + struct {{ + __uint(type, BPF_MAP_TYPE_ARRAY); + __type(key, __u32); + __type(value, __u32); + __uint(max_entries, 1); + }} output_map SEC(".maps"); + + SEC("tracepoint/bpf_prog") int bpf_prog(void *ctx) {{ + __u32 key = 0; + {relocation_code} + bpf_map_update_elem(&output_map, &key, &value, BPF_ANY); + return 0; + }} + + char _license[] SEC("license") = "GPL"; + "# + ), + ) + .context("Writing bpf program failed")?; + Command::new("clang") + .current_dir(tmp_dir.path()) + .args(["-c", "-g", "-O2", "-target", "bpf"]) + .args([ + "-I", + &std::env::var("LIBBPF_INCLUDE").context("LIBBPF_INCLUDE not set")?, + ]) + .arg(&ebpf_file) + .status() + .context("Failed to run clang")? + .success() + .then_some(()) + .context("Failed to compile eBPF program")?; + let ebpf = std::fs::read(ebpf_file.with_extension("o")) + .context("Error reading compiled eBPF program")?; + Ok(ebpf) + } + + /// - Generate the target BTF source with a mock main() + /// - Compile it with clang + /// - Extract the BTF with pahole + fn build_btf(&self) -> Result { + let target_btf = self.target_btf; + let tmp_dir = tempfile::tempdir().context("Error making temp dir")?; + // BTF files can be generated and inspected with these commands: + // $ clang -c -g -O2 -target bpf target.c + // $ pahole --btf_encode_detached=target.btf -V target.o + // $ bpftool btf dump file ./target.btf format c + let btf_file = tmp_dir.path().join("target_btf.c"); + std::fs::write( + &btf_file, + format!( + r#" + #include + {target_btf} + int main() {{ return 0; }} + "# + ), + ) + .context("Writing bpf program failed")?; + Command::new("clang") + .current_dir(tmp_dir.path()) + .args(["-c", "-g", "-O2", "-target", "bpf"]) + .arg(&btf_file) + .status() + .context("Failed to run clang")? + .success() + .then_some(()) + .context("Failed to compile BTF")?; + Command::new("pahole") + .current_dir(tmp_dir.path()) + .arg("--btf_encode_detached=target.btf") + .arg(btf_file.with_extension("o")) + .status() + .context("Failed to run pahole")? + .success() + .then_some(()) + .context("Failed to extract BTF")?; + let btf = Btf::parse_file(tmp_dir.path().join("target.btf"), Endianness::default()) + .context("Error parsing generated BTF")?; + Ok(btf) + } +} + +struct RelocationTestRunner { + ebpf: Vec, + btf: Btf, +} + +impl RelocationTestRunner { + /// Run test and return the output value + fn run(&self) -> Result { + self.run_internal(true) + } + + /// Run without loading btf + fn run_no_btf(&self) -> Result { + self.run_internal(false) + } + + fn run_internal(&self, with_relocations: bool) -> Result { + let mut loader = BpfLoader::new(); + if with_relocations { + loader.btf(Some(&self.btf)); + } + let mut bpf = loader.load(&self.ebpf).context("Loading eBPF failed")?; + let program: &mut TracePoint = bpf + .program_mut("bpf_prog") + .context("bpf_prog not found")? + .try_into() + .context("program not a tracepoint")?; + program.load().context("Loading tracepoint failed")?; + // Attach to sched_switch and wait some time to make sure it executed at least once + program + .attach("sched", "sched_switch") + .context("attach failed")?; + sleep(Duration::from_millis(1000)); + // To inspect the loaded eBPF bytecode, increse the timeout and run: + // $ sudo bpftool prog dump xlated name bpf_prog + + let output_map: Array<_, u32> = bpf.take_map("output_map").unwrap().try_into().unwrap(); + let key = 0; + output_map.get(&key, 0).context("Getting key 0 failed") + } +} diff --git a/xtask/src/build_ebpf.rs b/xtask/src/build_ebpf.rs index 4f98feba..0d3540e6 100644 --- a/xtask/src/build_ebpf.rs +++ b/xtask/src/build_ebpf.rs @@ -103,6 +103,7 @@ fn build_c_ebpf(opts: &BuildEbpfOptions) -> anyhow::Result<()> { let include_path = out_path.join("include"); get_libbpf_headers(&opts.libbpf_dir, &include_path)?; + std::env::set_var("LIBBPF_INCLUDE", &include_path); let files = fs::read_dir(&src).unwrap(); for file in files { let p = file.unwrap().path(); From b72abcc7ded3ba83bae6da1f3895cf73c8fb0602 Mon Sep 17 00:00:00 2001 From: Matteo Nardi Date: Mon, 19 Dec 2022 14:21:18 +0100 Subject: [PATCH 14/51] tests: add pointer relocation test --- .../integration-test/src/tests/relocations.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs index 4778f14f..2654dff6 100644 --- a/test/integration-test/src/tests/relocations.rs +++ b/test/integration-test/src/tests/relocations.rs @@ -54,6 +54,25 @@ fn relocate_enum() { assert_eq!(test.run_no_btf().unwrap(), 0); } +#[integration_test] +fn relocate_pointer() { + let test = RelocationTest { + local_definition: r#" + struct foo {}; + struct bar { struct foo *f; }; + "#, + target_btf: r#""#, + relocation_code: r#" + __u8 memory[] = {0, 0, 0, 0, 0, 0, 0, 42}; + struct foo *f = BPF_CORE_READ((struct bar *)&memory, f); + __u32 value = (f == (struct foo *) 42); + "#, + } + .build() + .unwrap(); + assert_eq!(test.run().unwrap(), 1); +} + /// Utility code for running relocation tests: /// - Generates the eBPF program using probided local definition and relocation code /// - Generates the BTF from the target btf code From 702f77b56503477165ac6e3050df1ef7c348b717 Mon Sep 17 00:00:00 2001 From: Matteo Nardi Date: Mon, 26 Dec 2022 10:49:53 +0100 Subject: [PATCH 15/51] tests: explain libbpf env variable --- test/integration-test/src/tests/relocations.rs | 4 +++- xtask/src/build_ebpf.rs | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs index 2654dff6..04a14f7a 100644 --- a/test/integration-test/src/tests/relocations.rs +++ b/test/integration-test/src/tests/relocations.rs @@ -14,7 +14,7 @@ fn relocate_field() { __u8 b; __u8 c; __u8 d; - } __attribute__((preserve_access_index)); + }; "#, target_btf: r#" struct foo { @@ -141,6 +141,8 @@ impl RelocationTest { Command::new("clang") .current_dir(tmp_dir.path()) .args(["-c", "-g", "-O2", "-target", "bpf"]) + // NOTE: these tests depend on libbpf, LIBBPF_INCLUDE must point its headers. + // This is set automatically by the integration-test xtask. .args([ "-I", &std::env::var("LIBBPF_INCLUDE").context("LIBBPF_INCLUDE not set")?, diff --git a/xtask/src/build_ebpf.rs b/xtask/src/build_ebpf.rs index 0d3540e6..9e22da89 100644 --- a/xtask/src/build_ebpf.rs +++ b/xtask/src/build_ebpf.rs @@ -103,7 +103,12 @@ fn build_c_ebpf(opts: &BuildEbpfOptions) -> anyhow::Result<()> { let include_path = out_path.join("include"); get_libbpf_headers(&opts.libbpf_dir, &include_path)?; + // Export libbpf location as an env variable since it's needed for building + // the relocation tests at test/integration-test/src/tests/relocations.rs + // We decided to make an exception and build its eBPF programs at run-time + // because of the many different permutations. std::env::set_var("LIBBPF_INCLUDE", &include_path); + let files = fs::read_dir(&src).unwrap(); for file in files { let p = file.unwrap().path(); From 27f22f205d7f04e69372eda370bb7b436cb87445 Mon Sep 17 00:00:00 2001 From: Matteo Nardi Date: Tue, 3 Jan 2023 07:48:34 +0100 Subject: [PATCH 16/51] Make relocations tests actually pass --- .../integration-test/src/tests/relocations.rs | 171 +++++++++--------- 1 file changed, 90 insertions(+), 81 deletions(-) diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs index 04a14f7a..abeb51a3 100644 --- a/test/integration-test/src/tests/relocations.rs +++ b/test/integration-test/src/tests/relocations.rs @@ -1,5 +1,6 @@ use anyhow::{Context, Result}; -use std::{process::Command, thread::sleep, time::Duration}; +use std::{path::PathBuf, process::Command, thread::sleep, time::Duration}; +use tempfile::TempDir; use aya::{maps::Array, programs::TracePoint, BpfLoader, Btf, Endianness}; @@ -51,7 +52,7 @@ fn relocate_enum() { .build() .unwrap(); assert_eq!(test.run().unwrap(), 4); - assert_eq!(test.run_no_btf().unwrap(), 0); + assert_eq!(test.run_no_btf().unwrap(), 1); } #[integration_test] @@ -61,16 +62,20 @@ fn relocate_pointer() { struct foo {}; struct bar { struct foo *f; }; "#, - target_btf: r#""#, + target_btf: r#" + struct foo {}; + struct bar { struct foo *f; }; + "#, relocation_code: r#" - __u8 memory[] = {0, 0, 0, 0, 0, 0, 0, 42}; + __u8 memory[] = {42, 0, 0, 0, 0, 0, 0, 0}; struct foo *f = BPF_CORE_READ((struct bar *)&memory, f); - __u32 value = (f == (struct foo *) 42); + __u32 value = ((__u64) f); "#, } .build() .unwrap(); - assert_eq!(test.run().unwrap(), 1); + assert_eq!(test.run().unwrap(), 42); + assert_eq!(test.run_no_btf().unwrap(), 42); } /// Utility code for running relocation tests: @@ -105,57 +110,37 @@ impl RelocationTest { fn build_ebpf(&self) -> Result> { let local_definition = self.local_definition; let relocation_code = self.relocation_code; - let tmp_dir = tempfile::tempdir().context("Error making temp dir")?; - let ebpf_file = tmp_dir.path().join("ebpf_program.c"); - std::fs::write( - &ebpf_file, - format!( - r#" - #include - - #include - #include - #include - - {local_definition} - - struct {{ - __uint(type, BPF_MAP_TYPE_ARRAY); - __type(key, __u32); - __type(value, __u32); - __uint(max_entries, 1); - }} output_map SEC(".maps"); - - SEC("tracepoint/bpf_prog") int bpf_prog(void *ctx) {{ - __u32 key = 0; - {relocation_code} - bpf_map_update_elem(&output_map, &key, &value, BPF_ANY); - return 0; - }} - - char _license[] SEC("license") = "GPL"; - "# - ), - ) - .context("Writing bpf program failed")?; - Command::new("clang") - .current_dir(tmp_dir.path()) - .args(["-c", "-g", "-O2", "-target", "bpf"]) - // NOTE: these tests depend on libbpf, LIBBPF_INCLUDE must point its headers. - // This is set automatically by the integration-test xtask. - .args([ - "-I", - &std::env::var("LIBBPF_INCLUDE").context("LIBBPF_INCLUDE not set")?, - ]) - .arg(&ebpf_file) - .status() - .context("Failed to run clang")? - .success() - .then_some(()) - .context("Failed to compile eBPF program")?; - let ebpf = std::fs::read(ebpf_file.with_extension("o")) - .context("Error reading compiled eBPF program")?; - Ok(ebpf) + let (_tmp_dir, compiled_file) = compile(&format!( + r#" + #include + + #include + #include + #include + + {local_definition} + + struct {{ + __uint(type, BPF_MAP_TYPE_ARRAY); + __type(key, __u32); + __type(value, __u32); + __uint(max_entries, 1); + }} output_map SEC(".maps"); + + SEC("tracepoint/bpf_prog") int bpf_prog(void *ctx) {{ + __u32 key = 0; + {relocation_code} + bpf_map_update_elem(&output_map, &key, &value, BPF_ANY); + return 0; + }} + + char _license[] SEC("license") = "GPL"; + "# + )) + .context("Failed to compile eBPF program")?; + let bytecode = + std::fs::read(compiled_file).context("Error reading compiled eBPF program")?; + Ok(bytecode) } /// - Generate the target BTF source with a mock main() @@ -163,36 +148,33 @@ impl RelocationTest { /// - Extract the BTF with pahole fn build_btf(&self) -> Result { let target_btf = self.target_btf; - let tmp_dir = tempfile::tempdir().context("Error making temp dir")?; + let relocation_code = self.relocation_code; // BTF files can be generated and inspected with these commands: // $ clang -c -g -O2 -target bpf target.c // $ pahole --btf_encode_detached=target.btf -V target.o // $ bpftool btf dump file ./target.btf format c - let btf_file = tmp_dir.path().join("target_btf.c"); - std::fs::write( - &btf_file, - format!( - r#" - #include - {target_btf} - int main() {{ return 0; }} - "# - ), - ) - .context("Writing bpf program failed")?; - Command::new("clang") - .current_dir(tmp_dir.path()) - .args(["-c", "-g", "-O2", "-target", "bpf"]) - .arg(&btf_file) - .status() - .context("Failed to run clang")? - .success() - .then_some(()) - .context("Failed to compile BTF")?; + let (tmp_dir, compiled_file) = compile(&format!( + r#" + #include + + #include + #include + #include + + {target_btf} + int main() {{ + // This is needed to make sure to emit BTF for the defined types, + // it could be dead code eliminated if we don't. + {relocation_code}; + return value; + }} + "# + )) + .context("Failed to compile BTF")?; Command::new("pahole") .current_dir(tmp_dir.path()) .arg("--btf_encode_detached=target.btf") - .arg(btf_file.with_extension("o")) + .arg(compiled_file) .status() .context("Failed to run pahole")? .success() @@ -204,6 +186,30 @@ impl RelocationTest { } } +/// Compile an eBPF program and return the path of the compiled object. +/// Also returns a TempDir handler, dropping it will clear the created dicretory. +fn compile(source_code: &str) -> Result<(TempDir, PathBuf)> { + let tmp_dir = tempfile::tempdir().context("Error making temp dir")?; + let source = tmp_dir.path().join("source.c"); + std::fs::write(&source, source_code).context("Writing bpf program failed")?; + Command::new("clang") + .current_dir(&tmp_dir) + .args(["-c", "-g", "-O2", "-target", "bpf"]) + // NOTE: these tests depend on libbpf, LIBBPF_INCLUDE must point its headers. + // This is set automatically by the integration-test xtask. + .args([ + "-I", + &std::env::var("LIBBPF_INCLUDE").context("LIBBPF_INCLUDE not set")?, + ]) + .arg(&source) + .status() + .context("Failed to run clang")? + .success() + .then_some(()) + .context("Failed to compile eBPF source")?; + Ok((tmp_dir, source.with_extension("o"))) +} + struct RelocationTestRunner { ebpf: Vec, btf: Btf, @@ -212,18 +218,21 @@ struct RelocationTestRunner { impl RelocationTestRunner { /// Run test and return the output value fn run(&self) -> Result { - self.run_internal(true) + self.run_internal(true).context("Error running with BTF") } /// Run without loading btf fn run_no_btf(&self) -> Result { self.run_internal(false) + .context("Error running without BTF") } fn run_internal(&self, with_relocations: bool) -> Result { let mut loader = BpfLoader::new(); if with_relocations { loader.btf(Some(&self.btf)); + } else { + loader.btf(None); } let mut bpf = loader.load(&self.ebpf).context("Loading eBPF failed")?; let program: &mut TracePoint = bpf From 33baf7ef2203a27c69ff640d17fb382fca870c5c Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Tue, 4 Oct 2022 13:04:09 +0200 Subject: [PATCH 17/51] aya-bpf/maps: Add `get_ptr` and `get_mut_ptr` methods to Array Signed-off-by: Michal Rostecki --- bpf/aya-bpf/src/maps/array.rs | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/bpf/aya-bpf/src/maps/array.rs b/bpf/aya-bpf/src/maps/array.rs index 53b596ca..2150dd6e 100644 --- a/bpf/aya-bpf/src/maps/array.rs +++ b/bpf/aya-bpf/src/maps/array.rs @@ -47,14 +47,28 @@ impl Array { } } + #[inline(always)] pub fn get(&self, index: u32) -> Option<&T> { - unsafe { - let value = bpf_map_lookup_elem( - self.def.get() as *mut _, - &index as *const _ as *const c_void, - ); - // FIXME: alignment - NonNull::new(value as *mut T).map(|p| p.as_ref()) - } + // FIXME: alignment + unsafe { self.lookup(index).map(|p| p.as_ref()) } + } + + #[inline(always)] + pub fn get_ptr(&self, index: u32) -> Option<*const T> { + unsafe { self.lookup(index).map(|p| p.as_ptr() as *const T) } + } + + #[inline(always)] + pub fn get_ptr_mut(&self, index: u32) -> Option<*mut T> { + unsafe { self.lookup(index).map(|p| p.as_ptr()) } + } + + #[inline(always)] + unsafe fn lookup(&self, index: u32) -> Option> { + let ptr = bpf_map_lookup_elem( + self.def.get() as *mut _, + &index as *const _ as *const c_void, + ); + NonNull::new(ptr as *mut T) } } From 34e040b8e9530f988e5334db486793e669933969 Mon Sep 17 00:00:00 2001 From: Matteo Nardi Date: Tue, 3 Jan 2023 12:05:54 +0100 Subject: [PATCH 18/51] tests: use libtest-mimic and fix CI --- .github/workflows/build-aya.yml | 6 +- test/integration-test/Cargo.toml | 1 + test/integration-test/src/main.rs | 83 ++++--------------- .../integration-test/src/tests/relocations.rs | 8 +- test/run.sh | 8 +- 5 files changed, 32 insertions(+), 74 deletions(-) diff --git a/.github/workflows/build-aya.yml b/.github/workflows/build-aya.yml index baf666de..991298fa 100644 --- a/.github/workflows/build-aya.yml +++ b/.github/workflows/build-aya.yml @@ -66,8 +66,12 @@ jobs: - name: Install Pre-requisites run: | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" | sudo tee -a /etc/apt/sources.list sudo apt-get update - sudo apt-get -qy install linux-tools-common qemu-system-x86 cloud-image-utils openssh-client libelf-dev gcc-multilib + sudo apt-get -qy install linux-tools-common qemu-system-x86 cloud-image-utils openssh-client libelf-dev gcc-multilib llvm-15 clang-15 + sudo update-alternatives --install /usr/bin/llvm-objcopy llvm-objcopy /usr/bin/llvm-objcopy-15 200 + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 200 cargo install bpf-linker - name: Lint integration tests diff --git a/test/integration-test/Cargo.toml b/test/integration-test/Cargo.toml index 5851e414..9282f8cc 100644 --- a/test/integration-test/Cargo.toml +++ b/test/integration-test/Cargo.toml @@ -19,3 +19,4 @@ object = { version = "0.30", default-features = false, features = ["std", "read_ rbpf = "0.1.0" regex = "1" tempfile = "3.3.0" +libtest-mimic = "0.6.0" diff --git a/test/integration-test/src/main.rs b/test/integration-test/src/main.rs index 1fd32ea4..b081e645 100644 --- a/test/integration-test/src/main.rs +++ b/test/integration-test/src/main.rs @@ -1,74 +1,21 @@ -use log::info; +use libtest_mimic::{Arguments, Trial}; mod tests; use tests::IntegrationTest; -use clap::Parser; - -#[derive(Debug, Parser)] -#[clap(author, version, about, long_about = None)] -#[clap(propagate_version = true)] -pub struct RunOptions { - #[clap(short, long, value_parser)] - tests: Option>, -} - -#[derive(Debug, Parser)] -struct Cli { - #[clap(subcommand)] - command: Option, -} - -#[derive(Debug, Parser)] -enum Command { - /// Run one or more tests: ... -- run -t test1 -t test2 - Run(RunOptions), - /// List all the tests: ... -- list - List, -} - -macro_rules! exec_test { - ($test:expr) => {{ - info!("Running {}", $test.name); - ($test.test_fn)(); - }}; -} - -macro_rules! exec_all_tests { - () => {{ - for t in inventory::iter:: { - exec_test!(t) - } - }}; -} - -fn main() -> anyhow::Result<()> { +fn main() { env_logger::init(); - - let cli = Cli::parse(); - - match &cli.command { - Some(Command::Run(opts)) => match &opts.tests { - Some(tests) => { - for t in inventory::iter:: { - if tests.contains(&t.name.into()) { - exec_test!(t) - } - } - } - None => { - exec_all_tests!() - } - }, - Some(Command::List) => { - for t in inventory::iter:: { - info!("{}", t.name); - } - } - None => { - exec_all_tests!() - } - } - - Ok(()) + let mut args = Arguments::from_args(); + // Force to run single-threaded + args.test_threads = Some(1); + let tests = inventory::iter:: + .into_iter() + .map(|test| { + Trial::test(test.name, move || { + (test.test_fn)(); + Ok(()) + }) + }) + .collect(); + libtest_mimic::run(&args, tests).exit(); } diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs index abeb51a3..23bc7a18 100644 --- a/test/integration-test/src/tests/relocations.rs +++ b/test/integration-test/src/tests/relocations.rs @@ -145,7 +145,7 @@ impl RelocationTest { /// - Generate the target BTF source with a mock main() /// - Compile it with clang - /// - Extract the BTF with pahole + /// - Extract the BTF with llvm-objcopy fn build_btf(&self) -> Result { let target_btf = self.target_btf; let relocation_code = self.relocation_code; @@ -171,12 +171,12 @@ impl RelocationTest { "# )) .context("Failed to compile BTF")?; - Command::new("pahole") + Command::new("llvm-objcopy") .current_dir(tmp_dir.path()) - .arg("--btf_encode_detached=target.btf") + .args(["--dump-section", ".BTF=target.btf"]) .arg(compiled_file) .status() - .context("Failed to run pahole")? + .context("Failed to run llvm-objcopy")? .success() .then_some(()) .context("Failed to extract BTF")?; diff --git a/test/run.sh b/test/run.sh index b195d7a9..3be2b862 100755 --- a/test/run.sh +++ b/test/run.sh @@ -185,4 +185,10 @@ trap stop_vm EXIT cargo xtask build-integration-test --musl --libbpf-dir "$1" scp_vm ../target/x86_64-unknown-linux-musl/debug/integration-test -exec_vm sudo ./integration-test +exec_vm sudo ./integration-test --skip relocations + +# Relocation tests build the eBPF programs and require libbpf. We run them outside VM. +export LIBBPF_INCLUDE="${AYA_TMPDIR}/libbpf/" +mkdir -p "$LIBBPF_INCLUDE" +(cd "$1/src" && make INCLUDEDIR="$LIBBPF_INCLUDE" install_headers) +sudo -E ../target/x86_64-unknown-linux-musl/debug/integration-test relocations From 5d13fd5acaa90efedb76d371b69431ac9a262fdd Mon Sep 17 00:00:00 2001 From: alessandrod Date: Sat, 7 Jan 2023 21:11:14 +0000 Subject: [PATCH 19/51] [codegen] Update libbpf to 3423d5e7cdab356d115aef7f987b4a1098ede448Update libbpf to 3423d5e7cdab356d115aef7f987b4a1098ede448 Files changed: M aya-obj/src/generated/linux_bindings_aarch64.rs M aya-obj/src/generated/linux_bindings_armv7.rs M aya-obj/src/generated/linux_bindings_riscv64.rs M aya-obj/src/generated/linux_bindings_x86_64.rs M bpf/aya-bpf-bindings/src/aarch64/bindings.rs M bpf/aya-bpf-bindings/src/aarch64/helpers.rs M bpf/aya-bpf-bindings/src/armv7/bindings.rs M bpf/aya-bpf-bindings/src/armv7/helpers.rs M bpf/aya-bpf-bindings/src/riscv64/bindings.rs M bpf/aya-bpf-bindings/src/riscv64/helpers.rs M bpf/aya-bpf-bindings/src/x86_64/bindings.rs M bpf/aya-bpf-bindings/src/x86_64/helpers.rs --- .../src/generated/linux_bindings_aarch64.rs | 224 +++++++------ aya-obj/src/generated/linux_bindings_armv7.rs | 224 +++++++------ .../src/generated/linux_bindings_riscv64.rs | 224 +++++++------ .../src/generated/linux_bindings_x86_64.rs | 224 +++++++------ bpf/aya-bpf-bindings/src/aarch64/bindings.rs | 303 ++++++++++++------ bpf/aya-bpf-bindings/src/aarch64/helpers.rs | 54 +++- bpf/aya-bpf-bindings/src/armv7/bindings.rs | 303 ++++++++++++------ bpf/aya-bpf-bindings/src/armv7/helpers.rs | 54 +++- bpf/aya-bpf-bindings/src/riscv64/bindings.rs | 303 ++++++++++++------ bpf/aya-bpf-bindings/src/riscv64/helpers.rs | 54 +++- bpf/aya-bpf-bindings/src/x86_64/bindings.rs | 303 ++++++++++++------ bpf/aya-bpf-bindings/src/x86_64/helpers.rs | 54 +++- 12 files changed, 1476 insertions(+), 848 deletions(-) diff --git a/aya-obj/src/generated/linux_bindings_aarch64.rs b/aya-obj/src/generated/linux_bindings_aarch64.rs index fab6978c..244910f6 100644 --- a/aya-obj/src/generated/linux_bindings_aarch64.rs +++ b/aya-obj/src/generated/linux_bindings_aarch64.rs @@ -275,6 +275,10 @@ pub enum bpf_cmd { BPF_LINK_DETACH = 34, BPF_PROG_BIND_MAP = 35, } +impl bpf_map_type { + pub const BPF_MAP_TYPE_CGROUP_STORAGE: bpf_map_type = + bpf_map_type::BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED; +} #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum bpf_map_type { @@ -297,7 +301,7 @@ pub enum bpf_map_type { BPF_MAP_TYPE_CPUMAP = 16, BPF_MAP_TYPE_XSKMAP = 17, BPF_MAP_TYPE_SOCKHASH = 18, - BPF_MAP_TYPE_CGROUP_STORAGE = 19, + BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED = 19, BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 20, BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 21, BPF_MAP_TYPE_QUEUE = 22, @@ -309,6 +313,8 @@ pub enum bpf_map_type { BPF_MAP_TYPE_INODE_STORAGE = 28, BPF_MAP_TYPE_TASK_STORAGE = 29, BPF_MAP_TYPE_BLOOM_FILTER = 30, + BPF_MAP_TYPE_USER_RINGBUF = 31, + BPF_MAP_TYPE_CGRP_STORAGE = 32, } #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -731,34 +737,37 @@ pub type _bindgen_ty_9 = ::core::ffi::c_uint; pub const BPF_F_ZERO_CSUM_TX: _bindgen_ty_10 = 2; pub const BPF_F_DONT_FRAGMENT: _bindgen_ty_10 = 4; pub const BPF_F_SEQ_NUMBER: _bindgen_ty_10 = 8; +pub const BPF_F_NO_TUNNEL_KEY: _bindgen_ty_10 = 16; pub type _bindgen_ty_10 = ::core::ffi::c_uint; -pub const BPF_F_INDEX_MASK: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CURRENT_CPU: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CTXLEN_MASK: _bindgen_ty_11 = 4503595332403200; -pub type _bindgen_ty_11 = ::core::ffi::c_ulong; -pub const BPF_F_CURRENT_NETNS: _bindgen_ty_12 = -1; -pub type _bindgen_ty_12 = ::core::ffi::c_int; -pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_14 = 1; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_14 = 2; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_14 = 4; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_14 = 8; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_14 = 16; -pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_14 = 32; -pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_14 = 64; -pub type _bindgen_ty_14 = ::core::ffi::c_uint; -pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_16 = 1; -pub type _bindgen_ty_16 = ::core::ffi::c_uint; -pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_18 = 1; -pub type _bindgen_ty_18 = ::core::ffi::c_uint; -pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_21 = 2147483648; -pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_21 = 1073741824; -pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_21 = 8; -pub type _bindgen_ty_21 = ::core::ffi::c_uint; -pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_23 = 1; -pub type _bindgen_ty_23 = ::core::ffi::c_uint; -pub const BPF_F_BROADCAST: _bindgen_ty_24 = 8; -pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_24 = 16; +pub const BPF_F_TUNINFO_FLAGS: _bindgen_ty_11 = 16; +pub type _bindgen_ty_11 = ::core::ffi::c_uint; +pub const BPF_F_INDEX_MASK: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CURRENT_CPU: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CTXLEN_MASK: _bindgen_ty_12 = 4503595332403200; +pub type _bindgen_ty_12 = ::core::ffi::c_ulong; +pub const BPF_F_CURRENT_NETNS: _bindgen_ty_13 = -1; +pub type _bindgen_ty_13 = ::core::ffi::c_int; +pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_15 = 1; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_15 = 2; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_15 = 4; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_15 = 8; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_15 = 16; +pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_15 = 32; +pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_15 = 64; +pub type _bindgen_ty_15 = ::core::ffi::c_uint; +pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_17 = 1; +pub type _bindgen_ty_17 = ::core::ffi::c_uint; +pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_19 = 1; +pub type _bindgen_ty_19 = ::core::ffi::c_uint; +pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_22 = 2147483648; +pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_22 = 1073741824; +pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_22 = 8; +pub type _bindgen_ty_22 = ::core::ffi::c_uint; +pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_24 = 1; pub type _bindgen_ty_24 = ::core::ffi::c_uint; +pub const BPF_F_BROADCAST: _bindgen_ty_25 = 8; +pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_25 = 16; +pub type _bindgen_ty_25 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_prog_info { @@ -905,6 +914,7 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4 { pub target_name: __u64, pub target_name_len: __u32, pub __bindgen_anon_1: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1, + pub __bindgen_anon_2: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2, } #[repr(C)] #[derive(Copy, Clone)] @@ -917,6 +927,24 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1 pub map_id: __u32, } #[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2 { + pub cgroup: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1, + pub task: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1 { + pub cgroup_id: __u64, + pub order: __u32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2 { + pub tid: __u32, + pub pid: __u32, +} +#[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_5 { pub netns_ino: __u32, @@ -966,29 +994,29 @@ pub union btf_type__bindgen_ty_1 { pub size: __u32, pub type_: __u32, } -pub const BTF_KIND_UNKN: _bindgen_ty_38 = 0; -pub const BTF_KIND_INT: _bindgen_ty_38 = 1; -pub const BTF_KIND_PTR: _bindgen_ty_38 = 2; -pub const BTF_KIND_ARRAY: _bindgen_ty_38 = 3; -pub const BTF_KIND_STRUCT: _bindgen_ty_38 = 4; -pub const BTF_KIND_UNION: _bindgen_ty_38 = 5; -pub const BTF_KIND_ENUM: _bindgen_ty_38 = 6; -pub const BTF_KIND_FWD: _bindgen_ty_38 = 7; -pub const BTF_KIND_TYPEDEF: _bindgen_ty_38 = 8; -pub const BTF_KIND_VOLATILE: _bindgen_ty_38 = 9; -pub const BTF_KIND_CONST: _bindgen_ty_38 = 10; -pub const BTF_KIND_RESTRICT: _bindgen_ty_38 = 11; -pub const BTF_KIND_FUNC: _bindgen_ty_38 = 12; -pub const BTF_KIND_FUNC_PROTO: _bindgen_ty_38 = 13; -pub const BTF_KIND_VAR: _bindgen_ty_38 = 14; -pub const BTF_KIND_DATASEC: _bindgen_ty_38 = 15; -pub const BTF_KIND_FLOAT: _bindgen_ty_38 = 16; -pub const BTF_KIND_DECL_TAG: _bindgen_ty_38 = 17; -pub const BTF_KIND_TYPE_TAG: _bindgen_ty_38 = 18; -pub const BTF_KIND_ENUM64: _bindgen_ty_38 = 19; -pub const NR_BTF_KINDS: _bindgen_ty_38 = 20; -pub const BTF_KIND_MAX: _bindgen_ty_38 = 19; -pub type _bindgen_ty_38 = ::core::ffi::c_uint; +pub const BTF_KIND_UNKN: _bindgen_ty_39 = 0; +pub const BTF_KIND_INT: _bindgen_ty_39 = 1; +pub const BTF_KIND_PTR: _bindgen_ty_39 = 2; +pub const BTF_KIND_ARRAY: _bindgen_ty_39 = 3; +pub const BTF_KIND_STRUCT: _bindgen_ty_39 = 4; +pub const BTF_KIND_UNION: _bindgen_ty_39 = 5; +pub const BTF_KIND_ENUM: _bindgen_ty_39 = 6; +pub const BTF_KIND_FWD: _bindgen_ty_39 = 7; +pub const BTF_KIND_TYPEDEF: _bindgen_ty_39 = 8; +pub const BTF_KIND_VOLATILE: _bindgen_ty_39 = 9; +pub const BTF_KIND_CONST: _bindgen_ty_39 = 10; +pub const BTF_KIND_RESTRICT: _bindgen_ty_39 = 11; +pub const BTF_KIND_FUNC: _bindgen_ty_39 = 12; +pub const BTF_KIND_FUNC_PROTO: _bindgen_ty_39 = 13; +pub const BTF_KIND_VAR: _bindgen_ty_39 = 14; +pub const BTF_KIND_DATASEC: _bindgen_ty_39 = 15; +pub const BTF_KIND_FLOAT: _bindgen_ty_39 = 16; +pub const BTF_KIND_DECL_TAG: _bindgen_ty_39 = 17; +pub const BTF_KIND_TYPE_TAG: _bindgen_ty_39 = 18; +pub const BTF_KIND_ENUM64: _bindgen_ty_39 = 19; +pub const NR_BTF_KINDS: _bindgen_ty_39 = 20; +pub const BTF_KIND_MAX: _bindgen_ty_39 = 19; +pub type _bindgen_ty_39 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct btf_enum { @@ -1015,10 +1043,10 @@ pub struct btf_param { pub name_off: __u32, pub type_: __u32, } -pub const BTF_VAR_STATIC: _bindgen_ty_39 = 0; -pub const BTF_VAR_GLOBAL_ALLOCATED: _bindgen_ty_39 = 1; -pub const BTF_VAR_GLOBAL_EXTERN: _bindgen_ty_39 = 2; -pub type _bindgen_ty_39 = ::core::ffi::c_uint; +pub const BTF_VAR_STATIC: _bindgen_ty_40 = 0; +pub const BTF_VAR_GLOBAL_ALLOCATED: _bindgen_ty_40 = 1; +pub const BTF_VAR_GLOBAL_EXTERN: _bindgen_ty_40 = 2; +pub type _bindgen_ty_40 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum btf_func_linkage { @@ -1113,7 +1141,7 @@ pub enum perf_sw_ids { PERF_COUNT_SW_CGROUP_SWITCHES = 11, PERF_COUNT_SW_MAX = 12, } -#[repr(u64)] +#[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum perf_event_sample_format { PERF_SAMPLE_IP = 1, @@ -1142,7 +1170,6 @@ pub enum perf_event_sample_format { PERF_SAMPLE_CODE_PAGE_SIZE = 8388608, PERF_SAMPLE_WEIGHT_STRUCT = 16777216, PERF_SAMPLE_MAX = 33554432, - __PERF_SAMPLE_CALLCHAIN_EARLY = 9223372036854775808, } #[repr(C)] #[derive(Copy, Clone)] @@ -2014,17 +2041,17 @@ pub enum perf_event_type { PERF_RECORD_AUX_OUTPUT_HW_ID = 21, PERF_RECORD_MAX = 22, } -pub const IFLA_XDP_UNSPEC: _bindgen_ty_85 = 0; -pub const IFLA_XDP_FD: _bindgen_ty_85 = 1; -pub const IFLA_XDP_ATTACHED: _bindgen_ty_85 = 2; -pub const IFLA_XDP_FLAGS: _bindgen_ty_85 = 3; -pub const IFLA_XDP_PROG_ID: _bindgen_ty_85 = 4; -pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_85 = 5; -pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_85 = 6; -pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_85 = 7; -pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_85 = 8; -pub const __IFLA_XDP_MAX: _bindgen_ty_85 = 9; -pub type _bindgen_ty_85 = ::core::ffi::c_uint; +pub const IFLA_XDP_UNSPEC: _bindgen_ty_89 = 0; +pub const IFLA_XDP_FD: _bindgen_ty_89 = 1; +pub const IFLA_XDP_ATTACHED: _bindgen_ty_89 = 2; +pub const IFLA_XDP_FLAGS: _bindgen_ty_89 = 3; +pub const IFLA_XDP_PROG_ID: _bindgen_ty_89 = 4; +pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_89 = 5; +pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_89 = 6; +pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_89 = 7; +pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_89 = 8; +pub const __IFLA_XDP_MAX: _bindgen_ty_89 = 9; +pub type _bindgen_ty_89 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { @@ -2046,38 +2073,37 @@ pub struct tcmsg { pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_100 = 0; -pub const TCA_KIND: _bindgen_ty_100 = 1; -pub const TCA_OPTIONS: _bindgen_ty_100 = 2; -pub const TCA_STATS: _bindgen_ty_100 = 3; -pub const TCA_XSTATS: _bindgen_ty_100 = 4; -pub const TCA_RATE: _bindgen_ty_100 = 5; -pub const TCA_FCNT: _bindgen_ty_100 = 6; -pub const TCA_STATS2: _bindgen_ty_100 = 7; -pub const TCA_STAB: _bindgen_ty_100 = 8; -pub const TCA_PAD: _bindgen_ty_100 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_100 = 10; -pub const TCA_CHAIN: _bindgen_ty_100 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_100 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_100 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_100 = 14; -pub const TCA_DUMP_FLAGS: _bindgen_ty_100 = 15; -pub const __TCA_MAX: _bindgen_ty_100 = 16; -pub type _bindgen_ty_100 = ::core::ffi::c_uint; -pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; -pub const TCA_BPF_FD: _bindgen_ty_156 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; -pub const TCA_BPF_ID: _bindgen_ty_156 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; -pub type _bindgen_ty_156 = ::core::ffi::c_uint; +pub const TCA_UNSPEC: _bindgen_ty_102 = 0; +pub const TCA_KIND: _bindgen_ty_102 = 1; +pub const TCA_OPTIONS: _bindgen_ty_102 = 2; +pub const TCA_STATS: _bindgen_ty_102 = 3; +pub const TCA_XSTATS: _bindgen_ty_102 = 4; +pub const TCA_RATE: _bindgen_ty_102 = 5; +pub const TCA_FCNT: _bindgen_ty_102 = 6; +pub const TCA_STATS2: _bindgen_ty_102 = 7; +pub const TCA_STAB: _bindgen_ty_102 = 8; +pub const TCA_PAD: _bindgen_ty_102 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_102 = 10; +pub const TCA_CHAIN: _bindgen_ty_102 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_102 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_102 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_102 = 14; +pub const __TCA_MAX: _bindgen_ty_102 = 15; +pub type _bindgen_ty_102 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_158 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_158 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_158 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_158 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_158 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_158 = 5; +pub const TCA_BPF_FD: _bindgen_ty_158 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_158 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_158 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_158 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_158 = 10; +pub const TCA_BPF_ID: _bindgen_ty_158 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_158 = 12; +pub type _bindgen_ty_158 = ::core::ffi::c_uint; pub const AYA_PERF_EVENT_IOC_ENABLE: ::core::ffi::c_int = 9216; pub const AYA_PERF_EVENT_IOC_DISABLE: ::core::ffi::c_int = 9217; pub const AYA_PERF_EVENT_IOC_SET_BPF: ::core::ffi::c_int = 1074013192; diff --git a/aya-obj/src/generated/linux_bindings_armv7.rs b/aya-obj/src/generated/linux_bindings_armv7.rs index 21355694..498d2083 100644 --- a/aya-obj/src/generated/linux_bindings_armv7.rs +++ b/aya-obj/src/generated/linux_bindings_armv7.rs @@ -275,6 +275,10 @@ pub enum bpf_cmd { BPF_LINK_DETACH = 34, BPF_PROG_BIND_MAP = 35, } +impl bpf_map_type { + pub const BPF_MAP_TYPE_CGROUP_STORAGE: bpf_map_type = + bpf_map_type::BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED; +} #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum bpf_map_type { @@ -297,7 +301,7 @@ pub enum bpf_map_type { BPF_MAP_TYPE_CPUMAP = 16, BPF_MAP_TYPE_XSKMAP = 17, BPF_MAP_TYPE_SOCKHASH = 18, - BPF_MAP_TYPE_CGROUP_STORAGE = 19, + BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED = 19, BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 20, BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 21, BPF_MAP_TYPE_QUEUE = 22, @@ -309,6 +313,8 @@ pub enum bpf_map_type { BPF_MAP_TYPE_INODE_STORAGE = 28, BPF_MAP_TYPE_TASK_STORAGE = 29, BPF_MAP_TYPE_BLOOM_FILTER = 30, + BPF_MAP_TYPE_USER_RINGBUF = 31, + BPF_MAP_TYPE_CGRP_STORAGE = 32, } #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -731,34 +737,37 @@ pub type _bindgen_ty_9 = ::core::ffi::c_uint; pub const BPF_F_ZERO_CSUM_TX: _bindgen_ty_10 = 2; pub const BPF_F_DONT_FRAGMENT: _bindgen_ty_10 = 4; pub const BPF_F_SEQ_NUMBER: _bindgen_ty_10 = 8; +pub const BPF_F_NO_TUNNEL_KEY: _bindgen_ty_10 = 16; pub type _bindgen_ty_10 = ::core::ffi::c_uint; -pub const BPF_F_INDEX_MASK: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CURRENT_CPU: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CTXLEN_MASK: _bindgen_ty_11 = 4503595332403200; -pub type _bindgen_ty_11 = ::core::ffi::c_ulonglong; -pub const BPF_F_CURRENT_NETNS: _bindgen_ty_12 = -1; -pub type _bindgen_ty_12 = ::core::ffi::c_int; -pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_14 = 1; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_14 = 2; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_14 = 4; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_14 = 8; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_14 = 16; -pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_14 = 32; -pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_14 = 64; -pub type _bindgen_ty_14 = ::core::ffi::c_uint; -pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_16 = 1; -pub type _bindgen_ty_16 = ::core::ffi::c_uint; -pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_18 = 1; -pub type _bindgen_ty_18 = ::core::ffi::c_uint; -pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_21 = 2147483648; -pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_21 = 1073741824; -pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_21 = 8; -pub type _bindgen_ty_21 = ::core::ffi::c_uint; -pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_23 = 1; -pub type _bindgen_ty_23 = ::core::ffi::c_uint; -pub const BPF_F_BROADCAST: _bindgen_ty_24 = 8; -pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_24 = 16; +pub const BPF_F_TUNINFO_FLAGS: _bindgen_ty_11 = 16; +pub type _bindgen_ty_11 = ::core::ffi::c_uint; +pub const BPF_F_INDEX_MASK: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CURRENT_CPU: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CTXLEN_MASK: _bindgen_ty_12 = 4503595332403200; +pub type _bindgen_ty_12 = ::core::ffi::c_ulonglong; +pub const BPF_F_CURRENT_NETNS: _bindgen_ty_13 = -1; +pub type _bindgen_ty_13 = ::core::ffi::c_int; +pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_15 = 1; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_15 = 2; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_15 = 4; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_15 = 8; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_15 = 16; +pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_15 = 32; +pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_15 = 64; +pub type _bindgen_ty_15 = ::core::ffi::c_uint; +pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_17 = 1; +pub type _bindgen_ty_17 = ::core::ffi::c_uint; +pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_19 = 1; +pub type _bindgen_ty_19 = ::core::ffi::c_uint; +pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_22 = 2147483648; +pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_22 = 1073741824; +pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_22 = 8; +pub type _bindgen_ty_22 = ::core::ffi::c_uint; +pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_24 = 1; pub type _bindgen_ty_24 = ::core::ffi::c_uint; +pub const BPF_F_BROADCAST: _bindgen_ty_25 = 8; +pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_25 = 16; +pub type _bindgen_ty_25 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_prog_info { @@ -905,6 +914,7 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4 { pub target_name: __u64, pub target_name_len: __u32, pub __bindgen_anon_1: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1, + pub __bindgen_anon_2: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2, } #[repr(C)] #[derive(Copy, Clone)] @@ -917,6 +927,24 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1 pub map_id: __u32, } #[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2 { + pub cgroup: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1, + pub task: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1 { + pub cgroup_id: __u64, + pub order: __u32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2 { + pub tid: __u32, + pub pid: __u32, +} +#[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_5 { pub netns_ino: __u32, @@ -966,29 +994,29 @@ pub union btf_type__bindgen_ty_1 { pub size: __u32, pub type_: __u32, } -pub const BTF_KIND_UNKN: _bindgen_ty_38 = 0; -pub const BTF_KIND_INT: _bindgen_ty_38 = 1; -pub const BTF_KIND_PTR: _bindgen_ty_38 = 2; -pub const BTF_KIND_ARRAY: _bindgen_ty_38 = 3; -pub const BTF_KIND_STRUCT: _bindgen_ty_38 = 4; -pub const BTF_KIND_UNION: _bindgen_ty_38 = 5; -pub const BTF_KIND_ENUM: _bindgen_ty_38 = 6; -pub const BTF_KIND_FWD: _bindgen_ty_38 = 7; -pub const BTF_KIND_TYPEDEF: _bindgen_ty_38 = 8; -pub const BTF_KIND_VOLATILE: _bindgen_ty_38 = 9; -pub const BTF_KIND_CONST: _bindgen_ty_38 = 10; -pub const BTF_KIND_RESTRICT: _bindgen_ty_38 = 11; -pub const BTF_KIND_FUNC: _bindgen_ty_38 = 12; -pub const BTF_KIND_FUNC_PROTO: _bindgen_ty_38 = 13; -pub const BTF_KIND_VAR: _bindgen_ty_38 = 14; -pub const BTF_KIND_DATASEC: _bindgen_ty_38 = 15; -pub const BTF_KIND_FLOAT: _bindgen_ty_38 = 16; -pub const BTF_KIND_DECL_TAG: _bindgen_ty_38 = 17; -pub const BTF_KIND_TYPE_TAG: _bindgen_ty_38 = 18; -pub const BTF_KIND_ENUM64: _bindgen_ty_38 = 19; -pub const NR_BTF_KINDS: _bindgen_ty_38 = 20; -pub const BTF_KIND_MAX: _bindgen_ty_38 = 19; -pub type _bindgen_ty_38 = ::core::ffi::c_uint; +pub const BTF_KIND_UNKN: _bindgen_ty_39 = 0; +pub const BTF_KIND_INT: _bindgen_ty_39 = 1; +pub const BTF_KIND_PTR: _bindgen_ty_39 = 2; +pub const BTF_KIND_ARRAY: _bindgen_ty_39 = 3; +pub const BTF_KIND_STRUCT: _bindgen_ty_39 = 4; +pub const BTF_KIND_UNION: _bindgen_ty_39 = 5; +pub const BTF_KIND_ENUM: _bindgen_ty_39 = 6; +pub const BTF_KIND_FWD: _bindgen_ty_39 = 7; +pub const BTF_KIND_TYPEDEF: _bindgen_ty_39 = 8; +pub const BTF_KIND_VOLATILE: _bindgen_ty_39 = 9; +pub const BTF_KIND_CONST: _bindgen_ty_39 = 10; +pub const BTF_KIND_RESTRICT: _bindgen_ty_39 = 11; +pub const BTF_KIND_FUNC: _bindgen_ty_39 = 12; +pub const BTF_KIND_FUNC_PROTO: _bindgen_ty_39 = 13; +pub const BTF_KIND_VAR: _bindgen_ty_39 = 14; +pub const BTF_KIND_DATASEC: _bindgen_ty_39 = 15; +pub const BTF_KIND_FLOAT: _bindgen_ty_39 = 16; +pub const BTF_KIND_DECL_TAG: _bindgen_ty_39 = 17; +pub const BTF_KIND_TYPE_TAG: _bindgen_ty_39 = 18; +pub const BTF_KIND_ENUM64: _bindgen_ty_39 = 19; +pub const NR_BTF_KINDS: _bindgen_ty_39 = 20; +pub const BTF_KIND_MAX: _bindgen_ty_39 = 19; +pub type _bindgen_ty_39 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct btf_enum { @@ -1015,10 +1043,10 @@ pub struct btf_param { pub name_off: __u32, pub type_: __u32, } -pub const BTF_VAR_STATIC: _bindgen_ty_39 = 0; -pub const BTF_VAR_GLOBAL_ALLOCATED: _bindgen_ty_39 = 1; -pub const BTF_VAR_GLOBAL_EXTERN: _bindgen_ty_39 = 2; -pub type _bindgen_ty_39 = ::core::ffi::c_uint; +pub const BTF_VAR_STATIC: _bindgen_ty_40 = 0; +pub const BTF_VAR_GLOBAL_ALLOCATED: _bindgen_ty_40 = 1; +pub const BTF_VAR_GLOBAL_EXTERN: _bindgen_ty_40 = 2; +pub type _bindgen_ty_40 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum btf_func_linkage { @@ -1113,7 +1141,7 @@ pub enum perf_sw_ids { PERF_COUNT_SW_CGROUP_SWITCHES = 11, PERF_COUNT_SW_MAX = 12, } -#[repr(u64)] +#[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum perf_event_sample_format { PERF_SAMPLE_IP = 1, @@ -1142,7 +1170,6 @@ pub enum perf_event_sample_format { PERF_SAMPLE_CODE_PAGE_SIZE = 8388608, PERF_SAMPLE_WEIGHT_STRUCT = 16777216, PERF_SAMPLE_MAX = 33554432, - __PERF_SAMPLE_CALLCHAIN_EARLY = 9223372036854775808, } #[repr(C)] #[derive(Copy, Clone)] @@ -2014,17 +2041,17 @@ pub enum perf_event_type { PERF_RECORD_AUX_OUTPUT_HW_ID = 21, PERF_RECORD_MAX = 22, } -pub const IFLA_XDP_UNSPEC: _bindgen_ty_85 = 0; -pub const IFLA_XDP_FD: _bindgen_ty_85 = 1; -pub const IFLA_XDP_ATTACHED: _bindgen_ty_85 = 2; -pub const IFLA_XDP_FLAGS: _bindgen_ty_85 = 3; -pub const IFLA_XDP_PROG_ID: _bindgen_ty_85 = 4; -pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_85 = 5; -pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_85 = 6; -pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_85 = 7; -pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_85 = 8; -pub const __IFLA_XDP_MAX: _bindgen_ty_85 = 9; -pub type _bindgen_ty_85 = ::core::ffi::c_uint; +pub const IFLA_XDP_UNSPEC: _bindgen_ty_89 = 0; +pub const IFLA_XDP_FD: _bindgen_ty_89 = 1; +pub const IFLA_XDP_ATTACHED: _bindgen_ty_89 = 2; +pub const IFLA_XDP_FLAGS: _bindgen_ty_89 = 3; +pub const IFLA_XDP_PROG_ID: _bindgen_ty_89 = 4; +pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_89 = 5; +pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_89 = 6; +pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_89 = 7; +pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_89 = 8; +pub const __IFLA_XDP_MAX: _bindgen_ty_89 = 9; +pub type _bindgen_ty_89 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { @@ -2046,38 +2073,37 @@ pub struct tcmsg { pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_100 = 0; -pub const TCA_KIND: _bindgen_ty_100 = 1; -pub const TCA_OPTIONS: _bindgen_ty_100 = 2; -pub const TCA_STATS: _bindgen_ty_100 = 3; -pub const TCA_XSTATS: _bindgen_ty_100 = 4; -pub const TCA_RATE: _bindgen_ty_100 = 5; -pub const TCA_FCNT: _bindgen_ty_100 = 6; -pub const TCA_STATS2: _bindgen_ty_100 = 7; -pub const TCA_STAB: _bindgen_ty_100 = 8; -pub const TCA_PAD: _bindgen_ty_100 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_100 = 10; -pub const TCA_CHAIN: _bindgen_ty_100 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_100 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_100 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_100 = 14; -pub const TCA_DUMP_FLAGS: _bindgen_ty_100 = 15; -pub const __TCA_MAX: _bindgen_ty_100 = 16; -pub type _bindgen_ty_100 = ::core::ffi::c_uint; -pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; -pub const TCA_BPF_FD: _bindgen_ty_156 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; -pub const TCA_BPF_ID: _bindgen_ty_156 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; -pub type _bindgen_ty_156 = ::core::ffi::c_uint; +pub const TCA_UNSPEC: _bindgen_ty_102 = 0; +pub const TCA_KIND: _bindgen_ty_102 = 1; +pub const TCA_OPTIONS: _bindgen_ty_102 = 2; +pub const TCA_STATS: _bindgen_ty_102 = 3; +pub const TCA_XSTATS: _bindgen_ty_102 = 4; +pub const TCA_RATE: _bindgen_ty_102 = 5; +pub const TCA_FCNT: _bindgen_ty_102 = 6; +pub const TCA_STATS2: _bindgen_ty_102 = 7; +pub const TCA_STAB: _bindgen_ty_102 = 8; +pub const TCA_PAD: _bindgen_ty_102 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_102 = 10; +pub const TCA_CHAIN: _bindgen_ty_102 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_102 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_102 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_102 = 14; +pub const __TCA_MAX: _bindgen_ty_102 = 15; +pub type _bindgen_ty_102 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_158 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_158 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_158 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_158 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_158 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_158 = 5; +pub const TCA_BPF_FD: _bindgen_ty_158 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_158 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_158 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_158 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_158 = 10; +pub const TCA_BPF_ID: _bindgen_ty_158 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_158 = 12; +pub type _bindgen_ty_158 = ::core::ffi::c_uint; pub const AYA_PERF_EVENT_IOC_ENABLE: ::core::ffi::c_int = 9216; pub const AYA_PERF_EVENT_IOC_DISABLE: ::core::ffi::c_int = 9217; pub const AYA_PERF_EVENT_IOC_SET_BPF: ::core::ffi::c_int = 1074013192; diff --git a/aya-obj/src/generated/linux_bindings_riscv64.rs b/aya-obj/src/generated/linux_bindings_riscv64.rs index fab6978c..244910f6 100644 --- a/aya-obj/src/generated/linux_bindings_riscv64.rs +++ b/aya-obj/src/generated/linux_bindings_riscv64.rs @@ -275,6 +275,10 @@ pub enum bpf_cmd { BPF_LINK_DETACH = 34, BPF_PROG_BIND_MAP = 35, } +impl bpf_map_type { + pub const BPF_MAP_TYPE_CGROUP_STORAGE: bpf_map_type = + bpf_map_type::BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED; +} #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum bpf_map_type { @@ -297,7 +301,7 @@ pub enum bpf_map_type { BPF_MAP_TYPE_CPUMAP = 16, BPF_MAP_TYPE_XSKMAP = 17, BPF_MAP_TYPE_SOCKHASH = 18, - BPF_MAP_TYPE_CGROUP_STORAGE = 19, + BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED = 19, BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 20, BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 21, BPF_MAP_TYPE_QUEUE = 22, @@ -309,6 +313,8 @@ pub enum bpf_map_type { BPF_MAP_TYPE_INODE_STORAGE = 28, BPF_MAP_TYPE_TASK_STORAGE = 29, BPF_MAP_TYPE_BLOOM_FILTER = 30, + BPF_MAP_TYPE_USER_RINGBUF = 31, + BPF_MAP_TYPE_CGRP_STORAGE = 32, } #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -731,34 +737,37 @@ pub type _bindgen_ty_9 = ::core::ffi::c_uint; pub const BPF_F_ZERO_CSUM_TX: _bindgen_ty_10 = 2; pub const BPF_F_DONT_FRAGMENT: _bindgen_ty_10 = 4; pub const BPF_F_SEQ_NUMBER: _bindgen_ty_10 = 8; +pub const BPF_F_NO_TUNNEL_KEY: _bindgen_ty_10 = 16; pub type _bindgen_ty_10 = ::core::ffi::c_uint; -pub const BPF_F_INDEX_MASK: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CURRENT_CPU: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CTXLEN_MASK: _bindgen_ty_11 = 4503595332403200; -pub type _bindgen_ty_11 = ::core::ffi::c_ulong; -pub const BPF_F_CURRENT_NETNS: _bindgen_ty_12 = -1; -pub type _bindgen_ty_12 = ::core::ffi::c_int; -pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_14 = 1; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_14 = 2; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_14 = 4; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_14 = 8; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_14 = 16; -pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_14 = 32; -pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_14 = 64; -pub type _bindgen_ty_14 = ::core::ffi::c_uint; -pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_16 = 1; -pub type _bindgen_ty_16 = ::core::ffi::c_uint; -pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_18 = 1; -pub type _bindgen_ty_18 = ::core::ffi::c_uint; -pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_21 = 2147483648; -pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_21 = 1073741824; -pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_21 = 8; -pub type _bindgen_ty_21 = ::core::ffi::c_uint; -pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_23 = 1; -pub type _bindgen_ty_23 = ::core::ffi::c_uint; -pub const BPF_F_BROADCAST: _bindgen_ty_24 = 8; -pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_24 = 16; +pub const BPF_F_TUNINFO_FLAGS: _bindgen_ty_11 = 16; +pub type _bindgen_ty_11 = ::core::ffi::c_uint; +pub const BPF_F_INDEX_MASK: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CURRENT_CPU: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CTXLEN_MASK: _bindgen_ty_12 = 4503595332403200; +pub type _bindgen_ty_12 = ::core::ffi::c_ulong; +pub const BPF_F_CURRENT_NETNS: _bindgen_ty_13 = -1; +pub type _bindgen_ty_13 = ::core::ffi::c_int; +pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_15 = 1; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_15 = 2; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_15 = 4; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_15 = 8; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_15 = 16; +pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_15 = 32; +pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_15 = 64; +pub type _bindgen_ty_15 = ::core::ffi::c_uint; +pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_17 = 1; +pub type _bindgen_ty_17 = ::core::ffi::c_uint; +pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_19 = 1; +pub type _bindgen_ty_19 = ::core::ffi::c_uint; +pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_22 = 2147483648; +pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_22 = 1073741824; +pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_22 = 8; +pub type _bindgen_ty_22 = ::core::ffi::c_uint; +pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_24 = 1; pub type _bindgen_ty_24 = ::core::ffi::c_uint; +pub const BPF_F_BROADCAST: _bindgen_ty_25 = 8; +pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_25 = 16; +pub type _bindgen_ty_25 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_prog_info { @@ -905,6 +914,7 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4 { pub target_name: __u64, pub target_name_len: __u32, pub __bindgen_anon_1: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1, + pub __bindgen_anon_2: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2, } #[repr(C)] #[derive(Copy, Clone)] @@ -917,6 +927,24 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1 pub map_id: __u32, } #[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2 { + pub cgroup: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1, + pub task: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1 { + pub cgroup_id: __u64, + pub order: __u32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2 { + pub tid: __u32, + pub pid: __u32, +} +#[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_5 { pub netns_ino: __u32, @@ -966,29 +994,29 @@ pub union btf_type__bindgen_ty_1 { pub size: __u32, pub type_: __u32, } -pub const BTF_KIND_UNKN: _bindgen_ty_38 = 0; -pub const BTF_KIND_INT: _bindgen_ty_38 = 1; -pub const BTF_KIND_PTR: _bindgen_ty_38 = 2; -pub const BTF_KIND_ARRAY: _bindgen_ty_38 = 3; -pub const BTF_KIND_STRUCT: _bindgen_ty_38 = 4; -pub const BTF_KIND_UNION: _bindgen_ty_38 = 5; -pub const BTF_KIND_ENUM: _bindgen_ty_38 = 6; -pub const BTF_KIND_FWD: _bindgen_ty_38 = 7; -pub const BTF_KIND_TYPEDEF: _bindgen_ty_38 = 8; -pub const BTF_KIND_VOLATILE: _bindgen_ty_38 = 9; -pub const BTF_KIND_CONST: _bindgen_ty_38 = 10; -pub const BTF_KIND_RESTRICT: _bindgen_ty_38 = 11; -pub const BTF_KIND_FUNC: _bindgen_ty_38 = 12; -pub const BTF_KIND_FUNC_PROTO: _bindgen_ty_38 = 13; -pub const BTF_KIND_VAR: _bindgen_ty_38 = 14; -pub const BTF_KIND_DATASEC: _bindgen_ty_38 = 15; -pub const BTF_KIND_FLOAT: _bindgen_ty_38 = 16; -pub const BTF_KIND_DECL_TAG: _bindgen_ty_38 = 17; -pub const BTF_KIND_TYPE_TAG: _bindgen_ty_38 = 18; -pub const BTF_KIND_ENUM64: _bindgen_ty_38 = 19; -pub const NR_BTF_KINDS: _bindgen_ty_38 = 20; -pub const BTF_KIND_MAX: _bindgen_ty_38 = 19; -pub type _bindgen_ty_38 = ::core::ffi::c_uint; +pub const BTF_KIND_UNKN: _bindgen_ty_39 = 0; +pub const BTF_KIND_INT: _bindgen_ty_39 = 1; +pub const BTF_KIND_PTR: _bindgen_ty_39 = 2; +pub const BTF_KIND_ARRAY: _bindgen_ty_39 = 3; +pub const BTF_KIND_STRUCT: _bindgen_ty_39 = 4; +pub const BTF_KIND_UNION: _bindgen_ty_39 = 5; +pub const BTF_KIND_ENUM: _bindgen_ty_39 = 6; +pub const BTF_KIND_FWD: _bindgen_ty_39 = 7; +pub const BTF_KIND_TYPEDEF: _bindgen_ty_39 = 8; +pub const BTF_KIND_VOLATILE: _bindgen_ty_39 = 9; +pub const BTF_KIND_CONST: _bindgen_ty_39 = 10; +pub const BTF_KIND_RESTRICT: _bindgen_ty_39 = 11; +pub const BTF_KIND_FUNC: _bindgen_ty_39 = 12; +pub const BTF_KIND_FUNC_PROTO: _bindgen_ty_39 = 13; +pub const BTF_KIND_VAR: _bindgen_ty_39 = 14; +pub const BTF_KIND_DATASEC: _bindgen_ty_39 = 15; +pub const BTF_KIND_FLOAT: _bindgen_ty_39 = 16; +pub const BTF_KIND_DECL_TAG: _bindgen_ty_39 = 17; +pub const BTF_KIND_TYPE_TAG: _bindgen_ty_39 = 18; +pub const BTF_KIND_ENUM64: _bindgen_ty_39 = 19; +pub const NR_BTF_KINDS: _bindgen_ty_39 = 20; +pub const BTF_KIND_MAX: _bindgen_ty_39 = 19; +pub type _bindgen_ty_39 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct btf_enum { @@ -1015,10 +1043,10 @@ pub struct btf_param { pub name_off: __u32, pub type_: __u32, } -pub const BTF_VAR_STATIC: _bindgen_ty_39 = 0; -pub const BTF_VAR_GLOBAL_ALLOCATED: _bindgen_ty_39 = 1; -pub const BTF_VAR_GLOBAL_EXTERN: _bindgen_ty_39 = 2; -pub type _bindgen_ty_39 = ::core::ffi::c_uint; +pub const BTF_VAR_STATIC: _bindgen_ty_40 = 0; +pub const BTF_VAR_GLOBAL_ALLOCATED: _bindgen_ty_40 = 1; +pub const BTF_VAR_GLOBAL_EXTERN: _bindgen_ty_40 = 2; +pub type _bindgen_ty_40 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum btf_func_linkage { @@ -1113,7 +1141,7 @@ pub enum perf_sw_ids { PERF_COUNT_SW_CGROUP_SWITCHES = 11, PERF_COUNT_SW_MAX = 12, } -#[repr(u64)] +#[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum perf_event_sample_format { PERF_SAMPLE_IP = 1, @@ -1142,7 +1170,6 @@ pub enum perf_event_sample_format { PERF_SAMPLE_CODE_PAGE_SIZE = 8388608, PERF_SAMPLE_WEIGHT_STRUCT = 16777216, PERF_SAMPLE_MAX = 33554432, - __PERF_SAMPLE_CALLCHAIN_EARLY = 9223372036854775808, } #[repr(C)] #[derive(Copy, Clone)] @@ -2014,17 +2041,17 @@ pub enum perf_event_type { PERF_RECORD_AUX_OUTPUT_HW_ID = 21, PERF_RECORD_MAX = 22, } -pub const IFLA_XDP_UNSPEC: _bindgen_ty_85 = 0; -pub const IFLA_XDP_FD: _bindgen_ty_85 = 1; -pub const IFLA_XDP_ATTACHED: _bindgen_ty_85 = 2; -pub const IFLA_XDP_FLAGS: _bindgen_ty_85 = 3; -pub const IFLA_XDP_PROG_ID: _bindgen_ty_85 = 4; -pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_85 = 5; -pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_85 = 6; -pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_85 = 7; -pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_85 = 8; -pub const __IFLA_XDP_MAX: _bindgen_ty_85 = 9; -pub type _bindgen_ty_85 = ::core::ffi::c_uint; +pub const IFLA_XDP_UNSPEC: _bindgen_ty_89 = 0; +pub const IFLA_XDP_FD: _bindgen_ty_89 = 1; +pub const IFLA_XDP_ATTACHED: _bindgen_ty_89 = 2; +pub const IFLA_XDP_FLAGS: _bindgen_ty_89 = 3; +pub const IFLA_XDP_PROG_ID: _bindgen_ty_89 = 4; +pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_89 = 5; +pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_89 = 6; +pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_89 = 7; +pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_89 = 8; +pub const __IFLA_XDP_MAX: _bindgen_ty_89 = 9; +pub type _bindgen_ty_89 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { @@ -2046,38 +2073,37 @@ pub struct tcmsg { pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_100 = 0; -pub const TCA_KIND: _bindgen_ty_100 = 1; -pub const TCA_OPTIONS: _bindgen_ty_100 = 2; -pub const TCA_STATS: _bindgen_ty_100 = 3; -pub const TCA_XSTATS: _bindgen_ty_100 = 4; -pub const TCA_RATE: _bindgen_ty_100 = 5; -pub const TCA_FCNT: _bindgen_ty_100 = 6; -pub const TCA_STATS2: _bindgen_ty_100 = 7; -pub const TCA_STAB: _bindgen_ty_100 = 8; -pub const TCA_PAD: _bindgen_ty_100 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_100 = 10; -pub const TCA_CHAIN: _bindgen_ty_100 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_100 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_100 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_100 = 14; -pub const TCA_DUMP_FLAGS: _bindgen_ty_100 = 15; -pub const __TCA_MAX: _bindgen_ty_100 = 16; -pub type _bindgen_ty_100 = ::core::ffi::c_uint; -pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; -pub const TCA_BPF_FD: _bindgen_ty_156 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; -pub const TCA_BPF_ID: _bindgen_ty_156 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; -pub type _bindgen_ty_156 = ::core::ffi::c_uint; +pub const TCA_UNSPEC: _bindgen_ty_102 = 0; +pub const TCA_KIND: _bindgen_ty_102 = 1; +pub const TCA_OPTIONS: _bindgen_ty_102 = 2; +pub const TCA_STATS: _bindgen_ty_102 = 3; +pub const TCA_XSTATS: _bindgen_ty_102 = 4; +pub const TCA_RATE: _bindgen_ty_102 = 5; +pub const TCA_FCNT: _bindgen_ty_102 = 6; +pub const TCA_STATS2: _bindgen_ty_102 = 7; +pub const TCA_STAB: _bindgen_ty_102 = 8; +pub const TCA_PAD: _bindgen_ty_102 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_102 = 10; +pub const TCA_CHAIN: _bindgen_ty_102 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_102 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_102 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_102 = 14; +pub const __TCA_MAX: _bindgen_ty_102 = 15; +pub type _bindgen_ty_102 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_158 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_158 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_158 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_158 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_158 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_158 = 5; +pub const TCA_BPF_FD: _bindgen_ty_158 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_158 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_158 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_158 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_158 = 10; +pub const TCA_BPF_ID: _bindgen_ty_158 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_158 = 12; +pub type _bindgen_ty_158 = ::core::ffi::c_uint; pub const AYA_PERF_EVENT_IOC_ENABLE: ::core::ffi::c_int = 9216; pub const AYA_PERF_EVENT_IOC_DISABLE: ::core::ffi::c_int = 9217; pub const AYA_PERF_EVENT_IOC_SET_BPF: ::core::ffi::c_int = 1074013192; diff --git a/aya-obj/src/generated/linux_bindings_x86_64.rs b/aya-obj/src/generated/linux_bindings_x86_64.rs index fab6978c..244910f6 100644 --- a/aya-obj/src/generated/linux_bindings_x86_64.rs +++ b/aya-obj/src/generated/linux_bindings_x86_64.rs @@ -275,6 +275,10 @@ pub enum bpf_cmd { BPF_LINK_DETACH = 34, BPF_PROG_BIND_MAP = 35, } +impl bpf_map_type { + pub const BPF_MAP_TYPE_CGROUP_STORAGE: bpf_map_type = + bpf_map_type::BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED; +} #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum bpf_map_type { @@ -297,7 +301,7 @@ pub enum bpf_map_type { BPF_MAP_TYPE_CPUMAP = 16, BPF_MAP_TYPE_XSKMAP = 17, BPF_MAP_TYPE_SOCKHASH = 18, - BPF_MAP_TYPE_CGROUP_STORAGE = 19, + BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED = 19, BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 20, BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 21, BPF_MAP_TYPE_QUEUE = 22, @@ -309,6 +313,8 @@ pub enum bpf_map_type { BPF_MAP_TYPE_INODE_STORAGE = 28, BPF_MAP_TYPE_TASK_STORAGE = 29, BPF_MAP_TYPE_BLOOM_FILTER = 30, + BPF_MAP_TYPE_USER_RINGBUF = 31, + BPF_MAP_TYPE_CGRP_STORAGE = 32, } #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -731,34 +737,37 @@ pub type _bindgen_ty_9 = ::core::ffi::c_uint; pub const BPF_F_ZERO_CSUM_TX: _bindgen_ty_10 = 2; pub const BPF_F_DONT_FRAGMENT: _bindgen_ty_10 = 4; pub const BPF_F_SEQ_NUMBER: _bindgen_ty_10 = 8; +pub const BPF_F_NO_TUNNEL_KEY: _bindgen_ty_10 = 16; pub type _bindgen_ty_10 = ::core::ffi::c_uint; -pub const BPF_F_INDEX_MASK: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CURRENT_CPU: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CTXLEN_MASK: _bindgen_ty_11 = 4503595332403200; -pub type _bindgen_ty_11 = ::core::ffi::c_ulong; -pub const BPF_F_CURRENT_NETNS: _bindgen_ty_12 = -1; -pub type _bindgen_ty_12 = ::core::ffi::c_int; -pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_14 = 1; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_14 = 2; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_14 = 4; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_14 = 8; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_14 = 16; -pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_14 = 32; -pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_14 = 64; -pub type _bindgen_ty_14 = ::core::ffi::c_uint; -pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_16 = 1; -pub type _bindgen_ty_16 = ::core::ffi::c_uint; -pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_18 = 1; -pub type _bindgen_ty_18 = ::core::ffi::c_uint; -pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_21 = 2147483648; -pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_21 = 1073741824; -pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_21 = 8; -pub type _bindgen_ty_21 = ::core::ffi::c_uint; -pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_23 = 1; -pub type _bindgen_ty_23 = ::core::ffi::c_uint; -pub const BPF_F_BROADCAST: _bindgen_ty_24 = 8; -pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_24 = 16; +pub const BPF_F_TUNINFO_FLAGS: _bindgen_ty_11 = 16; +pub type _bindgen_ty_11 = ::core::ffi::c_uint; +pub const BPF_F_INDEX_MASK: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CURRENT_CPU: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CTXLEN_MASK: _bindgen_ty_12 = 4503595332403200; +pub type _bindgen_ty_12 = ::core::ffi::c_ulong; +pub const BPF_F_CURRENT_NETNS: _bindgen_ty_13 = -1; +pub type _bindgen_ty_13 = ::core::ffi::c_int; +pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_15 = 1; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_15 = 2; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_15 = 4; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_15 = 8; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_15 = 16; +pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_15 = 32; +pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_15 = 64; +pub type _bindgen_ty_15 = ::core::ffi::c_uint; +pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_17 = 1; +pub type _bindgen_ty_17 = ::core::ffi::c_uint; +pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_19 = 1; +pub type _bindgen_ty_19 = ::core::ffi::c_uint; +pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_22 = 2147483648; +pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_22 = 1073741824; +pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_22 = 8; +pub type _bindgen_ty_22 = ::core::ffi::c_uint; +pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_24 = 1; pub type _bindgen_ty_24 = ::core::ffi::c_uint; +pub const BPF_F_BROADCAST: _bindgen_ty_25 = 8; +pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_25 = 16; +pub type _bindgen_ty_25 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_prog_info { @@ -905,6 +914,7 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4 { pub target_name: __u64, pub target_name_len: __u32, pub __bindgen_anon_1: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1, + pub __bindgen_anon_2: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2, } #[repr(C)] #[derive(Copy, Clone)] @@ -917,6 +927,24 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1 pub map_id: __u32, } #[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2 { + pub cgroup: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1, + pub task: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1 { + pub cgroup_id: __u64, + pub order: __u32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2 { + pub tid: __u32, + pub pid: __u32, +} +#[repr(C)] #[derive(Debug, Copy, Clone)] pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_5 { pub netns_ino: __u32, @@ -966,29 +994,29 @@ pub union btf_type__bindgen_ty_1 { pub size: __u32, pub type_: __u32, } -pub const BTF_KIND_UNKN: _bindgen_ty_38 = 0; -pub const BTF_KIND_INT: _bindgen_ty_38 = 1; -pub const BTF_KIND_PTR: _bindgen_ty_38 = 2; -pub const BTF_KIND_ARRAY: _bindgen_ty_38 = 3; -pub const BTF_KIND_STRUCT: _bindgen_ty_38 = 4; -pub const BTF_KIND_UNION: _bindgen_ty_38 = 5; -pub const BTF_KIND_ENUM: _bindgen_ty_38 = 6; -pub const BTF_KIND_FWD: _bindgen_ty_38 = 7; -pub const BTF_KIND_TYPEDEF: _bindgen_ty_38 = 8; -pub const BTF_KIND_VOLATILE: _bindgen_ty_38 = 9; -pub const BTF_KIND_CONST: _bindgen_ty_38 = 10; -pub const BTF_KIND_RESTRICT: _bindgen_ty_38 = 11; -pub const BTF_KIND_FUNC: _bindgen_ty_38 = 12; -pub const BTF_KIND_FUNC_PROTO: _bindgen_ty_38 = 13; -pub const BTF_KIND_VAR: _bindgen_ty_38 = 14; -pub const BTF_KIND_DATASEC: _bindgen_ty_38 = 15; -pub const BTF_KIND_FLOAT: _bindgen_ty_38 = 16; -pub const BTF_KIND_DECL_TAG: _bindgen_ty_38 = 17; -pub const BTF_KIND_TYPE_TAG: _bindgen_ty_38 = 18; -pub const BTF_KIND_ENUM64: _bindgen_ty_38 = 19; -pub const NR_BTF_KINDS: _bindgen_ty_38 = 20; -pub const BTF_KIND_MAX: _bindgen_ty_38 = 19; -pub type _bindgen_ty_38 = ::core::ffi::c_uint; +pub const BTF_KIND_UNKN: _bindgen_ty_39 = 0; +pub const BTF_KIND_INT: _bindgen_ty_39 = 1; +pub const BTF_KIND_PTR: _bindgen_ty_39 = 2; +pub const BTF_KIND_ARRAY: _bindgen_ty_39 = 3; +pub const BTF_KIND_STRUCT: _bindgen_ty_39 = 4; +pub const BTF_KIND_UNION: _bindgen_ty_39 = 5; +pub const BTF_KIND_ENUM: _bindgen_ty_39 = 6; +pub const BTF_KIND_FWD: _bindgen_ty_39 = 7; +pub const BTF_KIND_TYPEDEF: _bindgen_ty_39 = 8; +pub const BTF_KIND_VOLATILE: _bindgen_ty_39 = 9; +pub const BTF_KIND_CONST: _bindgen_ty_39 = 10; +pub const BTF_KIND_RESTRICT: _bindgen_ty_39 = 11; +pub const BTF_KIND_FUNC: _bindgen_ty_39 = 12; +pub const BTF_KIND_FUNC_PROTO: _bindgen_ty_39 = 13; +pub const BTF_KIND_VAR: _bindgen_ty_39 = 14; +pub const BTF_KIND_DATASEC: _bindgen_ty_39 = 15; +pub const BTF_KIND_FLOAT: _bindgen_ty_39 = 16; +pub const BTF_KIND_DECL_TAG: _bindgen_ty_39 = 17; +pub const BTF_KIND_TYPE_TAG: _bindgen_ty_39 = 18; +pub const BTF_KIND_ENUM64: _bindgen_ty_39 = 19; +pub const NR_BTF_KINDS: _bindgen_ty_39 = 20; +pub const BTF_KIND_MAX: _bindgen_ty_39 = 19; +pub type _bindgen_ty_39 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct btf_enum { @@ -1015,10 +1043,10 @@ pub struct btf_param { pub name_off: __u32, pub type_: __u32, } -pub const BTF_VAR_STATIC: _bindgen_ty_39 = 0; -pub const BTF_VAR_GLOBAL_ALLOCATED: _bindgen_ty_39 = 1; -pub const BTF_VAR_GLOBAL_EXTERN: _bindgen_ty_39 = 2; -pub type _bindgen_ty_39 = ::core::ffi::c_uint; +pub const BTF_VAR_STATIC: _bindgen_ty_40 = 0; +pub const BTF_VAR_GLOBAL_ALLOCATED: _bindgen_ty_40 = 1; +pub const BTF_VAR_GLOBAL_EXTERN: _bindgen_ty_40 = 2; +pub type _bindgen_ty_40 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum btf_func_linkage { @@ -1113,7 +1141,7 @@ pub enum perf_sw_ids { PERF_COUNT_SW_CGROUP_SWITCHES = 11, PERF_COUNT_SW_MAX = 12, } -#[repr(u64)] +#[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum perf_event_sample_format { PERF_SAMPLE_IP = 1, @@ -1142,7 +1170,6 @@ pub enum perf_event_sample_format { PERF_SAMPLE_CODE_PAGE_SIZE = 8388608, PERF_SAMPLE_WEIGHT_STRUCT = 16777216, PERF_SAMPLE_MAX = 33554432, - __PERF_SAMPLE_CALLCHAIN_EARLY = 9223372036854775808, } #[repr(C)] #[derive(Copy, Clone)] @@ -2014,17 +2041,17 @@ pub enum perf_event_type { PERF_RECORD_AUX_OUTPUT_HW_ID = 21, PERF_RECORD_MAX = 22, } -pub const IFLA_XDP_UNSPEC: _bindgen_ty_85 = 0; -pub const IFLA_XDP_FD: _bindgen_ty_85 = 1; -pub const IFLA_XDP_ATTACHED: _bindgen_ty_85 = 2; -pub const IFLA_XDP_FLAGS: _bindgen_ty_85 = 3; -pub const IFLA_XDP_PROG_ID: _bindgen_ty_85 = 4; -pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_85 = 5; -pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_85 = 6; -pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_85 = 7; -pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_85 = 8; -pub const __IFLA_XDP_MAX: _bindgen_ty_85 = 9; -pub type _bindgen_ty_85 = ::core::ffi::c_uint; +pub const IFLA_XDP_UNSPEC: _bindgen_ty_89 = 0; +pub const IFLA_XDP_FD: _bindgen_ty_89 = 1; +pub const IFLA_XDP_ATTACHED: _bindgen_ty_89 = 2; +pub const IFLA_XDP_FLAGS: _bindgen_ty_89 = 3; +pub const IFLA_XDP_PROG_ID: _bindgen_ty_89 = 4; +pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_89 = 5; +pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_89 = 6; +pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_89 = 7; +pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_89 = 8; +pub const __IFLA_XDP_MAX: _bindgen_ty_89 = 9; +pub type _bindgen_ty_89 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { @@ -2046,38 +2073,37 @@ pub struct tcmsg { pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_100 = 0; -pub const TCA_KIND: _bindgen_ty_100 = 1; -pub const TCA_OPTIONS: _bindgen_ty_100 = 2; -pub const TCA_STATS: _bindgen_ty_100 = 3; -pub const TCA_XSTATS: _bindgen_ty_100 = 4; -pub const TCA_RATE: _bindgen_ty_100 = 5; -pub const TCA_FCNT: _bindgen_ty_100 = 6; -pub const TCA_STATS2: _bindgen_ty_100 = 7; -pub const TCA_STAB: _bindgen_ty_100 = 8; -pub const TCA_PAD: _bindgen_ty_100 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_100 = 10; -pub const TCA_CHAIN: _bindgen_ty_100 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_100 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_100 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_100 = 14; -pub const TCA_DUMP_FLAGS: _bindgen_ty_100 = 15; -pub const __TCA_MAX: _bindgen_ty_100 = 16; -pub type _bindgen_ty_100 = ::core::ffi::c_uint; -pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; -pub const TCA_BPF_FD: _bindgen_ty_156 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; -pub const TCA_BPF_ID: _bindgen_ty_156 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; -pub type _bindgen_ty_156 = ::core::ffi::c_uint; +pub const TCA_UNSPEC: _bindgen_ty_102 = 0; +pub const TCA_KIND: _bindgen_ty_102 = 1; +pub const TCA_OPTIONS: _bindgen_ty_102 = 2; +pub const TCA_STATS: _bindgen_ty_102 = 3; +pub const TCA_XSTATS: _bindgen_ty_102 = 4; +pub const TCA_RATE: _bindgen_ty_102 = 5; +pub const TCA_FCNT: _bindgen_ty_102 = 6; +pub const TCA_STATS2: _bindgen_ty_102 = 7; +pub const TCA_STAB: _bindgen_ty_102 = 8; +pub const TCA_PAD: _bindgen_ty_102 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_102 = 10; +pub const TCA_CHAIN: _bindgen_ty_102 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_102 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_102 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_102 = 14; +pub const __TCA_MAX: _bindgen_ty_102 = 15; +pub type _bindgen_ty_102 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_158 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_158 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_158 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_158 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_158 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_158 = 5; +pub const TCA_BPF_FD: _bindgen_ty_158 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_158 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_158 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_158 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_158 = 10; +pub const TCA_BPF_ID: _bindgen_ty_158 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_158 = 12; +pub type _bindgen_ty_158 = ::core::ffi::c_uint; pub const AYA_PERF_EVENT_IOC_ENABLE: ::core::ffi::c_int = 9216; pub const AYA_PERF_EVENT_IOC_DISABLE: ::core::ffi::c_int = 9217; pub const AYA_PERF_EVENT_IOC_SET_BPF: ::core::ffi::c_int = 1074013192; diff --git a/bpf/aya-bpf-bindings/src/aarch64/bindings.rs b/bpf/aya-bpf-bindings/src/aarch64/bindings.rs index 181a9a6d..46730032 100644 --- a/bpf/aya-bpf-bindings/src/aarch64/bindings.rs +++ b/bpf/aya-bpf-bindings/src/aarch64/bindings.rs @@ -358,16 +358,40 @@ pub struct bpf_cgroup_storage_key { pub cgroup_inode_id: __u64, pub attach_type: __u32, } +pub mod bpf_cgroup_iter_order { + pub type Type = ::aya_bpf_cty::c_uint; + pub const BPF_CGROUP_ITER_ORDER_UNSPEC: Type = 0; + pub const BPF_CGROUP_ITER_SELF_ONLY: Type = 1; + pub const BPF_CGROUP_ITER_DESCENDANTS_PRE: Type = 2; + pub const BPF_CGROUP_ITER_DESCENDANTS_POST: Type = 3; + pub const BPF_CGROUP_ITER_ANCESTORS_UP: Type = 4; +} #[repr(C)] #[derive(Copy, Clone)] pub union bpf_iter_link_info { pub map: bpf_iter_link_info__bindgen_ty_1, + pub cgroup: bpf_iter_link_info__bindgen_ty_2, + pub task: bpf_iter_link_info__bindgen_ty_3, } #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_iter_link_info__bindgen_ty_1 { pub map_fd: __u32, } +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_iter_link_info__bindgen_ty_2 { + pub order: bpf_cgroup_iter_order::Type, + pub cgroup_fd: __u32, + pub cgroup_id: __u64, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_iter_link_info__bindgen_ty_3 { + pub tid: __u32, + pub pid: __u32, + pub pid_fd: __u32, +} pub mod bpf_cmd { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_MAP_CREATE: Type = 0; @@ -429,6 +453,7 @@ pub mod bpf_map_type { pub const BPF_MAP_TYPE_CPUMAP: Type = 16; pub const BPF_MAP_TYPE_XSKMAP: Type = 17; pub const BPF_MAP_TYPE_SOCKHASH: Type = 18; + pub const BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED: Type = 19; pub const BPF_MAP_TYPE_CGROUP_STORAGE: Type = 19; pub const BPF_MAP_TYPE_REUSEPORT_SOCKARRAY: Type = 20; pub const BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE: Type = 21; @@ -441,6 +466,8 @@ pub mod bpf_map_type { pub const BPF_MAP_TYPE_INODE_STORAGE: Type = 28; pub const BPF_MAP_TYPE_TASK_STORAGE: Type = 29; pub const BPF_MAP_TYPE_BLOOM_FILTER: Type = 30; + pub const BPF_MAP_TYPE_USER_RINGBUF: Type = 31; + pub const BPF_MAP_TYPE_CGRP_STORAGE: Type = 32; } pub mod bpf_prog_type { pub type Type = ::aya_bpf_cty::c_uint; @@ -1072,7 +1099,10 @@ pub mod bpf_func_id { pub const BPF_FUNC_tcp_raw_check_syncookie_ipv4: Type = 206; pub const BPF_FUNC_tcp_raw_check_syncookie_ipv6: Type = 207; pub const BPF_FUNC_ktime_get_tai_ns: Type = 208; - pub const __BPF_FUNC_MAX_ID: Type = 209; + pub const BPF_FUNC_user_ringbuf_drain: Type = 209; + pub const BPF_FUNC_cgrp_storage_get: Type = 210; + pub const BPF_FUNC_cgrp_storage_delete: Type = 211; + pub const __BPF_FUNC_MAX_ID: Type = 212; } pub const BPF_F_RECOMPUTE_CSUM: _bindgen_ty_4 = 1; pub const BPF_F_INVALIDATE_HASH: _bindgen_ty_4 = 2; @@ -1096,51 +1126,54 @@ pub type _bindgen_ty_9 = ::aya_bpf_cty::c_uint; pub const BPF_F_ZERO_CSUM_TX: _bindgen_ty_10 = 2; pub const BPF_F_DONT_FRAGMENT: _bindgen_ty_10 = 4; pub const BPF_F_SEQ_NUMBER: _bindgen_ty_10 = 8; +pub const BPF_F_NO_TUNNEL_KEY: _bindgen_ty_10 = 16; pub type _bindgen_ty_10 = ::aya_bpf_cty::c_uint; -pub const BPF_F_INDEX_MASK: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CURRENT_CPU: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CTXLEN_MASK: _bindgen_ty_11 = 4503595332403200; -pub type _bindgen_ty_11 = ::aya_bpf_cty::c_ulong; -pub const BPF_F_CURRENT_NETNS: _bindgen_ty_12 = -1; -pub type _bindgen_ty_12 = ::aya_bpf_cty::c_int; -pub const BPF_CSUM_LEVEL_QUERY: _bindgen_ty_13 = 0; -pub const BPF_CSUM_LEVEL_INC: _bindgen_ty_13 = 1; -pub const BPF_CSUM_LEVEL_DEC: _bindgen_ty_13 = 2; -pub const BPF_CSUM_LEVEL_RESET: _bindgen_ty_13 = 3; -pub type _bindgen_ty_13 = ::aya_bpf_cty::c_uint; -pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_14 = 1; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_14 = 2; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_14 = 4; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_14 = 8; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_14 = 16; -pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_14 = 32; -pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_14 = 64; +pub const BPF_F_TUNINFO_FLAGS: _bindgen_ty_11 = 16; +pub type _bindgen_ty_11 = ::aya_bpf_cty::c_uint; +pub const BPF_F_INDEX_MASK: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CURRENT_CPU: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CTXLEN_MASK: _bindgen_ty_12 = 4503595332403200; +pub type _bindgen_ty_12 = ::aya_bpf_cty::c_ulong; +pub const BPF_F_CURRENT_NETNS: _bindgen_ty_13 = -1; +pub type _bindgen_ty_13 = ::aya_bpf_cty::c_int; +pub const BPF_CSUM_LEVEL_QUERY: _bindgen_ty_14 = 0; +pub const BPF_CSUM_LEVEL_INC: _bindgen_ty_14 = 1; +pub const BPF_CSUM_LEVEL_DEC: _bindgen_ty_14 = 2; +pub const BPF_CSUM_LEVEL_RESET: _bindgen_ty_14 = 3; pub type _bindgen_ty_14 = ::aya_bpf_cty::c_uint; -pub const BPF_ADJ_ROOM_ENCAP_L2_MASK: _bindgen_ty_15 = 255; -pub const BPF_ADJ_ROOM_ENCAP_L2_SHIFT: _bindgen_ty_15 = 56; +pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_15 = 1; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_15 = 2; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_15 = 4; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_15 = 8; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_15 = 16; +pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_15 = 32; +pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_15 = 64; pub type _bindgen_ty_15 = ::aya_bpf_cty::c_uint; -pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_16 = 1; +pub const BPF_ADJ_ROOM_ENCAP_L2_MASK: _bindgen_ty_16 = 255; +pub const BPF_ADJ_ROOM_ENCAP_L2_SHIFT: _bindgen_ty_16 = 56; pub type _bindgen_ty_16 = ::aya_bpf_cty::c_uint; -pub const BPF_LOCAL_STORAGE_GET_F_CREATE: _bindgen_ty_17 = 1; -pub const BPF_SK_STORAGE_GET_F_CREATE: _bindgen_ty_17 = 1; +pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_17 = 1; pub type _bindgen_ty_17 = ::aya_bpf_cty::c_uint; -pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_18 = 1; +pub const BPF_LOCAL_STORAGE_GET_F_CREATE: _bindgen_ty_18 = 1; +pub const BPF_SK_STORAGE_GET_F_CREATE: _bindgen_ty_18 = 1; pub type _bindgen_ty_18 = ::aya_bpf_cty::c_uint; -pub const BPF_RB_NO_WAKEUP: _bindgen_ty_19 = 1; -pub const BPF_RB_FORCE_WAKEUP: _bindgen_ty_19 = 2; +pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_19 = 1; pub type _bindgen_ty_19 = ::aya_bpf_cty::c_uint; -pub const BPF_RB_AVAIL_DATA: _bindgen_ty_20 = 0; -pub const BPF_RB_RING_SIZE: _bindgen_ty_20 = 1; -pub const BPF_RB_CONS_POS: _bindgen_ty_20 = 2; -pub const BPF_RB_PROD_POS: _bindgen_ty_20 = 3; +pub const BPF_RB_NO_WAKEUP: _bindgen_ty_20 = 1; +pub const BPF_RB_FORCE_WAKEUP: _bindgen_ty_20 = 2; pub type _bindgen_ty_20 = ::aya_bpf_cty::c_uint; -pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_21 = 2147483648; -pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_21 = 1073741824; -pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_21 = 8; +pub const BPF_RB_AVAIL_DATA: _bindgen_ty_21 = 0; +pub const BPF_RB_RING_SIZE: _bindgen_ty_21 = 1; +pub const BPF_RB_CONS_POS: _bindgen_ty_21 = 2; +pub const BPF_RB_PROD_POS: _bindgen_ty_21 = 3; pub type _bindgen_ty_21 = ::aya_bpf_cty::c_uint; -pub const BPF_SK_LOOKUP_F_REPLACE: _bindgen_ty_22 = 1; -pub const BPF_SK_LOOKUP_F_NO_REUSEPORT: _bindgen_ty_22 = 2; +pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_22 = 2147483648; +pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_22 = 1073741824; +pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_22 = 8; pub type _bindgen_ty_22 = ::aya_bpf_cty::c_uint; +pub const BPF_SK_LOOKUP_F_REPLACE: _bindgen_ty_23 = 1; +pub const BPF_SK_LOOKUP_F_NO_REUSEPORT: _bindgen_ty_23 = 2; +pub type _bindgen_ty_23 = ::aya_bpf_cty::c_uint; pub mod bpf_adj_room_mode { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_ADJ_ROOM_NET: Type = 0; @@ -1157,12 +1190,12 @@ pub mod bpf_lwt_encap_mode { pub const BPF_LWT_ENCAP_SEG6_INLINE: Type = 1; pub const BPF_LWT_ENCAP_IP: Type = 2; } -pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_23 = 1; -pub type _bindgen_ty_23 = ::aya_bpf_cty::c_uint; -pub const BPF_F_BROADCAST: _bindgen_ty_24 = 8; -pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_24 = 16; +pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_24 = 1; pub type _bindgen_ty_24 = ::aya_bpf_cty::c_uint; -pub mod _bindgen_ty_25 { +pub const BPF_F_BROADCAST: _bindgen_ty_25 = 8; +pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_25 = 16; +pub type _bindgen_ty_25 = ::aya_bpf_cty::c_uint; +pub mod _bindgen_ty_26 { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_SKB_TSTAMP_UNSPEC: Type = 0; pub const BPF_SKB_TSTAMP_DELIVERY_MONO: Type = 1; @@ -1249,9 +1282,9 @@ pub struct bpf_tunnel_key { pub __bindgen_anon_1: bpf_tunnel_key__bindgen_ty_1, pub tunnel_tos: __u8, pub tunnel_ttl: __u8, - pub tunnel_ext: __u16, - pub tunnel_label: __u32, pub __bindgen_anon_2: bpf_tunnel_key__bindgen_ty_2, + pub tunnel_label: __u32, + pub __bindgen_anon_3: bpf_tunnel_key__bindgen_ty_3, } #[repr(C)] #[derive(Copy, Clone)] @@ -1262,6 +1295,12 @@ pub union bpf_tunnel_key__bindgen_ty_1 { #[repr(C)] #[derive(Copy, Clone)] pub union bpf_tunnel_key__bindgen_ty_2 { + pub tunnel_ext: __u16, + pub tunnel_flags: __be16, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_tunnel_key__bindgen_ty_3 { pub local_ipv4: __u32, pub local_ipv6: [__u32; 4usize], } @@ -1286,6 +1325,7 @@ pub mod bpf_ret_code { pub const BPF_DROP: Type = 2; pub const BPF_REDIRECT: Type = 7; pub const BPF_LWT_REROUTE: Type = 128; + pub const BPF_FLOW_DISSECTOR_CONTINUE: Type = 129; } #[repr(C)] #[derive(Copy, Clone)] @@ -1695,6 +1735,7 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4 { pub target_name: __u64, pub target_name_len: __u32, pub __bindgen_anon_1: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1, + pub __bindgen_anon_2: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2, } #[repr(C)] #[derive(Copy, Clone)] @@ -1708,6 +1749,24 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1 } #[repr(C)] #[derive(Copy, Clone)] +pub union bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2 { + pub cgroup: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1, + pub task: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1 { + pub cgroup_id: __u64, + pub order: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2 { + pub tid: __u32, + pub pid: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_5 { pub netns_ino: __u32, pub attach_type: __u32, @@ -1788,6 +1847,7 @@ pub struct bpf_sock_ops { pub __bindgen_anon_4: bpf_sock_ops__bindgen_ty_4, pub skb_len: __u32, pub skb_tcp_flags: __u32, + pub skb_hwtstamp: __u64, } #[repr(C)] #[derive(Copy, Clone)] @@ -1838,51 +1898,51 @@ impl bpf_sock_ops__bindgen_ty_4 { __bindgen_bitfield_unit } } -pub const BPF_SOCK_OPS_RTO_CB_FLAG: _bindgen_ty_26 = 1; -pub const BPF_SOCK_OPS_RETRANS_CB_FLAG: _bindgen_ty_26 = 2; -pub const BPF_SOCK_OPS_STATE_CB_FLAG: _bindgen_ty_26 = 4; -pub const BPF_SOCK_OPS_RTT_CB_FLAG: _bindgen_ty_26 = 8; -pub const BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG: _bindgen_ty_26 = 16; -pub const BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG: _bindgen_ty_26 = 32; -pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG: _bindgen_ty_26 = 64; -pub const BPF_SOCK_OPS_ALL_CB_FLAGS: _bindgen_ty_26 = 127; -pub type _bindgen_ty_26 = ::aya_bpf_cty::c_uint; -pub const BPF_SOCK_OPS_VOID: _bindgen_ty_27 = 0; -pub const BPF_SOCK_OPS_TIMEOUT_INIT: _bindgen_ty_27 = 1; -pub const BPF_SOCK_OPS_RWND_INIT: _bindgen_ty_27 = 2; -pub const BPF_SOCK_OPS_TCP_CONNECT_CB: _bindgen_ty_27 = 3; -pub const BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: _bindgen_ty_27 = 4; -pub const BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: _bindgen_ty_27 = 5; -pub const BPF_SOCK_OPS_NEEDS_ECN: _bindgen_ty_27 = 6; -pub const BPF_SOCK_OPS_BASE_RTT: _bindgen_ty_27 = 7; -pub const BPF_SOCK_OPS_RTO_CB: _bindgen_ty_27 = 8; -pub const BPF_SOCK_OPS_RETRANS_CB: _bindgen_ty_27 = 9; -pub const BPF_SOCK_OPS_STATE_CB: _bindgen_ty_27 = 10; -pub const BPF_SOCK_OPS_TCP_LISTEN_CB: _bindgen_ty_27 = 11; -pub const BPF_SOCK_OPS_RTT_CB: _bindgen_ty_27 = 12; -pub const BPF_SOCK_OPS_PARSE_HDR_OPT_CB: _bindgen_ty_27 = 13; -pub const BPF_SOCK_OPS_HDR_OPT_LEN_CB: _bindgen_ty_27 = 14; -pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB: _bindgen_ty_27 = 15; +pub const BPF_SOCK_OPS_RTO_CB_FLAG: _bindgen_ty_27 = 1; +pub const BPF_SOCK_OPS_RETRANS_CB_FLAG: _bindgen_ty_27 = 2; +pub const BPF_SOCK_OPS_STATE_CB_FLAG: _bindgen_ty_27 = 4; +pub const BPF_SOCK_OPS_RTT_CB_FLAG: _bindgen_ty_27 = 8; +pub const BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG: _bindgen_ty_27 = 16; +pub const BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG: _bindgen_ty_27 = 32; +pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG: _bindgen_ty_27 = 64; +pub const BPF_SOCK_OPS_ALL_CB_FLAGS: _bindgen_ty_27 = 127; pub type _bindgen_ty_27 = ::aya_bpf_cty::c_uint; -pub const BPF_TCP_ESTABLISHED: _bindgen_ty_28 = 1; -pub const BPF_TCP_SYN_SENT: _bindgen_ty_28 = 2; -pub const BPF_TCP_SYN_RECV: _bindgen_ty_28 = 3; -pub const BPF_TCP_FIN_WAIT1: _bindgen_ty_28 = 4; -pub const BPF_TCP_FIN_WAIT2: _bindgen_ty_28 = 5; -pub const BPF_TCP_TIME_WAIT: _bindgen_ty_28 = 6; -pub const BPF_TCP_CLOSE: _bindgen_ty_28 = 7; -pub const BPF_TCP_CLOSE_WAIT: _bindgen_ty_28 = 8; -pub const BPF_TCP_LAST_ACK: _bindgen_ty_28 = 9; -pub const BPF_TCP_LISTEN: _bindgen_ty_28 = 10; -pub const BPF_TCP_CLOSING: _bindgen_ty_28 = 11; -pub const BPF_TCP_NEW_SYN_RECV: _bindgen_ty_28 = 12; -pub const BPF_TCP_MAX_STATES: _bindgen_ty_28 = 13; +pub const BPF_SOCK_OPS_VOID: _bindgen_ty_28 = 0; +pub const BPF_SOCK_OPS_TIMEOUT_INIT: _bindgen_ty_28 = 1; +pub const BPF_SOCK_OPS_RWND_INIT: _bindgen_ty_28 = 2; +pub const BPF_SOCK_OPS_TCP_CONNECT_CB: _bindgen_ty_28 = 3; +pub const BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: _bindgen_ty_28 = 4; +pub const BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: _bindgen_ty_28 = 5; +pub const BPF_SOCK_OPS_NEEDS_ECN: _bindgen_ty_28 = 6; +pub const BPF_SOCK_OPS_BASE_RTT: _bindgen_ty_28 = 7; +pub const BPF_SOCK_OPS_RTO_CB: _bindgen_ty_28 = 8; +pub const BPF_SOCK_OPS_RETRANS_CB: _bindgen_ty_28 = 9; +pub const BPF_SOCK_OPS_STATE_CB: _bindgen_ty_28 = 10; +pub const BPF_SOCK_OPS_TCP_LISTEN_CB: _bindgen_ty_28 = 11; +pub const BPF_SOCK_OPS_RTT_CB: _bindgen_ty_28 = 12; +pub const BPF_SOCK_OPS_PARSE_HDR_OPT_CB: _bindgen_ty_28 = 13; +pub const BPF_SOCK_OPS_HDR_OPT_LEN_CB: _bindgen_ty_28 = 14; +pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB: _bindgen_ty_28 = 15; pub type _bindgen_ty_28 = ::aya_bpf_cty::c_uint; -pub mod _bindgen_ty_30 { +pub const BPF_TCP_ESTABLISHED: _bindgen_ty_29 = 1; +pub const BPF_TCP_SYN_SENT: _bindgen_ty_29 = 2; +pub const BPF_TCP_SYN_RECV: _bindgen_ty_29 = 3; +pub const BPF_TCP_FIN_WAIT1: _bindgen_ty_29 = 4; +pub const BPF_TCP_FIN_WAIT2: _bindgen_ty_29 = 5; +pub const BPF_TCP_TIME_WAIT: _bindgen_ty_29 = 6; +pub const BPF_TCP_CLOSE: _bindgen_ty_29 = 7; +pub const BPF_TCP_CLOSE_WAIT: _bindgen_ty_29 = 8; +pub const BPF_TCP_LAST_ACK: _bindgen_ty_29 = 9; +pub const BPF_TCP_LISTEN: _bindgen_ty_29 = 10; +pub const BPF_TCP_CLOSING: _bindgen_ty_29 = 11; +pub const BPF_TCP_NEW_SYN_RECV: _bindgen_ty_29 = 12; +pub const BPF_TCP_MAX_STATES: _bindgen_ty_29 = 13; +pub type _bindgen_ty_29 = ::aya_bpf_cty::c_uint; +pub mod _bindgen_ty_31 { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_LOAD_HDR_OPT_TCP_SYN: Type = 1; } -pub mod _bindgen_ty_31 { +pub mod _bindgen_ty_32 { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_WRITE_HDR_TCP_CURRENT_MSS: Type = 1; pub const BPF_WRITE_HDR_TCP_SYNACK_COOKIE: Type = 2; @@ -1894,13 +1954,13 @@ pub struct bpf_perf_event_value { pub enabled: __u64, pub running: __u64, } -pub const BPF_DEVCG_ACC_MKNOD: _bindgen_ty_32 = 1; -pub const BPF_DEVCG_ACC_READ: _bindgen_ty_32 = 2; -pub const BPF_DEVCG_ACC_WRITE: _bindgen_ty_32 = 4; -pub type _bindgen_ty_32 = ::aya_bpf_cty::c_uint; -pub const BPF_DEVCG_DEV_BLOCK: _bindgen_ty_33 = 1; -pub const BPF_DEVCG_DEV_CHAR: _bindgen_ty_33 = 2; +pub const BPF_DEVCG_ACC_MKNOD: _bindgen_ty_33 = 1; +pub const BPF_DEVCG_ACC_READ: _bindgen_ty_33 = 2; +pub const BPF_DEVCG_ACC_WRITE: _bindgen_ty_33 = 4; pub type _bindgen_ty_33 = ::aya_bpf_cty::c_uint; +pub const BPF_DEVCG_DEV_BLOCK: _bindgen_ty_34 = 1; +pub const BPF_DEVCG_DEV_CHAR: _bindgen_ty_34 = 2; +pub type _bindgen_ty_34 = ::aya_bpf_cty::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_cgroup_dev_ctx { @@ -1912,19 +1972,19 @@ pub struct bpf_cgroup_dev_ctx { pub struct bpf_raw_tracepoint_args { pub args: __IncompleteArrayField<__u64>, } -pub const BPF_FIB_LOOKUP_DIRECT: _bindgen_ty_34 = 1; -pub const BPF_FIB_LOOKUP_OUTPUT: _bindgen_ty_34 = 2; -pub type _bindgen_ty_34 = ::aya_bpf_cty::c_uint; -pub const BPF_FIB_LKUP_RET_SUCCESS: _bindgen_ty_35 = 0; -pub const BPF_FIB_LKUP_RET_BLACKHOLE: _bindgen_ty_35 = 1; -pub const BPF_FIB_LKUP_RET_UNREACHABLE: _bindgen_ty_35 = 2; -pub const BPF_FIB_LKUP_RET_PROHIBIT: _bindgen_ty_35 = 3; -pub const BPF_FIB_LKUP_RET_NOT_FWDED: _bindgen_ty_35 = 4; -pub const BPF_FIB_LKUP_RET_FWD_DISABLED: _bindgen_ty_35 = 5; -pub const BPF_FIB_LKUP_RET_UNSUPP_LWT: _bindgen_ty_35 = 6; -pub const BPF_FIB_LKUP_RET_NO_NEIGH: _bindgen_ty_35 = 7; -pub const BPF_FIB_LKUP_RET_FRAG_NEEDED: _bindgen_ty_35 = 8; +pub const BPF_FIB_LOOKUP_DIRECT: _bindgen_ty_35 = 1; +pub const BPF_FIB_LOOKUP_OUTPUT: _bindgen_ty_35 = 2; pub type _bindgen_ty_35 = ::aya_bpf_cty::c_uint; +pub const BPF_FIB_LKUP_RET_SUCCESS: _bindgen_ty_36 = 0; +pub const BPF_FIB_LKUP_RET_BLACKHOLE: _bindgen_ty_36 = 1; +pub const BPF_FIB_LKUP_RET_UNREACHABLE: _bindgen_ty_36 = 2; +pub const BPF_FIB_LKUP_RET_PROHIBIT: _bindgen_ty_36 = 3; +pub const BPF_FIB_LKUP_RET_NOT_FWDED: _bindgen_ty_36 = 4; +pub const BPF_FIB_LKUP_RET_FWD_DISABLED: _bindgen_ty_36 = 5; +pub const BPF_FIB_LKUP_RET_UNSUPP_LWT: _bindgen_ty_36 = 6; +pub const BPF_FIB_LKUP_RET_NO_NEIGH: _bindgen_ty_36 = 7; +pub const BPF_FIB_LKUP_RET_FRAG_NEEDED: _bindgen_ty_36 = 8; +pub type _bindgen_ty_36 = ::aya_bpf_cty::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_fib_lookup { @@ -1998,10 +2058,10 @@ pub mod bpf_task_fd_type { pub const BPF_FD_TYPE_UPROBE: Type = 4; pub const BPF_FD_TYPE_URETPROBE: Type = 5; } -pub const BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG: _bindgen_ty_36 = 1; -pub const BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL: _bindgen_ty_36 = 2; -pub const BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP: _bindgen_ty_36 = 4; -pub type _bindgen_ty_36 = ::aya_bpf_cty::c_uint; +pub const BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG: _bindgen_ty_37 = 1; +pub const BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL: _bindgen_ty_37 = 2; +pub const BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP: _bindgen_ty_37 = 4; +pub type _bindgen_ty_37 = ::aya_bpf_cty::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_flow_keys { @@ -2085,6 +2145,34 @@ impl bpf_dynptr { } } #[repr(C)] +#[repr(align(8))] +#[derive(Copy, Clone)] +pub struct bpf_list_head { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize]>, +} +impl bpf_list_head { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 16usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[repr(align(8))] +#[derive(Copy, Clone)] +pub struct bpf_list_node { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize]>, +} +impl bpf_list_node { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 16usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] #[derive(Copy, Clone)] pub struct bpf_sysctl { pub write: __u32, @@ -2300,6 +2388,11 @@ pub struct task_struct { } #[repr(C)] #[derive(Copy, Clone)] +pub struct cgroup { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Copy, Clone)] pub struct path { _unused: [u8; 0], } diff --git a/bpf/aya-bpf-bindings/src/aarch64/helpers.rs b/bpf/aya-bpf-bindings/src/aarch64/helpers.rs index 45b2efa2..be465ae5 100644 --- a/bpf/aya-bpf-bindings/src/aarch64/helpers.rs +++ b/bpf/aya-bpf-bindings/src/aarch64/helpers.rs @@ -461,12 +461,12 @@ pub unsafe fn bpf_skb_adjust_room( } pub unsafe fn bpf_redirect_map( map: *mut ::aya_bpf_cty::c_void, - key: __u32, + key: __u64, flags: __u64, ) -> ::aya_bpf_cty::c_long { let fun: unsafe extern "C" fn( map: *mut ::aya_bpf_cty::c_void, - key: __u32, + key: __u64, flags: __u64, ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(51usize); fun(map, key, flags) @@ -2027,28 +2027,28 @@ pub unsafe fn bpf_ringbuf_discard_dynptr(ptr: *mut bpf_dynptr, flags: __u64) { pub unsafe fn bpf_dynptr_read( dst: *mut ::aya_bpf_cty::c_void, len: __u32, - src: *mut bpf_dynptr, + src: *const bpf_dynptr, offset: __u32, flags: __u64, ) -> ::aya_bpf_cty::c_long { let fun: unsafe extern "C" fn( dst: *mut ::aya_bpf_cty::c_void, len: __u32, - src: *mut bpf_dynptr, + src: *const bpf_dynptr, offset: __u32, flags: __u64, ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(201usize); fun(dst, len, src, offset, flags) } pub unsafe fn bpf_dynptr_write( - dst: *mut bpf_dynptr, + dst: *const bpf_dynptr, offset: __u32, src: *mut ::aya_bpf_cty::c_void, len: __u32, flags: __u64, ) -> ::aya_bpf_cty::c_long { let fun: unsafe extern "C" fn( - dst: *mut bpf_dynptr, + dst: *const bpf_dynptr, offset: __u32, src: *mut ::aya_bpf_cty::c_void, len: __u32, @@ -2057,12 +2057,12 @@ pub unsafe fn bpf_dynptr_write( fun(dst, offset, src, len, flags) } pub unsafe fn bpf_dynptr_data( - ptr: *mut bpf_dynptr, + ptr: *const bpf_dynptr, offset: __u32, len: __u32, ) -> *mut ::aya_bpf_cty::c_void { let fun: unsafe extern "C" fn( - ptr: *mut bpf_dynptr, + ptr: *const bpf_dynptr, offset: __u32, len: __u32, ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(203usize); @@ -2106,3 +2106,41 @@ pub unsafe fn bpf_ktime_get_tai_ns() -> __u64 { let fun: unsafe extern "C" fn() -> __u64 = ::core::mem::transmute(208usize); fun() } +pub unsafe fn bpf_user_ringbuf_drain( + map: *mut ::aya_bpf_cty::c_void, + callback_fn: *mut ::aya_bpf_cty::c_void, + ctx: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let fun: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + callback_fn: *mut ::aya_bpf_cty::c_void, + ctx: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(209usize); + fun(map, callback_fn, ctx, flags) +} +pub unsafe fn bpf_cgrp_storage_get( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> *mut ::aya_bpf_cty::c_void { + let fun: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(210usize); + fun(map, cgroup, value, flags) +} +pub unsafe fn bpf_cgrp_storage_delete( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, +) -> ::aya_bpf_cty::c_long { + let fun: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(211usize); + fun(map, cgroup) +} diff --git a/bpf/aya-bpf-bindings/src/armv7/bindings.rs b/bpf/aya-bpf-bindings/src/armv7/bindings.rs index 455ee4fe..f9860f77 100644 --- a/bpf/aya-bpf-bindings/src/armv7/bindings.rs +++ b/bpf/aya-bpf-bindings/src/armv7/bindings.rs @@ -353,16 +353,40 @@ pub struct bpf_cgroup_storage_key { pub cgroup_inode_id: __u64, pub attach_type: __u32, } +pub mod bpf_cgroup_iter_order { + pub type Type = ::aya_bpf_cty::c_uint; + pub const BPF_CGROUP_ITER_ORDER_UNSPEC: Type = 0; + pub const BPF_CGROUP_ITER_SELF_ONLY: Type = 1; + pub const BPF_CGROUP_ITER_DESCENDANTS_PRE: Type = 2; + pub const BPF_CGROUP_ITER_DESCENDANTS_POST: Type = 3; + pub const BPF_CGROUP_ITER_ANCESTORS_UP: Type = 4; +} #[repr(C)] #[derive(Copy, Clone)] pub union bpf_iter_link_info { pub map: bpf_iter_link_info__bindgen_ty_1, + pub cgroup: bpf_iter_link_info__bindgen_ty_2, + pub task: bpf_iter_link_info__bindgen_ty_3, } #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_iter_link_info__bindgen_ty_1 { pub map_fd: __u32, } +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_iter_link_info__bindgen_ty_2 { + pub order: bpf_cgroup_iter_order::Type, + pub cgroup_fd: __u32, + pub cgroup_id: __u64, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_iter_link_info__bindgen_ty_3 { + pub tid: __u32, + pub pid: __u32, + pub pid_fd: __u32, +} pub mod bpf_cmd { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_MAP_CREATE: Type = 0; @@ -424,6 +448,7 @@ pub mod bpf_map_type { pub const BPF_MAP_TYPE_CPUMAP: Type = 16; pub const BPF_MAP_TYPE_XSKMAP: Type = 17; pub const BPF_MAP_TYPE_SOCKHASH: Type = 18; + pub const BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED: Type = 19; pub const BPF_MAP_TYPE_CGROUP_STORAGE: Type = 19; pub const BPF_MAP_TYPE_REUSEPORT_SOCKARRAY: Type = 20; pub const BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE: Type = 21; @@ -436,6 +461,8 @@ pub mod bpf_map_type { pub const BPF_MAP_TYPE_INODE_STORAGE: Type = 28; pub const BPF_MAP_TYPE_TASK_STORAGE: Type = 29; pub const BPF_MAP_TYPE_BLOOM_FILTER: Type = 30; + pub const BPF_MAP_TYPE_USER_RINGBUF: Type = 31; + pub const BPF_MAP_TYPE_CGRP_STORAGE: Type = 32; } pub mod bpf_prog_type { pub type Type = ::aya_bpf_cty::c_uint; @@ -1067,7 +1094,10 @@ pub mod bpf_func_id { pub const BPF_FUNC_tcp_raw_check_syncookie_ipv4: Type = 206; pub const BPF_FUNC_tcp_raw_check_syncookie_ipv6: Type = 207; pub const BPF_FUNC_ktime_get_tai_ns: Type = 208; - pub const __BPF_FUNC_MAX_ID: Type = 209; + pub const BPF_FUNC_user_ringbuf_drain: Type = 209; + pub const BPF_FUNC_cgrp_storage_get: Type = 210; + pub const BPF_FUNC_cgrp_storage_delete: Type = 211; + pub const __BPF_FUNC_MAX_ID: Type = 212; } pub const BPF_F_RECOMPUTE_CSUM: _bindgen_ty_4 = 1; pub const BPF_F_INVALIDATE_HASH: _bindgen_ty_4 = 2; @@ -1091,51 +1121,54 @@ pub type _bindgen_ty_9 = ::aya_bpf_cty::c_uint; pub const BPF_F_ZERO_CSUM_TX: _bindgen_ty_10 = 2; pub const BPF_F_DONT_FRAGMENT: _bindgen_ty_10 = 4; pub const BPF_F_SEQ_NUMBER: _bindgen_ty_10 = 8; +pub const BPF_F_NO_TUNNEL_KEY: _bindgen_ty_10 = 16; pub type _bindgen_ty_10 = ::aya_bpf_cty::c_uint; -pub const BPF_F_INDEX_MASK: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CURRENT_CPU: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CTXLEN_MASK: _bindgen_ty_11 = 4503595332403200; -pub type _bindgen_ty_11 = ::aya_bpf_cty::c_ulonglong; -pub const BPF_F_CURRENT_NETNS: _bindgen_ty_12 = -1; -pub type _bindgen_ty_12 = ::aya_bpf_cty::c_int; -pub const BPF_CSUM_LEVEL_QUERY: _bindgen_ty_13 = 0; -pub const BPF_CSUM_LEVEL_INC: _bindgen_ty_13 = 1; -pub const BPF_CSUM_LEVEL_DEC: _bindgen_ty_13 = 2; -pub const BPF_CSUM_LEVEL_RESET: _bindgen_ty_13 = 3; -pub type _bindgen_ty_13 = ::aya_bpf_cty::c_uint; -pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_14 = 1; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_14 = 2; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_14 = 4; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_14 = 8; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_14 = 16; -pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_14 = 32; -pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_14 = 64; +pub const BPF_F_TUNINFO_FLAGS: _bindgen_ty_11 = 16; +pub type _bindgen_ty_11 = ::aya_bpf_cty::c_uint; +pub const BPF_F_INDEX_MASK: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CURRENT_CPU: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CTXLEN_MASK: _bindgen_ty_12 = 4503595332403200; +pub type _bindgen_ty_12 = ::aya_bpf_cty::c_ulonglong; +pub const BPF_F_CURRENT_NETNS: _bindgen_ty_13 = -1; +pub type _bindgen_ty_13 = ::aya_bpf_cty::c_int; +pub const BPF_CSUM_LEVEL_QUERY: _bindgen_ty_14 = 0; +pub const BPF_CSUM_LEVEL_INC: _bindgen_ty_14 = 1; +pub const BPF_CSUM_LEVEL_DEC: _bindgen_ty_14 = 2; +pub const BPF_CSUM_LEVEL_RESET: _bindgen_ty_14 = 3; pub type _bindgen_ty_14 = ::aya_bpf_cty::c_uint; -pub const BPF_ADJ_ROOM_ENCAP_L2_MASK: _bindgen_ty_15 = 255; -pub const BPF_ADJ_ROOM_ENCAP_L2_SHIFT: _bindgen_ty_15 = 56; +pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_15 = 1; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_15 = 2; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_15 = 4; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_15 = 8; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_15 = 16; +pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_15 = 32; +pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_15 = 64; pub type _bindgen_ty_15 = ::aya_bpf_cty::c_uint; -pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_16 = 1; +pub const BPF_ADJ_ROOM_ENCAP_L2_MASK: _bindgen_ty_16 = 255; +pub const BPF_ADJ_ROOM_ENCAP_L2_SHIFT: _bindgen_ty_16 = 56; pub type _bindgen_ty_16 = ::aya_bpf_cty::c_uint; -pub const BPF_LOCAL_STORAGE_GET_F_CREATE: _bindgen_ty_17 = 1; -pub const BPF_SK_STORAGE_GET_F_CREATE: _bindgen_ty_17 = 1; +pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_17 = 1; pub type _bindgen_ty_17 = ::aya_bpf_cty::c_uint; -pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_18 = 1; +pub const BPF_LOCAL_STORAGE_GET_F_CREATE: _bindgen_ty_18 = 1; +pub const BPF_SK_STORAGE_GET_F_CREATE: _bindgen_ty_18 = 1; pub type _bindgen_ty_18 = ::aya_bpf_cty::c_uint; -pub const BPF_RB_NO_WAKEUP: _bindgen_ty_19 = 1; -pub const BPF_RB_FORCE_WAKEUP: _bindgen_ty_19 = 2; +pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_19 = 1; pub type _bindgen_ty_19 = ::aya_bpf_cty::c_uint; -pub const BPF_RB_AVAIL_DATA: _bindgen_ty_20 = 0; -pub const BPF_RB_RING_SIZE: _bindgen_ty_20 = 1; -pub const BPF_RB_CONS_POS: _bindgen_ty_20 = 2; -pub const BPF_RB_PROD_POS: _bindgen_ty_20 = 3; +pub const BPF_RB_NO_WAKEUP: _bindgen_ty_20 = 1; +pub const BPF_RB_FORCE_WAKEUP: _bindgen_ty_20 = 2; pub type _bindgen_ty_20 = ::aya_bpf_cty::c_uint; -pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_21 = 2147483648; -pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_21 = 1073741824; -pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_21 = 8; +pub const BPF_RB_AVAIL_DATA: _bindgen_ty_21 = 0; +pub const BPF_RB_RING_SIZE: _bindgen_ty_21 = 1; +pub const BPF_RB_CONS_POS: _bindgen_ty_21 = 2; +pub const BPF_RB_PROD_POS: _bindgen_ty_21 = 3; pub type _bindgen_ty_21 = ::aya_bpf_cty::c_uint; -pub const BPF_SK_LOOKUP_F_REPLACE: _bindgen_ty_22 = 1; -pub const BPF_SK_LOOKUP_F_NO_REUSEPORT: _bindgen_ty_22 = 2; +pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_22 = 2147483648; +pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_22 = 1073741824; +pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_22 = 8; pub type _bindgen_ty_22 = ::aya_bpf_cty::c_uint; +pub const BPF_SK_LOOKUP_F_REPLACE: _bindgen_ty_23 = 1; +pub const BPF_SK_LOOKUP_F_NO_REUSEPORT: _bindgen_ty_23 = 2; +pub type _bindgen_ty_23 = ::aya_bpf_cty::c_uint; pub mod bpf_adj_room_mode { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_ADJ_ROOM_NET: Type = 0; @@ -1152,12 +1185,12 @@ pub mod bpf_lwt_encap_mode { pub const BPF_LWT_ENCAP_SEG6_INLINE: Type = 1; pub const BPF_LWT_ENCAP_IP: Type = 2; } -pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_23 = 1; -pub type _bindgen_ty_23 = ::aya_bpf_cty::c_uint; -pub const BPF_F_BROADCAST: _bindgen_ty_24 = 8; -pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_24 = 16; +pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_24 = 1; pub type _bindgen_ty_24 = ::aya_bpf_cty::c_uint; -pub mod _bindgen_ty_25 { +pub const BPF_F_BROADCAST: _bindgen_ty_25 = 8; +pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_25 = 16; +pub type _bindgen_ty_25 = ::aya_bpf_cty::c_uint; +pub mod _bindgen_ty_26 { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_SKB_TSTAMP_UNSPEC: Type = 0; pub const BPF_SKB_TSTAMP_DELIVERY_MONO: Type = 1; @@ -1246,9 +1279,9 @@ pub struct bpf_tunnel_key { pub __bindgen_anon_1: bpf_tunnel_key__bindgen_ty_1, pub tunnel_tos: __u8, pub tunnel_ttl: __u8, - pub tunnel_ext: __u16, - pub tunnel_label: __u32, pub __bindgen_anon_2: bpf_tunnel_key__bindgen_ty_2, + pub tunnel_label: __u32, + pub __bindgen_anon_3: bpf_tunnel_key__bindgen_ty_3, } #[repr(C)] #[derive(Copy, Clone)] @@ -1259,6 +1292,12 @@ pub union bpf_tunnel_key__bindgen_ty_1 { #[repr(C)] #[derive(Copy, Clone)] pub union bpf_tunnel_key__bindgen_ty_2 { + pub tunnel_ext: __u16, + pub tunnel_flags: __be16, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_tunnel_key__bindgen_ty_3 { pub local_ipv4: __u32, pub local_ipv6: [__u32; 4usize], } @@ -1283,6 +1322,7 @@ pub mod bpf_ret_code { pub const BPF_DROP: Type = 2; pub const BPF_REDIRECT: Type = 7; pub const BPF_LWT_REROUTE: Type = 128; + pub const BPF_FLOW_DISSECTOR_CONTINUE: Type = 129; } #[repr(C)] #[derive(Copy, Clone)] @@ -1699,6 +1739,7 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4 { pub target_name: __u64, pub target_name_len: __u32, pub __bindgen_anon_1: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1, + pub __bindgen_anon_2: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2, } #[repr(C)] #[derive(Copy, Clone)] @@ -1712,6 +1753,24 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1 } #[repr(C)] #[derive(Copy, Clone)] +pub union bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2 { + pub cgroup: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1, + pub task: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1 { + pub cgroup_id: __u64, + pub order: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2 { + pub tid: __u32, + pub pid: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_5 { pub netns_ino: __u32, pub attach_type: __u32, @@ -1793,6 +1852,7 @@ pub struct bpf_sock_ops { pub __bindgen_anon_4: bpf_sock_ops__bindgen_ty_4, pub skb_len: __u32, pub skb_tcp_flags: __u32, + pub skb_hwtstamp: __u64, } #[repr(C)] #[derive(Copy, Clone)] @@ -1846,51 +1906,51 @@ impl bpf_sock_ops__bindgen_ty_4 { __bindgen_bitfield_unit } } -pub const BPF_SOCK_OPS_RTO_CB_FLAG: _bindgen_ty_26 = 1; -pub const BPF_SOCK_OPS_RETRANS_CB_FLAG: _bindgen_ty_26 = 2; -pub const BPF_SOCK_OPS_STATE_CB_FLAG: _bindgen_ty_26 = 4; -pub const BPF_SOCK_OPS_RTT_CB_FLAG: _bindgen_ty_26 = 8; -pub const BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG: _bindgen_ty_26 = 16; -pub const BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG: _bindgen_ty_26 = 32; -pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG: _bindgen_ty_26 = 64; -pub const BPF_SOCK_OPS_ALL_CB_FLAGS: _bindgen_ty_26 = 127; -pub type _bindgen_ty_26 = ::aya_bpf_cty::c_uint; -pub const BPF_SOCK_OPS_VOID: _bindgen_ty_27 = 0; -pub const BPF_SOCK_OPS_TIMEOUT_INIT: _bindgen_ty_27 = 1; -pub const BPF_SOCK_OPS_RWND_INIT: _bindgen_ty_27 = 2; -pub const BPF_SOCK_OPS_TCP_CONNECT_CB: _bindgen_ty_27 = 3; -pub const BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: _bindgen_ty_27 = 4; -pub const BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: _bindgen_ty_27 = 5; -pub const BPF_SOCK_OPS_NEEDS_ECN: _bindgen_ty_27 = 6; -pub const BPF_SOCK_OPS_BASE_RTT: _bindgen_ty_27 = 7; -pub const BPF_SOCK_OPS_RTO_CB: _bindgen_ty_27 = 8; -pub const BPF_SOCK_OPS_RETRANS_CB: _bindgen_ty_27 = 9; -pub const BPF_SOCK_OPS_STATE_CB: _bindgen_ty_27 = 10; -pub const BPF_SOCK_OPS_TCP_LISTEN_CB: _bindgen_ty_27 = 11; -pub const BPF_SOCK_OPS_RTT_CB: _bindgen_ty_27 = 12; -pub const BPF_SOCK_OPS_PARSE_HDR_OPT_CB: _bindgen_ty_27 = 13; -pub const BPF_SOCK_OPS_HDR_OPT_LEN_CB: _bindgen_ty_27 = 14; -pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB: _bindgen_ty_27 = 15; +pub const BPF_SOCK_OPS_RTO_CB_FLAG: _bindgen_ty_27 = 1; +pub const BPF_SOCK_OPS_RETRANS_CB_FLAG: _bindgen_ty_27 = 2; +pub const BPF_SOCK_OPS_STATE_CB_FLAG: _bindgen_ty_27 = 4; +pub const BPF_SOCK_OPS_RTT_CB_FLAG: _bindgen_ty_27 = 8; +pub const BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG: _bindgen_ty_27 = 16; +pub const BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG: _bindgen_ty_27 = 32; +pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG: _bindgen_ty_27 = 64; +pub const BPF_SOCK_OPS_ALL_CB_FLAGS: _bindgen_ty_27 = 127; pub type _bindgen_ty_27 = ::aya_bpf_cty::c_uint; -pub const BPF_TCP_ESTABLISHED: _bindgen_ty_28 = 1; -pub const BPF_TCP_SYN_SENT: _bindgen_ty_28 = 2; -pub const BPF_TCP_SYN_RECV: _bindgen_ty_28 = 3; -pub const BPF_TCP_FIN_WAIT1: _bindgen_ty_28 = 4; -pub const BPF_TCP_FIN_WAIT2: _bindgen_ty_28 = 5; -pub const BPF_TCP_TIME_WAIT: _bindgen_ty_28 = 6; -pub const BPF_TCP_CLOSE: _bindgen_ty_28 = 7; -pub const BPF_TCP_CLOSE_WAIT: _bindgen_ty_28 = 8; -pub const BPF_TCP_LAST_ACK: _bindgen_ty_28 = 9; -pub const BPF_TCP_LISTEN: _bindgen_ty_28 = 10; -pub const BPF_TCP_CLOSING: _bindgen_ty_28 = 11; -pub const BPF_TCP_NEW_SYN_RECV: _bindgen_ty_28 = 12; -pub const BPF_TCP_MAX_STATES: _bindgen_ty_28 = 13; +pub const BPF_SOCK_OPS_VOID: _bindgen_ty_28 = 0; +pub const BPF_SOCK_OPS_TIMEOUT_INIT: _bindgen_ty_28 = 1; +pub const BPF_SOCK_OPS_RWND_INIT: _bindgen_ty_28 = 2; +pub const BPF_SOCK_OPS_TCP_CONNECT_CB: _bindgen_ty_28 = 3; +pub const BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: _bindgen_ty_28 = 4; +pub const BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: _bindgen_ty_28 = 5; +pub const BPF_SOCK_OPS_NEEDS_ECN: _bindgen_ty_28 = 6; +pub const BPF_SOCK_OPS_BASE_RTT: _bindgen_ty_28 = 7; +pub const BPF_SOCK_OPS_RTO_CB: _bindgen_ty_28 = 8; +pub const BPF_SOCK_OPS_RETRANS_CB: _bindgen_ty_28 = 9; +pub const BPF_SOCK_OPS_STATE_CB: _bindgen_ty_28 = 10; +pub const BPF_SOCK_OPS_TCP_LISTEN_CB: _bindgen_ty_28 = 11; +pub const BPF_SOCK_OPS_RTT_CB: _bindgen_ty_28 = 12; +pub const BPF_SOCK_OPS_PARSE_HDR_OPT_CB: _bindgen_ty_28 = 13; +pub const BPF_SOCK_OPS_HDR_OPT_LEN_CB: _bindgen_ty_28 = 14; +pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB: _bindgen_ty_28 = 15; pub type _bindgen_ty_28 = ::aya_bpf_cty::c_uint; -pub mod _bindgen_ty_30 { +pub const BPF_TCP_ESTABLISHED: _bindgen_ty_29 = 1; +pub const BPF_TCP_SYN_SENT: _bindgen_ty_29 = 2; +pub const BPF_TCP_SYN_RECV: _bindgen_ty_29 = 3; +pub const BPF_TCP_FIN_WAIT1: _bindgen_ty_29 = 4; +pub const BPF_TCP_FIN_WAIT2: _bindgen_ty_29 = 5; +pub const BPF_TCP_TIME_WAIT: _bindgen_ty_29 = 6; +pub const BPF_TCP_CLOSE: _bindgen_ty_29 = 7; +pub const BPF_TCP_CLOSE_WAIT: _bindgen_ty_29 = 8; +pub const BPF_TCP_LAST_ACK: _bindgen_ty_29 = 9; +pub const BPF_TCP_LISTEN: _bindgen_ty_29 = 10; +pub const BPF_TCP_CLOSING: _bindgen_ty_29 = 11; +pub const BPF_TCP_NEW_SYN_RECV: _bindgen_ty_29 = 12; +pub const BPF_TCP_MAX_STATES: _bindgen_ty_29 = 13; +pub type _bindgen_ty_29 = ::aya_bpf_cty::c_uint; +pub mod _bindgen_ty_31 { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_LOAD_HDR_OPT_TCP_SYN: Type = 1; } -pub mod _bindgen_ty_31 { +pub mod _bindgen_ty_32 { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_WRITE_HDR_TCP_CURRENT_MSS: Type = 1; pub const BPF_WRITE_HDR_TCP_SYNACK_COOKIE: Type = 2; @@ -1902,13 +1962,13 @@ pub struct bpf_perf_event_value { pub enabled: __u64, pub running: __u64, } -pub const BPF_DEVCG_ACC_MKNOD: _bindgen_ty_32 = 1; -pub const BPF_DEVCG_ACC_READ: _bindgen_ty_32 = 2; -pub const BPF_DEVCG_ACC_WRITE: _bindgen_ty_32 = 4; -pub type _bindgen_ty_32 = ::aya_bpf_cty::c_uint; -pub const BPF_DEVCG_DEV_BLOCK: _bindgen_ty_33 = 1; -pub const BPF_DEVCG_DEV_CHAR: _bindgen_ty_33 = 2; +pub const BPF_DEVCG_ACC_MKNOD: _bindgen_ty_33 = 1; +pub const BPF_DEVCG_ACC_READ: _bindgen_ty_33 = 2; +pub const BPF_DEVCG_ACC_WRITE: _bindgen_ty_33 = 4; pub type _bindgen_ty_33 = ::aya_bpf_cty::c_uint; +pub const BPF_DEVCG_DEV_BLOCK: _bindgen_ty_34 = 1; +pub const BPF_DEVCG_DEV_CHAR: _bindgen_ty_34 = 2; +pub type _bindgen_ty_34 = ::aya_bpf_cty::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_cgroup_dev_ctx { @@ -1920,19 +1980,19 @@ pub struct bpf_cgroup_dev_ctx { pub struct bpf_raw_tracepoint_args { pub args: __IncompleteArrayField<__u64>, } -pub const BPF_FIB_LOOKUP_DIRECT: _bindgen_ty_34 = 1; -pub const BPF_FIB_LOOKUP_OUTPUT: _bindgen_ty_34 = 2; -pub type _bindgen_ty_34 = ::aya_bpf_cty::c_uint; -pub const BPF_FIB_LKUP_RET_SUCCESS: _bindgen_ty_35 = 0; -pub const BPF_FIB_LKUP_RET_BLACKHOLE: _bindgen_ty_35 = 1; -pub const BPF_FIB_LKUP_RET_UNREACHABLE: _bindgen_ty_35 = 2; -pub const BPF_FIB_LKUP_RET_PROHIBIT: _bindgen_ty_35 = 3; -pub const BPF_FIB_LKUP_RET_NOT_FWDED: _bindgen_ty_35 = 4; -pub const BPF_FIB_LKUP_RET_FWD_DISABLED: _bindgen_ty_35 = 5; -pub const BPF_FIB_LKUP_RET_UNSUPP_LWT: _bindgen_ty_35 = 6; -pub const BPF_FIB_LKUP_RET_NO_NEIGH: _bindgen_ty_35 = 7; -pub const BPF_FIB_LKUP_RET_FRAG_NEEDED: _bindgen_ty_35 = 8; +pub const BPF_FIB_LOOKUP_DIRECT: _bindgen_ty_35 = 1; +pub const BPF_FIB_LOOKUP_OUTPUT: _bindgen_ty_35 = 2; pub type _bindgen_ty_35 = ::aya_bpf_cty::c_uint; +pub const BPF_FIB_LKUP_RET_SUCCESS: _bindgen_ty_36 = 0; +pub const BPF_FIB_LKUP_RET_BLACKHOLE: _bindgen_ty_36 = 1; +pub const BPF_FIB_LKUP_RET_UNREACHABLE: _bindgen_ty_36 = 2; +pub const BPF_FIB_LKUP_RET_PROHIBIT: _bindgen_ty_36 = 3; +pub const BPF_FIB_LKUP_RET_NOT_FWDED: _bindgen_ty_36 = 4; +pub const BPF_FIB_LKUP_RET_FWD_DISABLED: _bindgen_ty_36 = 5; +pub const BPF_FIB_LKUP_RET_UNSUPP_LWT: _bindgen_ty_36 = 6; +pub const BPF_FIB_LKUP_RET_NO_NEIGH: _bindgen_ty_36 = 7; +pub const BPF_FIB_LKUP_RET_FRAG_NEEDED: _bindgen_ty_36 = 8; +pub type _bindgen_ty_36 = ::aya_bpf_cty::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_fib_lookup { @@ -2006,10 +2066,10 @@ pub mod bpf_task_fd_type { pub const BPF_FD_TYPE_UPROBE: Type = 4; pub const BPF_FD_TYPE_URETPROBE: Type = 5; } -pub const BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG: _bindgen_ty_36 = 1; -pub const BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL: _bindgen_ty_36 = 2; -pub const BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP: _bindgen_ty_36 = 4; -pub type _bindgen_ty_36 = ::aya_bpf_cty::c_uint; +pub const BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG: _bindgen_ty_37 = 1; +pub const BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL: _bindgen_ty_37 = 2; +pub const BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP: _bindgen_ty_37 = 4; +pub type _bindgen_ty_37 = ::aya_bpf_cty::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_flow_keys { @@ -2093,6 +2153,34 @@ impl bpf_dynptr { } } #[repr(C)] +#[repr(align(8))] +#[derive(Copy, Clone)] +pub struct bpf_list_head { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize]>, +} +impl bpf_list_head { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 16usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[repr(align(8))] +#[derive(Copy, Clone)] +pub struct bpf_list_node { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize]>, +} +impl bpf_list_node { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 16usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] #[derive(Copy, Clone)] pub struct bpf_sysctl { pub write: __u32, @@ -2304,6 +2392,11 @@ pub struct task_struct { } #[repr(C)] #[derive(Copy, Clone)] +pub struct cgroup { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Copy, Clone)] pub struct path { _unused: [u8; 0], } diff --git a/bpf/aya-bpf-bindings/src/armv7/helpers.rs b/bpf/aya-bpf-bindings/src/armv7/helpers.rs index 45b2efa2..be465ae5 100644 --- a/bpf/aya-bpf-bindings/src/armv7/helpers.rs +++ b/bpf/aya-bpf-bindings/src/armv7/helpers.rs @@ -461,12 +461,12 @@ pub unsafe fn bpf_skb_adjust_room( } pub unsafe fn bpf_redirect_map( map: *mut ::aya_bpf_cty::c_void, - key: __u32, + key: __u64, flags: __u64, ) -> ::aya_bpf_cty::c_long { let fun: unsafe extern "C" fn( map: *mut ::aya_bpf_cty::c_void, - key: __u32, + key: __u64, flags: __u64, ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(51usize); fun(map, key, flags) @@ -2027,28 +2027,28 @@ pub unsafe fn bpf_ringbuf_discard_dynptr(ptr: *mut bpf_dynptr, flags: __u64) { pub unsafe fn bpf_dynptr_read( dst: *mut ::aya_bpf_cty::c_void, len: __u32, - src: *mut bpf_dynptr, + src: *const bpf_dynptr, offset: __u32, flags: __u64, ) -> ::aya_bpf_cty::c_long { let fun: unsafe extern "C" fn( dst: *mut ::aya_bpf_cty::c_void, len: __u32, - src: *mut bpf_dynptr, + src: *const bpf_dynptr, offset: __u32, flags: __u64, ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(201usize); fun(dst, len, src, offset, flags) } pub unsafe fn bpf_dynptr_write( - dst: *mut bpf_dynptr, + dst: *const bpf_dynptr, offset: __u32, src: *mut ::aya_bpf_cty::c_void, len: __u32, flags: __u64, ) -> ::aya_bpf_cty::c_long { let fun: unsafe extern "C" fn( - dst: *mut bpf_dynptr, + dst: *const bpf_dynptr, offset: __u32, src: *mut ::aya_bpf_cty::c_void, len: __u32, @@ -2057,12 +2057,12 @@ pub unsafe fn bpf_dynptr_write( fun(dst, offset, src, len, flags) } pub unsafe fn bpf_dynptr_data( - ptr: *mut bpf_dynptr, + ptr: *const bpf_dynptr, offset: __u32, len: __u32, ) -> *mut ::aya_bpf_cty::c_void { let fun: unsafe extern "C" fn( - ptr: *mut bpf_dynptr, + ptr: *const bpf_dynptr, offset: __u32, len: __u32, ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(203usize); @@ -2106,3 +2106,41 @@ pub unsafe fn bpf_ktime_get_tai_ns() -> __u64 { let fun: unsafe extern "C" fn() -> __u64 = ::core::mem::transmute(208usize); fun() } +pub unsafe fn bpf_user_ringbuf_drain( + map: *mut ::aya_bpf_cty::c_void, + callback_fn: *mut ::aya_bpf_cty::c_void, + ctx: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let fun: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + callback_fn: *mut ::aya_bpf_cty::c_void, + ctx: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(209usize); + fun(map, callback_fn, ctx, flags) +} +pub unsafe fn bpf_cgrp_storage_get( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> *mut ::aya_bpf_cty::c_void { + let fun: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(210usize); + fun(map, cgroup, value, flags) +} +pub unsafe fn bpf_cgrp_storage_delete( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, +) -> ::aya_bpf_cty::c_long { + let fun: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(211usize); + fun(map, cgroup) +} diff --git a/bpf/aya-bpf-bindings/src/riscv64/bindings.rs b/bpf/aya-bpf-bindings/src/riscv64/bindings.rs index ef4185de..6e6f13ce 100644 --- a/bpf/aya-bpf-bindings/src/riscv64/bindings.rs +++ b/bpf/aya-bpf-bindings/src/riscv64/bindings.rs @@ -358,16 +358,40 @@ pub struct bpf_cgroup_storage_key { pub cgroup_inode_id: __u64, pub attach_type: __u32, } +pub mod bpf_cgroup_iter_order { + pub type Type = ::aya_bpf_cty::c_uint; + pub const BPF_CGROUP_ITER_ORDER_UNSPEC: Type = 0; + pub const BPF_CGROUP_ITER_SELF_ONLY: Type = 1; + pub const BPF_CGROUP_ITER_DESCENDANTS_PRE: Type = 2; + pub const BPF_CGROUP_ITER_DESCENDANTS_POST: Type = 3; + pub const BPF_CGROUP_ITER_ANCESTORS_UP: Type = 4; +} #[repr(C)] #[derive(Copy, Clone)] pub union bpf_iter_link_info { pub map: bpf_iter_link_info__bindgen_ty_1, + pub cgroup: bpf_iter_link_info__bindgen_ty_2, + pub task: bpf_iter_link_info__bindgen_ty_3, } #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_iter_link_info__bindgen_ty_1 { pub map_fd: __u32, } +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_iter_link_info__bindgen_ty_2 { + pub order: bpf_cgroup_iter_order::Type, + pub cgroup_fd: __u32, + pub cgroup_id: __u64, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_iter_link_info__bindgen_ty_3 { + pub tid: __u32, + pub pid: __u32, + pub pid_fd: __u32, +} pub mod bpf_cmd { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_MAP_CREATE: Type = 0; @@ -429,6 +453,7 @@ pub mod bpf_map_type { pub const BPF_MAP_TYPE_CPUMAP: Type = 16; pub const BPF_MAP_TYPE_XSKMAP: Type = 17; pub const BPF_MAP_TYPE_SOCKHASH: Type = 18; + pub const BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED: Type = 19; pub const BPF_MAP_TYPE_CGROUP_STORAGE: Type = 19; pub const BPF_MAP_TYPE_REUSEPORT_SOCKARRAY: Type = 20; pub const BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE: Type = 21; @@ -441,6 +466,8 @@ pub mod bpf_map_type { pub const BPF_MAP_TYPE_INODE_STORAGE: Type = 28; pub const BPF_MAP_TYPE_TASK_STORAGE: Type = 29; pub const BPF_MAP_TYPE_BLOOM_FILTER: Type = 30; + pub const BPF_MAP_TYPE_USER_RINGBUF: Type = 31; + pub const BPF_MAP_TYPE_CGRP_STORAGE: Type = 32; } pub mod bpf_prog_type { pub type Type = ::aya_bpf_cty::c_uint; @@ -1072,7 +1099,10 @@ pub mod bpf_func_id { pub const BPF_FUNC_tcp_raw_check_syncookie_ipv4: Type = 206; pub const BPF_FUNC_tcp_raw_check_syncookie_ipv6: Type = 207; pub const BPF_FUNC_ktime_get_tai_ns: Type = 208; - pub const __BPF_FUNC_MAX_ID: Type = 209; + pub const BPF_FUNC_user_ringbuf_drain: Type = 209; + pub const BPF_FUNC_cgrp_storage_get: Type = 210; + pub const BPF_FUNC_cgrp_storage_delete: Type = 211; + pub const __BPF_FUNC_MAX_ID: Type = 212; } pub const BPF_F_RECOMPUTE_CSUM: _bindgen_ty_4 = 1; pub const BPF_F_INVALIDATE_HASH: _bindgen_ty_4 = 2; @@ -1096,51 +1126,54 @@ pub type _bindgen_ty_9 = ::aya_bpf_cty::c_uint; pub const BPF_F_ZERO_CSUM_TX: _bindgen_ty_10 = 2; pub const BPF_F_DONT_FRAGMENT: _bindgen_ty_10 = 4; pub const BPF_F_SEQ_NUMBER: _bindgen_ty_10 = 8; +pub const BPF_F_NO_TUNNEL_KEY: _bindgen_ty_10 = 16; pub type _bindgen_ty_10 = ::aya_bpf_cty::c_uint; -pub const BPF_F_INDEX_MASK: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CURRENT_CPU: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CTXLEN_MASK: _bindgen_ty_11 = 4503595332403200; -pub type _bindgen_ty_11 = ::aya_bpf_cty::c_ulong; -pub const BPF_F_CURRENT_NETNS: _bindgen_ty_12 = -1; -pub type _bindgen_ty_12 = ::aya_bpf_cty::c_int; -pub const BPF_CSUM_LEVEL_QUERY: _bindgen_ty_13 = 0; -pub const BPF_CSUM_LEVEL_INC: _bindgen_ty_13 = 1; -pub const BPF_CSUM_LEVEL_DEC: _bindgen_ty_13 = 2; -pub const BPF_CSUM_LEVEL_RESET: _bindgen_ty_13 = 3; -pub type _bindgen_ty_13 = ::aya_bpf_cty::c_uint; -pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_14 = 1; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_14 = 2; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_14 = 4; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_14 = 8; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_14 = 16; -pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_14 = 32; -pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_14 = 64; +pub const BPF_F_TUNINFO_FLAGS: _bindgen_ty_11 = 16; +pub type _bindgen_ty_11 = ::aya_bpf_cty::c_uint; +pub const BPF_F_INDEX_MASK: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CURRENT_CPU: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CTXLEN_MASK: _bindgen_ty_12 = 4503595332403200; +pub type _bindgen_ty_12 = ::aya_bpf_cty::c_ulong; +pub const BPF_F_CURRENT_NETNS: _bindgen_ty_13 = -1; +pub type _bindgen_ty_13 = ::aya_bpf_cty::c_int; +pub const BPF_CSUM_LEVEL_QUERY: _bindgen_ty_14 = 0; +pub const BPF_CSUM_LEVEL_INC: _bindgen_ty_14 = 1; +pub const BPF_CSUM_LEVEL_DEC: _bindgen_ty_14 = 2; +pub const BPF_CSUM_LEVEL_RESET: _bindgen_ty_14 = 3; pub type _bindgen_ty_14 = ::aya_bpf_cty::c_uint; -pub const BPF_ADJ_ROOM_ENCAP_L2_MASK: _bindgen_ty_15 = 255; -pub const BPF_ADJ_ROOM_ENCAP_L2_SHIFT: _bindgen_ty_15 = 56; +pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_15 = 1; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_15 = 2; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_15 = 4; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_15 = 8; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_15 = 16; +pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_15 = 32; +pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_15 = 64; pub type _bindgen_ty_15 = ::aya_bpf_cty::c_uint; -pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_16 = 1; +pub const BPF_ADJ_ROOM_ENCAP_L2_MASK: _bindgen_ty_16 = 255; +pub const BPF_ADJ_ROOM_ENCAP_L2_SHIFT: _bindgen_ty_16 = 56; pub type _bindgen_ty_16 = ::aya_bpf_cty::c_uint; -pub const BPF_LOCAL_STORAGE_GET_F_CREATE: _bindgen_ty_17 = 1; -pub const BPF_SK_STORAGE_GET_F_CREATE: _bindgen_ty_17 = 1; +pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_17 = 1; pub type _bindgen_ty_17 = ::aya_bpf_cty::c_uint; -pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_18 = 1; +pub const BPF_LOCAL_STORAGE_GET_F_CREATE: _bindgen_ty_18 = 1; +pub const BPF_SK_STORAGE_GET_F_CREATE: _bindgen_ty_18 = 1; pub type _bindgen_ty_18 = ::aya_bpf_cty::c_uint; -pub const BPF_RB_NO_WAKEUP: _bindgen_ty_19 = 1; -pub const BPF_RB_FORCE_WAKEUP: _bindgen_ty_19 = 2; +pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_19 = 1; pub type _bindgen_ty_19 = ::aya_bpf_cty::c_uint; -pub const BPF_RB_AVAIL_DATA: _bindgen_ty_20 = 0; -pub const BPF_RB_RING_SIZE: _bindgen_ty_20 = 1; -pub const BPF_RB_CONS_POS: _bindgen_ty_20 = 2; -pub const BPF_RB_PROD_POS: _bindgen_ty_20 = 3; +pub const BPF_RB_NO_WAKEUP: _bindgen_ty_20 = 1; +pub const BPF_RB_FORCE_WAKEUP: _bindgen_ty_20 = 2; pub type _bindgen_ty_20 = ::aya_bpf_cty::c_uint; -pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_21 = 2147483648; -pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_21 = 1073741824; -pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_21 = 8; +pub const BPF_RB_AVAIL_DATA: _bindgen_ty_21 = 0; +pub const BPF_RB_RING_SIZE: _bindgen_ty_21 = 1; +pub const BPF_RB_CONS_POS: _bindgen_ty_21 = 2; +pub const BPF_RB_PROD_POS: _bindgen_ty_21 = 3; pub type _bindgen_ty_21 = ::aya_bpf_cty::c_uint; -pub const BPF_SK_LOOKUP_F_REPLACE: _bindgen_ty_22 = 1; -pub const BPF_SK_LOOKUP_F_NO_REUSEPORT: _bindgen_ty_22 = 2; +pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_22 = 2147483648; +pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_22 = 1073741824; +pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_22 = 8; pub type _bindgen_ty_22 = ::aya_bpf_cty::c_uint; +pub const BPF_SK_LOOKUP_F_REPLACE: _bindgen_ty_23 = 1; +pub const BPF_SK_LOOKUP_F_NO_REUSEPORT: _bindgen_ty_23 = 2; +pub type _bindgen_ty_23 = ::aya_bpf_cty::c_uint; pub mod bpf_adj_room_mode { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_ADJ_ROOM_NET: Type = 0; @@ -1157,12 +1190,12 @@ pub mod bpf_lwt_encap_mode { pub const BPF_LWT_ENCAP_SEG6_INLINE: Type = 1; pub const BPF_LWT_ENCAP_IP: Type = 2; } -pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_23 = 1; -pub type _bindgen_ty_23 = ::aya_bpf_cty::c_uint; -pub const BPF_F_BROADCAST: _bindgen_ty_24 = 8; -pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_24 = 16; +pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_24 = 1; pub type _bindgen_ty_24 = ::aya_bpf_cty::c_uint; -pub mod _bindgen_ty_25 { +pub const BPF_F_BROADCAST: _bindgen_ty_25 = 8; +pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_25 = 16; +pub type _bindgen_ty_25 = ::aya_bpf_cty::c_uint; +pub mod _bindgen_ty_26 { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_SKB_TSTAMP_UNSPEC: Type = 0; pub const BPF_SKB_TSTAMP_DELIVERY_MONO: Type = 1; @@ -1249,9 +1282,9 @@ pub struct bpf_tunnel_key { pub __bindgen_anon_1: bpf_tunnel_key__bindgen_ty_1, pub tunnel_tos: __u8, pub tunnel_ttl: __u8, - pub tunnel_ext: __u16, - pub tunnel_label: __u32, pub __bindgen_anon_2: bpf_tunnel_key__bindgen_ty_2, + pub tunnel_label: __u32, + pub __bindgen_anon_3: bpf_tunnel_key__bindgen_ty_3, } #[repr(C)] #[derive(Copy, Clone)] @@ -1262,6 +1295,12 @@ pub union bpf_tunnel_key__bindgen_ty_1 { #[repr(C)] #[derive(Copy, Clone)] pub union bpf_tunnel_key__bindgen_ty_2 { + pub tunnel_ext: __u16, + pub tunnel_flags: __be16, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_tunnel_key__bindgen_ty_3 { pub local_ipv4: __u32, pub local_ipv6: [__u32; 4usize], } @@ -1286,6 +1325,7 @@ pub mod bpf_ret_code { pub const BPF_DROP: Type = 2; pub const BPF_REDIRECT: Type = 7; pub const BPF_LWT_REROUTE: Type = 128; + pub const BPF_FLOW_DISSECTOR_CONTINUE: Type = 129; } #[repr(C)] #[derive(Copy, Clone)] @@ -1695,6 +1735,7 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4 { pub target_name: __u64, pub target_name_len: __u32, pub __bindgen_anon_1: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1, + pub __bindgen_anon_2: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2, } #[repr(C)] #[derive(Copy, Clone)] @@ -1708,6 +1749,24 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1 } #[repr(C)] #[derive(Copy, Clone)] +pub union bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2 { + pub cgroup: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1, + pub task: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1 { + pub cgroup_id: __u64, + pub order: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2 { + pub tid: __u32, + pub pid: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_5 { pub netns_ino: __u32, pub attach_type: __u32, @@ -1788,6 +1847,7 @@ pub struct bpf_sock_ops { pub __bindgen_anon_4: bpf_sock_ops__bindgen_ty_4, pub skb_len: __u32, pub skb_tcp_flags: __u32, + pub skb_hwtstamp: __u64, } #[repr(C)] #[derive(Copy, Clone)] @@ -1838,51 +1898,51 @@ impl bpf_sock_ops__bindgen_ty_4 { __bindgen_bitfield_unit } } -pub const BPF_SOCK_OPS_RTO_CB_FLAG: _bindgen_ty_26 = 1; -pub const BPF_SOCK_OPS_RETRANS_CB_FLAG: _bindgen_ty_26 = 2; -pub const BPF_SOCK_OPS_STATE_CB_FLAG: _bindgen_ty_26 = 4; -pub const BPF_SOCK_OPS_RTT_CB_FLAG: _bindgen_ty_26 = 8; -pub const BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG: _bindgen_ty_26 = 16; -pub const BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG: _bindgen_ty_26 = 32; -pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG: _bindgen_ty_26 = 64; -pub const BPF_SOCK_OPS_ALL_CB_FLAGS: _bindgen_ty_26 = 127; -pub type _bindgen_ty_26 = ::aya_bpf_cty::c_uint; -pub const BPF_SOCK_OPS_VOID: _bindgen_ty_27 = 0; -pub const BPF_SOCK_OPS_TIMEOUT_INIT: _bindgen_ty_27 = 1; -pub const BPF_SOCK_OPS_RWND_INIT: _bindgen_ty_27 = 2; -pub const BPF_SOCK_OPS_TCP_CONNECT_CB: _bindgen_ty_27 = 3; -pub const BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: _bindgen_ty_27 = 4; -pub const BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: _bindgen_ty_27 = 5; -pub const BPF_SOCK_OPS_NEEDS_ECN: _bindgen_ty_27 = 6; -pub const BPF_SOCK_OPS_BASE_RTT: _bindgen_ty_27 = 7; -pub const BPF_SOCK_OPS_RTO_CB: _bindgen_ty_27 = 8; -pub const BPF_SOCK_OPS_RETRANS_CB: _bindgen_ty_27 = 9; -pub const BPF_SOCK_OPS_STATE_CB: _bindgen_ty_27 = 10; -pub const BPF_SOCK_OPS_TCP_LISTEN_CB: _bindgen_ty_27 = 11; -pub const BPF_SOCK_OPS_RTT_CB: _bindgen_ty_27 = 12; -pub const BPF_SOCK_OPS_PARSE_HDR_OPT_CB: _bindgen_ty_27 = 13; -pub const BPF_SOCK_OPS_HDR_OPT_LEN_CB: _bindgen_ty_27 = 14; -pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB: _bindgen_ty_27 = 15; +pub const BPF_SOCK_OPS_RTO_CB_FLAG: _bindgen_ty_27 = 1; +pub const BPF_SOCK_OPS_RETRANS_CB_FLAG: _bindgen_ty_27 = 2; +pub const BPF_SOCK_OPS_STATE_CB_FLAG: _bindgen_ty_27 = 4; +pub const BPF_SOCK_OPS_RTT_CB_FLAG: _bindgen_ty_27 = 8; +pub const BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG: _bindgen_ty_27 = 16; +pub const BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG: _bindgen_ty_27 = 32; +pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG: _bindgen_ty_27 = 64; +pub const BPF_SOCK_OPS_ALL_CB_FLAGS: _bindgen_ty_27 = 127; pub type _bindgen_ty_27 = ::aya_bpf_cty::c_uint; -pub const BPF_TCP_ESTABLISHED: _bindgen_ty_28 = 1; -pub const BPF_TCP_SYN_SENT: _bindgen_ty_28 = 2; -pub const BPF_TCP_SYN_RECV: _bindgen_ty_28 = 3; -pub const BPF_TCP_FIN_WAIT1: _bindgen_ty_28 = 4; -pub const BPF_TCP_FIN_WAIT2: _bindgen_ty_28 = 5; -pub const BPF_TCP_TIME_WAIT: _bindgen_ty_28 = 6; -pub const BPF_TCP_CLOSE: _bindgen_ty_28 = 7; -pub const BPF_TCP_CLOSE_WAIT: _bindgen_ty_28 = 8; -pub const BPF_TCP_LAST_ACK: _bindgen_ty_28 = 9; -pub const BPF_TCP_LISTEN: _bindgen_ty_28 = 10; -pub const BPF_TCP_CLOSING: _bindgen_ty_28 = 11; -pub const BPF_TCP_NEW_SYN_RECV: _bindgen_ty_28 = 12; -pub const BPF_TCP_MAX_STATES: _bindgen_ty_28 = 13; +pub const BPF_SOCK_OPS_VOID: _bindgen_ty_28 = 0; +pub const BPF_SOCK_OPS_TIMEOUT_INIT: _bindgen_ty_28 = 1; +pub const BPF_SOCK_OPS_RWND_INIT: _bindgen_ty_28 = 2; +pub const BPF_SOCK_OPS_TCP_CONNECT_CB: _bindgen_ty_28 = 3; +pub const BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: _bindgen_ty_28 = 4; +pub const BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: _bindgen_ty_28 = 5; +pub const BPF_SOCK_OPS_NEEDS_ECN: _bindgen_ty_28 = 6; +pub const BPF_SOCK_OPS_BASE_RTT: _bindgen_ty_28 = 7; +pub const BPF_SOCK_OPS_RTO_CB: _bindgen_ty_28 = 8; +pub const BPF_SOCK_OPS_RETRANS_CB: _bindgen_ty_28 = 9; +pub const BPF_SOCK_OPS_STATE_CB: _bindgen_ty_28 = 10; +pub const BPF_SOCK_OPS_TCP_LISTEN_CB: _bindgen_ty_28 = 11; +pub const BPF_SOCK_OPS_RTT_CB: _bindgen_ty_28 = 12; +pub const BPF_SOCK_OPS_PARSE_HDR_OPT_CB: _bindgen_ty_28 = 13; +pub const BPF_SOCK_OPS_HDR_OPT_LEN_CB: _bindgen_ty_28 = 14; +pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB: _bindgen_ty_28 = 15; pub type _bindgen_ty_28 = ::aya_bpf_cty::c_uint; -pub mod _bindgen_ty_30 { +pub const BPF_TCP_ESTABLISHED: _bindgen_ty_29 = 1; +pub const BPF_TCP_SYN_SENT: _bindgen_ty_29 = 2; +pub const BPF_TCP_SYN_RECV: _bindgen_ty_29 = 3; +pub const BPF_TCP_FIN_WAIT1: _bindgen_ty_29 = 4; +pub const BPF_TCP_FIN_WAIT2: _bindgen_ty_29 = 5; +pub const BPF_TCP_TIME_WAIT: _bindgen_ty_29 = 6; +pub const BPF_TCP_CLOSE: _bindgen_ty_29 = 7; +pub const BPF_TCP_CLOSE_WAIT: _bindgen_ty_29 = 8; +pub const BPF_TCP_LAST_ACK: _bindgen_ty_29 = 9; +pub const BPF_TCP_LISTEN: _bindgen_ty_29 = 10; +pub const BPF_TCP_CLOSING: _bindgen_ty_29 = 11; +pub const BPF_TCP_NEW_SYN_RECV: _bindgen_ty_29 = 12; +pub const BPF_TCP_MAX_STATES: _bindgen_ty_29 = 13; +pub type _bindgen_ty_29 = ::aya_bpf_cty::c_uint; +pub mod _bindgen_ty_31 { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_LOAD_HDR_OPT_TCP_SYN: Type = 1; } -pub mod _bindgen_ty_31 { +pub mod _bindgen_ty_32 { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_WRITE_HDR_TCP_CURRENT_MSS: Type = 1; pub const BPF_WRITE_HDR_TCP_SYNACK_COOKIE: Type = 2; @@ -1894,13 +1954,13 @@ pub struct bpf_perf_event_value { pub enabled: __u64, pub running: __u64, } -pub const BPF_DEVCG_ACC_MKNOD: _bindgen_ty_32 = 1; -pub const BPF_DEVCG_ACC_READ: _bindgen_ty_32 = 2; -pub const BPF_DEVCG_ACC_WRITE: _bindgen_ty_32 = 4; -pub type _bindgen_ty_32 = ::aya_bpf_cty::c_uint; -pub const BPF_DEVCG_DEV_BLOCK: _bindgen_ty_33 = 1; -pub const BPF_DEVCG_DEV_CHAR: _bindgen_ty_33 = 2; +pub const BPF_DEVCG_ACC_MKNOD: _bindgen_ty_33 = 1; +pub const BPF_DEVCG_ACC_READ: _bindgen_ty_33 = 2; +pub const BPF_DEVCG_ACC_WRITE: _bindgen_ty_33 = 4; pub type _bindgen_ty_33 = ::aya_bpf_cty::c_uint; +pub const BPF_DEVCG_DEV_BLOCK: _bindgen_ty_34 = 1; +pub const BPF_DEVCG_DEV_CHAR: _bindgen_ty_34 = 2; +pub type _bindgen_ty_34 = ::aya_bpf_cty::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_cgroup_dev_ctx { @@ -1912,19 +1972,19 @@ pub struct bpf_cgroup_dev_ctx { pub struct bpf_raw_tracepoint_args { pub args: __IncompleteArrayField<__u64>, } -pub const BPF_FIB_LOOKUP_DIRECT: _bindgen_ty_34 = 1; -pub const BPF_FIB_LOOKUP_OUTPUT: _bindgen_ty_34 = 2; -pub type _bindgen_ty_34 = ::aya_bpf_cty::c_uint; -pub const BPF_FIB_LKUP_RET_SUCCESS: _bindgen_ty_35 = 0; -pub const BPF_FIB_LKUP_RET_BLACKHOLE: _bindgen_ty_35 = 1; -pub const BPF_FIB_LKUP_RET_UNREACHABLE: _bindgen_ty_35 = 2; -pub const BPF_FIB_LKUP_RET_PROHIBIT: _bindgen_ty_35 = 3; -pub const BPF_FIB_LKUP_RET_NOT_FWDED: _bindgen_ty_35 = 4; -pub const BPF_FIB_LKUP_RET_FWD_DISABLED: _bindgen_ty_35 = 5; -pub const BPF_FIB_LKUP_RET_UNSUPP_LWT: _bindgen_ty_35 = 6; -pub const BPF_FIB_LKUP_RET_NO_NEIGH: _bindgen_ty_35 = 7; -pub const BPF_FIB_LKUP_RET_FRAG_NEEDED: _bindgen_ty_35 = 8; +pub const BPF_FIB_LOOKUP_DIRECT: _bindgen_ty_35 = 1; +pub const BPF_FIB_LOOKUP_OUTPUT: _bindgen_ty_35 = 2; pub type _bindgen_ty_35 = ::aya_bpf_cty::c_uint; +pub const BPF_FIB_LKUP_RET_SUCCESS: _bindgen_ty_36 = 0; +pub const BPF_FIB_LKUP_RET_BLACKHOLE: _bindgen_ty_36 = 1; +pub const BPF_FIB_LKUP_RET_UNREACHABLE: _bindgen_ty_36 = 2; +pub const BPF_FIB_LKUP_RET_PROHIBIT: _bindgen_ty_36 = 3; +pub const BPF_FIB_LKUP_RET_NOT_FWDED: _bindgen_ty_36 = 4; +pub const BPF_FIB_LKUP_RET_FWD_DISABLED: _bindgen_ty_36 = 5; +pub const BPF_FIB_LKUP_RET_UNSUPP_LWT: _bindgen_ty_36 = 6; +pub const BPF_FIB_LKUP_RET_NO_NEIGH: _bindgen_ty_36 = 7; +pub const BPF_FIB_LKUP_RET_FRAG_NEEDED: _bindgen_ty_36 = 8; +pub type _bindgen_ty_36 = ::aya_bpf_cty::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_fib_lookup { @@ -1998,10 +2058,10 @@ pub mod bpf_task_fd_type { pub const BPF_FD_TYPE_UPROBE: Type = 4; pub const BPF_FD_TYPE_URETPROBE: Type = 5; } -pub const BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG: _bindgen_ty_36 = 1; -pub const BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL: _bindgen_ty_36 = 2; -pub const BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP: _bindgen_ty_36 = 4; -pub type _bindgen_ty_36 = ::aya_bpf_cty::c_uint; +pub const BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG: _bindgen_ty_37 = 1; +pub const BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL: _bindgen_ty_37 = 2; +pub const BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP: _bindgen_ty_37 = 4; +pub type _bindgen_ty_37 = ::aya_bpf_cty::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_flow_keys { @@ -2085,6 +2145,34 @@ impl bpf_dynptr { } } #[repr(C)] +#[repr(align(8))] +#[derive(Copy, Clone)] +pub struct bpf_list_head { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize]>, +} +impl bpf_list_head { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 16usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[repr(align(8))] +#[derive(Copy, Clone)] +pub struct bpf_list_node { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize]>, +} +impl bpf_list_node { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 16usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] #[derive(Copy, Clone)] pub struct bpf_sysctl { pub write: __u32, @@ -2292,6 +2380,11 @@ pub struct task_struct { } #[repr(C)] #[derive(Copy, Clone)] +pub struct cgroup { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Copy, Clone)] pub struct path { _unused: [u8; 0], } diff --git a/bpf/aya-bpf-bindings/src/riscv64/helpers.rs b/bpf/aya-bpf-bindings/src/riscv64/helpers.rs index 45b2efa2..be465ae5 100644 --- a/bpf/aya-bpf-bindings/src/riscv64/helpers.rs +++ b/bpf/aya-bpf-bindings/src/riscv64/helpers.rs @@ -461,12 +461,12 @@ pub unsafe fn bpf_skb_adjust_room( } pub unsafe fn bpf_redirect_map( map: *mut ::aya_bpf_cty::c_void, - key: __u32, + key: __u64, flags: __u64, ) -> ::aya_bpf_cty::c_long { let fun: unsafe extern "C" fn( map: *mut ::aya_bpf_cty::c_void, - key: __u32, + key: __u64, flags: __u64, ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(51usize); fun(map, key, flags) @@ -2027,28 +2027,28 @@ pub unsafe fn bpf_ringbuf_discard_dynptr(ptr: *mut bpf_dynptr, flags: __u64) { pub unsafe fn bpf_dynptr_read( dst: *mut ::aya_bpf_cty::c_void, len: __u32, - src: *mut bpf_dynptr, + src: *const bpf_dynptr, offset: __u32, flags: __u64, ) -> ::aya_bpf_cty::c_long { let fun: unsafe extern "C" fn( dst: *mut ::aya_bpf_cty::c_void, len: __u32, - src: *mut bpf_dynptr, + src: *const bpf_dynptr, offset: __u32, flags: __u64, ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(201usize); fun(dst, len, src, offset, flags) } pub unsafe fn bpf_dynptr_write( - dst: *mut bpf_dynptr, + dst: *const bpf_dynptr, offset: __u32, src: *mut ::aya_bpf_cty::c_void, len: __u32, flags: __u64, ) -> ::aya_bpf_cty::c_long { let fun: unsafe extern "C" fn( - dst: *mut bpf_dynptr, + dst: *const bpf_dynptr, offset: __u32, src: *mut ::aya_bpf_cty::c_void, len: __u32, @@ -2057,12 +2057,12 @@ pub unsafe fn bpf_dynptr_write( fun(dst, offset, src, len, flags) } pub unsafe fn bpf_dynptr_data( - ptr: *mut bpf_dynptr, + ptr: *const bpf_dynptr, offset: __u32, len: __u32, ) -> *mut ::aya_bpf_cty::c_void { let fun: unsafe extern "C" fn( - ptr: *mut bpf_dynptr, + ptr: *const bpf_dynptr, offset: __u32, len: __u32, ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(203usize); @@ -2106,3 +2106,41 @@ pub unsafe fn bpf_ktime_get_tai_ns() -> __u64 { let fun: unsafe extern "C" fn() -> __u64 = ::core::mem::transmute(208usize); fun() } +pub unsafe fn bpf_user_ringbuf_drain( + map: *mut ::aya_bpf_cty::c_void, + callback_fn: *mut ::aya_bpf_cty::c_void, + ctx: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let fun: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + callback_fn: *mut ::aya_bpf_cty::c_void, + ctx: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(209usize); + fun(map, callback_fn, ctx, flags) +} +pub unsafe fn bpf_cgrp_storage_get( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> *mut ::aya_bpf_cty::c_void { + let fun: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(210usize); + fun(map, cgroup, value, flags) +} +pub unsafe fn bpf_cgrp_storage_delete( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, +) -> ::aya_bpf_cty::c_long { + let fun: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(211usize); + fun(map, cgroup) +} diff --git a/bpf/aya-bpf-bindings/src/x86_64/bindings.rs b/bpf/aya-bpf-bindings/src/x86_64/bindings.rs index 23a44d35..3eb2762c 100644 --- a/bpf/aya-bpf-bindings/src/x86_64/bindings.rs +++ b/bpf/aya-bpf-bindings/src/x86_64/bindings.rs @@ -358,16 +358,40 @@ pub struct bpf_cgroup_storage_key { pub cgroup_inode_id: __u64, pub attach_type: __u32, } +pub mod bpf_cgroup_iter_order { + pub type Type = ::aya_bpf_cty::c_uint; + pub const BPF_CGROUP_ITER_ORDER_UNSPEC: Type = 0; + pub const BPF_CGROUP_ITER_SELF_ONLY: Type = 1; + pub const BPF_CGROUP_ITER_DESCENDANTS_PRE: Type = 2; + pub const BPF_CGROUP_ITER_DESCENDANTS_POST: Type = 3; + pub const BPF_CGROUP_ITER_ANCESTORS_UP: Type = 4; +} #[repr(C)] #[derive(Copy, Clone)] pub union bpf_iter_link_info { pub map: bpf_iter_link_info__bindgen_ty_1, + pub cgroup: bpf_iter_link_info__bindgen_ty_2, + pub task: bpf_iter_link_info__bindgen_ty_3, } #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_iter_link_info__bindgen_ty_1 { pub map_fd: __u32, } +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_iter_link_info__bindgen_ty_2 { + pub order: bpf_cgroup_iter_order::Type, + pub cgroup_fd: __u32, + pub cgroup_id: __u64, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_iter_link_info__bindgen_ty_3 { + pub tid: __u32, + pub pid: __u32, + pub pid_fd: __u32, +} pub mod bpf_cmd { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_MAP_CREATE: Type = 0; @@ -429,6 +453,7 @@ pub mod bpf_map_type { pub const BPF_MAP_TYPE_CPUMAP: Type = 16; pub const BPF_MAP_TYPE_XSKMAP: Type = 17; pub const BPF_MAP_TYPE_SOCKHASH: Type = 18; + pub const BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED: Type = 19; pub const BPF_MAP_TYPE_CGROUP_STORAGE: Type = 19; pub const BPF_MAP_TYPE_REUSEPORT_SOCKARRAY: Type = 20; pub const BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE: Type = 21; @@ -441,6 +466,8 @@ pub mod bpf_map_type { pub const BPF_MAP_TYPE_INODE_STORAGE: Type = 28; pub const BPF_MAP_TYPE_TASK_STORAGE: Type = 29; pub const BPF_MAP_TYPE_BLOOM_FILTER: Type = 30; + pub const BPF_MAP_TYPE_USER_RINGBUF: Type = 31; + pub const BPF_MAP_TYPE_CGRP_STORAGE: Type = 32; } pub mod bpf_prog_type { pub type Type = ::aya_bpf_cty::c_uint; @@ -1072,7 +1099,10 @@ pub mod bpf_func_id { pub const BPF_FUNC_tcp_raw_check_syncookie_ipv4: Type = 206; pub const BPF_FUNC_tcp_raw_check_syncookie_ipv6: Type = 207; pub const BPF_FUNC_ktime_get_tai_ns: Type = 208; - pub const __BPF_FUNC_MAX_ID: Type = 209; + pub const BPF_FUNC_user_ringbuf_drain: Type = 209; + pub const BPF_FUNC_cgrp_storage_get: Type = 210; + pub const BPF_FUNC_cgrp_storage_delete: Type = 211; + pub const __BPF_FUNC_MAX_ID: Type = 212; } pub const BPF_F_RECOMPUTE_CSUM: _bindgen_ty_4 = 1; pub const BPF_F_INVALIDATE_HASH: _bindgen_ty_4 = 2; @@ -1096,51 +1126,54 @@ pub type _bindgen_ty_9 = ::aya_bpf_cty::c_uint; pub const BPF_F_ZERO_CSUM_TX: _bindgen_ty_10 = 2; pub const BPF_F_DONT_FRAGMENT: _bindgen_ty_10 = 4; pub const BPF_F_SEQ_NUMBER: _bindgen_ty_10 = 8; +pub const BPF_F_NO_TUNNEL_KEY: _bindgen_ty_10 = 16; pub type _bindgen_ty_10 = ::aya_bpf_cty::c_uint; -pub const BPF_F_INDEX_MASK: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CURRENT_CPU: _bindgen_ty_11 = 4294967295; -pub const BPF_F_CTXLEN_MASK: _bindgen_ty_11 = 4503595332403200; -pub type _bindgen_ty_11 = ::aya_bpf_cty::c_ulong; -pub const BPF_F_CURRENT_NETNS: _bindgen_ty_12 = -1; -pub type _bindgen_ty_12 = ::aya_bpf_cty::c_int; -pub const BPF_CSUM_LEVEL_QUERY: _bindgen_ty_13 = 0; -pub const BPF_CSUM_LEVEL_INC: _bindgen_ty_13 = 1; -pub const BPF_CSUM_LEVEL_DEC: _bindgen_ty_13 = 2; -pub const BPF_CSUM_LEVEL_RESET: _bindgen_ty_13 = 3; -pub type _bindgen_ty_13 = ::aya_bpf_cty::c_uint; -pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_14 = 1; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_14 = 2; -pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_14 = 4; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_14 = 8; -pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_14 = 16; -pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_14 = 32; -pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_14 = 64; +pub const BPF_F_TUNINFO_FLAGS: _bindgen_ty_11 = 16; +pub type _bindgen_ty_11 = ::aya_bpf_cty::c_uint; +pub const BPF_F_INDEX_MASK: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CURRENT_CPU: _bindgen_ty_12 = 4294967295; +pub const BPF_F_CTXLEN_MASK: _bindgen_ty_12 = 4503595332403200; +pub type _bindgen_ty_12 = ::aya_bpf_cty::c_ulong; +pub const BPF_F_CURRENT_NETNS: _bindgen_ty_13 = -1; +pub type _bindgen_ty_13 = ::aya_bpf_cty::c_int; +pub const BPF_CSUM_LEVEL_QUERY: _bindgen_ty_14 = 0; +pub const BPF_CSUM_LEVEL_INC: _bindgen_ty_14 = 1; +pub const BPF_CSUM_LEVEL_DEC: _bindgen_ty_14 = 2; +pub const BPF_CSUM_LEVEL_RESET: _bindgen_ty_14 = 3; pub type _bindgen_ty_14 = ::aya_bpf_cty::c_uint; -pub const BPF_ADJ_ROOM_ENCAP_L2_MASK: _bindgen_ty_15 = 255; -pub const BPF_ADJ_ROOM_ENCAP_L2_SHIFT: _bindgen_ty_15 = 56; +pub const BPF_F_ADJ_ROOM_FIXED_GSO: _bindgen_ty_15 = 1; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: _bindgen_ty_15 = 2; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: _bindgen_ty_15 = 4; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: _bindgen_ty_15 = 8; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: _bindgen_ty_15 = 16; +pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: _bindgen_ty_15 = 32; +pub const BPF_F_ADJ_ROOM_ENCAP_L2_ETH: _bindgen_ty_15 = 64; pub type _bindgen_ty_15 = ::aya_bpf_cty::c_uint; -pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_16 = 1; +pub const BPF_ADJ_ROOM_ENCAP_L2_MASK: _bindgen_ty_16 = 255; +pub const BPF_ADJ_ROOM_ENCAP_L2_SHIFT: _bindgen_ty_16 = 56; pub type _bindgen_ty_16 = ::aya_bpf_cty::c_uint; -pub const BPF_LOCAL_STORAGE_GET_F_CREATE: _bindgen_ty_17 = 1; -pub const BPF_SK_STORAGE_GET_F_CREATE: _bindgen_ty_17 = 1; +pub const BPF_F_SYSCTL_BASE_NAME: _bindgen_ty_17 = 1; pub type _bindgen_ty_17 = ::aya_bpf_cty::c_uint; -pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_18 = 1; +pub const BPF_LOCAL_STORAGE_GET_F_CREATE: _bindgen_ty_18 = 1; +pub const BPF_SK_STORAGE_GET_F_CREATE: _bindgen_ty_18 = 1; pub type _bindgen_ty_18 = ::aya_bpf_cty::c_uint; -pub const BPF_RB_NO_WAKEUP: _bindgen_ty_19 = 1; -pub const BPF_RB_FORCE_WAKEUP: _bindgen_ty_19 = 2; +pub const BPF_F_GET_BRANCH_RECORDS_SIZE: _bindgen_ty_19 = 1; pub type _bindgen_ty_19 = ::aya_bpf_cty::c_uint; -pub const BPF_RB_AVAIL_DATA: _bindgen_ty_20 = 0; -pub const BPF_RB_RING_SIZE: _bindgen_ty_20 = 1; -pub const BPF_RB_CONS_POS: _bindgen_ty_20 = 2; -pub const BPF_RB_PROD_POS: _bindgen_ty_20 = 3; +pub const BPF_RB_NO_WAKEUP: _bindgen_ty_20 = 1; +pub const BPF_RB_FORCE_WAKEUP: _bindgen_ty_20 = 2; pub type _bindgen_ty_20 = ::aya_bpf_cty::c_uint; -pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_21 = 2147483648; -pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_21 = 1073741824; -pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_21 = 8; +pub const BPF_RB_AVAIL_DATA: _bindgen_ty_21 = 0; +pub const BPF_RB_RING_SIZE: _bindgen_ty_21 = 1; +pub const BPF_RB_CONS_POS: _bindgen_ty_21 = 2; +pub const BPF_RB_PROD_POS: _bindgen_ty_21 = 3; pub type _bindgen_ty_21 = ::aya_bpf_cty::c_uint; -pub const BPF_SK_LOOKUP_F_REPLACE: _bindgen_ty_22 = 1; -pub const BPF_SK_LOOKUP_F_NO_REUSEPORT: _bindgen_ty_22 = 2; +pub const BPF_RINGBUF_BUSY_BIT: _bindgen_ty_22 = 2147483648; +pub const BPF_RINGBUF_DISCARD_BIT: _bindgen_ty_22 = 1073741824; +pub const BPF_RINGBUF_HDR_SZ: _bindgen_ty_22 = 8; pub type _bindgen_ty_22 = ::aya_bpf_cty::c_uint; +pub const BPF_SK_LOOKUP_F_REPLACE: _bindgen_ty_23 = 1; +pub const BPF_SK_LOOKUP_F_NO_REUSEPORT: _bindgen_ty_23 = 2; +pub type _bindgen_ty_23 = ::aya_bpf_cty::c_uint; pub mod bpf_adj_room_mode { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_ADJ_ROOM_NET: Type = 0; @@ -1157,12 +1190,12 @@ pub mod bpf_lwt_encap_mode { pub const BPF_LWT_ENCAP_SEG6_INLINE: Type = 1; pub const BPF_LWT_ENCAP_IP: Type = 2; } -pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_23 = 1; -pub type _bindgen_ty_23 = ::aya_bpf_cty::c_uint; -pub const BPF_F_BROADCAST: _bindgen_ty_24 = 8; -pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_24 = 16; +pub const BPF_F_BPRM_SECUREEXEC: _bindgen_ty_24 = 1; pub type _bindgen_ty_24 = ::aya_bpf_cty::c_uint; -pub mod _bindgen_ty_25 { +pub const BPF_F_BROADCAST: _bindgen_ty_25 = 8; +pub const BPF_F_EXCLUDE_INGRESS: _bindgen_ty_25 = 16; +pub type _bindgen_ty_25 = ::aya_bpf_cty::c_uint; +pub mod _bindgen_ty_26 { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_SKB_TSTAMP_UNSPEC: Type = 0; pub const BPF_SKB_TSTAMP_DELIVERY_MONO: Type = 1; @@ -1249,9 +1282,9 @@ pub struct bpf_tunnel_key { pub __bindgen_anon_1: bpf_tunnel_key__bindgen_ty_1, pub tunnel_tos: __u8, pub tunnel_ttl: __u8, - pub tunnel_ext: __u16, - pub tunnel_label: __u32, pub __bindgen_anon_2: bpf_tunnel_key__bindgen_ty_2, + pub tunnel_label: __u32, + pub __bindgen_anon_3: bpf_tunnel_key__bindgen_ty_3, } #[repr(C)] #[derive(Copy, Clone)] @@ -1262,6 +1295,12 @@ pub union bpf_tunnel_key__bindgen_ty_1 { #[repr(C)] #[derive(Copy, Clone)] pub union bpf_tunnel_key__bindgen_ty_2 { + pub tunnel_ext: __u16, + pub tunnel_flags: __be16, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_tunnel_key__bindgen_ty_3 { pub local_ipv4: __u32, pub local_ipv6: [__u32; 4usize], } @@ -1286,6 +1325,7 @@ pub mod bpf_ret_code { pub const BPF_DROP: Type = 2; pub const BPF_REDIRECT: Type = 7; pub const BPF_LWT_REROUTE: Type = 128; + pub const BPF_FLOW_DISSECTOR_CONTINUE: Type = 129; } #[repr(C)] #[derive(Copy, Clone)] @@ -1695,6 +1735,7 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4 { pub target_name: __u64, pub target_name_len: __u32, pub __bindgen_anon_1: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1, + pub __bindgen_anon_2: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2, } #[repr(C)] #[derive(Copy, Clone)] @@ -1708,6 +1749,24 @@ pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1 } #[repr(C)] #[derive(Copy, Clone)] +pub union bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2 { + pub cgroup: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1, + pub task: bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_1 { + pub cgroup_id: __u64, + pub order: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_4__bindgen_ty_2__bindgen_ty_2 { + pub tid: __u32, + pub pid: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] pub struct bpf_link_info__bindgen_ty_1__bindgen_ty_5 { pub netns_ino: __u32, pub attach_type: __u32, @@ -1788,6 +1847,7 @@ pub struct bpf_sock_ops { pub __bindgen_anon_4: bpf_sock_ops__bindgen_ty_4, pub skb_len: __u32, pub skb_tcp_flags: __u32, + pub skb_hwtstamp: __u64, } #[repr(C)] #[derive(Copy, Clone)] @@ -1838,51 +1898,51 @@ impl bpf_sock_ops__bindgen_ty_4 { __bindgen_bitfield_unit } } -pub const BPF_SOCK_OPS_RTO_CB_FLAG: _bindgen_ty_26 = 1; -pub const BPF_SOCK_OPS_RETRANS_CB_FLAG: _bindgen_ty_26 = 2; -pub const BPF_SOCK_OPS_STATE_CB_FLAG: _bindgen_ty_26 = 4; -pub const BPF_SOCK_OPS_RTT_CB_FLAG: _bindgen_ty_26 = 8; -pub const BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG: _bindgen_ty_26 = 16; -pub const BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG: _bindgen_ty_26 = 32; -pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG: _bindgen_ty_26 = 64; -pub const BPF_SOCK_OPS_ALL_CB_FLAGS: _bindgen_ty_26 = 127; -pub type _bindgen_ty_26 = ::aya_bpf_cty::c_uint; -pub const BPF_SOCK_OPS_VOID: _bindgen_ty_27 = 0; -pub const BPF_SOCK_OPS_TIMEOUT_INIT: _bindgen_ty_27 = 1; -pub const BPF_SOCK_OPS_RWND_INIT: _bindgen_ty_27 = 2; -pub const BPF_SOCK_OPS_TCP_CONNECT_CB: _bindgen_ty_27 = 3; -pub const BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: _bindgen_ty_27 = 4; -pub const BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: _bindgen_ty_27 = 5; -pub const BPF_SOCK_OPS_NEEDS_ECN: _bindgen_ty_27 = 6; -pub const BPF_SOCK_OPS_BASE_RTT: _bindgen_ty_27 = 7; -pub const BPF_SOCK_OPS_RTO_CB: _bindgen_ty_27 = 8; -pub const BPF_SOCK_OPS_RETRANS_CB: _bindgen_ty_27 = 9; -pub const BPF_SOCK_OPS_STATE_CB: _bindgen_ty_27 = 10; -pub const BPF_SOCK_OPS_TCP_LISTEN_CB: _bindgen_ty_27 = 11; -pub const BPF_SOCK_OPS_RTT_CB: _bindgen_ty_27 = 12; -pub const BPF_SOCK_OPS_PARSE_HDR_OPT_CB: _bindgen_ty_27 = 13; -pub const BPF_SOCK_OPS_HDR_OPT_LEN_CB: _bindgen_ty_27 = 14; -pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB: _bindgen_ty_27 = 15; +pub const BPF_SOCK_OPS_RTO_CB_FLAG: _bindgen_ty_27 = 1; +pub const BPF_SOCK_OPS_RETRANS_CB_FLAG: _bindgen_ty_27 = 2; +pub const BPF_SOCK_OPS_STATE_CB_FLAG: _bindgen_ty_27 = 4; +pub const BPF_SOCK_OPS_RTT_CB_FLAG: _bindgen_ty_27 = 8; +pub const BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG: _bindgen_ty_27 = 16; +pub const BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG: _bindgen_ty_27 = 32; +pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG: _bindgen_ty_27 = 64; +pub const BPF_SOCK_OPS_ALL_CB_FLAGS: _bindgen_ty_27 = 127; pub type _bindgen_ty_27 = ::aya_bpf_cty::c_uint; -pub const BPF_TCP_ESTABLISHED: _bindgen_ty_28 = 1; -pub const BPF_TCP_SYN_SENT: _bindgen_ty_28 = 2; -pub const BPF_TCP_SYN_RECV: _bindgen_ty_28 = 3; -pub const BPF_TCP_FIN_WAIT1: _bindgen_ty_28 = 4; -pub const BPF_TCP_FIN_WAIT2: _bindgen_ty_28 = 5; -pub const BPF_TCP_TIME_WAIT: _bindgen_ty_28 = 6; -pub const BPF_TCP_CLOSE: _bindgen_ty_28 = 7; -pub const BPF_TCP_CLOSE_WAIT: _bindgen_ty_28 = 8; -pub const BPF_TCP_LAST_ACK: _bindgen_ty_28 = 9; -pub const BPF_TCP_LISTEN: _bindgen_ty_28 = 10; -pub const BPF_TCP_CLOSING: _bindgen_ty_28 = 11; -pub const BPF_TCP_NEW_SYN_RECV: _bindgen_ty_28 = 12; -pub const BPF_TCP_MAX_STATES: _bindgen_ty_28 = 13; +pub const BPF_SOCK_OPS_VOID: _bindgen_ty_28 = 0; +pub const BPF_SOCK_OPS_TIMEOUT_INIT: _bindgen_ty_28 = 1; +pub const BPF_SOCK_OPS_RWND_INIT: _bindgen_ty_28 = 2; +pub const BPF_SOCK_OPS_TCP_CONNECT_CB: _bindgen_ty_28 = 3; +pub const BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: _bindgen_ty_28 = 4; +pub const BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: _bindgen_ty_28 = 5; +pub const BPF_SOCK_OPS_NEEDS_ECN: _bindgen_ty_28 = 6; +pub const BPF_SOCK_OPS_BASE_RTT: _bindgen_ty_28 = 7; +pub const BPF_SOCK_OPS_RTO_CB: _bindgen_ty_28 = 8; +pub const BPF_SOCK_OPS_RETRANS_CB: _bindgen_ty_28 = 9; +pub const BPF_SOCK_OPS_STATE_CB: _bindgen_ty_28 = 10; +pub const BPF_SOCK_OPS_TCP_LISTEN_CB: _bindgen_ty_28 = 11; +pub const BPF_SOCK_OPS_RTT_CB: _bindgen_ty_28 = 12; +pub const BPF_SOCK_OPS_PARSE_HDR_OPT_CB: _bindgen_ty_28 = 13; +pub const BPF_SOCK_OPS_HDR_OPT_LEN_CB: _bindgen_ty_28 = 14; +pub const BPF_SOCK_OPS_WRITE_HDR_OPT_CB: _bindgen_ty_28 = 15; pub type _bindgen_ty_28 = ::aya_bpf_cty::c_uint; -pub mod _bindgen_ty_30 { +pub const BPF_TCP_ESTABLISHED: _bindgen_ty_29 = 1; +pub const BPF_TCP_SYN_SENT: _bindgen_ty_29 = 2; +pub const BPF_TCP_SYN_RECV: _bindgen_ty_29 = 3; +pub const BPF_TCP_FIN_WAIT1: _bindgen_ty_29 = 4; +pub const BPF_TCP_FIN_WAIT2: _bindgen_ty_29 = 5; +pub const BPF_TCP_TIME_WAIT: _bindgen_ty_29 = 6; +pub const BPF_TCP_CLOSE: _bindgen_ty_29 = 7; +pub const BPF_TCP_CLOSE_WAIT: _bindgen_ty_29 = 8; +pub const BPF_TCP_LAST_ACK: _bindgen_ty_29 = 9; +pub const BPF_TCP_LISTEN: _bindgen_ty_29 = 10; +pub const BPF_TCP_CLOSING: _bindgen_ty_29 = 11; +pub const BPF_TCP_NEW_SYN_RECV: _bindgen_ty_29 = 12; +pub const BPF_TCP_MAX_STATES: _bindgen_ty_29 = 13; +pub type _bindgen_ty_29 = ::aya_bpf_cty::c_uint; +pub mod _bindgen_ty_31 { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_LOAD_HDR_OPT_TCP_SYN: Type = 1; } -pub mod _bindgen_ty_31 { +pub mod _bindgen_ty_32 { pub type Type = ::aya_bpf_cty::c_uint; pub const BPF_WRITE_HDR_TCP_CURRENT_MSS: Type = 1; pub const BPF_WRITE_HDR_TCP_SYNACK_COOKIE: Type = 2; @@ -1894,13 +1954,13 @@ pub struct bpf_perf_event_value { pub enabled: __u64, pub running: __u64, } -pub const BPF_DEVCG_ACC_MKNOD: _bindgen_ty_32 = 1; -pub const BPF_DEVCG_ACC_READ: _bindgen_ty_32 = 2; -pub const BPF_DEVCG_ACC_WRITE: _bindgen_ty_32 = 4; -pub type _bindgen_ty_32 = ::aya_bpf_cty::c_uint; -pub const BPF_DEVCG_DEV_BLOCK: _bindgen_ty_33 = 1; -pub const BPF_DEVCG_DEV_CHAR: _bindgen_ty_33 = 2; +pub const BPF_DEVCG_ACC_MKNOD: _bindgen_ty_33 = 1; +pub const BPF_DEVCG_ACC_READ: _bindgen_ty_33 = 2; +pub const BPF_DEVCG_ACC_WRITE: _bindgen_ty_33 = 4; pub type _bindgen_ty_33 = ::aya_bpf_cty::c_uint; +pub const BPF_DEVCG_DEV_BLOCK: _bindgen_ty_34 = 1; +pub const BPF_DEVCG_DEV_CHAR: _bindgen_ty_34 = 2; +pub type _bindgen_ty_34 = ::aya_bpf_cty::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_cgroup_dev_ctx { @@ -1912,19 +1972,19 @@ pub struct bpf_cgroup_dev_ctx { pub struct bpf_raw_tracepoint_args { pub args: __IncompleteArrayField<__u64>, } -pub const BPF_FIB_LOOKUP_DIRECT: _bindgen_ty_34 = 1; -pub const BPF_FIB_LOOKUP_OUTPUT: _bindgen_ty_34 = 2; -pub type _bindgen_ty_34 = ::aya_bpf_cty::c_uint; -pub const BPF_FIB_LKUP_RET_SUCCESS: _bindgen_ty_35 = 0; -pub const BPF_FIB_LKUP_RET_BLACKHOLE: _bindgen_ty_35 = 1; -pub const BPF_FIB_LKUP_RET_UNREACHABLE: _bindgen_ty_35 = 2; -pub const BPF_FIB_LKUP_RET_PROHIBIT: _bindgen_ty_35 = 3; -pub const BPF_FIB_LKUP_RET_NOT_FWDED: _bindgen_ty_35 = 4; -pub const BPF_FIB_LKUP_RET_FWD_DISABLED: _bindgen_ty_35 = 5; -pub const BPF_FIB_LKUP_RET_UNSUPP_LWT: _bindgen_ty_35 = 6; -pub const BPF_FIB_LKUP_RET_NO_NEIGH: _bindgen_ty_35 = 7; -pub const BPF_FIB_LKUP_RET_FRAG_NEEDED: _bindgen_ty_35 = 8; +pub const BPF_FIB_LOOKUP_DIRECT: _bindgen_ty_35 = 1; +pub const BPF_FIB_LOOKUP_OUTPUT: _bindgen_ty_35 = 2; pub type _bindgen_ty_35 = ::aya_bpf_cty::c_uint; +pub const BPF_FIB_LKUP_RET_SUCCESS: _bindgen_ty_36 = 0; +pub const BPF_FIB_LKUP_RET_BLACKHOLE: _bindgen_ty_36 = 1; +pub const BPF_FIB_LKUP_RET_UNREACHABLE: _bindgen_ty_36 = 2; +pub const BPF_FIB_LKUP_RET_PROHIBIT: _bindgen_ty_36 = 3; +pub const BPF_FIB_LKUP_RET_NOT_FWDED: _bindgen_ty_36 = 4; +pub const BPF_FIB_LKUP_RET_FWD_DISABLED: _bindgen_ty_36 = 5; +pub const BPF_FIB_LKUP_RET_UNSUPP_LWT: _bindgen_ty_36 = 6; +pub const BPF_FIB_LKUP_RET_NO_NEIGH: _bindgen_ty_36 = 7; +pub const BPF_FIB_LKUP_RET_FRAG_NEEDED: _bindgen_ty_36 = 8; +pub type _bindgen_ty_36 = ::aya_bpf_cty::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_fib_lookup { @@ -1998,10 +2058,10 @@ pub mod bpf_task_fd_type { pub const BPF_FD_TYPE_UPROBE: Type = 4; pub const BPF_FD_TYPE_URETPROBE: Type = 5; } -pub const BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG: _bindgen_ty_36 = 1; -pub const BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL: _bindgen_ty_36 = 2; -pub const BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP: _bindgen_ty_36 = 4; -pub type _bindgen_ty_36 = ::aya_bpf_cty::c_uint; +pub const BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG: _bindgen_ty_37 = 1; +pub const BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL: _bindgen_ty_37 = 2; +pub const BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP: _bindgen_ty_37 = 4; +pub type _bindgen_ty_37 = ::aya_bpf_cty::c_uint; #[repr(C)] #[derive(Copy, Clone)] pub struct bpf_flow_keys { @@ -2085,6 +2145,34 @@ impl bpf_dynptr { } } #[repr(C)] +#[repr(align(8))] +#[derive(Copy, Clone)] +pub struct bpf_list_head { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize]>, +} +impl bpf_list_head { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 16usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[repr(align(8))] +#[derive(Copy, Clone)] +pub struct bpf_list_node { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize]>, +} +impl bpf_list_node { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 16usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] #[derive(Copy, Clone)] pub struct bpf_sysctl { pub write: __u32, @@ -2312,6 +2400,11 @@ pub struct task_struct { } #[repr(C)] #[derive(Copy, Clone)] +pub struct cgroup { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Copy, Clone)] pub struct path { _unused: [u8; 0], } diff --git a/bpf/aya-bpf-bindings/src/x86_64/helpers.rs b/bpf/aya-bpf-bindings/src/x86_64/helpers.rs index 45b2efa2..be465ae5 100644 --- a/bpf/aya-bpf-bindings/src/x86_64/helpers.rs +++ b/bpf/aya-bpf-bindings/src/x86_64/helpers.rs @@ -461,12 +461,12 @@ pub unsafe fn bpf_skb_adjust_room( } pub unsafe fn bpf_redirect_map( map: *mut ::aya_bpf_cty::c_void, - key: __u32, + key: __u64, flags: __u64, ) -> ::aya_bpf_cty::c_long { let fun: unsafe extern "C" fn( map: *mut ::aya_bpf_cty::c_void, - key: __u32, + key: __u64, flags: __u64, ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(51usize); fun(map, key, flags) @@ -2027,28 +2027,28 @@ pub unsafe fn bpf_ringbuf_discard_dynptr(ptr: *mut bpf_dynptr, flags: __u64) { pub unsafe fn bpf_dynptr_read( dst: *mut ::aya_bpf_cty::c_void, len: __u32, - src: *mut bpf_dynptr, + src: *const bpf_dynptr, offset: __u32, flags: __u64, ) -> ::aya_bpf_cty::c_long { let fun: unsafe extern "C" fn( dst: *mut ::aya_bpf_cty::c_void, len: __u32, - src: *mut bpf_dynptr, + src: *const bpf_dynptr, offset: __u32, flags: __u64, ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(201usize); fun(dst, len, src, offset, flags) } pub unsafe fn bpf_dynptr_write( - dst: *mut bpf_dynptr, + dst: *const bpf_dynptr, offset: __u32, src: *mut ::aya_bpf_cty::c_void, len: __u32, flags: __u64, ) -> ::aya_bpf_cty::c_long { let fun: unsafe extern "C" fn( - dst: *mut bpf_dynptr, + dst: *const bpf_dynptr, offset: __u32, src: *mut ::aya_bpf_cty::c_void, len: __u32, @@ -2057,12 +2057,12 @@ pub unsafe fn bpf_dynptr_write( fun(dst, offset, src, len, flags) } pub unsafe fn bpf_dynptr_data( - ptr: *mut bpf_dynptr, + ptr: *const bpf_dynptr, offset: __u32, len: __u32, ) -> *mut ::aya_bpf_cty::c_void { let fun: unsafe extern "C" fn( - ptr: *mut bpf_dynptr, + ptr: *const bpf_dynptr, offset: __u32, len: __u32, ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(203usize); @@ -2106,3 +2106,41 @@ pub unsafe fn bpf_ktime_get_tai_ns() -> __u64 { let fun: unsafe extern "C" fn() -> __u64 = ::core::mem::transmute(208usize); fun() } +pub unsafe fn bpf_user_ringbuf_drain( + map: *mut ::aya_bpf_cty::c_void, + callback_fn: *mut ::aya_bpf_cty::c_void, + ctx: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let fun: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + callback_fn: *mut ::aya_bpf_cty::c_void, + ctx: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(209usize); + fun(map, callback_fn, ctx, flags) +} +pub unsafe fn bpf_cgrp_storage_get( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> *mut ::aya_bpf_cty::c_void { + let fun: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(210usize); + fun(map, cgroup, value, flags) +} +pub unsafe fn bpf_cgrp_storage_delete( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, +) -> ::aya_bpf_cty::c_long { + let fun: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + cgroup: *mut cgroup, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(211usize); + fun(map, cgroup) +} From dad75f45ac357e86eebc92c4f95f6dd4e43d8496 Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Mon, 9 Jan 2023 11:17:30 +0800 Subject: [PATCH 20/51] Update Tokio and inventory Signed-off-by: Michal Rostecki --- aya-log/Cargo.toml | 2 +- aya/Cargo.toml | 2 +- test/integration-test/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aya-log/Cargo.toml b/aya-log/Cargo.toml index 47333e33..adcdc7a5 100644 --- a/aya-log/Cargo.toml +++ b/aya-log/Cargo.toml @@ -16,7 +16,7 @@ aya-log-common = { path = "../aya-log-common", version = "0.1.13", features=["us thiserror = "1" log = "0.4" bytes = "1.1" -tokio = { version = "1.2.0" } +tokio = { version = "1.24" } [dev-dependencies] env_logger = "0.10" diff --git a/aya/Cargo.toml b/aya/Cargo.toml index 341bdac0..1b00546e 100644 --- a/aya/Cargo.toml +++ b/aya/Cargo.toml @@ -19,7 +19,7 @@ bitflags = "1.2.1" bytes = "1" lazy_static = "1" parking_lot = { version = "0.12.0", features = ["send_guard"] } -tokio = { version = "1.2.0", features = ["macros", "rt", "rt-multi-thread", "net"], optional = true } +tokio = { version = "1.24.0", features = ["macros", "rt", "rt-multi-thread", "net"], optional = true } async-io = { version = "1.3", optional = true } log = "0.4" diff --git a/test/integration-test/Cargo.toml b/test/integration-test/Cargo.toml index 9282f8cc..bfcc5d0b 100644 --- a/test/integration-test/Cargo.toml +++ b/test/integration-test/Cargo.toml @@ -10,7 +10,7 @@ aya = { path = "../../aya" } aya-obj = { path = "../../aya-obj" } clap = { version = "4", features = ["derive"] } env_logger = "0.10" -inventory = "0.2" +inventory = "0.3" integration-test-macros = { path = "../integration-test-macros" } lazy_static = "1" libc = { version = "0.2.105" } From 3000949bcc3b1ba950bf904d296b53b5e2572da4 Mon Sep 17 00:00:00 2001 From: Matteo Nardi Date: Mon, 9 Jan 2023 15:44:25 +0100 Subject: [PATCH 21/51] Remove libbpf dependency from relocation tests Simplifiy the relocation tests build process by removing the need for libbpf at runtime. Its usage is replaced with local `__builtin_*` attributes. This removes the need for the `LIBBPF_INCLUDE` env variable. --- .../integration-test/src/tests/relocations.rs | 47 ++++++++++--------- test/run.sh | 5 +- xtask/src/build_ebpf.rs | 6 --- 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs index 23bc7a18..bc2c1883 100644 --- a/test/integration-test/src/tests/relocations.rs +++ b/test/integration-test/src/tests/relocations.rs @@ -27,7 +27,10 @@ fn relocate_field() { "#, relocation_code: r#" __u8 memory[] = {1, 2, 3, 4}; - __u32 value = BPF_CORE_READ((struct foo *)&memory, c); + struct foo *ptr = (struct foo *) &memory; + bpf_probe_read_kernel(&value, + sizeof(__u8), + __builtin_preserve_access_index(&ptr->c)); "#, } .build() @@ -46,7 +49,8 @@ fn relocate_enum() { enum foo { D = 4 } e1; "#, relocation_code: r#" - __u32 value = bpf_core_enum_value(enum foo, D); + #define BPF_ENUMVAL_VALUE 1 + value = __builtin_preserve_enum_value(*(typeof(enum foo) *)D, BPF_ENUMVAL_VALUE); "#, } .build() @@ -68,8 +72,10 @@ fn relocate_pointer() { "#, relocation_code: r#" __u8 memory[] = {42, 0, 0, 0, 0, 0, 0, 0}; - struct foo *f = BPF_CORE_READ((struct bar *)&memory, f); - __u32 value = ((__u64) f); + struct bar* ptr = (struct bar *) &memory; + bpf_probe_read_kernel(&value, + sizeof(void *), + __builtin_preserve_access_index(&ptr->f)); "#, } .build() @@ -114,27 +120,29 @@ impl RelocationTest { r#" #include - #include - #include - #include + static long (*bpf_map_update_elem)(void *map, const void *key, const void *value, __u64 flags) = (void *) 2; + static long (*bpf_probe_read_kernel)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 113; {local_definition} struct {{ - __uint(type, BPF_MAP_TYPE_ARRAY); - __type(key, __u32); - __type(value, __u32); - __uint(max_entries, 1); - }} output_map SEC(".maps"); + int (*type)[BPF_MAP_TYPE_ARRAY]; + __u32 *key; + __u32 *value; + int (*max_entries)[1]; + }} output_map + __attribute__((section(".maps"), used)); - SEC("tracepoint/bpf_prog") int bpf_prog(void *ctx) {{ + __attribute__((section("tracepoint/bpf_prog"), used)) + int bpf_prog(void *ctx) {{ __u32 key = 0; + __u32 value = 0; {relocation_code} bpf_map_update_elem(&output_map, &key, &value, BPF_ANY); return 0; }} - char _license[] SEC("license") = "GPL"; + char _license[] __attribute__((section("license"), used)) = "GPL"; "# )) .context("Failed to compile eBPF program")?; @@ -157,12 +165,11 @@ impl RelocationTest { r#" #include - #include - #include - #include + static long (*bpf_probe_read_kernel)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 113; {target_btf} int main() {{ + __u32 value = 0; // This is needed to make sure to emit BTF for the defined types, // it could be dead code eliminated if we don't. {relocation_code}; @@ -195,12 +202,6 @@ fn compile(source_code: &str) -> Result<(TempDir, PathBuf)> { Command::new("clang") .current_dir(&tmp_dir) .args(["-c", "-g", "-O2", "-target", "bpf"]) - // NOTE: these tests depend on libbpf, LIBBPF_INCLUDE must point its headers. - // This is set automatically by the integration-test xtask. - .args([ - "-I", - &std::env::var("LIBBPF_INCLUDE").context("LIBBPF_INCLUDE not set")?, - ]) .arg(&source) .status() .context("Failed to run clang")? diff --git a/test/run.sh b/test/run.sh index 3be2b862..3bb6c6f3 100755 --- a/test/run.sh +++ b/test/run.sh @@ -187,8 +187,5 @@ cargo xtask build-integration-test --musl --libbpf-dir "$1" scp_vm ../target/x86_64-unknown-linux-musl/debug/integration-test exec_vm sudo ./integration-test --skip relocations -# Relocation tests build the eBPF programs and require libbpf. We run them outside VM. -export LIBBPF_INCLUDE="${AYA_TMPDIR}/libbpf/" -mkdir -p "$LIBBPF_INCLUDE" -(cd "$1/src" && make INCLUDEDIR="$LIBBPF_INCLUDE" install_headers) +# Relocation tests build the eBPF programs themself. We run them outside VM. sudo -E ../target/x86_64-unknown-linux-musl/debug/integration-test relocations diff --git a/xtask/src/build_ebpf.rs b/xtask/src/build_ebpf.rs index 9e22da89..4f98feba 100644 --- a/xtask/src/build_ebpf.rs +++ b/xtask/src/build_ebpf.rs @@ -103,12 +103,6 @@ fn build_c_ebpf(opts: &BuildEbpfOptions) -> anyhow::Result<()> { let include_path = out_path.join("include"); get_libbpf_headers(&opts.libbpf_dir, &include_path)?; - // Export libbpf location as an env variable since it's needed for building - // the relocation tests at test/integration-test/src/tests/relocations.rs - // We decided to make an exception and build its eBPF programs at run-time - // because of the many different permutations. - std::env::set_var("LIBBPF_INCLUDE", &include_path); - let files = fs::read_dir(&src).unwrap(); for file in files { let p = file.unwrap().path(); From 75336e5a35997dbcb2f61ca5b532f5ea938c9259 Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Tue, 10 Jan 2023 11:50:36 +0800 Subject: [PATCH 22/51] integration-test: Fix the kernel version chceck for smoke test Before this chane, the check was always negative if the minor version was less then 9. So, for example, the smoke test was skipped for kernel 6.1: ``` skipping as 6.1 does not meet version requirement of 5.9 ``` Signed-off-by: Michal Rostecki --- test/integration-test/src/tests/smoke.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration-test/src/tests/smoke.rs b/test/integration-test/src/tests/smoke.rs index 67ee8f06..a7450064 100644 --- a/test/integration-test/src/tests/smoke.rs +++ b/test/integration-test/src/tests/smoke.rs @@ -19,7 +19,7 @@ fn xdp() { #[integration_test] fn extension() { let (major, minor, _) = kernel_version().unwrap(); - if major < 5 || minor < 9 { + if major < 5 || (minor == 5 && minor < 9) { info!( "skipping as {}.{} does not meet version requirement of 5.9", major, minor From cb28533e2f9eb0b2cd80f4bf9515cdec31763749 Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Tue, 10 Jan 2023 12:27:56 +0800 Subject: [PATCH 23/51] aya-obj: Update `BPF_MAP_TYPE_CGROUP_STORAGE` name to `BPF_MAP_TYPE_CGRP_STORAGE` It changed in libbpf Signed-off-by: Michal Rostecki --- aya-obj/src/maps.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aya-obj/src/maps.rs b/aya-obj/src/maps.rs index b6467d94..f7706667 100644 --- a/aya-obj/src/maps.rs +++ b/aya-obj/src/maps.rs @@ -37,7 +37,7 @@ impl TryFrom for crate::generated::bpf_map_type { x if x == BPF_MAP_TYPE_CPUMAP as u32 => BPF_MAP_TYPE_CPUMAP, x if x == BPF_MAP_TYPE_XSKMAP as u32 => BPF_MAP_TYPE_XSKMAP, x if x == BPF_MAP_TYPE_SOCKHASH as u32 => BPF_MAP_TYPE_SOCKHASH, - x if x == BPF_MAP_TYPE_CGROUP_STORAGE as u32 => BPF_MAP_TYPE_CGROUP_STORAGE, + x if x == BPF_MAP_TYPE_CGRP_STORAGE as u32 => BPF_MAP_TYPE_CGRP_STORAGE, x if x == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY as u32 => BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, x if x == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE as u32 => { BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE From 3d03c8a8e0a9033be8c1ab020129db7790cc7493 Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Tue, 10 Jan 2023 17:39:08 +0800 Subject: [PATCH 24/51] aya-obj: Add new map types Include all new map types which were included in the last libbpf update (5d13fd5acaa9). Fixes: cb28533e2f9e ("aya-obj: Update `BPF_MAP_TYPE_CGROUP_STORAGE` name to `BPF_MAP_TYPE_CGRP_STORAGE`") Signed-off-by: Michal Rostecki --- aya-obj/src/maps.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/aya-obj/src/maps.rs b/aya-obj/src/maps.rs index f7706667..aa2d213c 100644 --- a/aya-obj/src/maps.rs +++ b/aya-obj/src/maps.rs @@ -37,6 +37,9 @@ impl TryFrom for crate::generated::bpf_map_type { x if x == BPF_MAP_TYPE_CPUMAP as u32 => BPF_MAP_TYPE_CPUMAP, x if x == BPF_MAP_TYPE_XSKMAP as u32 => BPF_MAP_TYPE_XSKMAP, x if x == BPF_MAP_TYPE_SOCKHASH as u32 => BPF_MAP_TYPE_SOCKHASH, + x if x == BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED as u32 => { + BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED + } x if x == BPF_MAP_TYPE_CGRP_STORAGE as u32 => BPF_MAP_TYPE_CGRP_STORAGE, x if x == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY as u32 => BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, x if x == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE as u32 => { @@ -50,6 +53,9 @@ impl TryFrom for crate::generated::bpf_map_type { x if x == BPF_MAP_TYPE_RINGBUF as u32 => BPF_MAP_TYPE_RINGBUF, x if x == BPF_MAP_TYPE_INODE_STORAGE as u32 => BPF_MAP_TYPE_INODE_STORAGE, x if x == BPF_MAP_TYPE_TASK_STORAGE as u32 => BPF_MAP_TYPE_TASK_STORAGE, + x if x == BPF_MAP_TYPE_BLOOM_FILTER as u32 => BPF_MAP_TYPE_BLOOM_FILTER, + x if x == BPF_MAP_TYPE_USER_RINGBUF as u32 => BPF_MAP_TYPE_USER_RINGBUF, + x if x == BPF_MAP_TYPE_CGRP_STORAGE as u32 => BPF_MAP_TYPE_CGRP_STORAGE, _ => return Err(InvalidMapTypeError { map_type }), }) } From d33ed21fc4126acacea80afea9afaa06b4c0c07d Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Mon, 16 Jan 2023 19:10:56 +1100 Subject: [PATCH 25/51] Pin nightly to nightly-2023-01-10 This until https://github.com/rust-lang/rust/pull/106796 gets fixed --- .github/workflows/build-aya-bpf.yml | 2 +- .github/workflows/build-aya.yml | 2 +- netlify.toml | 2 +- xtask/src/build_ebpf.rs | 2 +- xtask/src/docs/mod.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-aya-bpf.yml b/.github/workflows/build-aya-bpf.yml index a29d7c09..1d134ca9 100644 --- a/.github/workflows/build-aya-bpf.yml +++ b/.github/workflows/build-aya-bpf.yml @@ -30,7 +30,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: nightly-2023-01-10 components: rust-src override: true diff --git a/.github/workflows/build-aya.yml b/.github/workflows/build-aya.yml index 991298fa..0b9a0ef5 100644 --- a/.github/workflows/build-aya.yml +++ b/.github/workflows/build-aya.yml @@ -57,7 +57,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: nightly-2023-01-10 components: rustfmt, clippy, rust-src target: x86_64-unknown-linux-musl override: true diff --git a/netlify.toml b/netlify.toml index 3ad62912..8e0773ea 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,3 +1,3 @@ [build] publish = "site" - command = "rustup toolchain install nightly -c rust-src && cargo xtask docs" + command = "rustup toolchain install nightly-2023-01-10 -c rust-src && cargo xtask docs" diff --git a/xtask/src/build_ebpf.rs b/xtask/src/build_ebpf.rs index 4f98feba..cd5b9234 100644 --- a/xtask/src/build_ebpf.rs +++ b/xtask/src/build_ebpf.rs @@ -60,7 +60,7 @@ fn build_rust_ebpf(opts: &BuildEbpfOptions) -> anyhow::Result<()> { let target = format!("--target={}", opts.target); let mut args = vec![ - "+nightly", + "+nightly-2023-01-10", "build", "--verbose", target.as_str(), diff --git a/xtask/src/docs/mod.rs b/xtask/src/docs/mod.rs index bfeca3a9..b17ecb7c 100644 --- a/xtask/src/docs/mod.rs +++ b/xtask/src/docs/mod.rs @@ -61,7 +61,7 @@ fn build_docs(working_dir: &PathBuf, abs_header_path: &Path) -> Result<(), anyho .expect("failed to replace logo"); assert!(replace.success()); - let args = vec!["+nightly", "doc", "--no-deps", "--all-features"]; + let args = vec!["+nightly-2023-01-10", "doc", "--no-deps", "--all-features"]; let status = Command::new("cargo") .current_dir(working_dir) From 9f4ef6f67df397c7e243435ccb3bdd517fd467cf Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Thu, 19 Jan 2023 14:04:05 +1100 Subject: [PATCH 26/51] Fix lints --- aya-obj/src/btf/types.rs | 9 ++------- aya-obj/src/maps.rs | 9 ++------- aya-obj/src/obj.rs | 7 +------ aya-obj/src/programs/cgroup_sock.rs | 11 ++--------- 4 files changed, 7 insertions(+), 29 deletions(-) diff --git a/aya-obj/src/btf/types.rs b/aya-obj/src/btf/types.rs index 177b97a5..72474f7e 100644 --- a/aya-obj/src/btf/types.rs +++ b/aya-obj/src/btf/types.rs @@ -799,9 +799,10 @@ impl DeclTag { } } -#[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] #[repr(u32)] pub enum BtfKind { + #[default] Unknown = 0, Int = 1, Ptr = 2, @@ -879,12 +880,6 @@ impl Display for BtfKind { } } -impl Default for BtfKind { - fn default() -> Self { - BtfKind::Unknown - } -} - unsafe fn read(data: &[u8]) -> Result { if mem::size_of::() > data.len() { return Err(BtfError::InvalidTypeInfo); diff --git a/aya-obj/src/maps.rs b/aya-obj/src/maps.rs index aa2d213c..a6c3c96c 100644 --- a/aya-obj/src/maps.rs +++ b/aya-obj/src/maps.rs @@ -81,9 +81,10 @@ pub struct BtfMapDef { /// Upon pinning a map, a file representation is created for the map, /// so that the map can be alive and retrievable across sessions. #[repr(u32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)] pub enum PinningType { /// No pinning + #[default] None = 0, /// Pin by the name ByName = 1, @@ -112,12 +113,6 @@ impl TryFrom for PinningType { } } -impl Default for PinningType { - fn default() -> Self { - PinningType::None - } -} - /// Map definition in legacy BPF map declaration style #[allow(non_camel_case_types)] #[repr(C)] diff --git a/aya-obj/src/obj.rs b/aya-obj/src/obj.rs index 23943236..72f13ed7 100644 --- a/aya-obj/src/obj.rs +++ b/aya-obj/src/obj.rs @@ -1463,7 +1463,6 @@ mod tests { map_flags: 5, id: 0, pinning: PinningType::None, - ..Default::default() }; assert_eq!( @@ -1482,7 +1481,6 @@ mod tests { map_flags: 5, id: 6, pinning: PinningType::ByName, - ..Default::default() }; assert_eq!(parse_map_def("foo", bytes_of(&def)).unwrap(), def); @@ -1498,7 +1496,6 @@ mod tests { map_flags: 5, id: 6, pinning: PinningType::ByName, - ..Default::default() }; let mut buf = [0u8; 128]; unsafe { ptr::write_unaligned(buf.as_mut_ptr() as *mut _, def) }; @@ -1529,7 +1526,6 @@ mod tests { map_flags: 5, id: 0, pinning: PinningType::None, - ..Default::default() }) ), "foo" @@ -1664,7 +1660,7 @@ mod tests { buf.extend(&map_data); buf.extend(&map_data); // throw in some padding - buf.extend(&[0, 0, 0, 0]); + buf.extend([0, 0, 0, 0]); buf.extend(&map_data); assert_matches!( obj.parse_section(fake_section(BpfSectionKind::Maps, "maps", buf.as_slice(),)), @@ -2198,7 +2194,6 @@ mod tests { map_flags: BPF_F_RDONLY_PROG, id: 1, pinning: PinningType::None, - ..Default::default() }, section_index: 1, symbol_index: 1, diff --git a/aya-obj/src/programs/cgroup_sock.rs b/aya-obj/src/programs/cgroup_sock.rs index ed470f8a..b9194e24 100644 --- a/aya-obj/src/programs/cgroup_sock.rs +++ b/aya-obj/src/programs/cgroup_sock.rs @@ -7,26 +7,19 @@ use crate::{ }; /// Defines where to attach a `CgroupSock` program. -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, Default)] pub enum CgroupSockAttachType { /// Called after the IPv4 bind events. PostBind4, /// Called after the IPv6 bind events. PostBind6, /// Attach to IPv4 connect events. + #[default] SockCreate, /// Attach to IPv6 connect events. SockRelease, } -impl Default for CgroupSockAttachType { - // The kernel checks for a 0 attach_type and sets it to sock_create - // We may as well do that here also - fn default() -> Self { - CgroupSockAttachType::SockCreate - } -} - impl From for bpf_attach_type { fn from(s: CgroupSockAttachType) -> bpf_attach_type { match s { From 1899d5f4fd3ec5d91e40a94d671a7756125a4487 Mon Sep 17 00:00:00 2001 From: Andrew Stoycos Date: Thu, 19 Jan 2023 12:47:50 -0500 Subject: [PATCH 27/51] Expose inner errors Currently aya will just report a standard outer level error on failure. Ensure that we also report the inner error condition back to the user Signed-off-by: Andrew Stoycos --- aya/src/bpf.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aya/src/bpf.rs b/aya/src/bpf.rs index 3f765b9a..6ad6b084 100644 --- a/aya/src/bpf.rs +++ b/aya/src/bpf.rs @@ -857,11 +857,11 @@ pub enum BpfError { }, /// Error parsing BPF object - #[error("error parsing BPF object")] + #[error("error parsing BPF object: {0}")] ParseError(#[from] ParseError), /// Error parsing BTF object - #[error("BTF error")] + #[error("BTF error: {0}")] BtfError(#[from] BtfError), /// Error performing relocations @@ -876,11 +876,11 @@ pub enum BpfError { #[error("no BTF parsed for object")] NoBTF, - #[error("map error")] + #[error("map error: {0}")] /// A map error MapError(#[from] MapError), - #[error("program error")] + #[error("program error: {0}")] /// A program error ProgramError(#[from] ProgramError), } From f46fd17cc31f7f900f01d8e97baebe6445c468d4 Mon Sep 17 00:00:00 2001 From: Andre Fredette Date: Sun, 23 Oct 2022 18:33:59 -0400 Subject: [PATCH 28/51] Support reconstruction of `SchedClassifierLink` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the proposed solution for Step 2 of issue #414 “For cases where you have done program.take_link() to manage ownership of TcLink we need an API similar to PinnedLink::from_pin that can reconstruct a TcLink” As long as a user application continues to run after executing `take_link()`, the `SchedClassifierLink` returned can be used to detach the program. However, if we want to handle cases where the application exits or crashes, we need a way to save and reconstruct the link, and to do that, we also need to know the information required for the reconstruction -- namely, the `interface`, `attach_type`, `priority`, and `handle`. The user knows the first two because they are required to execute `attach()` in the first place; however, the user will not know the others if they let the system choose them. This pr solves the problems by adding an `impl` for `SchedClassifierLink` with an accessor for `tc_options` and a `new()` function. Signed-off-by: Andre Fredette --- aya/src/programs/tc.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index d1e90be1..6ff044dc 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -228,6 +228,33 @@ define_link_wrapper!( TcLinkId ); +impl SchedClassifierLink { + /// Creates a new SchedClassifierLink instance + pub fn new( + interface: &str, + attach_type: TcAttachType, + priority: u16, + handle: u32, + ) -> Result { + let if_index = ifindex_from_ifname(interface) + .map_err(|io_error| TcError::NetlinkError { io_error })?; + Ok(SchedClassifierLink(TcLink { + if_index: if_index as i32, + attach_type, + priority, + handle, + })) + } + + /// Returns options for a SchedClassifierLink + pub fn tc_options(&self) -> TcOptions { + TcOptions { + priority: self.0.priority, + handle: self.0.handle, + } + } +} + /// Add the `clasct` qdisc to the given interface. /// /// The `clsact` qdisc must be added to an interface before [`SchedClassifier`] From c3a8400e4d219eb72167ccaeb500d36ad924873d Mon Sep 17 00:00:00 2001 From: Andre Fredette Date: Mon, 21 Nov 2022 16:08:45 -0500 Subject: [PATCH 29/51] Add example for SchedClassifierLink::new() Also modified the impl a bit to work as described in the example. Signed-off-by: Andre Fredette --- aya/src/programs/tc.rs | 69 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 10 deletions(-) diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index 6ff044dc..dfef6e99 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -228,16 +228,63 @@ define_link_wrapper!( TcLinkId ); +/// # Examples +/// +/// ```no_run +/// # #[derive(Debug, thiserror::Error)] +/// # enum Error { +/// # #[error(transparent)] +/// # IO(#[from] std::io::Error), +/// # #[error(transparent)] +/// # Map(#[from] aya::maps::MapError), +/// # #[error(transparent)] +/// # Program(#[from] aya::programs::ProgramError), +/// # #[error(transparent)] +/// # Bpf(#[from] aya::BpfError) +/// # } +/// # let mut bpf = aya::Bpf::load(&[])?; +/// # tc::qdisc_add_clsact("eth0")?; +/// # let prog: &mut SchedClassifier = bpf.program_mut("redirect_ingress").unwrap().try_into()?; +/// # prog.load()?; +/// +/// use aya::programs::tc::{SchedClassifierLink}; +/// use aya::programs::{tc, Link, SchedClassifier, TcAttachType}; +/// +/// // SchedClassifier::attach returns a SchedClassifierLinkId that can be used to +/// // detach the program. +/// let tc_link_id = prog.attach("eth0", TcAttachType::Ingress)?; +/// +/// // The user may take ownership of the lifetime of a link using +/// // SchedClassifier::take_link, which returns a SchedClassifierLink +/// let tc_link = prog.take_link(tc_link_id)?; +/// +/// // Once ownership is taken, SchedClassifierLink::detach can be used to detach the +/// // link. If needed, the link can be reconstructed via the SchedClassifierLink::new +/// // using the if_name, attach_type, priority, and handle. The user knows the first +/// // two because they were required to execute attach(); however, the user may not +/// // know the priority, and/or handle if they let the system choose them as happens +/// // with SchedClassifier::attach. If needed, These items may be retrieved as follows: +/// let priority = tc_link.priority(); +/// let handle = tc_link.handle(); +/// +/// // Then, the link can be reconstructed as follows: +/// let tc_link = SchedClassifierLink::new("eth0", TcAttachType::Ingress, priority, handle)?; +/// +/// // And, the user can then detatch the link as follows: +/// tc_link.detach()?; +/// +/// # Ok::<(), Error>(()) +/// ``` impl SchedClassifierLink { - /// Creates a new SchedClassifierLink instance + /// Creates a new `SchedClassifierLink` instance pub fn new( - interface: &str, + if_name: &str, attach_type: TcAttachType, priority: u16, handle: u32, ) -> Result { - let if_index = ifindex_from_ifname(interface) - .map_err(|io_error| TcError::NetlinkError { io_error })?; + let if_index = + ifindex_from_ifname(if_name).map_err(|io_error| TcError::NetlinkError { io_error })?; Ok(SchedClassifierLink(TcLink { if_index: if_index as i32, attach_type, @@ -246,12 +293,14 @@ impl SchedClassifierLink { })) } - /// Returns options for a SchedClassifierLink - pub fn tc_options(&self) -> TcOptions { - TcOptions { - priority: self.0.priority, - handle: self.0.handle, - } + /// Returns the `priority` for a `SchedClassifierLink` + pub fn priority(&self) -> u16 { + self.0.priority + } + + /// Returns the `handle` for a `SchedClassifierLink` + pub fn handle(&self) -> u32 { + self.0.handle } } From 6563e6cc065d01270aad50d9c3449f9deb9f04d6 Mon Sep 17 00:00:00 2001 From: Andre Fredette Date: Tue, 22 Nov 2022 09:23:52 -0500 Subject: [PATCH 30/51] Combine updates to SchedClassifierLink example made by Dave Tucker Co-authored-by: Dave Tucker Signed-off-by: Andre Fredette --- aya/src/programs/tc.rs | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index dfef6e99..650fe22f 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -228,6 +228,8 @@ define_link_wrapper!( TcLinkId ); +/// SchedClassifier link is the link type used by [`SchedClassifier`] programs. +/// /// # Examples /// /// ```no_run @@ -246,37 +248,27 @@ define_link_wrapper!( /// # tc::qdisc_add_clsact("eth0")?; /// # let prog: &mut SchedClassifier = bpf.program_mut("redirect_ingress").unwrap().try_into()?; /// # prog.load()?; +/// # +/// # use aya::programs::tc::{SchedClassifierLink}; +/// # use aya::programs::{tc, Link, SchedClassifier, TcAttachType}; /// -/// use aya::programs::tc::{SchedClassifierLink}; -/// use aya::programs::{tc, Link, SchedClassifier, TcAttachType}; -/// -/// // SchedClassifier::attach returns a SchedClassifierLinkId that can be used to -/// // detach the program. /// let tc_link_id = prog.attach("eth0", TcAttachType::Ingress)?; /// -/// // The user may take ownership of the lifetime of a link using -/// // SchedClassifier::take_link, which returns a SchedClassifierLink /// let tc_link = prog.take_link(tc_link_id)?; /// -/// // Once ownership is taken, SchedClassifierLink::detach can be used to detach the -/// // link. If needed, the link can be reconstructed via the SchedClassifierLink::new -/// // using the if_name, attach_type, priority, and handle. The user knows the first -/// // two because they were required to execute attach(); however, the user may not -/// // know the priority, and/or handle if they let the system choose them as happens -/// // with SchedClassifier::attach. If needed, These items may be retrieved as follows: +/// // The priority and handle assigned during attach can be accessed as follows: /// let priority = tc_link.priority(); /// let handle = tc_link.handle(); /// -/// // Then, the link can be reconstructed as follows: +/// // A new SchedClassifierLink can be constructed to access an existing attachment /// let tc_link = SchedClassifierLink::new("eth0", TcAttachType::Ingress, priority, handle)?; /// -/// // And, the user can then detatch the link as follows: /// tc_link.detach()?; /// /// # Ok::<(), Error>(()) /// ``` impl SchedClassifierLink { - /// Creates a new `SchedClassifierLink` instance + /// Creates a new link from the provided values. pub fn new( if_name: &str, attach_type: TcAttachType, @@ -293,12 +285,12 @@ impl SchedClassifierLink { })) } - /// Returns the `priority` for a `SchedClassifierLink` + /// Returns the allocated priority. This may be different to what was provided to [`SchedClassifier::attach`]. pub fn priority(&self) -> u16 { self.0.priority } - /// Returns the `handle` for a `SchedClassifierLink` + /// Returns the assigned handle. This was auto-generated if none was supplied to [`SchedClassifier::attach`]. pub fn handle(&self) -> u32 { self.0.handle } From 67efc33414df049853247e344dfaa37eeeafe602 Mon Sep 17 00:00:00 2001 From: Andre Fredette Date: Tue, 22 Nov 2022 14:11:33 -0500 Subject: [PATCH 31/51] Additional edits to SchedClassifierLink documentation. Signed-off-by: Andre Fredette --- aya/src/programs/tc.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index 650fe22f..5185bb8d 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -228,7 +228,7 @@ define_link_wrapper!( TcLinkId ); -/// SchedClassifier link is the link type used by [`SchedClassifier`] programs. +/// [`SchedClassifierLink`] is the link type used by [`SchedClassifier`] programs. /// /// # Examples /// @@ -251,7 +251,6 @@ define_link_wrapper!( /// # /// # use aya::programs::tc::{SchedClassifierLink}; /// # use aya::programs::{tc, Link, SchedClassifier, TcAttachType}; -/// /// let tc_link_id = prog.attach("eth0", TcAttachType::Ingress)?; /// /// let tc_link = prog.take_link(tc_link_id)?; @@ -261,14 +260,25 @@ define_link_wrapper!( /// let handle = tc_link.handle(); /// /// // A new SchedClassifierLink can be constructed to access an existing attachment -/// let tc_link = SchedClassifierLink::new("eth0", TcAttachType::Ingress, priority, handle)?; +/// let new_tc_link = SchedClassifierLink::new("eth0", TcAttachType::Ingress, priority, handle)?; /// -/// tc_link.detach()?; +/// new_tc_link.detach()?; /// /// # Ok::<(), Error>(()) /// ``` impl SchedClassifierLink { /// Creates a new link from the provided values. + /// + /// This API is used to construct a [`SchedClassifierLink`] where the `if_name`, `attach_type`, + /// `priority` and `handle` are already known. This may have been found from a link created by + /// [SchedClassifier::attach], the output of the `tc filter` command or from the output of + /// another BPF loader. + /// + /// # Warnings + /// - If a program is not attached with the provided parameters, calls to + /// [`SchedClassifierLink::detach`] will return a [`TcError::NetlinkError`] + /// - If you create a link for a program that you do not own, detaching it may have unintended + /// consequences. pub fn new( if_name: &str, attach_type: TcAttachType, @@ -285,12 +295,12 @@ impl SchedClassifierLink { })) } - /// Returns the allocated priority. This may be different to what was provided to [`SchedClassifier::attach`]. + /// Returns the allocated priority. If none was provided at attach time, this was allocated for you. pub fn priority(&self) -> u16 { self.0.priority } - /// Returns the assigned handle. This was auto-generated if none was supplied to [`SchedClassifier::attach`]. + /// Returns the assigned handle. If none was provided at attach time, this was allocated for you. pub fn handle(&self) -> u32 { self.0.handle } From 849796c4208b520cd12a7ac5de28857dc885c026 Mon Sep 17 00:00:00 2001 From: Andre Fredette Date: Sun, 18 Dec 2022 10:42:36 -0500 Subject: [PATCH 32/51] rename SchedClassifierLink:new() to new_tc_link() Avoids name confilct with pr #462 Signed-off-by: Andre Fredette --- aya/src/programs/tc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index 5185bb8d..e83fc633 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -279,7 +279,7 @@ impl SchedClassifierLink { /// [`SchedClassifierLink::detach`] will return a [`TcError::NetlinkError`] /// - If you create a link for a program that you do not own, detaching it may have unintended /// consequences. - pub fn new( + pub fn new_tc_link( if_name: &str, attach_type: TcAttachType, priority: u16, From 65f5b76593f35b8ca09f5d868a4195086ddca831 Mon Sep 17 00:00:00 2001 From: Andre Fredette Date: Mon, 19 Dec 2022 06:52:04 -0500 Subject: [PATCH 33/51] Address review comments Signed-off-by: Andre Fredette --- aya/src/programs/tc.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index e83fc633..4d021489 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -251,6 +251,7 @@ define_link_wrapper!( /// # /// # use aya::programs::tc::{SchedClassifierLink}; /// # use aya::programs::{tc, Link, SchedClassifier, TcAttachType}; +/// # use std::mem; /// let tc_link_id = prog.attach("eth0", TcAttachType::Ingress)?; /// /// let tc_link = prog.take_link(tc_link_id)?; @@ -259,9 +260,16 @@ define_link_wrapper!( /// let priority = tc_link.priority(); /// let handle = tc_link.handle(); /// -/// // A new SchedClassifierLink can be constructed to access an existing attachment -/// let new_tc_link = SchedClassifierLink::new("eth0", TcAttachType::Ingress, priority, handle)?; +/// // The following call "forgets" about tc_link so that it is not detached on drop. +/// mem::forget(tc_link); /// +/// // The link can be re-instantiated and detached as shown below. +/// let new_tc_link = SchedClassifierLink::new_tc_link( +/// "eth0", +/// TcAttachType::Ingress, +/// priority, +/// handle, +/// )?; /// new_tc_link.detach()?; /// /// # Ok::<(), Error>(()) @@ -274,19 +282,19 @@ impl SchedClassifierLink { /// [SchedClassifier::attach], the output of the `tc filter` command or from the output of /// another BPF loader. /// - /// # Warnings + /// Note: If you create a link for a program that you do not own, detaching it may have + /// unintended consequences. + /// + /// # Errors /// - If a program is not attached with the provided parameters, calls to /// [`SchedClassifierLink::detach`] will return a [`TcError::NetlinkError`] - /// - If you create a link for a program that you do not own, detaching it may have unintended - /// consequences. pub fn new_tc_link( if_name: &str, attach_type: TcAttachType, priority: u16, handle: u32, - ) -> Result { - let if_index = - ifindex_from_ifname(if_name).map_err(|io_error| TcError::NetlinkError { io_error })?; + ) -> Result { + let if_index = ifindex_from_ifname(if_name)?; Ok(SchedClassifierLink(TcLink { if_index: if_index as i32, attach_type, From 2972d462a505aaba8d9e40ddf2c6110e497283db Mon Sep 17 00:00:00 2001 From: Andre Fredette Date: Thu, 22 Dec 2022 07:51:35 -0500 Subject: [PATCH 34/51] Address review comments - Rename `new_tc_link` to `attached` - Simplified example for `attached` The following was not requested in reviews: - Moved example from `SchedClassifierLink` tor `SchedClassifierLink::attached' since we're only showing an example of that one method Signed-off-by: Andre Fredette --- aya/src/programs/tc.rs | 69 +++++++++++++----------------------------- 1 file changed, 21 insertions(+), 48 deletions(-) diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index 4d021489..7bf536e7 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -229,54 +229,7 @@ define_link_wrapper!( ); /// [`SchedClassifierLink`] is the link type used by [`SchedClassifier`] programs. -/// -/// # Examples -/// -/// ```no_run -/// # #[derive(Debug, thiserror::Error)] -/// # enum Error { -/// # #[error(transparent)] -/// # IO(#[from] std::io::Error), -/// # #[error(transparent)] -/// # Map(#[from] aya::maps::MapError), -/// # #[error(transparent)] -/// # Program(#[from] aya::programs::ProgramError), -/// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) -/// # } -/// # let mut bpf = aya::Bpf::load(&[])?; -/// # tc::qdisc_add_clsact("eth0")?; -/// # let prog: &mut SchedClassifier = bpf.program_mut("redirect_ingress").unwrap().try_into()?; -/// # prog.load()?; -/// # -/// # use aya::programs::tc::{SchedClassifierLink}; -/// # use aya::programs::{tc, Link, SchedClassifier, TcAttachType}; -/// # use std::mem; -/// let tc_link_id = prog.attach("eth0", TcAttachType::Ingress)?; -/// -/// let tc_link = prog.take_link(tc_link_id)?; -/// -/// // The priority and handle assigned during attach can be accessed as follows: -/// let priority = tc_link.priority(); -/// let handle = tc_link.handle(); -/// -/// // The following call "forgets" about tc_link so that it is not detached on drop. -/// mem::forget(tc_link); -/// -/// // The link can be re-instantiated and detached as shown below. -/// let new_tc_link = SchedClassifierLink::new_tc_link( -/// "eth0", -/// TcAttachType::Ingress, -/// priority, -/// handle, -/// )?; -/// new_tc_link.detach()?; -/// -/// # Ok::<(), Error>(()) -/// ``` impl SchedClassifierLink { - /// Creates a new link from the provided values. - /// /// This API is used to construct a [`SchedClassifierLink`] where the `if_name`, `attach_type`, /// `priority` and `handle` are already known. This may have been found from a link created by /// [SchedClassifier::attach], the output of the `tc filter` command or from the output of @@ -288,7 +241,27 @@ impl SchedClassifierLink { /// # Errors /// - If a program is not attached with the provided parameters, calls to /// [`SchedClassifierLink::detach`] will return a [`TcError::NetlinkError`] - pub fn new_tc_link( + /// + /// # Examples + /// ```no_run + /// # use aya::programs::tc::SchedClassifierLink; + /// # use aya::programs::TcAttachType; + /// # #[derive(Debug, thiserror::Error)] + /// # enum Error { + /// # #[error(transparent)] + /// # IO(#[from] std::io::Error), + /// # } + /// # fn read_persisted_link_details() -> (String, TcAttachType, u16, u32) { + /// # ("eth0".to_string(), TcAttachType::Ingress, 50, 1) + /// # } + /// // Get the link parameters from some external source. Where and how the parameters are + /// // persisted is up to your application. + /// let (if_name, attach_type, priority, handle) = read_persisted_link_details(); + /// let new_tc_link = SchedClassifierLink::attached(&if_name, attach_type, priority, handle)?; + /// + /// # Ok::<(), Error>(()) + /// ``` + pub fn attached( if_name: &str, attach_type: TcAttachType, priority: u16, From 6766532341803ab70501e0c522afc0656385e002 Mon Sep 17 00:00:00 2001 From: Andre Fredette Date: Thu, 22 Dec 2022 09:28:40 -0500 Subject: [PATCH 35/51] Remove SchedClassifierLink description It was redundant with the one provided in define_link_wrapper Signed-off-by: Andre Fredette --- aya/src/programs/tc.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index 7bf536e7..105911f5 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -228,7 +228,6 @@ define_link_wrapper!( TcLinkId ); -/// [`SchedClassifierLink`] is the link type used by [`SchedClassifier`] programs. impl SchedClassifierLink { /// This API is used to construct a [`SchedClassifierLink`] where the `if_name`, `attach_type`, /// `priority` and `handle` are already known. This may have been found from a link created by From d43879d99177c33c5d33827d8a3c7572841dd9df Mon Sep 17 00:00:00 2001 From: Andre Fredette Date: Wed, 25 Jan 2023 15:12:21 -0500 Subject: [PATCH 36/51] Updates after rebase due to changes in define_link_wrapper Signed-off-by: Andre Fredette --- aya/src/programs/tc.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index 105911f5..e803dc68 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -267,22 +267,22 @@ impl SchedClassifierLink { handle: u32, ) -> Result { let if_index = ifindex_from_ifname(if_name)?; - Ok(SchedClassifierLink(TcLink { + Ok(SchedClassifierLink(Some(TcLink { if_index: if_index as i32, attach_type, priority, handle, - })) + }))) } /// Returns the allocated priority. If none was provided at attach time, this was allocated for you. pub fn priority(&self) -> u16 { - self.0.priority + self.inner().priority } /// Returns the assigned handle. If none was provided at attach time, this was allocated for you. pub fn handle(&self) -> u32 { - self.0.handle + self.inner().handle } } From 556463a85ff7cf921049cb0679a787389a87d7ec Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Wed, 25 Jan 2023 22:25:00 +0000 Subject: [PATCH 37/51] ebpf: SkbBuff: add some accessors --- bpf/aya-bpf/src/programs/sk_buff.rs | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/bpf/aya-bpf/src/programs/sk_buff.rs b/bpf/aya-bpf/src/programs/sk_buff.rs index 3ae6cf3d..669c2c95 100644 --- a/bpf/aya-bpf/src/programs/sk_buff.rs +++ b/bpf/aya-bpf/src/programs/sk_buff.rs @@ -217,6 +217,46 @@ impl SkBuff { pub(crate) fn as_ptr(&self) -> *mut c_void { self.skb as *mut _ } + + #[inline] + pub fn protocol(&self) -> u32 { + unsafe { (*self.skb).protocol } + } + + #[inline] + pub fn family(&self) -> u32 { + unsafe { (*self.skb).family } + } + + #[inline] + pub fn local_ipv4(&self) -> u32 { + unsafe { (*self.skb).local_ip4 } + } + + #[inline] + pub fn local_ipv6(&self) -> &[u32; 4] { + unsafe { &(*self.skb).local_ip6 } + } + + #[inline] + pub fn remote_ipv4(&self) -> u32 { + unsafe { (*self.skb).remote_ip4 } + } + + #[inline] + pub fn remote_ipv6(&self) -> &[u32; 4] { + unsafe { &(*self.skb).remote_ip6 } + } + + #[inline] + pub fn local_port(&self) -> u32 { + unsafe { (*self.skb).local_port } + } + + #[inline] + pub fn remote_port(&self) -> u32 { + unsafe { (*self.skb).remote_port } + } } pub struct SkBuffContext { From 6ad2c3c3731da5e70443ad771765d9454cee195c Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Thu, 26 Jan 2023 17:12:06 +0800 Subject: [PATCH 38/51] aya-bpf-macros: Allow to make programs public Allow to define programs as public functions (even in library crates) and then import them. For example, we can have library crate with `libfoo/src/lib.rs` containing: ```rust pub fn my_xdp_program(ctx: XdpContext) -> u32 { xdp_action::XDP_PASS } ``` And then a binary importing it: ```rust pub use libfoo::my_xdp_program; ``` This way, commonly used eBPF programs can be distributed as lib crates. Tested with: https://github.com/vadorovsky/aya-examples/tree/main/pub-progs Signed-off-by: Michal Rostecki --- aya-bpf-macros/src/expand.rs | 108 ++++++++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 21 deletions(-) diff --git a/aya-bpf-macros/src/expand.rs b/aya-bpf-macros/src/expand.rs index b793a92d..7c47e579 100644 --- a/aya-bpf-macros/src/expand.rs +++ b/aya-bpf-macros/src/expand.rs @@ -119,12 +119,13 @@ impl Probe { pub fn expand(&self) -> Result { let section_name = format!("{}/{}", self.kind, self.name); + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::core::ffi::c_void) -> u32 { + #fn_vis fn #fn_name(ctx: *mut ::core::ffi::c_void) -> u32 { let _ = #fn_name(::aya_bpf::programs::ProbeContext::new(ctx)); return 0; @@ -152,12 +153,13 @@ impl SockOps { } else { "sockops".to_owned() }; + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_sock_ops) -> u32 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_sock_ops) -> u32 { return #fn_name(::aya_bpf::programs::SockOpsContext::new(ctx)); #item @@ -180,12 +182,13 @@ impl SkMsg { pub fn expand(&self) -> Result { let section_name = format!("sk_msg/{}", self.name); + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::sk_msg_md) -> u32 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::sk_msg_md) -> u32 { return #fn_name(::aya_bpf::programs::SkMsgContext::new(ctx)); #item @@ -212,12 +215,13 @@ impl Xdp { } else { "xdp".to_owned() }; + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::xdp_md) -> u32 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::xdp_md) -> u32 { return #fn_name(::aya_bpf::programs::XdpContext::new(ctx)); #item @@ -244,12 +248,13 @@ impl SchedClassifier { } else { "classifier".to_owned() }; + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> i32 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> i32 { return #fn_name(::aya_bpf::programs::TcContext::new(ctx)); #item @@ -276,12 +281,13 @@ impl CgroupSysctl { } else { ("cgroup/sysctl").to_owned() }; + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_sysctl) -> i32 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_sysctl) -> i32 { return #fn_name(::aya_bpf::programs::SysctlContext::new(ctx)); #item @@ -313,12 +319,13 @@ impl CgroupSockopt { } else { format!("cgroup/{}", self.attach_type) }; + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_sockopt) -> i32 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_sockopt) -> i32 { return #fn_name(::aya_bpf::programs::SockoptContext::new(ctx)); #item @@ -358,12 +365,13 @@ impl CgroupSkb { } else { ("cgroup/skb").to_owned() }; + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> i32 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> i32 { return #fn_name(::aya_bpf::programs::SkBuffContext::new(ctx)); #item @@ -396,12 +404,13 @@ impl CgroupSockAddr { } else { format!("cgroup/{}", self.attach_type) }; + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_sock_addr) -> i32 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_sock_addr) -> i32 { return #fn_name(::aya_bpf::programs::SockAddrContext::new(ctx)); #item @@ -441,12 +450,13 @@ impl CgroupSock { } else { "cgroup/sock".to_string() }; + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_sock) -> i32 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_sock) -> i32 { return #fn_name(::aya_bpf::programs::SockContext::new(ctx)); #item @@ -512,12 +522,13 @@ impl TracePoint { pub fn expand(&self) -> Result { let section_name = format!("tp/{}", self.name); + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::core::ffi::c_void) -> u32 { + #fn_vis fn #fn_name(ctx: *mut ::core::ffi::c_void) -> u32 { let _ = #fn_name(::aya_bpf::programs::TracePointContext::new(ctx)); return 0; @@ -541,12 +552,13 @@ impl PerfEvent { pub fn expand(&self) -> Result { let section_name = format!("perf_event/{}", self.name); + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::core::ffi::c_void) -> u32 { + #fn_vis fn #fn_name(ctx: *mut ::core::ffi::c_void) -> u32 { let _ = #fn_name(::aya_bpf::programs::PerfEventContext::new(ctx)); return 0; @@ -570,12 +582,13 @@ impl RawTracePoint { pub fn expand(&self) -> Result { let section_name = format!("raw_tp/{}", self.name); + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::core::ffi::c_void) -> u32 { + #fn_vis fn #fn_name(ctx: *mut ::core::ffi::c_void) -> u32 { let _ = #fn_name(::aya_bpf::programs::RawTracePointContext::new(ctx)); return 0; @@ -599,6 +612,7 @@ impl Lsm { pub fn expand(&self) -> Result { let section_name = format!("lsm/{}", self.name); + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; // LSM probes need to return an integer corresponding to the correct @@ -607,7 +621,7 @@ impl Lsm { Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::core::ffi::c_void) -> i32 { + #fn_vis fn #fn_name(ctx: *mut ::core::ffi::c_void) -> i32 { return #fn_name(::aya_bpf::programs::LsmContext::new(ctx)); #item @@ -630,12 +644,13 @@ impl BtfTracePoint { pub fn expand(&self) -> Result { let section_name = format!("tp_btf/{}", self.name); + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::core::ffi::c_void) -> i32 { + #fn_vis fn #fn_name(ctx: *mut ::core::ffi::c_void) -> i32 { let _ = #fn_name(::aya_bpf::programs::BtfTracePointContext::new(ctx)); return 0; @@ -683,12 +698,13 @@ impl SkSkb { } else { format!("sk_skb/{kind}") }; + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> u32 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> u32 { return #fn_name(::aya_bpf::programs::SkBuffContext::new(ctx)); #item @@ -716,12 +732,13 @@ impl SocketFilter { } else { "socket".to_owned() }; + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> i64 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> i64 { return #fn_name(::aya_bpf::programs::SkBuffContext::new(ctx)); #item @@ -744,12 +761,13 @@ impl FEntry { pub fn expand(&self) -> Result { let section_name = format!("fentry/{}", self.name); + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::core::ffi::c_void) -> i32 { + #fn_vis fn #fn_name(ctx: *mut ::core::ffi::c_void) -> i32 { let _ = #fn_name(::aya_bpf::programs::FEntryContext::new(ctx)); return 0; @@ -773,12 +791,13 @@ impl FExit { pub fn expand(&self) -> Result { let section_name = format!("fexit/{}", self.name); + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::core::ffi::c_void) -> i32 { + #fn_vis fn #fn_name(ctx: *mut ::core::ffi::c_void) -> i32 { let _ = #fn_name(::aya_bpf::programs::FExitContext::new(ctx)); return 0; @@ -806,12 +825,13 @@ impl SkLookup { } else { "sk_lookup".to_owned() }; + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_sk_lookup) -> u32 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_sk_lookup) -> u32 { return #fn_name(::aya_bpf::programs::SkLookupContext::new(ctx)); #item @@ -838,12 +858,13 @@ impl CgroupDevice { } else { ("cgroup/dev").to_owned() }; + let fn_vis = &self.item.vis; let fn_name = &self.item.sig.ident; let item = &self.item; Ok(quote! { #[no_mangle] #[link_section = #section_name] - fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_cgroup_dev_ctx) -> i32 { + #fn_vis fn #fn_name(ctx: *mut ::aya_bpf::bindings::bpf_cgroup_dev_ctx) -> i32 { return #fn_name(::aya_bpf::programs::DeviceContext::new(ctx)); #item @@ -941,4 +962,49 @@ mod tests { .to_string() .contains("[link_section = \"cgroup/dev\"]")); } + + #[test] + fn priv_function() { + let prog = CgroupSkb::from_syn( + parse_quote!(attach = "egress"), + parse_quote!( + fn foo(ctx: SkBuffContext) -> i32 { + 0 + } + ), + ) + .unwrap(); + let stream = prog.expand().unwrap(); + assert!(stream.to_string().contains("] fn foo (")); + } + + #[test] + fn pub_function() { + let prog = CgroupSkb::from_syn( + parse_quote!(attach = "egress"), + parse_quote!( + pub fn foo(ctx: SkBuffContext) -> i32 { + 0 + } + ), + ) + .unwrap(); + let stream = prog.expand().unwrap(); + assert!(stream.to_string().contains("] pub fn foo (")); + } + + #[test] + fn pub_crate_function() { + let prog = CgroupSkb::from_syn( + parse_quote!(attach = "egress"), + parse_quote!( + pub(crate) fn foo(ctx: SkBuffContext) -> i32 { + 0 + } + ), + ) + .unwrap(); + let stream = prog.expand().unwrap(); + assert!(stream.to_string().contains("] pub (crate) fn foo (")); + } } From c6c4ac7eeaf7e6cfa31ab0b949aa93b136eda91b Mon Sep 17 00:00:00 2001 From: banditopazzo Date: Thu, 22 Dec 2022 01:51:13 +0100 Subject: [PATCH 39/51] feat: get_tracefs function --- aya/src/programs/mod.rs | 4 ++++ aya/src/programs/probe.rs | 42 ++++++++++++++++++++------------- aya/src/programs/trace_point.rs | 14 +++++++---- aya/src/programs/utils.rs | 24 ++++++++++++++++++- 4 files changed, 62 insertions(+), 22 deletions(-) diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs index a2a45969..828de7ba 100644 --- a/aya/src/programs/mod.rs +++ b/aya/src/programs/mod.rs @@ -206,6 +206,10 @@ pub enum ProgramError { /// program name name: String, }, + + /// TraceFS not found. + #[error("tracefs non found")] + TraceFsNotFound, } /// A [`Program`] file descriptor. diff --git a/aya/src/programs/probe.rs b/aya/src/programs/probe.rs index e41ea603..f5b0f939 100644 --- a/aya/src/programs/probe.rs +++ b/aya/src/programs/probe.rs @@ -2,14 +2,15 @@ use libc::pid_t; use std::{ fs::{self, OpenOptions}, io::{self, Write}, + path::Path, process, }; use crate::{ programs::{ kprobe::KProbeError, perf_attach, perf_attach::PerfLink, perf_attach_debugfs, - trace_point::read_sys_fs_trace_point_id, uprobe::UProbeError, Link, ProgramData, - ProgramError, + trace_point::read_sys_fs_trace_point_id, uprobe::UProbeError, utils::get_tracefs, Link, + ProgramData, ProgramError, }, sys::{kernel_version, perf_event_open_probe, perf_event_open_trace_point}, }; @@ -60,10 +61,12 @@ pub(crate) fn attach>( pub(crate) fn detach_debug_fs(kind: ProbeKind, event_alias: &str) -> Result<(), ProgramError> { use ProbeKind::*; + let tracefs = get_tracefs()?; + match kind { - KProbe | KRetProbe => delete_probe_event(kind, event_alias) + KProbe | KRetProbe => delete_probe_event(tracefs, kind, event_alias) .map_err(|(filename, io_error)| KProbeError::FileError { filename, io_error })?, - UProbe | URetProbe => delete_probe_event(kind, event_alias) + UProbe | URetProbe => delete_probe_event(tracefs, kind, event_alias) .map_err(|(filename, io_error)| UProbeError::FileError { filename, io_error })?, }; @@ -115,15 +118,17 @@ fn create_as_trace_point( ) -> Result<(i32, String), ProgramError> { use ProbeKind::*; + let tracefs = get_tracefs()?; + let event_alias = match kind { - KProbe | KRetProbe => create_probe_event(kind, name, offset) + KProbe | KRetProbe => create_probe_event(tracefs, kind, name, offset) .map_err(|(filename, io_error)| KProbeError::FileError { filename, io_error })?, - UProbe | URetProbe => create_probe_event(kind, name, offset) + UProbe | URetProbe => create_probe_event(tracefs, kind, name, offset) .map_err(|(filename, io_error)| UProbeError::FileError { filename, io_error })?, }; let category = format!("{}s", kind.pmu()); - let tpid = read_sys_fs_trace_point_id(&category, &event_alias)?; + let tpid = read_sys_fs_trace_point_id(tracefs, &category, &event_alias)?; let fd = perf_event_open_trace_point(tpid, pid).map_err(|(_code, io_error)| { ProgramError::SyscallError { call: "perf_event_open".to_owned(), @@ -135,13 +140,14 @@ fn create_as_trace_point( } fn create_probe_event( + tracefs: &Path, kind: ProbeKind, fn_name: &str, offset: u64, ) -> Result { use ProbeKind::*; - let events_file_name = format!("/sys/kernel/debug/tracing/{}_events", kind.pmu()); + let events_file_name = tracefs.join(format!("{}_events", kind.pmu())); let probe_type_prefix = match kind { KProbe | UProbe => 'p', KRetProbe | URetProbe => 'r', @@ -170,20 +176,24 @@ fn create_probe_event( let mut events_file = OpenOptions::new() .append(true) .open(&events_file_name) - .map_err(|e| (events_file_name.clone(), e))?; + .map_err(|e| (events_file_name.display().to_string(), e))?; events_file .write_all(probe.as_bytes()) - .map_err(|e| (events_file_name.clone(), e))?; + .map_err(|e| (events_file_name.display().to_string(), e))?; Ok(event_alias) } -fn delete_probe_event(kind: ProbeKind, event_alias: &str) -> Result<(), (String, io::Error)> { - let events_file_name = format!("/sys/kernel/debug/tracing/{}_events", kind.pmu()); +fn delete_probe_event( + tracefs: &Path, + kind: ProbeKind, + event_alias: &str, +) -> Result<(), (String, io::Error)> { + let events_file_name = tracefs.join(format!("{}_events", kind.pmu())); - let events = - fs::read_to_string(&events_file_name).map_err(|e| (events_file_name.clone(), e))?; + let events = fs::read_to_string(&events_file_name) + .map_err(|e| (events_file_name.display().to_string(), e))?; let found = events.lines().any(|line| line.contains(event_alias)); @@ -191,13 +201,13 @@ fn delete_probe_event(kind: ProbeKind, event_alias: &str) -> Result<(), (String, let mut events_file = OpenOptions::new() .append(true) .open(&events_file_name) - .map_err(|e| (events_file_name.to_string(), e))?; + .map_err(|e| (events_file_name.display().to_string(), e))?; let rm = format!("-:{event_alias}\n"); events_file .write_all(rm.as_bytes()) - .map_err(|e| (events_file_name.to_string(), e))?; + .map_err(|e| (events_file_name.display().to_string(), e))?; } Ok(()) diff --git a/aya/src/programs/trace_point.rs b/aya/src/programs/trace_point.rs index a3480c27..a5f25e1d 100644 --- a/aya/src/programs/trace_point.rs +++ b/aya/src/programs/trace_point.rs @@ -1,5 +1,5 @@ //! Tracepoint programs. -use std::{fs, io}; +use std::{fs, io, path::Path}; use thiserror::Error; use crate::{ @@ -12,6 +12,8 @@ use crate::{ sys::perf_event_open_trace_point, }; +use super::utils::get_tracefs; + /// The type returned when attaching a [`TracePoint`] fails. #[derive(Debug, Error)] pub enum TracePointError { @@ -77,7 +79,8 @@ impl TracePoint { /// /// The returned value can be used to detach, see [TracePoint::detach]. pub fn attach(&mut self, category: &str, name: &str) -> Result { - let id = read_sys_fs_trace_point_id(category, name)?; + let tracefs = get_tracefs()?; + let id = read_sys_fs_trace_point_id(tracefs, category, name)?; let fd = perf_event_open_trace_point(id, None).map_err(|(_code, io_error)| { ProgramError::SyscallError { call: "perf_event_open".to_owned(), @@ -114,20 +117,21 @@ define_link_wrapper!( ); pub(crate) fn read_sys_fs_trace_point_id( + tracefs: &Path, category: &str, name: &str, ) -> Result { - let file = format!("/sys/kernel/debug/tracing/events/{category}/{name}/id"); + let file = tracefs.join("events").join(category).join(name).join("id"); let id = fs::read_to_string(&file).map_err(|io_error| TracePointError::FileError { - filename: file.clone(), + filename: file.display().to_string(), io_error, })?; let id = id .trim() .parse::() .map_err(|error| TracePointError::FileError { - filename: file.clone(), + filename: file.display().to_string(), io_error: io::Error::new(io::ErrorKind::Other, error), })?; diff --git a/aya/src/programs/utils.rs b/aya/src/programs/utils.rs index 56af2a0f..e9c431b0 100644 --- a/aya/src/programs/utils.rs +++ b/aya/src/programs/utils.rs @@ -1,5 +1,5 @@ //! Common functions shared between multiple eBPF program types. -use std::{ffi::CStr, os::unix::io::RawFd}; +use std::{ffi::CStr, os::unix::io::RawFd, path::Path}; use crate::{ programs::{FdLink, Link, ProgramData, ProgramError}, @@ -22,3 +22,25 @@ pub(crate) fn attach_raw_tracepoint>( program_data.links.insert(FdLink::new(pfd).into()) } + +// Get tracefs filesystem +pub(crate) fn get_tracefs() -> Result<&'static Path, ProgramError> { + lazy_static::lazy_static! { + static ref TRACE_FS: Option<&'static Path> = { + let mounts = [ + Path::new("/sys/kernel/tracing"), + Path::new("/sys/kernel/debug/tracing"), + ]; + + for mount in mounts { + if mount.exists() { + return Some(mount); + } + } + None + + }; + } + + TRACE_FS.as_deref().ok_or(ProgramError::TraceFsNotFound) +} From 48fdf5a250ce74516a02c0f34b0f359f7f9a4d63 Mon Sep 17 00:00:00 2001 From: banditopazzo Date: Tue, 10 Jan 2023 10:57:52 +0100 Subject: [PATCH 40/51] chore: tracefs review fixes --- aya/src/programs/mod.rs | 6 +++--- aya/src/programs/probe.rs | 8 ++++---- aya/src/programs/trace_point.rs | 5 ++--- aya/src/programs/utils.rs | 15 ++++++++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs index 828de7ba..4454fcc3 100644 --- a/aya/src/programs/mod.rs +++ b/aya/src/programs/mod.rs @@ -207,9 +207,9 @@ pub enum ProgramError { name: String, }, - /// TraceFS not found. - #[error("tracefs non found")] - TraceFsNotFound, + /// An error occurred while working with IO. + #[error(transparent)] + IOError(#[from] io::Error), } /// A [`Program`] file descriptor. diff --git a/aya/src/programs/probe.rs b/aya/src/programs/probe.rs index f5b0f939..f595ca53 100644 --- a/aya/src/programs/probe.rs +++ b/aya/src/programs/probe.rs @@ -9,8 +9,8 @@ use std::{ use crate::{ programs::{ kprobe::KProbeError, perf_attach, perf_attach::PerfLink, perf_attach_debugfs, - trace_point::read_sys_fs_trace_point_id, uprobe::UProbeError, utils::get_tracefs, Link, - ProgramData, ProgramError, + trace_point::read_sys_fs_trace_point_id, uprobe::UProbeError, utils::find_tracefs_path, + Link, ProgramData, ProgramError, }, sys::{kernel_version, perf_event_open_probe, perf_event_open_trace_point}, }; @@ -61,7 +61,7 @@ pub(crate) fn attach>( pub(crate) fn detach_debug_fs(kind: ProbeKind, event_alias: &str) -> Result<(), ProgramError> { use ProbeKind::*; - let tracefs = get_tracefs()?; + let tracefs = find_tracefs_path()?; match kind { KProbe | KRetProbe => delete_probe_event(tracefs, kind, event_alias) @@ -118,7 +118,7 @@ fn create_as_trace_point( ) -> Result<(i32, String), ProgramError> { use ProbeKind::*; - let tracefs = get_tracefs()?; + let tracefs = find_tracefs_path()?; let event_alias = match kind { KProbe | KRetProbe => create_probe_event(tracefs, kind, name, offset) diff --git a/aya/src/programs/trace_point.rs b/aya/src/programs/trace_point.rs index a5f25e1d..d4bf158d 100644 --- a/aya/src/programs/trace_point.rs +++ b/aya/src/programs/trace_point.rs @@ -7,13 +7,12 @@ use crate::{ programs::{ define_link_wrapper, load_program, perf_attach::{perf_attach, PerfLink, PerfLinkId}, + utils::find_tracefs_path, ProgramData, ProgramError, }, sys::perf_event_open_trace_point, }; -use super::utils::get_tracefs; - /// The type returned when attaching a [`TracePoint`] fails. #[derive(Debug, Error)] pub enum TracePointError { @@ -79,7 +78,7 @@ impl TracePoint { /// /// The returned value can be used to detach, see [TracePoint::detach]. pub fn attach(&mut self, category: &str, name: &str) -> Result { - let tracefs = get_tracefs()?; + let tracefs = find_tracefs_path()?; let id = read_sys_fs_trace_point_id(tracefs, category, name)?; let fd = perf_event_open_trace_point(id, None).map_err(|(_code, io_error)| { ProgramError::SyscallError { diff --git a/aya/src/programs/utils.rs b/aya/src/programs/utils.rs index e9c431b0..143e8664 100644 --- a/aya/src/programs/utils.rs +++ b/aya/src/programs/utils.rs @@ -1,5 +1,5 @@ //! Common functions shared between multiple eBPF program types. -use std::{ffi::CStr, os::unix::io::RawFd, path::Path}; +use std::{ffi::CStr, io, os::unix::io::RawFd, path::Path}; use crate::{ programs::{FdLink, Link, ProgramData, ProgramError}, @@ -23,24 +23,25 @@ pub(crate) fn attach_raw_tracepoint>( program_data.links.insert(FdLink::new(pfd).into()) } -// Get tracefs filesystem -pub(crate) fn get_tracefs() -> Result<&'static Path, ProgramError> { +/// Find tracefs filesystem path +pub(crate) fn find_tracefs_path() -> Result<&'static Path, ProgramError> { lazy_static::lazy_static! { static ref TRACE_FS: Option<&'static Path> = { - let mounts = [ + let known_mounts = [ Path::new("/sys/kernel/tracing"), Path::new("/sys/kernel/debug/tracing"), ]; - for mount in mounts { + for mount in known_mounts { if mount.exists() { return Some(mount); } } None - }; } - TRACE_FS.as_deref().ok_or(ProgramError::TraceFsNotFound) + TRACE_FS + .as_deref() + .ok_or_else(|| io::Error::new(io::ErrorKind::Other, "tracefs not found").into()) } From 7d19bde66bfe893cb69a550552740524064e60fa Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Sat, 28 Jan 2023 13:22:56 +0800 Subject: [PATCH 41/51] Unpin Rust nightly The issues with core::sync::atomic got fixed. Signed-off-by: Michal Rostecki --- .github/workflows/build-aya-bpf.yml | 2 +- .github/workflows/build-aya.yml | 2 +- netlify.toml | 2 +- xtask/src/build_ebpf.rs | 2 +- xtask/src/docs/mod.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-aya-bpf.yml b/.github/workflows/build-aya-bpf.yml index 1d134ca9..a29d7c09 100644 --- a/.github/workflows/build-aya-bpf.yml +++ b/.github/workflows/build-aya-bpf.yml @@ -30,7 +30,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2023-01-10 + toolchain: nightly components: rust-src override: true diff --git a/.github/workflows/build-aya.yml b/.github/workflows/build-aya.yml index 0b9a0ef5..991298fa 100644 --- a/.github/workflows/build-aya.yml +++ b/.github/workflows/build-aya.yml @@ -57,7 +57,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2023-01-10 + toolchain: nightly components: rustfmt, clippy, rust-src target: x86_64-unknown-linux-musl override: true diff --git a/netlify.toml b/netlify.toml index 8e0773ea..3ad62912 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,3 +1,3 @@ [build] publish = "site" - command = "rustup toolchain install nightly-2023-01-10 -c rust-src && cargo xtask docs" + command = "rustup toolchain install nightly -c rust-src && cargo xtask docs" diff --git a/xtask/src/build_ebpf.rs b/xtask/src/build_ebpf.rs index cd5b9234..4f98feba 100644 --- a/xtask/src/build_ebpf.rs +++ b/xtask/src/build_ebpf.rs @@ -60,7 +60,7 @@ fn build_rust_ebpf(opts: &BuildEbpfOptions) -> anyhow::Result<()> { let target = format!("--target={}", opts.target); let mut args = vec![ - "+nightly-2023-01-10", + "+nightly", "build", "--verbose", target.as_str(), diff --git a/xtask/src/docs/mod.rs b/xtask/src/docs/mod.rs index b17ecb7c..bfeca3a9 100644 --- a/xtask/src/docs/mod.rs +++ b/xtask/src/docs/mod.rs @@ -61,7 +61,7 @@ fn build_docs(working_dir: &PathBuf, abs_header_path: &Path) -> Result<(), anyho .expect("failed to replace logo"); assert!(replace.success()); - let args = vec!["+nightly-2023-01-10", "doc", "--no-deps", "--all-features"]; + let args = vec!["+nightly", "doc", "--no-deps", "--all-features"]; let status = Command::new("cargo") .current_dir(working_dir) From c7b262641b0657fdcf71182e0a7fd95a516f802c Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Fri, 27 Jan 2023 00:28:33 +1100 Subject: [PATCH 42/51] Run integration tests under fedora37 --- test/run.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/run.sh b/test/run.sh index 3bb6c6f3..a01171c2 100755 --- a/test/run.sh +++ b/test/run.sh @@ -15,7 +15,7 @@ fi # Test Image if [ -z "${AYA_TEST_IMAGE}" ]; then - AYA_TEST_IMAGE="fedora36" + AYA_TEST_IMAGE="fedora37" fi case "${AYA_TEST_IMAGE}" in @@ -26,12 +26,12 @@ esac download_images() { mkdir -p "${AYA_IMGDIR}" case $1 in - fedora36) - if [ ! -f "${AYA_IMGDIR}/fedora36.${AYA_TEST_ARCH}.qcow2" ]; then - IMAGE="Fedora-Cloud-Base-36-1.5.${AYA_TEST_ARCH}.qcow2" - IMAGE_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/36/Cloud/${AYA_TEST_ARCH}/images" + fedora37) + if [ ! -f "${AYA_IMGDIR}/fedora37.${AYA_TEST_ARCH}.qcow2" ]; then + IMAGE="Fedora-Cloud-Base-37-1.7.${AYA_TEST_ARCH}.qcow2" + IMAGE_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/37/Cloud/${AYA_TEST_ARCH}/images" echo "Downloading: ${IMAGE}, this may take a while..." - curl -o "${AYA_IMGDIR}/fedora36.${AYA_TEST_ARCH}.qcow2" -sSL "${IMAGE_URL}/${IMAGE}" + curl -o "${AYA_IMGDIR}/fedora37.${AYA_TEST_ARCH}.qcow2" -sSL "${IMAGE_URL}/${IMAGE}" fi ;; centos8) From 8e9608eedd3c437919e74b3256639faad430dd20 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Fri, 27 Jan 2023 08:25:48 +1100 Subject: [PATCH 43/51] test/run.sh: output `uname -a` after starting the vm --- test/run.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/run.sh b/test/run.sh index a01171c2..66a282b1 100755 --- a/test/run.sh +++ b/test/run.sh @@ -139,7 +139,9 @@ EOF sleep 1 done - echo "VM launched, installing dependencies" + echo "VM launched" + exec_vm uname -a + echo "Installing dependencies" exec_vm sudo dnf install -qy bpftool } From 455cc95e8f317f6512ec935e0835db230e758765 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Sun, 29 Jan 2023 18:37:25 +1100 Subject: [PATCH 44/51] integration-tests: run on macos to get nested virtualization Switch integration-test host to macos as only macos runners support nested virtualization. Adjust integration test runner accordingly. --- .cargo/config | 5 +- .github/workflows/build-aya.yml | 41 +--- .github/workflows/integration-tests.yml | 43 ++++ test/cloud-localds | 264 ++++++++++++++++++++++++ test/run.sh | 134 ++++++++---- xtask/src/build_test.rs | 15 +- 6 files changed, 416 insertions(+), 86 deletions(-) create mode 100644 .github/workflows/integration-tests.yml create mode 100755 test/cloud-localds diff --git a/.cargo/config b/.cargo/config index dbd1a2b4..8f7da22a 100644 --- a/.cargo/config +++ b/.cargo/config @@ -7,4 +7,7 @@ build-bpfeb = "build -Zbuild-std=core --target=bpfeb-unknown-none" linker = "arm-linux-gnueabi-gcc" [target.armv7-unknown-linux-gnueabihf] -linker = "arm-linux-gnueabihf-gcc" \ No newline at end of file +linker = "arm-linux-gnueabihf-gcc" + +[target.aarch64-unknown-linux-musl] +linker = "aarch64-linux-musl-gcc" diff --git a/.github/workflows/build-aya.yml b/.github/workflows/build-aya.yml index 991298fa..076e3ac5 100644 --- a/.github/workflows/build-aya.yml +++ b/.github/workflows/build-aya.yml @@ -14,7 +14,7 @@ env: CARGO_TERM_COLOR: always jobs: - build: + build-test: strategy: matrix: arch: @@ -43,42 +43,3 @@ jobs: RUST_BACKTRACE: full run: | cross test --verbose --target ${{matrix.arch}} - - test: - runs-on: ubuntu-20.04 - needs: build - - steps: - - uses: actions/checkout@v2 - - uses: actions/checkout@v2 - with: - repository: libbpf/libbpf - path: libbpf - - - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - components: rustfmt, clippy, rust-src - target: x86_64-unknown-linux-musl - override: true - - - uses: Swatinem/rust-cache@v1 - - - name: Install Pre-requisites - run: | - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" | sudo tee -a /etc/apt/sources.list - sudo apt-get update - sudo apt-get -qy install linux-tools-common qemu-system-x86 cloud-image-utils openssh-client libelf-dev gcc-multilib llvm-15 clang-15 - sudo update-alternatives --install /usr/bin/llvm-objcopy llvm-objcopy /usr/bin/llvm-objcopy-15 200 - sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 200 - cargo install bpf-linker - - - name: Lint integration tests - run: | - cargo xtask build-integration-test-ebpf --libbpf-dir ./libbpf - cargo clippy -p integration-test -- --deny warnings - - - name: Run integration tests - run: | - (cd test && ./run.sh ../libbpf) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml new file mode 100644 index 00000000..f06de720 --- /dev/null +++ b/.github/workflows/integration-tests.yml @@ -0,0 +1,43 @@ +name: integration-tests + +on: + push: + branches: + - main + + pull_request: + branches: + - main + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + runs-on: macos-latest + + steps: + - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + with: + repository: libbpf/libbpf + path: libbpf + + - name: Install Pre-requisites + run: | + brew install qemu gnu-getopt coreutils cdrtools + + - name: Cache tmp files + uses: actions/cache@v3 + with: + path: | + .tmp/*.qcow2 + .tmp/test_rsa + .tmp/test_rsa.pub + # FIXME: we should invalidate the cache on new bpf-linker releases. + # For now we must manually delete the cache when we release a new + # bpf-linker version. + key: tmp-files-${{ hashFiles('test/run.sh') }} + + - name: Run integration tests + run: test/run.sh ./libbpf diff --git a/test/cloud-localds b/test/cloud-localds new file mode 100755 index 00000000..3a28129f --- /dev/null +++ b/test/cloud-localds @@ -0,0 +1,264 @@ +#!/bin/bash + +VERBOSITY=0 +TEMP_D="" +DEF_DISK_FORMAT="raw" +DEF_FILESYSTEM="iso9660" +CR=" +" + +error() { echo "$@" 1>&2; } +fail() { [ $# -eq 0 ] || error "$@"; exit 1; } + +Usage() { + cat < my-meta-data + * ${0##*/} my-seed.img my-user-data my-meta-data + * kvm -net nic -net user,hostfwd=tcp::2222-:22 \\ + -drive file=disk1.img,if=virtio -drive file=my-seed.img,if=virtio + * ssh -p 2222 ubuntu@localhost +EOF +} + +bad_Usage() { Usage 1>&2; [ $# -eq 0 ] || error "$@"; exit 1; } +cleanup() { + [ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}" +} + +debug() { + local level=${1}; shift; + [ "${level}" -gt "${VERBOSITY}" ] && return + error "${@}" +} + +has_cmd() { + command -v "$1" >/dev/null 2>&1 +} + +short_opts="hH:i:d:f:m:N:o:V:v" +long_opts="disk-format:,dsmode:,filesystem:,help,hostname:,interfaces:," +long_opts="${long_opts}network-config:,output:,vendor-data:,verbose" +getopt_out=$(getopt -n "${0##*/}" \ + -o "${short_opts}" -l "${long_opts}" -- "$@") && + eval set -- "${getopt_out}" || + bad_Usage + +## <> +output="" +userdata="" +metadata="" +vendordata="" +filesystem="" +diskformat=$DEF_DISK_FORMAT +interfaces=_unset +dsmode="" +hostname="" +ncname="network-config" + + +while [ $# -ne 0 ]; do + cur=${1}; next=${2}; + case "$cur" in + -h|--help) Usage ; exit 0;; + -d|--disk-format) diskformat=$next; shift;; + -f|--filesystem) filesystem=$next; shift;; + -H|--hostname) hostname=$next; shift;; + -i|--interfaces) interfaces=$next; shift;; + -N|--network-config) netcfg=$next; shift;; + -m|--dsmode) dsmode=$next; shift;; + -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));; + -V|--vendor-data) vendordata="$next";; + --) shift; break;; + esac + shift; +done + +## check arguments here +## how many args do you expect? +echo $1 +echo $2 +echo $3 +[ $# -ge 2 ] || bad_Usage "must provide output, userdata" +[ $# -le 3 ] || bad_Usage "confused by additional args" + +output=$1 +userdata=$2 +metadata=$3 + +if [ -n "$metadata" ]; then + [ "$interfaces" = "_unset" -a -z "$dsmode" -a -z "$hostname" ] || + fail "metadata is incompatible with:" \ + "--interfaces, --hostname, --dsmode" +fi + +case "$diskformat" in + tar|tar-seed-local|tar-seed-net) + if [ "${filesystem:-tar}" != "tar" ]; then + fail "diskformat=tar is incompatible with filesystem" + fi + filesystem="$diskformat" + ;; + tar*) + fail "supported 'tar' formats are tar, tar-seed-local, tar-seed-net" +esac + +if [ -z "$filesystem" ]; then + filesystem="$DEF_FILESYSTEM" +fi +if [ "$filesystem" = "iso" ]; then + filesystem="iso9660" +fi + +case "$filesystem" in + tar*) + has_cmd tar || + fail "missing 'tar'. Required for --filesystem=$filesystem";; + vfat) + has_cmd mkfs.vfat || + fail "missing 'mkfs.vfat'. Required for --filesystem=vfat." + has_cmd mcopy || + fail "missing 'mcopy'. Required for --filesystem=vfat." + ;; + iso9660) + has_cmd mkisofs || + fail "missing 'mkisofs'. Required for --filesystem=iso9660." + ;; + *) fail "unknown filesystem $filesystem";; +esac + +case "$diskformat" in + tar*|raw) :;; + *) has_cmd "qemu-img" || + fail "missing 'qemu-img'. Required for --disk-format=$diskformat." +esac + +[ "$interfaces" = "_unset" -o -r "$interfaces" ] || + fail "$interfaces: not a readable file" + +TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") || + fail "failed to make tempdir" +trap cleanup EXIT + +files=( "${TEMP_D}/user-data" "${TEMP_D}/meta-data" ) +if [ -n "$metadata" ]; then + cp "$metadata" "$TEMP_D/meta-data" || fail "$metadata: failed to copy" +else + instance_id="iid-local01" + iface_data="" + [ "$interfaces" != "_unset" ] && + iface_data=$(sed ':a;N;$!ba;s/\n/\\n/g' "$interfaces") + + # write json formatted user-data (json is a subset of yaml) + mdata="" + for kv in "instance-id:$instance_id" "local-hostname:$hostname" \ + "interfaces:${iface_data}" "dsmode:$dsmode"; do + key=${kv%%:*} + val=${kv#*:} + [ -n "$val" ] || continue + mdata="${mdata:+${mdata},${CR}}\"$key\": \"$val\"" + done + printf "{\n%s\n}\n" "$mdata" > "${TEMP_D}/meta-data" +fi + +if [ -n "$netcfg" ]; then + cp "$netcfg" "${TEMP_D}/$ncname" || + fail "failed to copy network config" + files[${#files[@]}]="$TEMP_D/$ncname" +fi + +if [ -n "$vendordata" ]; then + cp "$vendordata" "${TEMP_D}/vendor-data" || + fail "failed to copy vendor data" + files[${#files[@]}]="$TEMP_D/vendor-data" +fi + +files_rel=( ) +for f in "${files[@]}"; do + files_rel[${#files_rel[@]}]="${f#${TEMP_D}/}" +done + +if [ "$userdata" = "-" ]; then + cat > "$TEMP_D/user-data" || fail "failed to read from stdin" +else + cp "$userdata" "$TEMP_D/user-data" || fail "$userdata: failed to copy" +fi + +## alternatively, create a vfat filesystem with same files +img="$TEMP_D/seed-data" +tar_opts=( --owner=root --group=root ) + +case "$filesystem" in + tar) + tar "${tar_opts[@]}" -C "${TEMP_D}" -cf "$img" "${files_rel[@]}" || + fail "failed to create tarball of ${files_rel[*]}" + ;; + tar-seed-local|tar-seed-net) + if [ "$filesystem" = "tar-seed-local" ]; then + path="var/lib/cloud/seed/nocloud" + else + path="var/lib/cloud/seed/nocloud-net" + fi + mkdir -p "${TEMP_D}/${path}" || + fail "failed making path for seed files" + mv "${files[@]}" "${TEMP_D}/$path" || + fail "failed moving files" + tar "${tar_opts[@]}" -C "${TEMP_D}" -cf "$img" "${path}" || + fail "failed to create tarball with $path" + ;; + iso9660) + mkisofs -output "$img" -volid cidata \ + -joliet -rock "${files[@]}" > "$TEMP_D/err" 2>&1 || + { cat "$TEMP_D/err" 1>&2; fail "failed to mkisofs"; } + ;; + vfat) + truncate -s 128K "$img" || fail "failed truncate image" + out=$(mkfs.vfat -n cidata "$img" 2>&1) || + { error "failed: mkfs.vfat -n cidata $img"; error "$out"; } + mcopy -oi "$img" "${files[@]}" :: || + fail "failed to copy user-data, meta-data to img" + ;; +esac + +[ "$output" = "-" ] && output="$TEMP_D/final" +if [ "${diskformat#tar}" != "$diskformat" -o "$diskformat" = "raw" ]; then + cp "$img" "$output" || + fail "failed to copy image to $output" +else + qemu-img convert -f raw -O "$diskformat" "$img" "$output" || + fail "failed to convert to disk format $diskformat" +fi + +[ "$output" != "$TEMP_D/final" ] || { cat "$output" && output="-"; } || + fail "failed to write to -" + +debug 1 "wrote ${output} with filesystem=$filesystem and diskformat=$diskformat" +# vi: ts=4 noexpandtab diff --git a/test/run.sh b/test/run.sh index 66a282b1..94600529 100755 --- a/test/run.sh +++ b/test/run.sh @@ -2,15 +2,40 @@ set -e +if [ "$(uname -s)" = "Darwin" ]; then + export PATH="$(dirname $(brew list gnu-getopt | grep "bin/getopt$")):$PATH" +fi + +AYA_SOURCE_DIR="$(realpath $(dirname $0)/..)" +LIBBPF_DIR=$1 + # Temporary directory for tests to use. -AYA_TMPDIR="$(pwd)/.tmp" +AYA_TMPDIR="${AYA_SOURCE_DIR}/.tmp" # Directory for VM images AYA_IMGDIR=${AYA_TMPDIR} -# Test Architecture -if [ -z "${AYA_TEST_ARCH}" ]; then - AYA_TEST_ARCH="$(uname -m)" +if [ -z "${AYA_BUILD_TARGET}" ]; then + AYA_BUILD_TARGET=$(rustc -vV | sed -n 's|host: ||p') +fi + +AYA_HOST_ARCH=$(uname -m) +if [ "${AYA_HOST_ARCH}" = "arm64" ]; then + AYA_HOST_ARCH="aarch64" +fi + +if [ -z "${AYA_GUEST_ARCH}" ]; then + AYA_GUEST_ARCH="${AYA_HOST_ARCH}" +fi + +if [ "${AYA_GUEST_ARCH}" = "aarch64" ]; then + if [ -z "${AARCH64_UEFI}" ]; then + AARCH64_UEFI="$(brew list qemu -1 -v | grep edk2-aarch64-code.fd)" + fi +fi + +if [ -z "$AYA_MUSL_TARGET" ]; then + AYA_MUSL_TARGET=${AYA_GUEST_ARCH}-unknown-linux-musl fi # Test Image @@ -27,19 +52,19 @@ download_images() { mkdir -p "${AYA_IMGDIR}" case $1 in fedora37) - if [ ! -f "${AYA_IMGDIR}/fedora37.${AYA_TEST_ARCH}.qcow2" ]; then - IMAGE="Fedora-Cloud-Base-37-1.7.${AYA_TEST_ARCH}.qcow2" - IMAGE_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/37/Cloud/${AYA_TEST_ARCH}/images" + if [ ! -f "${AYA_IMGDIR}/fedora37.${AYA_GUEST_ARCH}.qcow2" ]; then + IMAGE="Fedora-Cloud-Base-37-1.7.${AYA_GUEST_ARCH}.qcow2" + IMAGE_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/37/Cloud/${AYA_GUEST_ARCH}/images" echo "Downloading: ${IMAGE}, this may take a while..." - curl -o "${AYA_IMGDIR}/fedora37.${AYA_TEST_ARCH}.qcow2" -sSL "${IMAGE_URL}/${IMAGE}" + curl -o "${AYA_IMGDIR}/fedora37.${AYA_GUEST_ARCH}.qcow2" -sSL "${IMAGE_URL}/${IMAGE}" fi ;; centos8) - if [ ! -f "${AYA_IMGDIR}/centos8.${AYA_TEST_ARCH}.qcow2" ]; then - IMAGE="CentOS-8-GenericCloud-8.4.2105-20210603.0.${AYA_TEST_ARCH}.qcow2" - IMAGE_URL="https://cloud.centos.org/centos/8/${AYA_TEST_ARCH}/images" + if [ ! -f "${AYA_IMGDIR}/centos8.${AYA_GUEST_ARCH}.qcow2" ]; then + IMAGE="CentOS-8-GenericCloud-8.4.2105-20210603.0.${AYA_GUEST_ARCH}.qcow2" + IMAGE_URL="https://cloud.centos.org/centos/8/${AYA_GUEST_ARCH}/images" echo "Downloading: ${IMAGE}, this may take a while..." - curl -o "${AYA_IMGDIR}/centos8.${AYA_TEST_ARCH}.qcow2" -sSL "${IMAGE_URL}/${IMAGE}" + curl -o "${AYA_IMGDIR}/centos8.${AYA_GUEST_ARCH}.qcow2" -sSL "${IMAGE_URL}/${IMAGE}" fi ;; *) @@ -60,11 +85,6 @@ EOF if [ ! -f "${AYA_TMPDIR}/test_rsa" ]; then ssh-keygen -t rsa -b 4096 -f "${AYA_TMPDIR}/test_rsa" -N "" -C "" -q pub_key=$(cat "${AYA_TMPDIR}/test_rsa.pub") - cat > "${AYA_TMPDIR}/user-data.yaml" < "${AYA_TMPDIR}/user-data.yaml" < actual_cores + nr_cpus=8 fi fi ;; *) - echo "${AYA_TEST_ARCH} is not supported" + echo "${AYA_GUEST_ARCH} is not supported" return 1 ;; esac - qemu-img create -F qcow2 -f qcow2 -o backing_file="${AYA_IMGDIR}/${AYA_TEST_IMAGE}.${AYA_TEST_ARCH}.qcow2" "${AYA_TMPDIR}/vm.qcow2" || return 1 + if [ ! -f "${AYA_IMGDIR}/vm.qcow2" ]; then + echo "Creating VM image" + qemu-img create -F qcow2 -f qcow2 -o backing_file="${AYA_IMGDIR}/${AYA_TEST_IMAGE}.${AYA_GUEST_ARCH}.qcow2" "${AYA_IMGDIR}/vm.qcow2" || return 1 + CACHED_VM=0 + else + echo "Reusing existing VM image" + CACHED_VM=1 + fi $QEMU \ -machine "${machine}" \ -cpu "${cpu}" \ - -m 2G \ + -m 3G \ + -smp "${nr_cpus}" \ -display none \ -monitor none \ -daemonize \ -pidfile "${AYA_TMPDIR}/vm.pid" \ -device virtio-net-pci,netdev=net0 \ -netdev user,id=net0,hostfwd=tcp::2222-:22 \ - -drive if=virtio,format=qcow2,file="${AYA_TMPDIR}/vm.qcow2" \ + $uefi \ + -drive if=virtio,format=qcow2,file="${AYA_IMGDIR}/vm.qcow2" \ -drive if=virtio,format=raw,file="${AYA_TMPDIR}/seed.img" || return 1 trap cleanup_vm EXIT @@ -142,7 +182,11 @@ EOF echo "VM launched" exec_vm uname -a echo "Installing dependencies" - exec_vm sudo dnf install -qy bpftool + exec_vm sudo dnf install -qy bpftool llvm llvm-devel clang clang-devel zlib-devel + exec_vm 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ + -y --profile minimal --default-toolchain nightly --component rust-src --component clippy' + exec_vm 'echo source ~/.cargo/env >> ~/.bashrc' + exec_vm cargo install bpf-linker --no-default-features --features system-llvm } scp_vm() { @@ -154,6 +198,10 @@ scp_vm() { "${AYA_SSH_USER}@localhost:${remote}" } +rsync_vm() { + rsync -a -e "ssh -p 2222 -F ${AYA_TMPDIR}/ssh_config -i ${AYA_TMPDIR}/test_rsa" $1 $AYA_SSH_USER@localhost: +} + exec_vm() { ssh -q -F "${AYA_TMPDIR}/ssh_config" \ -i "${AYA_TMPDIR}/test_rsa" \ @@ -168,26 +216,34 @@ stop_vm() { kill -9 "$(cat "${AYA_TMPDIR}/vm.pid")" rm "${AYA_TMPDIR}/vm.pid" fi - rm -f "${AYA_TMPDIR}/vm.qcow2" } cleanup_vm() { + stop_vm if [ "$?" != "0" ]; then - stop_vm + rm -f "${AYA_IMGDIR}/vm.qcow2" fi } -if [ -z "$1" ]; then +if [ -z "$LIBBPF_DIR" ]; then echo "path to libbpf required" exit 1 fi start_vm -trap stop_vm EXIT - -cargo xtask build-integration-test --musl --libbpf-dir "$1" -scp_vm ../target/x86_64-unknown-linux-musl/debug/integration-test -exec_vm sudo ./integration-test --skip relocations - -# Relocation tests build the eBPF programs themself. We run them outside VM. -sudo -E ../target/x86_64-unknown-linux-musl/debug/integration-test relocations +trap cleanup_vm EXIT + +# make sure we always use fresh aya and libbpf (also see comment at the end) +exec_vm "rm -rf aya/* libbpf" +rsync_vm "--exclude=target --exclude=.tmp $AYA_SOURCE_DIR" +rsync_vm "$LIBBPF_DIR" + +# need to build or linting will fail trying to include object files +exec_vm "cd aya; cargo xtask build-integration-test --libbpf-dir ~/libbpf" +exec_vm "cd aya; cargo clippy -p integration-test -- --deny warnings" +exec_vm "cd aya; cargo xtask integration-test --libbpf-dir ~/libbpf" + +# we rm and sync but it doesn't seem to work reliably - I guess we could sleep a +# few seconds after but ain't nobody got time for that. Instead we also rm +# before rsyncing. +exec_vm "rm -rf aya/* libbpf; sync" diff --git a/xtask/src/build_test.rs b/xtask/src/build_test.rs index 5d727ac0..b45943a1 100644 --- a/xtask/src/build_test.rs +++ b/xtask/src/build_test.rs @@ -5,9 +5,9 @@ use crate::build_ebpf; #[derive(Parser)] pub struct Options { - /// Whether to compile for the musl libc target - #[clap(short, long)] - pub musl: bool, + /// Target triple for which the code is compiled + #[clap(long)] + pub musl_target: Option, #[clap(flatten)] pub ebpf_options: build_ebpf::BuildEbpfOptions, @@ -16,9 +16,12 @@ pub struct Options { pub fn build_test(opts: Options) -> anyhow::Result<()> { build_ebpf::build_ebpf(opts.ebpf_options)?; - let mut args = vec!["build", "-p", "integration-test", "--verbose"]; - if opts.musl { - args.push("--target=x86_64-unknown-linux-musl"); + let mut args = ["build", "-p", "integration-test", "--verbose"] + .iter() + .map(|s| s.to_string()) + .collect::>(); + if let Some(target) = opts.musl_target { + args.push(format!("--target={target}")); } let status = Command::new("cargo") .args(&args) From d6b976c6f1f6163680c179502f4f454d0cec747e Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Wed, 30 Nov 2022 19:10:57 +1100 Subject: [PATCH 45/51] aya: btf: switch ComputedRelocationValue::value to u64 This is in preparation of adding Enum64 relocation support --- aya-obj/src/btf/relocation.rs | 34 +++++++++---------- .../integration-test/src/tests/relocations.rs | 25 +++++--------- 2 files changed, 26 insertions(+), 33 deletions(-) diff --git a/aya-obj/src/btf/relocation.rs b/aya-obj/src/btf/relocation.rs index f70502b0..05551dd0 100644 --- a/aya-obj/src/btf/relocation.rs +++ b/aya-obj/src/btf/relocation.rs @@ -786,7 +786,7 @@ struct ComputedRelocation { #[derive(Debug)] struct ComputedRelocationValue { - value: u32, + value: u64, size: u32, type_id: Option, } @@ -854,7 +854,7 @@ impl ComputedRelocation { ins.imm = target_value as i32; } BPF_LDX | BPF_ST | BPF_STX => { - if target_value > i16::MAX as u32 { + if target_value > i16::MAX as u64 { return Err(RelocationError::InvalidInstruction { relocation_number: rel.number, index: ins_index, @@ -914,7 +914,7 @@ impl ComputedRelocation { }, )?; - next_ins.imm = 0; + next_ins.imm = (target_value >> 32) as i32; } class => { return Err(RelocationError::InvalidInstruction { @@ -934,11 +934,11 @@ impl ComputedRelocation { ) -> Result { use RelocationKind::*; let value = match (rel.kind, spec) { - (EnumVariantExists, spec) => spec.is_some() as u32, + (EnumVariantExists, spec) => spec.is_some() as u64, (EnumVariantValue, Some(spec)) => { let accessor = &spec.accessors[0]; match spec.btf.type_by_id(accessor.type_id)? { - BtfType::Enum(en) => en.variants[accessor.index].value as u32, + BtfType::Enum(en) => en.variants[accessor.index].value as u64, // candidate selection ensures that rel_kind == local_kind == target_kind _ => unreachable!(), } @@ -969,7 +969,7 @@ impl ComputedRelocation { // this is the bpf_preserve_field_info(member_access, FIELD_EXISTENCE) case. If we // managed to build a spec, it means the field exists. return Ok(ComputedRelocationValue { - value: spec.is_some() as u32, + value: spec.is_some() as u64, size: 0, type_id: None, }); @@ -991,12 +991,12 @@ impl ComputedRelocation { // the last accessor is unnamed, meaning that this is an array access return match rel.kind { FieldByteOffset => Ok(ComputedRelocationValue { - value: (spec.bit_offset / 8) as u32, + value: (spec.bit_offset / 8) as u64, size: spec.btf.type_size(accessor.type_id)? as u32, type_id: Some(accessor.type_id), }), FieldByteSize => Ok(ComputedRelocationValue { - value: spec.btf.type_size(accessor.type_id)? as u32, + value: spec.btf.type_size(accessor.type_id)? as u64, size: 0, type_id: Some(accessor.type_id), }), @@ -1061,30 +1061,30 @@ impl ComputedRelocation { #[allow(clippy::wildcard_in_or_patterns)] match rel.kind { FieldByteOffset => { - value.value = byte_off; + value.value = byte_off as u64; if !is_bitfield { value.size = byte_size; value.type_id = Some(member_type_id); } } FieldByteSize => { - value.value = byte_size; + value.value = byte_size as u64; } FieldSigned => match member_ty { BtfType::Enum(_) => value.value = 1, - BtfType::Int(i) => value.value = i.encoding() as u32 & IntEncoding::Signed as u32, + BtfType::Int(i) => value.value = i.encoding() as u64 & IntEncoding::Signed as u64, _ => (), }, #[cfg(target_endian = "little")] FieldLShift64 => { - value.value = 64 - (bit_off + bit_size - byte_off * 8); + value.value = 64 - (bit_off + bit_size - byte_off * 8) as u64; } #[cfg(target_endian = "big")] FieldLShift64 => { value.value = (8 - byte_size) * 8 + (bit_off - byte_off * 8); } FieldRShift64 => { - value.value = 64 - bit_size; + value.value = 64 - bit_size as u64; } FieldExists // this is handled at the start of the function | _ => panic!("bug! this should not be reached"), @@ -1101,11 +1101,11 @@ impl ComputedRelocation { use RelocationKind::*; let value = match (rel.kind, target_spec) { - (TypeIdLocal, _) => local_spec.root_type_id, - (TypeIdTarget, Some(target_spec)) => target_spec.root_type_id, - (TypeExists, target_spec) => target_spec.is_some() as u32, + (TypeIdLocal, _) => local_spec.root_type_id as u64, + (TypeIdTarget, Some(target_spec)) => target_spec.root_type_id as u64, + (TypeExists, target_spec) => target_spec.is_some() as u64, (TypeSize, Some(target_spec)) => { - target_spec.btf.type_size(target_spec.root_type_id)? as u32 + target_spec.btf.type_size(target_spec.root_type_id)? as u64 } _ => { return Err(RelocationError::MissingTargetDefinition { diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs index bc2c1883..198001bd 100644 --- a/test/integration-test/src/tests/relocations.rs +++ b/test/integration-test/src/tests/relocations.rs @@ -28,9 +28,7 @@ fn relocate_field() { relocation_code: r#" __u8 memory[] = {1, 2, 3, 4}; struct foo *ptr = (struct foo *) &memory; - bpf_probe_read_kernel(&value, - sizeof(__u8), - __builtin_preserve_access_index(&ptr->c)); + value = __builtin_preserve_access_index(ptr->c); "#, } .build() @@ -73,9 +71,7 @@ fn relocate_pointer() { relocation_code: r#" __u8 memory[] = {42, 0, 0, 0, 0, 0, 0, 0}; struct bar* ptr = (struct bar *) &memory; - bpf_probe_read_kernel(&value, - sizeof(void *), - __builtin_preserve_access_index(&ptr->f)); + value = (__u64) __builtin_preserve_access_index(ptr->f); "#, } .build() @@ -121,14 +117,13 @@ impl RelocationTest { #include static long (*bpf_map_update_elem)(void *map, const void *key, const void *value, __u64 flags) = (void *) 2; - static long (*bpf_probe_read_kernel)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 113; {local_definition} struct {{ int (*type)[BPF_MAP_TYPE_ARRAY]; __u32 *key; - __u32 *value; + __u64 *value; int (*max_entries)[1]; }} output_map __attribute__((section(".maps"), used)); @@ -136,7 +131,7 @@ impl RelocationTest { __attribute__((section("tracepoint/bpf_prog"), used)) int bpf_prog(void *ctx) {{ __u32 key = 0; - __u32 value = 0; + __u64 value = 0; {relocation_code} bpf_map_update_elem(&output_map, &key, &value, BPF_ANY); return 0; @@ -165,11 +160,9 @@ impl RelocationTest { r#" #include - static long (*bpf_probe_read_kernel)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 113; - {target_btf} int main() {{ - __u32 value = 0; + __u64 value = 0; // This is needed to make sure to emit BTF for the defined types, // it could be dead code eliminated if we don't. {relocation_code}; @@ -218,17 +211,17 @@ struct RelocationTestRunner { impl RelocationTestRunner { /// Run test and return the output value - fn run(&self) -> Result { + fn run(&self) -> Result { self.run_internal(true).context("Error running with BTF") } /// Run without loading btf - fn run_no_btf(&self) -> Result { + fn run_no_btf(&self) -> Result { self.run_internal(false) .context("Error running without BTF") } - fn run_internal(&self, with_relocations: bool) -> Result { + fn run_internal(&self, with_relocations: bool) -> Result { let mut loader = BpfLoader::new(); if with_relocations { loader.btf(Some(&self.btf)); @@ -250,7 +243,7 @@ impl RelocationTestRunner { // To inspect the loaded eBPF bytecode, increse the timeout and run: // $ sudo bpftool prog dump xlated name bpf_prog - let output_map: Array<_, u32> = bpf.take_map("output_map").unwrap().try_into().unwrap(); + let output_map: Array<_, u64> = bpf.take_map("output_map").unwrap().try_into().unwrap(); let key = 0; output_map.get(&key, 0).context("Getting key 0 failed") } From 4482db42d86c657826efe80f484f57a601ed2f38 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Thu, 26 Jan 2023 15:36:01 +1100 Subject: [PATCH 46/51] aya: btf: fix relocations for signed enums (32 bits) Enums now carry a signed bit in the info flags. Take it into account when applying enum relocations. --- aya-obj/src/btf/btf.rs | 6 ++-- aya-obj/src/btf/relocation.rs | 11 +++++-- aya-obj/src/btf/types.rs | 8 +++-- .../integration-test/src/tests/relocations.rs | 31 ++++++++++++++++--- 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/aya-obj/src/btf/btf.rs b/aya-obj/src/btf/btf.rs index 61fa6a52..f439ee1a 100644 --- a/aya-obj/src/btf/btf.rs +++ b/aya-obj/src/btf/btf.rs @@ -529,7 +529,7 @@ impl Btf { .iter() .map(|p| BtfEnum { name_offset: p.name_offset, - value: p.btf_type as i32, + value: p.btf_type, }) .collect(); let enum_type = BtfType::Enum(Enum::new(ty.name_offset, members)); @@ -1246,9 +1246,9 @@ mod tests { assert!(fixed.name_offset == 0); assert!(fixed.variants.len() == 2); assert!(btf.string_at(fixed.variants[0].name_offset).unwrap() == "a"); - assert!(fixed.variants[0].value == int_type_id as i32); + assert!(fixed.variants[0].value == int_type_id); assert!(btf.string_at(fixed.variants[1].name_offset).unwrap() == "b"); - assert!(fixed.variants[1].value == int_type_id as i32); + assert!(fixed.variants[1].value == int_type_id); } else { panic!("not an emum") } diff --git a/aya-obj/src/btf/relocation.rs b/aya-obj/src/btf/relocation.rs index 05551dd0..4a618c0a 100644 --- a/aya-obj/src/btf/relocation.rs +++ b/aya-obj/src/btf/relocation.rs @@ -938,7 +938,14 @@ impl ComputedRelocation { (EnumVariantValue, Some(spec)) => { let accessor = &spec.accessors[0]; match spec.btf.type_by_id(accessor.type_id)? { - BtfType::Enum(en) => en.variants[accessor.index].value as u64, + BtfType::Enum(en) => { + let value = en.variants[accessor.index].value; + if en.is_signed() { + value as i32 as u64 + } else { + value as u64 + } + } // candidate selection ensures that rel_kind == local_kind == target_kind _ => unreachable!(), } @@ -1071,7 +1078,7 @@ impl ComputedRelocation { value.value = byte_size as u64; } FieldSigned => match member_ty { - BtfType::Enum(_) => value.value = 1, + BtfType::Enum(en) => value.value = en.is_signed() as u64, BtfType::Int(i) => value.value = i.encoding() as u64 & IntEncoding::Signed as u64, _ => (), }, diff --git a/aya-obj/src/btf/types.rs b/aya-obj/src/btf/types.rs index 72474f7e..629e54f5 100644 --- a/aya-obj/src/btf/types.rs +++ b/aya-obj/src/btf/types.rs @@ -389,7 +389,7 @@ impl Int { #[derive(Debug, Clone)] pub(crate) struct BtfEnum { pub(crate) name_offset: u32, - pub(crate) value: i32, + pub(crate) value: u32, } #[repr(C)] @@ -409,7 +409,7 @@ impl Enum { buf.extend(bytes_of::(&self.size)); for v in &self.variants { buf.extend(bytes_of::(&v.name_offset)); - buf.extend(bytes_of::(&v.value)); + buf.extend(bytes_of::(&v.value)); } buf } @@ -432,6 +432,10 @@ impl Enum { variants, } } + + pub(crate) fn is_signed(&self) -> bool { + self.info >> 31 == 1 + } } #[repr(C)] diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs index 198001bd..74eee2f9 100644 --- a/test/integration-test/src/tests/relocations.rs +++ b/test/integration-test/src/tests/relocations.rs @@ -6,6 +6,9 @@ use aya::{maps::Array, programs::TracePoint, BpfLoader, Btf, Endianness}; use super::{integration_test, IntegrationTest}; +// In the tests below we often use values like 0xAAAAAAAA or -0x7AAAAAAA. Those values have no +// special meaning, they just have "nice" bit patterns that can be helpful while debugging. + #[integration_test] fn relocate_field() { let test = RelocationTest { @@ -41,10 +44,30 @@ fn relocate_field() { fn relocate_enum() { let test = RelocationTest { local_definition: r#" - enum foo { D = 1 }; + enum foo { D = 0xAAAAAAAA }; + "#, + target_btf: r#" + enum foo { D = 0xBBBBBBBB } e1; + "#, + relocation_code: r#" + #define BPF_ENUMVAL_VALUE 1 + value = __builtin_preserve_enum_value(*(typeof(enum foo) *)D, BPF_ENUMVAL_VALUE); + "#, + } + .build() + .unwrap(); + assert_eq!(test.run().unwrap(), 0xBBBBBBBB); + assert_eq!(test.run_no_btf().unwrap(), 0xAAAAAAAA); +} + +#[integration_test] +fn relocate_enum_signed() { + let test = RelocationTest { + local_definition: r#" + enum foo { D = -0x7AAAAAAA }; "#, target_btf: r#" - enum foo { D = 4 } e1; + enum foo { D = -0x7BBBBBBB } e1; "#, relocation_code: r#" #define BPF_ENUMVAL_VALUE 1 @@ -53,8 +76,8 @@ fn relocate_enum() { } .build() .unwrap(); - assert_eq!(test.run().unwrap(), 4); - assert_eq!(test.run_no_btf().unwrap(), 1); + assert_eq!(test.run().unwrap() as i64, -0x7BBBBBBBi64); + assert_eq!(test.run_no_btf().unwrap() as i64, -0x7AAAAAAAi64); } #[integration_test] From 9a6f8143a1a4c5c88a373701d74d96596c75242f Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Wed, 30 Nov 2022 22:20:23 +1100 Subject: [PATCH 47/51] aya: btf: add support for BTF_KIND_ENUM64 --- aya-obj/src/btf/relocation.rs | 63 +++++++++++---- aya-obj/src/btf/types.rs | 79 ++++++++++++++++++- .../integration-test/src/tests/relocations.rs | 40 ++++++++++ 3 files changed, 162 insertions(+), 20 deletions(-) diff --git a/aya-obj/src/btf/relocation.rs b/aya-obj/src/btf/relocation.rs index 4a618c0a..7b8cf002 100644 --- a/aya-obj/src/btf/relocation.rs +++ b/aya-obj/src/btf/relocation.rs @@ -406,19 +406,35 @@ fn match_candidate<'target>( let target_ty = candidate.btf.type_by_id(target_id)?; // the first accessor is guaranteed to have a name by construction let local_variant_name = local_spec.accessors[0].name.as_ref().unwrap(); + let match_enum = + |name_offset, index, target_spec: &mut AccessSpec| -> Result<_, BtfError> { + let target_variant_name = candidate.btf.string_at(name_offset)?; + if flavorless_name(local_variant_name) == flavorless_name(&target_variant_name) + { + target_spec.parts.push(index); + target_spec.accessors.push(Accessor { + index, + type_id: target_id, + name: None, + }); + Ok(Some(())) + } else { + Ok(None) + } + }; match target_ty { BtfType::Enum(en) => { for (index, member) in en.variants.iter().enumerate() { - let target_variant_name = candidate.btf.string_at(member.name_offset)?; - if flavorless_name(local_variant_name) - == flavorless_name(&target_variant_name) + if let Ok(Some(_)) = match_enum(member.name_offset, index, &mut target_spec) + { + return Ok(Some(target_spec)); + } + } + } + BtfType::Enum64(en) => { + for (index, member) in en.variants.iter().enumerate() { + if let Ok(Some(_)) = match_enum(member.name_offset, index, &mut target_spec) { - target_spec.parts.push(index); - target_spec.accessors.push(Accessor { - index, - type_id: target_id, - name: None, - }); return Ok(Some(target_spec)); } } @@ -620,29 +636,39 @@ impl<'a> AccessSpec<'a> { } } RelocationKind::EnumVariantExists | RelocationKind::EnumVariantValue => match ty { - BtfType::Enum(en) => { + BtfType::Enum(_) | BtfType::Enum64(_) => { if parts.len() != 1 { return Err(RelocationError::InvalidAccessString { access_str: spec.to_string(), }); } let index = parts[0]; - if index >= en.variants.len() { + + let (n_variants, name_offset) = match ty { + BtfType::Enum(en) => ( + en.variants.len(), + en.variants.get(index).map(|v| v.name_offset), + ), + BtfType::Enum64(en) => ( + en.variants.len(), + en.variants.get(index).map(|v| v.name_offset), + ), + _ => unreachable!(), + }; + + if name_offset.is_none() { return Err(RelocationError::InvalidAccessIndex { type_name: btf.err_type_name(ty), spec: spec.to_string(), index, - max_index: en.variants.len(), + max_index: n_variants, error: "tried to access nonexistant enum variant".to_string(), }); } let accessors = vec![Accessor { type_id, index, - name: Some( - btf.string_at(en.variants.get(index).unwrap().name_offset)? - .to_string(), - ), + name: Some(btf.string_at(name_offset.unwrap())?.to_string()), }]; AccessSpec { @@ -946,6 +972,10 @@ impl ComputedRelocation { value as u64 } } + BtfType::Enum64(en) => { + let variant = &en.variants[accessor.index]; + (variant.value_high as u64) << 32 | variant.value_low as u64 + } // candidate selection ensures that rel_kind == local_kind == target_kind _ => unreachable!(), } @@ -1079,6 +1109,7 @@ impl ComputedRelocation { } FieldSigned => match member_ty { BtfType::Enum(en) => value.value = en.is_signed() as u64, + BtfType::Enum64(en) => value.value = en.is_signed() as u64, BtfType::Int(i) => value.value = i.encoding() as u64 & IntEncoding::Signed as u64, _ => (), }, diff --git a/aya-obj/src/btf/types.rs b/aya-obj/src/btf/types.rs index 629e54f5..dcd869fe 100644 --- a/aya-obj/src/btf/types.rs +++ b/aya-obj/src/btf/types.rs @@ -28,6 +28,7 @@ pub enum BtfType { DataSec(DataSec), DeclTag(DeclTag), TypeTag(TypeTag), + Enum64(Enum64), } #[repr(C)] @@ -438,6 +439,50 @@ impl Enum { } } +#[repr(C)] +#[derive(Debug, Clone)] +pub struct BtfEnum64 { + pub(crate) name_offset: u32, + pub(crate) value_low: u32, + pub(crate) value_high: u32, +} + +#[repr(C)] +#[derive(Clone, Debug)] +pub struct Enum64 { + pub(crate) name_offset: u32, + info: u32, + pub(crate) size: u32, + pub(crate) variants: Vec, +} + +impl Enum64 { + pub(crate) fn to_bytes(&self) -> Vec { + let mut buf = vec![]; + buf.extend(bytes_of::(&self.name_offset)); + buf.extend(bytes_of::(&self.info)); + buf.extend(bytes_of::(&self.size)); + for v in &self.variants { + buf.extend(bytes_of::(&v.name_offset)); + buf.extend(bytes_of::(&v.value_high)); + buf.extend(bytes_of::(&v.value_low)); + } + buf + } + + pub(crate) fn kind(&self) -> BtfKind { + BtfKind::Enum64 + } + + pub(crate) fn type_info_size(&self) -> usize { + mem::size_of::() + mem::size_of::() * self.variants.len() + } + + pub(crate) fn is_signed(&self) -> bool { + self.info >> 31 == 1 + } +} + #[repr(C)] #[derive(Clone, Debug)] pub(crate) struct BtfMember { @@ -826,6 +871,7 @@ pub enum BtfKind { Float = 16, DeclTag = 17, TypeTag = 18, + Enum64 = 19, } impl TryFrom for BtfKind { @@ -853,6 +899,7 @@ impl TryFrom for BtfKind { 16 => Float, 17 => DeclTag, 18 => TypeTag, + 19 => Enum64, kind => return Err(BtfError::InvalidTypeKind { kind }), }) } @@ -880,6 +927,7 @@ impl Display for BtfKind { BtfKind::DataSec => write!(f, "[DATASEC]"), BtfKind::DeclTag => write!(f, "[DECL_TAG]"), BtfKind::TypeTag => write!(f, "[TYPE_TAG]"), + BtfKind::Enum64 => write!(f, "[ENUM64]"), } } } @@ -974,6 +1022,12 @@ impl BtfType { size: ty[2], variants: unsafe { read_array::(data, vlen)? }, }), + BtfKind::Enum64 => BtfType::Enum64(Enum64 { + name_offset: ty[0], + info: ty[1], + size: ty[2], + variants: unsafe { read_array::(data, vlen)? }, + }), BtfKind::Array => BtfType::Array(Array { name_offset: ty[0], info: ty[1], @@ -1037,6 +1091,7 @@ impl BtfType { BtfType::Int(t) => t.to_bytes(), BtfType::Float(t) => t.to_bytes(), BtfType::Enum(t) => t.to_bytes(), + BtfType::Enum64(t) => t.to_bytes(), BtfType::Array(t) => t.to_bytes(), BtfType::Struct(t) => t.to_bytes(), BtfType::Union(t) => t.to_bytes(), @@ -1053,6 +1108,7 @@ impl BtfType { BtfType::Int(t) => Some(t.size), BtfType::Float(t) => Some(t.size), BtfType::Enum(t) => Some(t.size), + BtfType::Enum64(t) => Some(t.size), BtfType::Struct(t) => Some(t.size), BtfType::Union(t) => Some(t.size), BtfType::DataSec(t) => Some(t.size), @@ -1090,6 +1146,7 @@ impl BtfType { BtfType::Int(t) => t.type_info_size(), BtfType::Float(t) => t.type_info_size(), BtfType::Enum(t) => t.type_info_size(), + BtfType::Enum64(t) => t.type_info_size(), BtfType::Array(t) => t.type_info_size(), BtfType::Struct(t) => t.type_info_size(), BtfType::Union(t) => t.type_info_size(), @@ -1114,6 +1171,7 @@ impl BtfType { BtfType::Int(t) => t.name_offset, BtfType::Float(t) => t.name_offset, BtfType::Enum(t) => t.name_offset, + BtfType::Enum64(t) => t.name_offset, BtfType::Array(t) => t.name_offset, BtfType::Struct(t) => t.name_offset, BtfType::Union(t) => t.name_offset, @@ -1138,6 +1196,7 @@ impl BtfType { BtfType::Int(t) => t.kind(), BtfType::Float(t) => t.kind(), BtfType::Enum(t) => t.kind(), + BtfType::Enum64(t) => t.kind(), BtfType::Array(t) => t.kind(), BtfType::Struct(t) => t.kind(), BtfType::Union(t) => t.kind(), @@ -1176,6 +1235,17 @@ impl BtfType { _ => None, } } + + pub(crate) fn is_compatible(&self, other: &BtfType) -> bool { + if self.kind() == other.kind() { + return true; + } + + matches!( + (self.kind(), other.kind()), + (BtfKind::Enum, BtfKind::Enum64) | (BtfKind::Enum64, BtfKind::Enum) + ) + } } fn type_kind(info: u32) -> Result { @@ -1197,7 +1267,7 @@ pub(crate) fn types_are_compatible( let local_ty = local_btf.type_by_id(local_id)?; let target_ty = target_btf.type_by_id(target_id)?; - if local_ty.kind() != target_ty.kind() { + if !local_ty.is_compatible(target_ty) { return Ok(false); } @@ -1207,7 +1277,7 @@ pub(crate) fn types_are_compatible( let local_ty = local_btf.type_by_id(local_id)?; let target_ty = target_btf.type_by_id(target_id)?; - if local_ty.kind() != target_ty.kind() { + if !local_ty.is_compatible(target_ty) { return Ok(false); } @@ -1216,6 +1286,7 @@ pub(crate) fn types_are_compatible( | BtfType::Struct(_) | BtfType::Union(_) | BtfType::Enum(_) + | BtfType::Enum64(_) | BtfType::Fwd(_) | BtfType::Float(_) => return Ok(true), BtfType::Int(local) => { @@ -1279,12 +1350,12 @@ pub(crate) fn fields_are_compatible( return Ok(true); } - if local_ty.kind() != target_ty.kind() { + if !local_ty.is_compatible(target_ty) { return Ok(false); } match local_ty { - BtfType::Fwd(_) | BtfType::Enum(_) => { + BtfType::Fwd(_) | BtfType::Enum(_) | BtfType::Enum64(_) => { let flavorless_name = |name: &str| name.split_once("___").map_or(name, |x| x.0).to_string(); diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs index 74eee2f9..53de8b5d 100644 --- a/test/integration-test/src/tests/relocations.rs +++ b/test/integration-test/src/tests/relocations.rs @@ -80,6 +80,46 @@ fn relocate_enum_signed() { assert_eq!(test.run_no_btf().unwrap() as i64, -0x7AAAAAAAi64); } +#[integration_test] +fn relocate_enum64() { + let test = RelocationTest { + local_definition: r#" + enum foo { D = 0xAAAAAAAABBBBBBBB }; + "#, + target_btf: r#" + enum foo { D = 0xCCCCCCCCDDDDDDDD } e1; + "#, + relocation_code: r#" + #define BPF_ENUMVAL_VALUE 1 + value = __builtin_preserve_enum_value(*(typeof(enum foo) *)D, BPF_ENUMVAL_VALUE); + "#, + } + .build() + .unwrap(); + assert_eq!(test.run().unwrap(), 0xCCCCCCCCDDDDDDDD); + assert_eq!(test.run_no_btf().unwrap(), 0xAAAAAAAABBBBBBBB); +} + +#[integration_test] +fn relocate_enum64_signed() { + let test = RelocationTest { + local_definition: r#" + enum foo { D = -0xAAAAAAABBBBBBBB }; + "#, + target_btf: r#" + enum foo { D = -0xCCCCCCCDDDDDDDD } e1; + "#, + relocation_code: r#" + #define BPF_ENUMVAL_VALUE 1 + value = __builtin_preserve_enum_value(*(typeof(enum foo) *)D, BPF_ENUMVAL_VALUE); + "#, + } + .build() + .unwrap(); + assert_eq!(test.run().unwrap() as i64, -0xCCCCCCCDDDDDDDDi64); + assert_eq!(test.run_no_btf().unwrap() as i64, -0xAAAAAAABBBBBBBBi64); +} + #[integration_test] fn relocate_pointer() { let test = RelocationTest { From 912ee06f39b66fbd20fb171bb97341c1f1b2d4c2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 13:05:14 +0000 Subject: [PATCH 48/51] build(deps): update indoc requirement from 1.0 to 2.0 Updates the requirements on [indoc](https://github.com/dtolnay/indoc) to permit the latest version. - [Release notes](https://github.com/dtolnay/indoc/releases) - [Commits](https://github.com/dtolnay/indoc/compare/1.0.0...2.0.0) --- updated-dependencies: - dependency-name: indoc dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- xtask/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index f20827f6..38bf920f 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -11,6 +11,6 @@ anyhow = "1" syn = "1" quote = "1" proc-macro2 = "1" -indoc = "1.0" +indoc = "2.0" lazy_static = "1" serde_json = "1" From 7c24296b5df73a5d9d07872a3832cf4e9aa9c76f Mon Sep 17 00:00:00 2001 From: Andre Fredette Date: Mon, 30 Jan 2023 10:03:38 -0500 Subject: [PATCH 49/51] Address review comments from @alessandrod Signed-off-by: Andre Fredette --- aya/src/programs/tc.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index e803dc68..cece3232 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -229,7 +229,7 @@ define_link_wrapper!( ); impl SchedClassifierLink { - /// This API is used to construct a [`SchedClassifierLink`] where the `if_name`, `attach_type`, + /// Constructs a [`SchedClassifierLink`] where the `if_name`, `attach_type`, /// `priority` and `handle` are already known. This may have been found from a link created by /// [SchedClassifier::attach], the output of the `tc filter` command or from the output of /// another BPF loader. @@ -238,8 +238,8 @@ impl SchedClassifierLink { /// unintended consequences. /// /// # Errors - /// - If a program is not attached with the provided parameters, calls to - /// [`SchedClassifierLink::detach`] will return a [`TcError::NetlinkError`] + /// Returns [`io::Error`] if `if_name` is invalid. If the other parameters are invalid this call + /// will succeed, but calling [`SchedClassifierLink::detach`] will return [`TcError::NetlinkError`]. /// /// # Examples /// ```no_run From 52e625060e463c5b7b0ec0fe9f683b82d7227ad0 Mon Sep 17 00:00:00 2001 From: Andrew Stoycos Date: Thu, 19 Jan 2023 20:42:26 -0500 Subject: [PATCH 51/51] Support BTF key/value specification for all maps Fix a bug which was resulting in `ENOTSUPP` following the `BPF_MAP_CREATE` Syscall. This fix was initially found by libbpf maintainers in: https://github.com/libbpf/libbpf/issues/355. Signed-off-by: Andrew Stoycos --- aya/src/sys/bpf.rs | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs index 43d08fbd..e7384976 100644 --- a/aya/src/sys/bpf.rs +++ b/aya/src/sys/bpf.rs @@ -12,7 +12,7 @@ use libc::{c_char, c_long, close, ENOENT, ENOSPC}; use crate::{ generated::{ bpf_attach_type, bpf_attr, bpf_btf_info, bpf_cmd, bpf_insn, bpf_link_info, bpf_map_info, - bpf_prog_info, bpf_prog_type, BPF_F_REPLACE, + bpf_map_type, bpf_prog_info, bpf_prog_type, BPF_F_REPLACE, }, maps::PerCpuValues, obj::{ @@ -39,9 +39,36 @@ pub(crate) fn bpf_create_map(name: &CStr, def: &obj::Map, btf_fd: Option) u.map_flags = def.map_flags(); if let obj::Map::Btf(m) = def { - u.btf_key_type_id = m.def.btf_key_type_id; - u.btf_value_type_id = m.def.btf_value_type_id; - u.btf_fd = btf_fd.unwrap() as u32; + use bpf_map_type::*; + + // Mimic https://github.com/libbpf/libbpf/issues/355 + // Currently a bunch of (usually pretty specialized) BPF maps do not support + // specifying BTF types for the key and value. + match u.map_type.try_into() { + Ok(BPF_MAP_TYPE_PERF_EVENT_ARRAY) + | Ok(BPF_MAP_TYPE_CGROUP_ARRAY) + | Ok(BPF_MAP_TYPE_STACK_TRACE) + | Ok(BPF_MAP_TYPE_ARRAY_OF_MAPS) + | Ok(BPF_MAP_TYPE_HASH_OF_MAPS) + | Ok(BPF_MAP_TYPE_DEVMAP) + | Ok(BPF_MAP_TYPE_DEVMAP_HASH) + | Ok(BPF_MAP_TYPE_CPUMAP) + | Ok(BPF_MAP_TYPE_XSKMAP) + | Ok(BPF_MAP_TYPE_SOCKMAP) + | Ok(BPF_MAP_TYPE_SOCKHASH) + | Ok(BPF_MAP_TYPE_QUEUE) + | Ok(BPF_MAP_TYPE_STACK) + | Ok(BPF_MAP_TYPE_RINGBUF) => { + u.btf_key_type_id = 0; + u.btf_value_type_id = 0; + u.btf_fd = 0; + } + _ => { + u.btf_key_type_id = m.def.btf_key_type_id; + u.btf_value_type_id = m.def.btf_value_type_id; + u.btf_fd = btf_fd.unwrap() as u32; + } + } } // https://github.com/torvalds/linux/commit/ad5b177bd73f5107d97c36f56395c4281fb6f089