From 8c79b71bd5699a686f33360520aa95c1a2895fa5 Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Tue, 5 Mar 2024 11:12:35 +0000 Subject: [PATCH] feat(aya): Rename Bpf to Ebpf And BpfLoader to EbpfLoader. This also adds type aliases to preserve the use of the old names, making updating to a new Aya release less of a burden. These aliases are marked as deprecated since we'll likely remove them in a later release. Signed-off-by: Dave Tucker --- aya-log/src/lib.rs | 8 +- aya-obj/src/btf/btf.rs | 6 +- aya/src/bpf.rs | 180 +++++++++--------- aya/src/maps/array/array.rs | 4 +- aya/src/maps/array/per_cpu_array.rs | 4 +- aya/src/maps/array/program_array.rs | 4 +- aya/src/maps/bloom_filter.rs | 10 +- aya/src/maps/hash_map/hash_map.rs | 34 ++-- aya/src/maps/hash_map/mod.rs | 2 +- aya/src/maps/hash_map/per_cpu_hash_map.rs | 8 +- aya/src/maps/lpm_trie.rs | 12 +- aya/src/maps/mod.rs | 44 ++--- aya/src/maps/perf/async_perf_event_array.rs | 4 +- aya/src/maps/perf/perf_event_array.rs | 4 +- aya/src/maps/queue.rs | 4 +- aya/src/maps/ring_buf.rs | 4 +- aya/src/maps/sock/sock_hash.rs | 4 +- aya/src/maps/sock/sock_map.rs | 4 +- aya/src/maps/stack.rs | 4 +- aya/src/maps/stack_trace.rs | 4 +- aya/src/maps/xdp/cpu_map.rs | 4 +- aya/src/maps/xdp/dev_map.rs | 4 +- aya/src/maps/xdp/dev_map_hash.rs | 4 +- aya/src/maps/xdp/xsk_map.rs | 4 +- aya/src/programs/cgroup_device.rs | 4 +- aya/src/programs/cgroup_skb.rs | 4 +- aya/src/programs/cgroup_sock.rs | 4 +- aya/src/programs/cgroup_sock_addr.rs | 4 +- aya/src/programs/cgroup_sockopt.rs | 4 +- aya/src/programs/cgroup_sysctl.rs | 4 +- aya/src/programs/extension.rs | 6 +- aya/src/programs/fentry.rs | 6 +- aya/src/programs/fexit.rs | 6 +- aya/src/programs/kprobe.rs | 6 +- aya/src/programs/links.rs | 10 +- aya/src/programs/lirc_mode2.rs | 6 +- aya/src/programs/lsm.rs | 6 +- aya/src/programs/mod.rs | 28 +-- aya/src/programs/perf_event.rs | 4 +- aya/src/programs/raw_trace_point.rs | 6 +- aya/src/programs/sk_lookup.rs | 4 +- aya/src/programs/sk_msg.rs | 4 +- aya/src/programs/sk_skb.rs | 4 +- aya/src/programs/sock_ops.rs | 4 +- aya/src/programs/socket_filter.rs | 8 +- aya/src/programs/tc.rs | 4 +- aya/src/programs/tp_btf.rs | 6 +- aya/src/programs/trace_point.rs | 4 +- aya/src/programs/xdp.rs | 6 +- aya/src/sys/bpf.rs | 10 +- aya/src/sys/mod.rs | 8 +- aya/src/util.rs | 8 +- .../src/tests/bpf_probe_read.rs | 14 +- .../src/tests/btf_relocations.rs | 4 +- test/integration-test/src/tests/load.rs | 30 +-- test/integration-test/src/tests/log.rs | 4 +- .../integration-test/src/tests/relocations.rs | 6 +- test/integration-test/src/tests/ring_buf.rs | 6 +- test/integration-test/src/tests/smoke.rs | 14 +- test/integration-test/src/tests/xdp.rs | 8 +- 60 files changed, 318 insertions(+), 310 deletions(-) diff --git a/aya-log/src/lib.rs b/aya-log/src/lib.rs index e533526d..e24acfb4 100644 --- a/aya-log/src/lib.rs +++ b/aya-log/src/lib.rs @@ -12,7 +12,7 @@ //! This example uses the [env_logger] crate to log messages to the terminal. //! //! ```no_run -//! # let mut bpf = aya::Bpf::load(&[]).unwrap(); +//! # let mut bpf = aya::Ebpf::load(&[]).unwrap(); //! use aya_log::EbpfLogger; //! //! // initialize env_logger as the default logger @@ -65,7 +65,7 @@ use aya::{ MapError, }, util::online_cpus, - Bpf, Pod, + Ebpf, Pod, }; use aya_log_common::{ Argument, DisplayHint, Level, LogValueLength, RecordField, LOG_BUF_CAPACITY, LOG_FIELDS, @@ -102,14 +102,14 @@ pub type BpfLogger = EbpfLogger; impl EbpfLogger { /// Starts reading log records created with `aya-log-ebpf` and logs them /// with the default logger. See [log::logger]. - pub fn init(bpf: &mut Bpf) -> Result { + pub fn init(bpf: &mut Ebpf) -> Result { EbpfLogger::init_with_logger(bpf, log::logger()) } /// Starts reading log records created with `aya-log-ebpf` and logs them /// with the given logger. pub fn init_with_logger( - bpf: &mut Bpf, + bpf: &mut Ebpf, logger: T, ) -> Result { let logger = Arc::new(logger); diff --git a/aya-obj/src/btf/btf.rs b/aya-obj/src/btf/btf.rs index de9e54e4..d83171ea 100644 --- a/aya-obj/src/btf/btf.rs +++ b/aya-obj/src/btf/btf.rs @@ -235,14 +235,14 @@ impl BtfFeatures { } } -/// Bpf Type Format metadata. +/// BPF Type Format metadata. /// /// 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`. You +/// Aya automatically loads BTF metadata if you use `Ebpf::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`. +/// location or if you are using `Ebpf::load`. #[derive(Clone, Debug)] pub struct Btf { header: btf_header, diff --git a/aya/src/bpf.rs b/aya/src/bpf.rs index fa3ecb03..998f8a07 100644 --- a/aya/src/bpf.rs +++ b/aya/src/bpf.rs @@ -110,26 +110,26 @@ pub fn features() -> &'static Features { /// Builder style API for advanced loading of eBPF programs. /// /// Loading eBPF code involves a few steps, including loading maps and applying -/// relocations. You can use `BpfLoader` to customize some of the loading +/// relocations. You can use `EbpfLoader` to customize some of the loading /// options. /// /// # Examples /// /// ```no_run -/// use aya::{BpfLoader, Btf}; +/// use aya::{EbpfLoader, Btf}; /// use std::fs; /// -/// let bpf = BpfLoader::new() +/// let bpf = EbpfLoader::new() /// // load the BTF data from /sys/kernel/btf/vmlinux /// .btf(Btf::from_sys_fs().ok().as_ref()) /// // load pinned maps from /sys/fs/bpf/my-program /// .map_pin_path("/sys/fs/bpf/my-program") /// // finally load the code /// .load_file("file.o")?; -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[derive(Debug)] -pub struct BpfLoader<'a> { +pub struct EbpfLoader<'a> { btf: Option>, map_pin_path: Option, globals: HashMap<&'a str, (&'a [u8], bool)>, @@ -139,8 +139,12 @@ pub struct BpfLoader<'a> { allow_unsupported_maps: bool, } +/// Builder style API for advanced loading of eBPF programs. +#[deprecated(since = "0.13.0", note = "use `EbpfLoader` instead")] +pub type BpfLoader<'a> = EbpfLoader<'a>; + bitflags::bitflags! { - /// Used to set the verifier log level flags in [BpfLoader](BpfLoader::verifier_log_level()). + /// Used to set the verifier log level flags in [EbpfLoader](EbpfLoader::verifier_log_level()). #[derive(Clone, Copy, Debug)] pub struct VerifierLogLevel: u32 { /// Sets no verifier logging. @@ -160,7 +164,7 @@ impl Default for VerifierLogLevel { } } -impl<'a> BpfLoader<'a> { +impl<'a> EbpfLoader<'a> { /// Creates a new loader instance. pub fn new() -> Self { Self { @@ -182,16 +186,16 @@ impl<'a> BpfLoader<'a> { /// # Example /// /// ```no_run - /// use aya::{BpfLoader, Btf, Endianness}; + /// use aya::{EbpfLoader, Btf, Endianness}; /// - /// let bpf = BpfLoader::new() + /// let bpf = EbpfLoader::new() /// // load the BTF data from a custom location /// .btf(Btf::parse_file("/custom_btf_file", Endianness::default()).ok().as_ref()) /// .load_file("file.o")?; /// - /// # Ok::<(), aya::BpfError>(()) + /// # Ok::<(), aya::EbpfError>(()) /// ``` - pub fn btf(&mut self, btf: Option<&'a Btf>) -> &mut BpfLoader<'a> { + pub fn btf(&mut self, btf: Option<&'a Btf>) -> &mut EbpfLoader<'a> { self.btf = btf.map(Cow::Borrowed); self } @@ -207,15 +211,15 @@ impl<'a> BpfLoader<'a> { /// # Example /// /// ```no_run - /// use aya::BpfLoader; + /// use aya::EbpfLoader; /// - /// let bpf = BpfLoader::new() + /// let bpf = EbpfLoader::new() /// .allow_unsupported_maps() /// .load_file("file.o")?; - /// # Ok::<(), aya::BpfError>(()) + /// # Ok::<(), aya::EbpfError>(()) /// ``` /// - pub fn allow_unsupported_maps(&mut self) -> &mut BpfLoader<'a> { + pub fn allow_unsupported_maps(&mut self) -> &mut EbpfLoader<'a> { self.allow_unsupported_maps = true; self } @@ -228,22 +232,22 @@ impl<'a> BpfLoader<'a> { /// # Example /// /// ```no_run - /// use aya::BpfLoader; + /// use aya::EbpfLoader; /// - /// let bpf = BpfLoader::new() + /// let bpf = EbpfLoader::new() /// .map_pin_path("/sys/fs/bpf/my-program") /// .load_file("file.o")?; - /// # Ok::<(), aya::BpfError>(()) + /// # Ok::<(), aya::EbpfError>(()) /// ``` /// - pub fn map_pin_path>(&mut self, path: P) -> &mut BpfLoader<'a> { + pub fn map_pin_path>(&mut self, path: P) -> &mut EbpfLoader<'a> { self.map_pin_path = Some(path.as_ref().to_owned()); self } /// Sets the value of a global variable. /// - /// If the `must_exist` argument is `true`, [`BpfLoader::load`] will fail with [`ParseError::SymbolNotFound`] if the loaded object code does not contain the variable. + /// If the `must_exist` argument is `true`, [`EbpfLoader::load`] will fail with [`ParseError::SymbolNotFound`] if the loaded object code does not contain the variable. /// /// From Rust eBPF, a global variable can be defined as follows: /// @@ -271,13 +275,13 @@ impl<'a> BpfLoader<'a> { /// # Example /// /// ```no_run - /// use aya::BpfLoader; + /// use aya::EbpfLoader; /// - /// let bpf = BpfLoader::new() + /// let bpf = EbpfLoader::new() /// .set_global("VERSION", &2, true) /// .set_global("PIDS", &[1234u16, 5678], true) /// .load_file("file.o")?; - /// # Ok::<(), aya::BpfError>(()) + /// # Ok::<(), aya::EbpfError>(()) /// ``` /// pub fn set_global>>( @@ -285,7 +289,7 @@ impl<'a> BpfLoader<'a> { name: &'a str, value: T, must_exist: bool, - ) -> &mut BpfLoader<'a> { + ) -> &mut EbpfLoader<'a> { self.globals.insert(name, (value.into().bytes, must_exist)); self } @@ -298,15 +302,15 @@ impl<'a> BpfLoader<'a> { /// # Example /// /// ```no_run - /// use aya::BpfLoader; + /// use aya::EbpfLoader; /// - /// let bpf = BpfLoader::new() + /// let bpf = EbpfLoader::new() /// .set_max_entries("map", 64) /// .load_file("file.o")?; - /// # Ok::<(), aya::BpfError>(()) + /// # Ok::<(), aya::EbpfError>(()) /// ``` /// - pub fn set_max_entries(&mut self, name: &'a str, size: u32) -> &mut BpfLoader<'a> { + pub fn set_max_entries(&mut self, name: &'a str, size: u32) -> &mut EbpfLoader<'a> { self.max_entries.insert(name, size); self } @@ -320,15 +324,15 @@ impl<'a> BpfLoader<'a> { /// # Example /// /// ```no_run - /// use aya::BpfLoader; + /// use aya::EbpfLoader; /// - /// let bpf = BpfLoader::new() + /// let bpf = EbpfLoader::new() /// .extension("myfunc") /// .load_file("file.o")?; - /// # Ok::<(), aya::BpfError>(()) + /// # Ok::<(), aya::EbpfError>(()) /// ``` /// - pub fn extension(&mut self, name: &'a str) -> &mut BpfLoader<'a> { + pub fn extension(&mut self, name: &'a str) -> &mut EbpfLoader<'a> { self.extensions.insert(name); self } @@ -338,15 +342,15 @@ impl<'a> BpfLoader<'a> { /// # Example /// /// ```no_run - /// use aya::{BpfLoader, VerifierLogLevel}; + /// use aya::{EbpfLoader, VerifierLogLevel}; /// - /// let bpf = BpfLoader::new() + /// let bpf = EbpfLoader::new() /// .verifier_log_level(VerifierLogLevel::VERBOSE | VerifierLogLevel::STATS) /// .load_file("file.o")?; - /// # Ok::<(), aya::BpfError>(()) + /// # Ok::<(), aya::EbpfError>(()) /// ``` /// - pub fn verifier_log_level(&mut self, level: VerifierLogLevel) -> &mut BpfLoader<'a> { + pub fn verifier_log_level(&mut self, level: VerifierLogLevel) -> &mut EbpfLoader<'a> { self.verifier_log_level = level; self } @@ -356,14 +360,14 @@ impl<'a> BpfLoader<'a> { /// # Examples /// /// ```no_run - /// use aya::BpfLoader; + /// use aya::EbpfLoader; /// - /// let bpf = BpfLoader::new().load_file("file.o")?; - /// # Ok::<(), aya::BpfError>(()) + /// let bpf = EbpfLoader::new().load_file("file.o")?; + /// # Ok::<(), aya::EbpfError>(()) /// ``` - pub fn load_file>(&mut self, path: P) -> Result { + pub fn load_file>(&mut self, path: P) -> Result { let path = path.as_ref(); - self.load(&fs::read(path).map_err(|error| BpfError::FileError { + self.load(&fs::read(path).map_err(|error| EbpfError::FileError { path: path.to_owned(), error, })?) @@ -374,14 +378,14 @@ impl<'a> BpfLoader<'a> { /// # Examples /// /// ```no_run - /// use aya::BpfLoader; + /// use aya::EbpfLoader; /// use std::fs; /// /// let data = fs::read("file.o").unwrap(); - /// let bpf = BpfLoader::new().load(&data)?; - /// # Ok::<(), aya::BpfError>(()) + /// let bpf = EbpfLoader::new().load(&data)?; + /// # Ok::<(), aya::EbpfError>(()) /// ``` - pub fn load(&mut self, data: &[u8]) -> Result { + pub fn load(&mut self, data: &[u8]) -> Result { let Self { btf, map_pin_path, @@ -407,7 +411,7 @@ impl<'a> BpfLoader<'a> { | ProgramSection::FExit { sleepable: _ } | ProgramSection::Lsm { sleepable: _ } | ProgramSection::BtfTracePoint => { - return Err(BpfError::BtfError(err)) + return Err(EbpfError::BtfError(err)) } ProgramSection::KRetProbe | ProgramSection::KProbe @@ -461,9 +465,9 @@ impl<'a> BpfLoader<'a> { { continue; } - let num_cpus = || -> Result { + let num_cpus = || -> Result { Ok(possible_cpus() - .map_err(|error| BpfError::FileError { + .map_err(|error| EbpfError::FileError { path: PathBuf::from(POSSIBLE_CPUS), error, })? @@ -694,22 +698,22 @@ impl<'a> BpfLoader<'a> { let maps = maps .drain() .map(parse_map) - .collect::, BpfError>>()?; + .collect::, EbpfError>>()?; if !*allow_unsupported_maps { maps.iter().try_for_each(|(_, x)| match x { - Map::Unsupported(map) => Err(BpfError::MapError(MapError::Unsupported { + Map::Unsupported(map) => Err(EbpfError::MapError(MapError::Unsupported { map_type: map.obj().map_type(), })), _ => Ok(()), })?; }; - Ok(Bpf { maps, programs }) + Ok(Ebpf { maps, programs }) } } -fn parse_map(data: (String, MapData)) -> Result<(String, Map), BpfError> { +fn parse_map(data: (String, MapData)) -> Result<(String, Map), EbpfError> { let (name, map) = data; let map_type = bpf_map_type::try_from(map.obj().map_type()).map_err(MapError::from)?; let map = match map_type { @@ -748,9 +752,9 @@ fn max_entries_override( map_type: bpf_map_type, user_override: Option, current_value: impl Fn() -> u32, - num_cpus: impl Fn() -> Result, + num_cpus: impl Fn() -> Result, page_size: impl Fn() -> u32, -) -> Result, BpfError> { +) -> Result, EbpfError> { let max_entries = || user_override.unwrap_or_else(¤t_value); Ok(match map_type { BPF_MAP_TYPE_PERF_EVENT_ARRAY if max_entries() == 0 => Some(num_cpus()?), @@ -841,38 +845,42 @@ mod tests { } } -impl Default for BpfLoader<'_> { +impl Default for EbpfLoader<'_> { fn default() -> Self { - BpfLoader::new() + EbpfLoader::new() } } /// The main entry point into the library, used to work with eBPF programs and maps. #[derive(Debug)] -pub struct Bpf { +pub struct Ebpf { maps: HashMap, programs: HashMap, } -impl Bpf { +/// The main entry point into the library, used to work with eBPF programs and maps. +#[deprecated(since = "0.13.0", note = "use `Ebpf` instead")] +pub type Bpf = Ebpf; + +impl Ebpf { /// Loads eBPF bytecode from a file. /// /// Parses the given object code file and initializes the [maps](crate::maps) defined in it. If /// the kernel supports [BTF](Btf) debug info, it is automatically loaded from /// `/sys/kernel/btf/vmlinux`. /// - /// For more loading options, see [BpfLoader]. + /// For more loading options, see [EbpfLoader]. /// /// # Examples /// /// ```no_run - /// use aya::Bpf; + /// use aya::Ebpf; /// - /// let bpf = Bpf::load_file("file.o")?; - /// # Ok::<(), aya::BpfError>(()) + /// let bpf = Ebpf::load_file("file.o")?; + /// # Ok::<(), aya::EbpfError>(()) /// ``` - pub fn load_file>(path: P) -> Result { - BpfLoader::new() + pub fn load_file>(path: P) -> Result { + EbpfLoader::new() .btf(Btf::from_sys_fs().ok().as_ref()) .load_file(path) } @@ -883,21 +891,21 @@ impl Bpf { /// [maps](crate::maps) defined in it. If the kernel supports [BTF](Btf) /// debug info, it is automatically loaded from `/sys/kernel/btf/vmlinux`. /// - /// For more loading options, see [BpfLoader]. + /// For more loading options, see [EbpfLoader]. /// /// # Examples /// /// ```no_run - /// use aya::{Bpf, Btf}; + /// use aya::{Ebpf, Btf}; /// use std::fs; /// /// let data = fs::read("file.o").unwrap(); /// // load the BTF data from /sys/kernel/btf/vmlinux - /// let bpf = Bpf::load(&data)?; - /// # Ok::<(), aya::BpfError>(()) + /// let bpf = Ebpf::load(&data)?; + /// # Ok::<(), aya::EbpfError>(()) /// ``` - pub fn load(data: &[u8]) -> Result { - BpfLoader::new() + pub fn load(data: &[u8]) -> Result { + EbpfLoader::new() .btf(Btf::from_sys_fs().ok().as_ref()) .load(data) } @@ -926,7 +934,7 @@ impl Bpf { /// Takes ownership of a map with the given name. /// - /// Use this when borrowing with [`map`](crate::Bpf::map) or [`map_mut`](crate::Bpf::map_mut) + /// Use this when borrowing with [`map`](crate::Ebpf::map) or [`map_mut`](crate::Ebpf::map_mut) /// is not possible (eg when using the map from an async task). The returned /// map will be closed on `Drop`, therefore the caller is responsible for /// managing its lifetime. @@ -944,14 +952,14 @@ impl Bpf { /// /// # Examples /// ```no_run - /// # let mut bpf = aya::Bpf::load(&[])?; + /// # let mut bpf = aya::Ebpf::load(&[])?; /// for (name, map) in bpf.maps() { /// println!( /// "found map `{}`", /// name, /// ); /// } - /// # Ok::<(), aya::BpfError>(()) + /// # Ok::<(), aya::EbpfError>(()) /// ``` pub fn maps(&self) -> impl Iterator { self.maps.iter().map(|(name, map)| (name.as_str(), map)) @@ -965,11 +973,11 @@ impl Bpf { /// # #[derive(thiserror::Error, Debug)] /// # enum Error { /// # #[error(transparent)] - /// # Bpf(#[from] aya::BpfError), + /// # Ebpf(#[from] aya::EbpfError), /// # #[error(transparent)] /// # Pin(#[from] aya::pin::PinError) /// # } - /// # let mut bpf = aya::Bpf::load(&[])?; + /// # let mut bpf = aya::Ebpf::load(&[])?; /// # let pin_path = Path::new("/tmp/pin_path"); /// for (_, map) in bpf.maps_mut() { /// map.pin(pin_path)?; @@ -991,10 +999,10 @@ impl Bpf { /// # Examples /// /// ```no_run - /// # let bpf = aya::Bpf::load(&[])?; + /// # let bpf = aya::Ebpf::load(&[])?; /// let program = bpf.program("SSL_read").unwrap(); /// println!("program SSL_read is of type {:?}", program.prog_type()); - /// # Ok::<(), aya::BpfError>(()) + /// # Ok::<(), aya::EbpfError>(()) /// ``` pub fn program(&self, name: &str) -> Option<&Program> { self.programs.get(name) @@ -1008,13 +1016,13 @@ impl Bpf { /// # Examples /// /// ```no_run - /// # let mut bpf = aya::Bpf::load(&[])?; + /// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::programs::UProbe; /// /// let program: &mut UProbe = bpf.program_mut("SSL_read").unwrap().try_into()?; /// program.load()?; /// program.attach(Some("SSL_read"), 0, "libssl", None)?; - /// # Ok::<(), aya::BpfError>(()) + /// # Ok::<(), aya::EbpfError>(()) /// ``` pub fn program_mut(&mut self, name: &str) -> Option<&mut Program> { self.programs.get_mut(name) @@ -1024,7 +1032,7 @@ impl Bpf { /// /// # Examples /// ```no_run - /// # let bpf = aya::Bpf::load(&[])?; + /// # let bpf = aya::Ebpf::load(&[])?; /// for (name, program) in bpf.programs() { /// println!( /// "found program `{}` of type `{:?}`", @@ -1032,7 +1040,7 @@ impl Bpf { /// program.prog_type() /// ); /// } - /// # Ok::<(), aya::BpfError>(()) + /// # Ok::<(), aya::EbpfError>(()) /// ``` pub fn programs(&self) -> impl Iterator { self.programs.iter().map(|(s, p)| (s.as_str(), p)) @@ -1046,11 +1054,11 @@ impl Bpf { /// # #[derive(thiserror::Error, Debug)] /// # enum Error { /// # #[error(transparent)] - /// # Bpf(#[from] aya::BpfError), + /// # Ebpf(#[from] aya::EbpfError), /// # #[error(transparent)] /// # Pin(#[from] aya::pin::PinError) /// # } - /// # let mut bpf = aya::Bpf::load(&[])?; + /// # let mut bpf = aya::Ebpf::load(&[])?; /// # let pin_path = Path::new("/tmp/pin_path"); /// for (_, program) in bpf.programs_mut() { /// program.pin(pin_path)?; @@ -1062,9 +1070,9 @@ impl Bpf { } } -/// The error type returned by [`Bpf::load_file`] and [`Bpf::load`]. +/// The error type returned by [`Ebpf::load_file`] and [`Ebpf::load`]. #[derive(Debug, Error)] -pub enum BpfError { +pub enum EbpfError { /// Error loading file #[error("error loading {path}")] FileError { @@ -1124,7 +1132,7 @@ fn load_btf(raw_btf: Vec, verifier_log_level: VerifierLogLevel) -> Result { bytes: &'a [u8], } diff --git a/aya/src/maps/array/array.rs b/aya/src/maps/array/array.rs index 9fdc91e3..8ca907f5 100644 --- a/aya/src/maps/array/array.rs +++ b/aya/src/maps/array/array.rs @@ -21,13 +21,13 @@ use crate::{ /// /// # Examples /// ```no_run -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::Array; /// /// let mut array = Array::try_from(bpf.map_mut("ARRAY").unwrap())?; /// array.set(1, 42, 0)?; /// assert_eq!(array.get(&1, 0)?, 42); -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[doc(alias = "BPF_MAP_TYPE_ARRAY")] pub struct Array { diff --git a/aya/src/maps/array/per_cpu_array.rs b/aya/src/maps/array/per_cpu_array.rs index 9c261f0c..5238da73 100644 --- a/aya/src/maps/array/per_cpu_array.rs +++ b/aya/src/maps/array/per_cpu_array.rs @@ -28,9 +28,9 @@ use crate::{ /// # #[error(transparent)] /// # Map(#[from] aya::maps::MapError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::{PerCpuArray, PerCpuValues}; /// use aya::util::nr_cpus; /// diff --git a/aya/src/maps/array/program_array.rs b/aya/src/maps/array/program_array.rs index 513bf77f..ca6beb8e 100644 --- a/aya/src/maps/array/program_array.rs +++ b/aya/src/maps/array/program_array.rs @@ -23,7 +23,7 @@ use crate::{ /// /// # Examples /// ```no_run -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::ProgramArray; /// use aya::programs::CgroupSkb; /// @@ -44,7 +44,7 @@ use crate::{ /// /// // bpf_tail_call(ctx, JUMP_TABLE, 2) will jump to prog_2 /// prog_array.set(2, &prog_2_fd, flags); -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[doc(alias = "BPF_MAP_TYPE_PROG_ARRAY")] pub struct ProgramArray { diff --git a/aya/src/maps/bloom_filter.rs b/aya/src/maps/bloom_filter.rs index 2278d513..817c785c 100644 --- a/aya/src/maps/bloom_filter.rs +++ b/aya/src/maps/bloom_filter.rs @@ -20,7 +20,7 @@ use crate::{ /// # Examples /// /// ```no_run -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::bloom_filter::BloomFilter; /// /// let mut bloom_filter = BloomFilter::try_from(bpf.map_mut("BLOOM_FILTER").unwrap())?; @@ -30,7 +30,7 @@ use crate::{ /// assert!(bloom_filter.contains(&1, 0).is_ok()); /// assert!(bloom_filter.contains(&2, 0).is_err()); /// -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[doc(alias = "BPF_MAP_TYPE_BLOOM_FILTER")] @@ -114,7 +114,7 @@ mod tests { fn new_map(obj: obj::Map) -> MapData { override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_CREATE, .. } => Ok(1337), @@ -197,7 +197,7 @@ mod tests { let mut bloom_filter = BloomFilter::<_, u32>::new(&mut map).unwrap(); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_UPDATE_ELEM, .. } => Ok(1), @@ -226,7 +226,7 @@ mod tests { let bloom_filter = BloomFilter::<_, u32>::new(&map).unwrap(); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_LOOKUP_ELEM, .. } => sys_error(ENOENT), diff --git a/aya/src/maps/hash_map/hash_map.rs b/aya/src/maps/hash_map/hash_map.rs index 72c81b95..f1f8fceb 100644 --- a/aya/src/maps/hash_map/hash_map.rs +++ b/aya/src/maps/hash_map/hash_map.rs @@ -19,7 +19,7 @@ use crate::{ /// # Examples /// /// ```no_run -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::HashMap; /// /// let mut redirect_ports = HashMap::try_from(bpf.map_mut("REDIRECT_PORTS").unwrap())?; @@ -28,7 +28,7 @@ use crate::{ /// redirect_ports.insert(80, 8080, 0); /// // redirect port 443 to 8443 /// redirect_ports.insert(443, 8443, 0); -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[doc(alias = "BPF_MAP_TYPE_HASH")] #[doc(alias = "BPF_MAP_TYPE_LRU_HASH")] @@ -218,7 +218,7 @@ mod tests { let mut hm = HashMap::<_, u32, u32>::new(&mut map).unwrap(); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_UPDATE_ELEM, .. } => Ok(1), @@ -234,7 +234,7 @@ mod tests { let mut hm = HashMap::<_, u32, u32>::new(&mut map).unwrap(); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_UPDATE_ELEM, .. } => Ok(1), @@ -263,7 +263,7 @@ mod tests { let mut hm = HashMap::<_, u32, u32>::new(&mut map).unwrap(); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_DELETE_ELEM, .. } => Ok(1), @@ -289,7 +289,7 @@ mod tests { fn test_get_not_found() { let map = new_map(new_obj_map()); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_LOOKUP_ELEM, .. } => sys_error(ENOENT), @@ -321,7 +321,7 @@ mod tests { fn test_keys_empty() { let map = new_map(new_obj_map()); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_GET_NEXT_KEY, .. } => sys_error(ENOENT), @@ -365,7 +365,7 @@ mod tests { let map = new_map(new_obj_map()); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_GET_NEXT_KEY, attr, } => get_next_key(attr), @@ -386,7 +386,7 @@ mod tests { fn test_keys_error() { let map = new_map(new_obj_map()); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_GET_NEXT_KEY, attr, } => { @@ -423,11 +423,11 @@ mod tests { fn test_iter() { let map = new_map(new_obj_map()); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_GET_NEXT_KEY, attr, } => get_next_key(attr), - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_LOOKUP_ELEM, attr, } => lookup_elem(attr), @@ -446,11 +446,11 @@ mod tests { fn test_iter_key_deleted() { let map = new_map(new_obj_map()); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_GET_NEXT_KEY, attr, } => get_next_key(attr), - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_LOOKUP_ELEM, attr, } => { @@ -480,7 +480,7 @@ mod tests { fn test_iter_key_error() { let map = new_map(new_obj_map()); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_GET_NEXT_KEY, attr, } => { @@ -494,7 +494,7 @@ mod tests { Ok(1) } - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_LOOKUP_ELEM, attr, } => lookup_elem(attr), @@ -523,11 +523,11 @@ mod tests { fn test_iter_value_error() { let map = new_map(new_obj_map()); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_GET_NEXT_KEY, attr, } => get_next_key(attr), - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_LOOKUP_ELEM, attr, } => { diff --git a/aya/src/maps/hash_map/mod.rs b/aya/src/maps/hash_map/mod.rs index dc143212..93f345bd 100644 --- a/aya/src/maps/hash_map/mod.rs +++ b/aya/src/maps/hash_map/mod.rs @@ -56,7 +56,7 @@ mod test_utils { pub(super) fn new_map(obj: obj::Map) -> MapData { override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_CREATE, .. } => Ok(1337), diff --git a/aya/src/maps/hash_map/per_cpu_hash_map.rs b/aya/src/maps/hash_map/per_cpu_hash_map.rs index fe404ce0..6dd3ee19 100644 --- a/aya/src/maps/hash_map/per_cpu_hash_map.rs +++ b/aya/src/maps/hash_map/per_cpu_hash_map.rs @@ -26,7 +26,7 @@ use crate::{ /// # Examples /// /// ```no_run -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::PerCpuHashMap; /// /// const CPU_IDS: u8 = 1; @@ -38,7 +38,7 @@ use crate::{ /// for (cpu_id, wakeups) in cpu_ids.iter().zip(wakeups.iter()) { /// println!("cpu {} woke up {} times", cpu_id, wakeups); /// } -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[doc(alias = "BPF_MAP_TYPE_LRU_PERCPU_HASH")] #[doc(alias = "BPF_MAP_TYPE_PERCPU_HASH")] @@ -97,9 +97,9 @@ impl, K: Pod, V: Pod> PerCpuHashMap { /// # #[error(transparent)] /// # Map(#[from] aya::maps::MapError), /// # #[error(transparent)] - /// # Bpf(#[from] aya::BpfError) + /// # Ebpf(#[from] aya::EbpfError) /// # } - /// # let mut bpf = aya::Bpf::load(&[])?; + /// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::{PerCpuHashMap, PerCpuValues}; /// use aya::util::nr_cpus; /// diff --git a/aya/src/maps/lpm_trie.rs b/aya/src/maps/lpm_trie.rs index 81d9759a..c3dd528a 100644 --- a/aya/src/maps/lpm_trie.rs +++ b/aya/src/maps/lpm_trie.rs @@ -20,7 +20,7 @@ use crate::{ /// # Examples /// /// ```no_run -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::lpm_trie::{LpmTrie, Key}; /// use std::net::Ipv4Addr; /// @@ -42,7 +42,7 @@ use crate::{ /// trie.insert(&longer_key, 2, 0)?; /// let value = trie.get(&lookup, 0)?; /// assert_eq!(value, 2); -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[doc(alias = "BPF_MAP_TYPE_LPM_TRIE")] @@ -231,7 +231,7 @@ mod tests { fn new_map(obj: obj::Map) -> MapData { override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_CREATE, .. } => Ok(1337), @@ -330,7 +330,7 @@ mod tests { let key = Key::new(16, u32::from(ipaddr).to_be()); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_UPDATE_ELEM, .. } => Ok(1), @@ -363,7 +363,7 @@ mod tests { let key = Key::new(16, u32::from(ipaddr).to_be()); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_DELETE_ELEM, .. } => Ok(1), @@ -396,7 +396,7 @@ mod tests { let key = Key::new(16, u32::from(ipaddr).to_be()); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_LOOKUP_ELEM, .. } => sys_error(ENOENT), diff --git a/aya/src/maps/mod.rs b/aya/src/maps/mod.rs index 68ce9904..192c988b 100644 --- a/aya/src/maps/mod.rs +++ b/aya/src/maps/mod.rs @@ -2,17 +2,17 @@ //! //! The eBPF platform provides data structures - maps in eBPF speak - that are //! used to setup and share data with eBPF programs. When you call -//! [`Bpf::load_file`](crate::Bpf::load_file) or -//! [`Bpf::load`](crate::Bpf::load), all the maps defined in the eBPF code get -//! initialized and can then be accessed using [`Bpf::map`](crate::Bpf::map), -//! [`Bpf::map_mut`](crate::Bpf::map_mut), or -//! [`Bpf::take_map`](crate::Bpf::take_map). +//! [`Ebpf::load_file`](crate::Ebpf::load_file) or +//! [`Ebpf::load`](crate::Ebpf::load), all the maps defined in the eBPF code get +//! initialized and can then be accessed using [`Ebpf::map`](crate::Ebpf::map), +//! [`Ebpf::map_mut`](crate::Ebpf::map_mut), or +//! [`Ebpf::take_map`](crate::Ebpf::take_map). //! //! # Typed maps //! //! The eBPF API includes many map types each supporting different operations. -//! [`Bpf::map`](crate::Bpf::map), [`Bpf::map_mut`](crate::Bpf::map_mut), and -//! [`Bpf::take_map`](crate::Bpf::take_map) always return the opaque +//! [`Ebpf::map`](crate::Ebpf::map), [`Ebpf::map_mut`](crate::Ebpf::map_mut), and +//! [`Ebpf::take_map`](crate::Ebpf::take_map) always return the opaque //! [`&Map`](crate::maps::Map), [`&mut Map`](crate::maps::Map), and [`Map`] //! types respectively. Those three types can be converted to *typed maps* using //! the [`TryFrom`] or [`TryInto`] trait. For example: @@ -27,9 +27,9 @@ //! # #[error(transparent)] //! # Program(#[from] aya::programs::ProgramError), //! # #[error(transparent)] -//! # Bpf(#[from] aya::BpfError) +//! # Ebpf(#[from] aya::EbpfError) //! # } -//! # let mut bpf = aya::Bpf::load(&[])?; +//! # let mut bpf = aya::Ebpf::load(&[])?; //! use aya::maps::SockMap; //! use aya::programs::SkMsg; //! @@ -678,7 +678,7 @@ impl MapData { /// # Example /// /// ```no_run - /// # let mut bpf = aya::Bpf::load(&[])?; + /// # let mut bpf = aya::Ebpf::load(&[])?; /// # use aya::maps::MapData; /// /// let mut map = MapData::from_pin("/sys/fs/bpf/my_map")?; @@ -833,9 +833,9 @@ impl PerCpuKernelMem { /// # #[error(transparent)] /// # Map(#[from] aya::maps::MapError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let bpf = aya::Bpf::load(&[])?; +/// # let bpf = aya::Ebpf::load(&[])?; /// use aya::maps::PerCpuValues; /// use aya::util::nr_cpus; /// @@ -992,8 +992,8 @@ impl MapInfo { /// Returns an iterator over all loaded bpf maps. /// -/// This differs from [`crate::Bpf::maps`] since it will return all maps -/// listed on the host system and not only maps for a specific [`crate::Bpf`] instance. +/// This differs from [`crate::Ebpf::maps`] since it will return all maps +/// listed on the host system and not only maps for a specific [`crate::Ebpf`] instance. /// /// # Example /// ``` @@ -1054,7 +1054,7 @@ mod tests { #[test] fn test_from_map_id() { override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_GET_FD_BY_ID, attr, } => { @@ -1064,7 +1064,7 @@ mod tests { ); Ok(42) } - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_OBJ_GET_INFO_BY_FD, attr, } => { @@ -1086,7 +1086,7 @@ mod tests { #[test] fn test_create() { override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_CREATE, .. } => Ok(42), @@ -1113,11 +1113,11 @@ mod tests { const TEST_NAME: &str = "foo"; override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_CREATE, .. } => Ok(42), - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_OBJ_GET_INFO_BY_FD, attr, } => { @@ -1146,7 +1146,7 @@ mod tests { use crate::generated::bpf_map_info; override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_GET_NEXT_ID, attr, } => unsafe { @@ -1158,11 +1158,11 @@ mod tests { Err((-1, io::Error::from_raw_os_error(libc::ENOENT))) } }, - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_MAP_GET_FD_BY_ID, attr, } => Ok((1000 + unsafe { attr.__bindgen_anon_6.__bindgen_anon_1.map_id }) as c_long), - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_OBJ_GET_INFO_BY_FD, attr, } => { diff --git a/aya/src/maps/perf/async_perf_event_array.rs b/aya/src/maps/perf/async_perf_event_array.rs index a7444245..fff98456 100644 --- a/aya/src/maps/perf/async_perf_event_array.rs +++ b/aya/src/maps/perf/async_perf_event_array.rs @@ -42,13 +42,13 @@ use crate::maps::{ /// # #[error(transparent)] /// # Map(#[from] aya::maps::MapError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError), +/// # Ebpf(#[from] aya::EbpfError), /// # #[error(transparent)] /// # PerfBuf(#[from] aya::maps::perf::PerfBufferError), /// # } /// # #[cfg(feature = "async_tokio")] /// # async fn try_main() -> Result<(), Error> { -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::perf::{AsyncPerfEventArray, PerfBufferError}; /// use aya::util::online_cpus; /// use bytes::BytesMut; diff --git a/aya/src/maps/perf/perf_event_array.rs b/aya/src/maps/perf/perf_event_array.rs index 0a6fdfc8..d867e659 100644 --- a/aya/src/maps/perf/perf_event_array.rs +++ b/aya/src/maps/perf/perf_event_array.rs @@ -108,11 +108,11 @@ impl> AsRawFd for PerfEventArrayBuffer { /// # #[error(transparent)] /// # Map(#[from] aya::maps::MapError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError), +/// # Ebpf(#[from] aya::EbpfError), /// # #[error(transparent)] /// # PerfBuf(#[from] aya::maps::perf::PerfBufferError), /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::PerfEventArray; /// use aya::util::online_cpus; /// use bytes::BytesMut; diff --git a/aya/src/maps/queue.rs b/aya/src/maps/queue.rs index b9177b24..9c342525 100644 --- a/aya/src/maps/queue.rs +++ b/aya/src/maps/queue.rs @@ -19,14 +19,14 @@ use crate::{ /// /// # Examples /// ```no_run -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::Queue; /// /// let mut queue = Queue::try_from(bpf.map_mut("ARRAY").unwrap())?; /// queue.push(42, 0)?; /// queue.push(43, 0)?; /// assert_eq!(queue.pop(0)?, 42); -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[doc(alias = "BPF_MAP_TYPE_QUEUE")] pub struct Queue { diff --git a/aya/src/maps/ring_buf.rs b/aya/src/maps/ring_buf.rs index 9344780b..e4cb3cb4 100644 --- a/aya/src/maps/ring_buf.rs +++ b/aya/src/maps/ring_buf.rs @@ -68,7 +68,7 @@ use crate::{ /// # } /// # fn clear_ready(&mut self) {} /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::RingBuf; /// use std::convert::TryFrom; /// @@ -82,7 +82,7 @@ use crate::{ /// } /// guard.clear_ready(); /// } -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` /// /// # Polling diff --git a/aya/src/maps/sock/sock_hash.rs b/aya/src/maps/sock/sock_hash.rs index e3074be8..9be05ee4 100644 --- a/aya/src/maps/sock/sock_hash.rs +++ b/aya/src/maps/sock/sock_hash.rs @@ -38,9 +38,9 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use std::io::Write; /// use std::net::TcpStream; /// use std::os::fd::AsRawFd; diff --git a/aya/src/maps/sock/sock_map.rs b/aya/src/maps/sock/sock_map.rs index 090ccf84..f0590467 100644 --- a/aya/src/maps/sock/sock_map.rs +++ b/aya/src/maps/sock/sock_map.rs @@ -35,9 +35,9 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::SockMap; /// use aya::programs::SkSkb; /// diff --git a/aya/src/maps/stack.rs b/aya/src/maps/stack.rs index a85fe14d..8a7b94bd 100644 --- a/aya/src/maps/stack.rs +++ b/aya/src/maps/stack.rs @@ -19,14 +19,14 @@ use crate::{ /// /// # Examples /// ```no_run -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::Stack; /// /// let mut stack = Stack::try_from(bpf.map_mut("STACK").unwrap())?; /// stack.push(42, 0)?; /// stack.push(43, 0)?; /// assert_eq!(stack.pop(0)?, 43); -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[doc(alias = "BPF_MAP_TYPE_STACK")] pub struct Stack { diff --git a/aya/src/maps/stack_trace.rs b/aya/src/maps/stack_trace.rs index 5a122a92..74b85b66 100644 --- a/aya/src/maps/stack_trace.rs +++ b/aya/src/maps/stack_trace.rs @@ -35,9 +35,9 @@ use crate::{ /// # #[error(transparent)] /// # Map(#[from] aya::maps::MapError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let bpf = aya::Bpf::load(&[])?; +/// # let bpf = aya::Ebpf::load(&[])?; /// use aya::maps::StackTraceMap; /// use aya::util::kernel_symbols; /// diff --git a/aya/src/maps/xdp/cpu_map.rs b/aya/src/maps/xdp/cpu_map.rs index 85f9e679..b5c0727c 100644 --- a/aya/src/maps/xdp/cpu_map.rs +++ b/aya/src/maps/xdp/cpu_map.rs @@ -31,7 +31,7 @@ use crate::{ /// use aya::maps::xdp::CpuMap; /// /// let ncpus = aya::util::nr_cpus().unwrap() as u32; -/// let mut bpf = aya::BpfLoader::new() +/// let mut bpf = aya::EbpfLoader::new() /// .set_max_entries("CPUS", ncpus) /// .load(elf_bytes) /// .unwrap(); @@ -42,7 +42,7 @@ use crate::{ /// cpumap.set(i, queue_size, None, flags); /// } /// -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` /// /// # See also diff --git a/aya/src/maps/xdp/dev_map.rs b/aya/src/maps/xdp/dev_map.rs index 31e9b3ac..44062df5 100644 --- a/aya/src/maps/xdp/dev_map.rs +++ b/aya/src/maps/xdp/dev_map.rs @@ -27,14 +27,14 @@ use crate::{ /// /// # Examples /// ```no_run -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::xdp::DevMap; /// /// let mut devmap = DevMap::try_from(bpf.map_mut("IFACES").unwrap())?; /// // Lookups at index 2 will redirect packets to interface with index 3 (e.g. eth1) /// devmap.set(2, 3, None, 0); /// -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` /// /// # See also diff --git a/aya/src/maps/xdp/dev_map_hash.rs b/aya/src/maps/xdp/dev_map_hash.rs index 63a93b02..1b941bc4 100644 --- a/aya/src/maps/xdp/dev_map_hash.rs +++ b/aya/src/maps/xdp/dev_map_hash.rs @@ -27,14 +27,14 @@ use crate::{ /// /// # Examples /// ```no_run -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::xdp::DevMapHash; /// /// let mut devmap = DevMapHash::try_from(bpf.map_mut("IFACES").unwrap())?; /// // Lookups with key 2 will redirect packets to interface with index 3 (e.g. eth1) /// devmap.insert(2, 3, None, 0); /// -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` /// /// # See also diff --git a/aya/src/maps/xdp/xsk_map.rs b/aya/src/maps/xdp/xsk_map.rs index 43924abf..95c593cc 100644 --- a/aya/src/maps/xdp/xsk_map.rs +++ b/aya/src/maps/xdp/xsk_map.rs @@ -21,14 +21,14 @@ use crate::{ /// /// # Examples /// ```no_run -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// # let socket_fd = 1; /// use aya::maps::XskMap; /// /// let mut xskmap = XskMap::try_from(bpf.map_mut("SOCKETS").unwrap())?; /// // socket_fd is the RawFd of an AF_XDP socket /// xskmap.set(0, socket_fd, 0); -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` /// /// # See also diff --git a/aya/src/programs/cgroup_device.rs b/aya/src/programs/cgroup_device.rs index b8c96267..15263791 100644 --- a/aya/src/programs/cgroup_device.rs +++ b/aya/src/programs/cgroup_device.rs @@ -35,9 +35,9 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::programs::CgroupDevice; /// /// let cgroup = std::fs::File::open("/sys/fs/cgroup/unified")?; diff --git a/aya/src/programs/cgroup_skb.rs b/aya/src/programs/cgroup_skb.rs index 1f99835c..84749423 100644 --- a/aya/src/programs/cgroup_skb.rs +++ b/aya/src/programs/cgroup_skb.rs @@ -39,9 +39,9 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use std::fs::File; /// use aya::programs::{CgroupSkb, CgroupSkbAttachType}; /// diff --git a/aya/src/programs/cgroup_sock.rs b/aya/src/programs/cgroup_sock.rs index 971ef9e9..24f07869 100644 --- a/aya/src/programs/cgroup_sock.rs +++ b/aya/src/programs/cgroup_sock.rs @@ -37,9 +37,9 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use std::fs::File; /// use aya::programs::{CgroupSock, CgroupSockAttachType}; /// diff --git a/aya/src/programs/cgroup_sock_addr.rs b/aya/src/programs/cgroup_sock_addr.rs index f9a2fb7f..79b607ca 100644 --- a/aya/src/programs/cgroup_sock_addr.rs +++ b/aya/src/programs/cgroup_sock_addr.rs @@ -38,9 +38,9 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use std::fs::File; /// use aya::programs::{CgroupSockAddr, CgroupSockAddrAttachType}; /// diff --git a/aya/src/programs/cgroup_sockopt.rs b/aya/src/programs/cgroup_sockopt.rs index 33ac84fe..414fece6 100644 --- a/aya/src/programs/cgroup_sockopt.rs +++ b/aya/src/programs/cgroup_sockopt.rs @@ -35,9 +35,9 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use std::fs::File; /// use aya::programs::CgroupSockopt; /// diff --git a/aya/src/programs/cgroup_sysctl.rs b/aya/src/programs/cgroup_sysctl.rs index 80c1e028..617e3dd8 100644 --- a/aya/src/programs/cgroup_sysctl.rs +++ b/aya/src/programs/cgroup_sysctl.rs @@ -32,9 +32,9 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use std::fs::File; /// use aya::programs::CgroupSysctl; /// diff --git a/aya/src/programs/extension.rs b/aya/src/programs/extension.rs index 3785a57c..648bbfc4 100644 --- a/aya/src/programs/extension.rs +++ b/aya/src/programs/extension.rs @@ -35,9 +35,9 @@ pub enum ExtensionError { /// # Examples /// /// ```no_run -/// use aya::{BpfLoader, programs::{Xdp, XdpFlags, Extension}}; +/// use aya::{EbpfLoader, programs::{Xdp, XdpFlags, Extension}}; /// -/// let mut bpf = BpfLoader::new().extension("extension").load_file("app.o")?; +/// let mut bpf = EbpfLoader::new().extension("extension").load_file("app.o")?; /// let prog: &mut Xdp = bpf.program_mut("main").unwrap().try_into()?; /// prog.load()?; /// prog.attach("eth0", XdpFlags::default())?; @@ -47,7 +47,7 @@ pub enum ExtensionError { /// let ext: &mut Extension = bpf.program_mut("extension").unwrap().try_into()?; /// ext.load(prog_fd, "function_to_replace")?; /// ext.attach()?; -/// Ok::<(), aya::BpfError>(()) +/// Ok::<(), aya::EbpfError>(()) /// ``` #[derive(Debug)] #[doc(alias = "BPF_PROG_TYPE_EXT")] diff --git a/aya/src/programs/fentry.rs b/aya/src/programs/fentry.rs index 8f59061a..0a1d082f 100644 --- a/aya/src/programs/fentry.rs +++ b/aya/src/programs/fentry.rs @@ -31,10 +31,10 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError), +/// # Ebpf(#[from] aya::EbpfError), /// # } -/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; -/// use aya::{Bpf, programs::FEntry, BtfError, Btf}; +/// # let mut bpf = Ebpf::load_file("ebpf_programs.o")?; +/// use aya::{Ebpf, programs::FEntry, BtfError, Btf}; /// /// let btf = Btf::from_sys_fs()?; /// let program: &mut FEntry = bpf.program_mut("filename_lookup").unwrap().try_into()?; diff --git a/aya/src/programs/fexit.rs b/aya/src/programs/fexit.rs index ba2e1f1b..5efca285 100644 --- a/aya/src/programs/fexit.rs +++ b/aya/src/programs/fexit.rs @@ -31,10 +31,10 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError), +/// # Ebpf(#[from] aya::EbpfError), /// # } -/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; -/// use aya::{Bpf, programs::FExit, BtfError, Btf}; +/// # let mut bpf = Ebpf::load_file("ebpf_programs.o")?; +/// use aya::{Ebpf, programs::FExit, BtfError, Btf}; /// /// let btf = Btf::from_sys_fs()?; /// let program: &mut FExit = bpf.program_mut("filename_lookup").unwrap().try_into()?; diff --git a/aya/src/programs/kprobe.rs b/aya/src/programs/kprobe.rs index 8902c9eb..81e830e9 100644 --- a/aya/src/programs/kprobe.rs +++ b/aya/src/programs/kprobe.rs @@ -35,13 +35,13 @@ use crate::{ /// # Examples /// /// ```no_run -/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; -/// use aya::{Bpf, programs::KProbe}; +/// # let mut bpf = Ebpf::load_file("ebpf_programs.o")?; +/// use aya::{Ebpf, programs::KProbe}; /// /// let program: &mut KProbe = bpf.program_mut("intercept_wakeups").unwrap().try_into()?; /// program.load()?; /// program.attach("try_to_wake_up", 0)?; -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[derive(Debug)] #[doc(alias = "BPF_PROG_TYPE_KPROBE")] diff --git a/aya/src/programs/links.rs b/aya/src/programs/links.rs index 2a87dff7..9dfd3b02 100644 --- a/aya/src/programs/links.rs +++ b/aya/src/programs/links.rs @@ -93,8 +93,8 @@ pub struct FdLinkId(pub(crate) RawFd); /// # Example /// ///```no_run -/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; -/// use aya::{Bpf, programs::{links::FdLink, KProbe}}; +/// # let mut bpf = Ebpf::load_file("ebpf_programs.o")?; +/// use aya::{Ebpf, programs::{links::FdLink, KProbe}}; /// /// let program: &mut KProbe = bpf.program_mut("intercept_wakeups").unwrap().try_into()?; /// program.load()?; @@ -103,7 +103,7 @@ pub struct FdLinkId(pub(crate) RawFd); /// let fd_link: FdLink = link.try_into().unwrap(); /// fd_link.pin("/sys/fs/bpf/intercept_wakeups_link").unwrap(); /// -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[derive(Debug)] pub struct FdLink { @@ -130,13 +130,13 @@ impl FdLink { /// # #[derive(thiserror::Error, Debug)] /// # enum Error { /// # #[error(transparent)] - /// # Bpf(#[from] aya::BpfError), + /// # Ebpf(#[from] aya::EbpfError), /// # #[error(transparent)] /// # Pin(#[from] aya::pin::PinError), /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError) /// # } - /// # let mut bpf = aya::Bpf::load(&[])?; + /// # let mut bpf = aya::Ebpf::load(&[])?; /// # let prog: &mut Extension = bpf.program_mut("example").unwrap().try_into()?; /// let link_id = prog.attach()?; /// let owned_link = prog.take_link(link_id)?; diff --git a/aya/src/programs/lirc_mode2.rs b/aya/src/programs/lirc_mode2.rs index 6e62ce60..cbd47d95 100644 --- a/aya/src/programs/lirc_mode2.rs +++ b/aya/src/programs/lirc_mode2.rs @@ -30,14 +30,14 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use std::fs::File; /// use aya::programs::LircMode2; /// /// let file = File::open("/dev/lirc0")?; -/// let mut bpf = aya::Bpf::load_file("imon_rsc.o")?; +/// let mut bpf = aya::Ebpf::load_file("imon_rsc.o")?; /// let decoder: &mut LircMode2 = bpf.program_mut("imon_rsc").unwrap().try_into().unwrap(); /// decoder.load()?; /// decoder.attach(file)?; diff --git a/aya/src/programs/lsm.rs b/aya/src/programs/lsm.rs index 3a455707..7c1d9ddf 100644 --- a/aya/src/programs/lsm.rs +++ b/aya/src/programs/lsm.rs @@ -33,10 +33,10 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError), +/// # Ebpf(#[from] aya::EbpfError), /// # } -/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; -/// use aya::{Bpf, programs::Lsm, BtfError, Btf}; +/// # let mut bpf = Ebpf::load_file("ebpf_programs.o")?; +/// use aya::{Ebpf, programs::Lsm, BtfError, Btf}; /// /// let btf = Btf::from_sys_fs()?; /// let program: &mut Lsm = bpf.program_mut("lsm_prog").unwrap().try_into()?; diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs index 92eb2069..675e36f0 100644 --- a/aya/src/programs/mod.rs +++ b/aya/src/programs/mod.rs @@ -5,35 +5,35 @@ //! //! # Loading and attaching programs //! -//! When you call [`Bpf::load_file`] or [`Bpf::load`], all the programs included +//! When you call [`Ebpf::load_file`] or [`Ebpf::load`], all the programs included //! in the object code are parsed and relocated. Programs are not loaded //! automatically though, since often you will need to do some application //! specific setup before you can actually load them. //! -//! In order to load and attach a program, you need to retrieve it using [`Bpf::program_mut`], +//! In order to load and attach a program, you need to retrieve it using [`Ebpf::program_mut`], //! then call the `load()` and `attach()` methods, for example: //! //! ```no_run -//! use aya::{Bpf, programs::KProbe}; +//! use aya::{Ebpf, programs::KProbe}; //! -//! let mut bpf = Bpf::load_file("ebpf_programs.o")?; +//! let mut bpf = Ebpf::load_file("ebpf_programs.o")?; //! // intercept_wakeups is the name of the program we want to load //! let program: &mut KProbe = bpf.program_mut("intercept_wakeups").unwrap().try_into()?; //! program.load()?; //! // intercept_wakeups will be called every time try_to_wake_up() is called //! // inside the kernel //! program.attach("try_to_wake_up", 0)?; -//! # Ok::<(), aya::BpfError>(()) +//! # Ok::<(), aya::EbpfError>(()) //! ``` //! //! The signature of the `attach()` method varies depending on what kind of //! program you're trying to attach. //! -//! [`Bpf::load_file`]: crate::Bpf::load_file -//! [`Bpf::load`]: crate::Bpf::load -//! [`Bpf::programs`]: crate::Bpf::programs -//! [`Bpf::program`]: crate::Bpf::program -//! [`Bpf::program_mut`]: crate::Bpf::program_mut +//! [`Ebpf::load_file`]: crate::Ebpf::load_file +//! [`Ebpf::load`]: crate::Ebpf::load +//! [`Ebpf::programs`]: crate::Ebpf::programs +//! [`Ebpf::program`]: crate::Ebpf::program +//! [`Ebpf::program_mut`]: crate::Ebpf::program_mut //! [`maps`]: crate::maps // modules we don't export @@ -124,7 +124,7 @@ use crate::{ bpf_btf_get_fd_by_id, bpf_get_object, bpf_link_get_fd_by_id, bpf_link_get_info_by_fd, bpf_load_program, bpf_pin_object, bpf_prog_get_fd_by_id, bpf_prog_get_info_by_fd, bpf_prog_query, iter_link_ids, iter_prog_ids, retry_with_verifier_logs, - BpfLoadProgramAttrs, SyscallError, + EbpfLoadProgramAttrs, SyscallError, }, util::{bytes_of_bpf_name, KernelVersion}, VerifierLogLevel, @@ -641,7 +641,7 @@ fn load_program( None }; - let attr = BpfLoadProgramAttrs { + let attr = EbpfLoadProgramAttrs { name: prog_name, ty: prog_type, insns: instructions, @@ -1117,8 +1117,8 @@ impl ProgramInfo { /// Returns an iterator over all loaded bpf programs. /// -/// This differs from [`crate::Bpf::programs`] since it will return all programs -/// listed on the host system and not only programs a specific [`crate::Bpf`] instance. +/// This differs from [`crate::Ebpf::programs`] since it will return all programs +/// listed on the host system and not only programs a specific [`crate::Ebpf`] instance. /// /// # Example /// ``` diff --git a/aya/src/programs/perf_event.rs b/aya/src/programs/perf_event.rs index 37b7ea4a..00ac4b38 100644 --- a/aya/src/programs/perf_event.rs +++ b/aya/src/programs/perf_event.rs @@ -98,9 +98,9 @@ pub enum PerfEventScope { /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::util::online_cpus; /// use aya::programs::perf_event::{ /// perf_sw_ids::PERF_COUNT_SW_CPU_CLOCK, PerfEvent, PerfEventScope, PerfTypeId, SamplePolicy, diff --git a/aya/src/programs/raw_trace_point.rs b/aya/src/programs/raw_trace_point.rs index af451e59..214bee71 100644 --- a/aya/src/programs/raw_trace_point.rs +++ b/aya/src/programs/raw_trace_point.rs @@ -24,13 +24,13 @@ use crate::{ /// # Examples /// /// ```no_run -/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; -/// use aya::{Bpf, programs::RawTracePoint}; +/// # let mut bpf = Ebpf::load_file("ebpf_programs.o")?; +/// use aya::{Ebpf, programs::RawTracePoint}; /// /// let program: &mut RawTracePoint = bpf.program_mut("sys_enter").unwrap().try_into()?; /// program.load()?; /// program.attach("sys_enter")?; -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[derive(Debug)] #[doc(alias = "BPF_PROG_TYPE_RAW_TRACEPOINT")] diff --git a/aya/src/programs/sk_lookup.rs b/aya/src/programs/sk_lookup.rs index 00277c5a..dab0ebc7 100644 --- a/aya/src/programs/sk_lookup.rs +++ b/aya/src/programs/sk_lookup.rs @@ -32,9 +32,9 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use std::fs::File; /// use aya::programs::SkLookup; /// diff --git a/aya/src/programs/sk_msg.rs b/aya/src/programs/sk_msg.rs index f169447b..b5a89b87 100644 --- a/aya/src/programs/sk_msg.rs +++ b/aya/src/programs/sk_msg.rs @@ -33,9 +33,9 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use std::io::Write; /// use std::net::TcpStream; /// use std::os::fd::AsRawFd; diff --git a/aya/src/programs/sk_skb.rs b/aya/src/programs/sk_skb.rs index 81bc9534..4d571dcb 100644 --- a/aya/src/programs/sk_skb.rs +++ b/aya/src/programs/sk_skb.rs @@ -46,9 +46,9 @@ pub enum SkSkbKind { /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::maps::SockMap; /// use aya::programs::SkSkb; /// diff --git a/aya/src/programs/sock_ops.rs b/aya/src/programs/sock_ops.rs index d8cb1383..0694dcbd 100644 --- a/aya/src/programs/sock_ops.rs +++ b/aya/src/programs/sock_ops.rs @@ -31,9 +31,9 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use std::fs::File; /// use aya::programs::SockOps; /// diff --git a/aya/src/programs/socket_filter.rs b/aya/src/programs/socket_filter.rs index abf6e7ed..02be9e05 100644 --- a/aya/src/programs/socket_filter.rs +++ b/aya/src/programs/socket_filter.rs @@ -17,7 +17,7 @@ use crate::{ pub enum SocketFilterError { /// Setting the `SO_ATTACH_BPF` socket option failed. #[error("setsockopt SO_ATTACH_BPF failed")] - SoAttachBpfError { + SoAttachEbpfError { /// original [`io::Error`] #[source] io_error: io::Error, @@ -45,9 +45,9 @@ pub enum SocketFilterError { /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use std::net::TcpStream; /// use aya::programs::SocketFilter; /// @@ -89,7 +89,7 @@ impl SocketFilter { ) }; if ret < 0 { - return Err(SocketFilterError::SoAttachBpfError { + return Err(SocketFilterError::SoAttachEbpfError { io_error: io::Error::last_os_error(), } .into()); diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index cebbe4be..c2dd5a13 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -55,9 +55,9 @@ pub enum TcAttachType { /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::programs::{tc, SchedClassifier, TcAttachType}; /// /// // the clsact qdisc needs to be added before SchedClassifier programs can be diff --git a/aya/src/programs/tp_btf.rs b/aya/src/programs/tp_btf.rs index eb419ab1..8c235d43 100644 --- a/aya/src/programs/tp_btf.rs +++ b/aya/src/programs/tp_btf.rs @@ -30,10 +30,10 @@ use crate::{ /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError), +/// # Ebpf(#[from] aya::EbpfError), /// # } -/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; -/// use aya::{Bpf, programs::BtfTracePoint, BtfError, Btf}; +/// # let mut bpf = Ebpf::load_file("ebpf_programs.o")?; +/// use aya::{Ebpf, programs::BtfTracePoint, BtfError, Btf}; /// /// let btf = Btf::from_sys_fs()?; /// let program: &mut BtfTracePoint = bpf.program_mut("sched_process_fork").unwrap().try_into()?; diff --git a/aya/src/programs/trace_point.rs b/aya/src/programs/trace_point.rs index 2096f1cb..9d304204 100644 --- a/aya/src/programs/trace_point.rs +++ b/aya/src/programs/trace_point.rs @@ -50,9 +50,9 @@ pub enum TracePointError { /// # #[error(transparent)] /// # Program(#[from] aya::programs::ProgramError), /// # #[error(transparent)] -/// # Bpf(#[from] aya::BpfError) +/// # Ebpf(#[from] aya::EbpfError) /// # } -/// # let mut bpf = aya::Bpf::load(&[])?; +/// # let mut bpf = aya::Ebpf::load(&[])?; /// use aya::programs::TracePoint; /// /// let prog: &mut TracePoint = bpf.program_mut("trace_context_switch").unwrap().try_into()?; diff --git a/aya/src/programs/xdp.rs b/aya/src/programs/xdp.rs index 9c4f23d3..5d49f4f1 100644 --- a/aya/src/programs/xdp.rs +++ b/aya/src/programs/xdp.rs @@ -71,12 +71,12 @@ bitflags::bitflags! { /// # Examples /// /// ```no_run -/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; -/// use aya::{Bpf, programs::{Xdp, XdpFlags}}; +/// # let mut bpf = Ebpf::load_file("ebpf_programs.o")?; +/// use aya::{Ebpf, programs::{Xdp, XdpFlags}}; /// /// let program: &mut Xdp = bpf.program_mut("intercept_packets").unwrap().try_into()?; /// program.attach("eth0", XdpFlags::default())?; -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[derive(Debug)] #[doc(alias = "BPF_PROG_TYPE_XDP")] diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs index 33863f21..a956bf6c 100644 --- a/aya/src/sys/bpf.rs +++ b/aya/src/sys/bpf.rs @@ -112,7 +112,7 @@ pub(crate) fn bpf_get_object(path: &CStr) -> SysResult { unsafe { fd_sys_bpf(bpf_cmd::BPF_OBJ_GET, &mut attr) } } -pub(crate) struct BpfLoadProgramAttrs<'a> { +pub(crate) struct EbpfLoadProgramAttrs<'a> { pub(crate) name: Option, pub(crate) ty: bpf_prog_type, pub(crate) insns: &'a [bpf_insn], @@ -131,7 +131,7 @@ pub(crate) struct BpfLoadProgramAttrs<'a> { } pub(crate) fn bpf_load_program( - aya_attr: &BpfLoadProgramAttrs<'_>, + aya_attr: &EbpfLoadProgramAttrs<'_>, log_buf: &mut [u8], verifier_log_level: VerifierLogLevel, ) -> SysResult { @@ -993,7 +993,7 @@ fn bpf_prog_load(attr: &mut bpf_attr) -> SysResult { } fn sys_bpf(cmd: bpf_cmd, attr: &mut bpf_attr) -> SysResult { - syscall(Syscall::Bpf { cmd, attr }) + syscall(Syscall::Ebpf { cmd, attr }) } fn bpf_obj_get_next_id( @@ -1096,7 +1096,7 @@ mod tests { #[test] fn test_perf_link_supported() { override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_LINK_CREATE, .. } => Err((-1, io::Error::from_raw_os_error(EBADF))), @@ -1106,7 +1106,7 @@ mod tests { assert!(supported); override_syscall(|call| match call { - Syscall::Bpf { + Syscall::Ebpf { cmd: bpf_cmd::BPF_LINK_CREATE, .. } => Err((-1, io::Error::from_raw_os_error(EINVAL))), diff --git a/aya/src/sys/mod.rs b/aya/src/sys/mod.rs index 0b22463a..fddab712 100644 --- a/aya/src/sys/mod.rs +++ b/aya/src/sys/mod.rs @@ -26,7 +26,7 @@ use crate::generated::{bpf_attr, bpf_cmd, perf_event_attr}; pub(crate) type SysResult = Result; pub(crate) enum Syscall<'a> { - Bpf { + Ebpf { cmd: bpf_cmd, attr: &'a mut bpf_attr, }, @@ -57,8 +57,8 @@ pub struct SyscallError { impl std::fmt::Debug for Syscall<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::Bpf { cmd, attr: _ } => f - .debug_struct("Syscall::Bpf") + Self::Ebpf { cmd, attr: _ } => f + .debug_struct("Syscall::Ebpf") .field("cmd", cmd) .field("attr", &format_args!("_")) .finish(), @@ -93,7 +93,7 @@ fn syscall(call: Syscall<'_>) -> SysResult { #[cfg_attr(test, allow(unreachable_code))] match unsafe { match call { - Syscall::Bpf { cmd, attr } => { + Syscall::Ebpf { cmd, attr } => { libc::syscall(SYS_bpf, cmd, attr, mem::size_of::()) } Syscall::PerfEventOpen { diff --git a/aya/src/util.rs b/aya/src/util.rs index 3ce8aef4..f3b68017 100644 --- a/aya/src/util.rs +++ b/aya/src/util.rs @@ -307,7 +307,7 @@ pub(crate) fn tc_handler_make(major: u32, minor: u32) -> u32 { (major & TC_H_MAJ_MASK) | (minor & TC_H_MIN_MASK) } -/// Include bytes from a file for use in a subsequent [`crate::Bpf::load`]. +/// Include bytes from a file for use in a subsequent [`crate::Ebpf::load`]. /// /// This macro differs from the standard `include_bytes!` macro since it also ensures that /// the bytes are correctly aligned to be parsed as an ELF binary. This avoid some nasty @@ -315,13 +315,13 @@ pub(crate) fn tc_handler_make(major: u32, minor: u32) -> u32 { /// /// # Examples /// ```ignore -/// use aya::{Bpf, include_bytes_aligned}; +/// use aya::{Ebpf, include_bytes_aligned}; /// -/// let mut bpf = Bpf::load(include_bytes_aligned!( +/// let mut bpf = Ebpf::load(include_bytes_aligned!( /// "/path/to/bpf.o" /// ))?; /// -/// # Ok::<(), aya::BpfError>(()) +/// # Ok::<(), aya::EbpfError>(()) /// ``` #[macro_export] macro_rules! include_bytes_aligned { diff --git a/test/integration-test/src/tests/bpf_probe_read.rs b/test/integration-test/src/tests/bpf_probe_read.rs index 5d7cf6ab..6479a2df 100644 --- a/test/integration-test/src/tests/bpf_probe_read.rs +++ b/test/integration-test/src/tests/bpf_probe_read.rs @@ -1,4 +1,4 @@ -use aya::{maps::Array, programs::UProbe, Bpf}; +use aya::{maps::Array, programs::UProbe, Ebpf}; use test_log::test; const RESULT_BUF_LEN: usize = 1024; @@ -64,7 +64,7 @@ fn bpf_probe_read_kernel_str_bytes_empty_dest() { assert_eq!(result_bytes(&bpf), b""); } -fn set_user_buffer(bytes: &[u8], dest_len: usize) -> Bpf { +fn set_user_buffer(bytes: &[u8], dest_len: usize) -> Ebpf { let bpf = load_and_attach_uprobe( "test_bpf_probe_read_user_str_bytes", "trigger_bpf_probe_read_user", @@ -74,7 +74,7 @@ fn set_user_buffer(bytes: &[u8], dest_len: usize) -> Bpf { bpf } -fn set_kernel_buffer(bytes: &[u8], dest_len: usize) -> Bpf { +fn set_kernel_buffer(bytes: &[u8], dest_len: usize) -> Ebpf { let mut bpf = load_and_attach_uprobe( "test_bpf_probe_read_kernel_str_bytes", "trigger_bpf_probe_read_kernel", @@ -85,7 +85,7 @@ fn set_kernel_buffer(bytes: &[u8], dest_len: usize) -> Bpf { bpf } -fn set_kernel_buffer_element(bpf: &mut Bpf, bytes: &[u8]) { +fn set_kernel_buffer_element(bpf: &mut Ebpf, bytes: &[u8]) { let mut bytes = bytes.to_vec(); bytes.resize(1024, 0xFF); let bytes: [u8; 1024] = bytes.try_into().unwrap(); @@ -94,7 +94,7 @@ fn set_kernel_buffer_element(bpf: &mut Bpf, bytes: &[u8]) { } #[track_caller] -fn result_bytes(bpf: &Bpf) -> Vec { +fn result_bytes(bpf: &Ebpf) -> Vec { let m = Array::<_, TestResult>::try_from(bpf.map("RESULT").unwrap()).unwrap(); let TestResult { buf, len } = m.get(&0, 0).unwrap(); let len = len.unwrap(); @@ -104,8 +104,8 @@ fn result_bytes(bpf: &Bpf) -> Vec { buf[..len].to_vec() } -fn load_and_attach_uprobe(prog_name: &str, func_name: &str, bytes: &[u8]) -> Bpf { - let mut bpf = Bpf::load(bytes).unwrap(); +fn load_and_attach_uprobe(prog_name: &str, func_name: &str, bytes: &[u8]) -> Ebpf { + let mut bpf = Ebpf::load(bytes).unwrap(); let prog: &mut UProbe = bpf.program_mut(prog_name).unwrap().try_into().unwrap(); prog.load().unwrap(); diff --git a/test/integration-test/src/tests/btf_relocations.rs b/test/integration-test/src/tests/btf_relocations.rs index 2e6c2ee4..29616850 100644 --- a/test/integration-test/src/tests/btf_relocations.rs +++ b/test/integration-test/src/tests/btf_relocations.rs @@ -1,4 +1,4 @@ -use aya::{maps::Array, programs::UProbe, util::KernelVersion, BpfLoader, Btf, Endianness}; +use aya::{maps::Array, programs::UProbe, util::KernelVersion, Btf, EbpfLoader, Endianness}; use test_case::test_case; #[test_case("enum_signed_32", false, Some((KernelVersion::new(6, 0, 0), "https://github.com/torvalds/linux/commit/6089fb3")), -0x7AAAAAAAi32 as u64)] @@ -36,7 +36,7 @@ fn relocation_tests( return; } } - let mut bpf = BpfLoader::new() + let mut bpf = EbpfLoader::new() .btf( with_relocations .then(|| Btf::parse(crate::RELOC_BTF, Endianness::default()).unwrap()) diff --git a/test/integration-test/src/tests/load.rs b/test/integration-test/src/tests/load.rs index ee5ba713..ffc8ddf7 100644 --- a/test/integration-test/src/tests/load.rs +++ b/test/integration-test/src/tests/load.rs @@ -13,7 +13,7 @@ use aya::{ loaded_links, loaded_programs, KProbe, TracePoint, UProbe, Xdp, XdpFlags, }, util::KernelVersion, - Bpf, + Ebpf, }; use aya_obj::programs::XdpAttachType; use test_log::test; @@ -23,7 +23,7 @@ const RETRY_DURATION: Duration = Duration::from_millis(10); #[test] fn long_name() { - let mut bpf = Bpf::load(crate::NAME_TEST).unwrap(); + let mut bpf = Ebpf::load(crate::NAME_TEST).unwrap(); let name_prog: &mut Xdp = bpf .program_mut("ihaveaverylongname") .unwrap() @@ -39,7 +39,7 @@ fn long_name() { #[test] fn multiple_btf_maps() { - let mut bpf = Bpf::load(crate::MULTIMAP_BTF).unwrap(); + let mut bpf = Ebpf::load(crate::MULTIMAP_BTF).unwrap(); let map_1: Array<_, u64> = bpf.take_map("map_1").unwrap().try_into().unwrap(); let map_2: Array<_, u64> = bpf.take_map("map_2").unwrap().try_into().unwrap(); @@ -69,7 +69,7 @@ fn multiple_btf_maps() { #[test] fn pin_lifecycle_multiple_btf_maps() { - let mut bpf = Bpf::load(crate::MULTIMAP_BTF).unwrap(); + let mut bpf = Ebpf::load(crate::MULTIMAP_BTF).unwrap(); // "map_pin_by_name" should already be pinned, unpin and pin again later let map_pin_by_name_path = Path::new("/sys/fs/bpf/map_pin_by_name"); @@ -198,7 +198,7 @@ fn assert_unloaded(name: &str) { #[test] fn unload_xdp() { - let mut bpf = Bpf::load(crate::TEST).unwrap(); + let mut bpf = Ebpf::load(crate::TEST).unwrap(); let prog: &mut Xdp = bpf.program_mut("pass").unwrap().try_into().unwrap(); prog.load().unwrap(); assert_loaded("pass"); @@ -223,7 +223,7 @@ fn unload_xdp() { #[test] fn test_loaded_at() { - let mut bpf = Bpf::load(crate::TEST).unwrap(); + let mut bpf = Ebpf::load(crate::TEST).unwrap(); let prog: &mut Xdp = bpf.program_mut("pass").unwrap().try_into().unwrap(); // SystemTime is not monotonic, which can cause this test to flake. We don't expect the clock @@ -259,7 +259,7 @@ fn test_loaded_at() { #[test] fn unload_kprobe() { - let mut bpf = Bpf::load(crate::TEST).unwrap(); + let mut bpf = Ebpf::load(crate::TEST).unwrap(); let prog: &mut KProbe = bpf.program_mut("test_kprobe").unwrap().try_into().unwrap(); prog.load().unwrap(); assert_loaded("test_kprobe"); @@ -284,7 +284,7 @@ fn unload_kprobe() { #[test] fn basic_tracepoint() { - let mut bpf = Bpf::load(crate::TEST).unwrap(); + let mut bpf = Ebpf::load(crate::TEST).unwrap(); let prog: &mut TracePoint = bpf .program_mut("test_tracepoint") .unwrap() @@ -315,7 +315,7 @@ fn basic_tracepoint() { #[test] fn basic_uprobe() { - let mut bpf = Bpf::load(crate::TEST).unwrap(); + let mut bpf = Ebpf::load(crate::TEST).unwrap(); let prog: &mut UProbe = bpf.program_mut("test_uprobe").unwrap().try_into().unwrap(); prog.load().unwrap(); @@ -351,7 +351,7 @@ fn pin_link() { return; } - let mut bpf = Bpf::load(crate::TEST).unwrap(); + let mut bpf = Ebpf::load(crate::TEST).unwrap(); let prog: &mut Xdp = bpf.program_mut("pass").unwrap().try_into().unwrap(); prog.load().unwrap(); let link_id = prog.attach("lo", XdpFlags::default()).unwrap(); @@ -384,7 +384,7 @@ fn pin_lifecycle() { // 1. Load Program and Pin { - let mut bpf = Bpf::load(crate::PASS).unwrap(); + let mut bpf = Ebpf::load(crate::PASS).unwrap(); let prog: &mut Xdp = bpf.program_mut("pass").unwrap().try_into().unwrap(); prog.load().unwrap(); prog.pin("/sys/fs/bpf/aya-xdp-test-prog").unwrap(); @@ -419,7 +419,7 @@ fn pin_lifecycle() { // 4. Load a new version of the program, unpin link, and atomically replace old program { - let mut bpf = Bpf::load(crate::PASS).unwrap(); + let mut bpf = Ebpf::load(crate::PASS).unwrap(); let prog: &mut Xdp = bpf.program_mut("pass").unwrap().try_into().unwrap(); prog.load().unwrap(); @@ -439,7 +439,7 @@ fn pin_lifecycle() { fn pin_lifecycle_tracepoint() { // 1. Load Program and Pin { - let mut bpf = Bpf::load(crate::TEST).unwrap(); + let mut bpf = Ebpf::load(crate::TEST).unwrap(); let prog: &mut TracePoint = bpf .program_mut("test_tracepoint") .unwrap() @@ -493,7 +493,7 @@ fn pin_lifecycle_tracepoint() { fn pin_lifecycle_kprobe() { // 1. Load Program and Pin { - let mut bpf = Bpf::load(crate::TEST).unwrap(); + let mut bpf = Ebpf::load(crate::TEST).unwrap(); let prog: &mut KProbe = bpf.program_mut("test_kprobe").unwrap().try_into().unwrap(); prog.load().unwrap(); prog.pin("/sys/fs/bpf/aya-kprobe-test-prog").unwrap(); @@ -560,7 +560,7 @@ fn pin_lifecycle_uprobe() { // 1. Load Program and Pin { - let mut bpf = Bpf::load(crate::TEST).unwrap(); + let mut bpf = Ebpf::load(crate::TEST).unwrap(); let prog: &mut UProbe = bpf.program_mut("test_uprobe").unwrap().try_into().unwrap(); prog.load().unwrap(); prog.pin(FIRST_PIN_PATH).unwrap(); diff --git a/test/integration-test/src/tests/log.rs b/test/integration-test/src/tests/log.rs index 1f325851..56f5edec 100644 --- a/test/integration-test/src/tests/log.rs +++ b/test/integration-test/src/tests/log.rs @@ -3,7 +3,7 @@ use std::{ sync::{Arc, Mutex}, }; -use aya::{programs::UProbe, Bpf}; +use aya::{programs::UProbe, Ebpf}; use aya_log::EbpfLogger; use log::{Level, Log, Record}; use test_log::test; @@ -40,7 +40,7 @@ struct CapturedLog<'a> { #[test(tokio::test)] async fn log() { - let mut bpf = Bpf::load(crate::LOG).unwrap(); + let mut bpf = Ebpf::load(crate::LOG).unwrap(); let captured_logs = Arc::new(Mutex::new(Vec::new())); { diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs index 9c5dab7f..eb43466a 100644 --- a/test/integration-test/src/tests/relocations.rs +++ b/test/integration-test/src/tests/relocations.rs @@ -1,4 +1,4 @@ -use aya::{programs::UProbe, util::KernelVersion, Bpf}; +use aya::{programs::UProbe, util::KernelVersion, Ebpf}; use test_log::test; #[test] @@ -33,8 +33,8 @@ fn text_64_64_reloc() { assert_eq!(m.get(&1, 0).unwrap(), 3); } -fn load_and_attach(name: &str, bytes: &[u8]) -> Bpf { - let mut bpf = Bpf::load(bytes).unwrap(); +fn load_and_attach(name: &str, bytes: &[u8]) -> Ebpf { + let mut bpf = Ebpf::load(bytes).unwrap(); let prog: &mut UProbe = bpf.program_mut(name).unwrap().try_into().unwrap(); prog.load().unwrap(); diff --git a/test/integration-test/src/tests/ring_buf.rs b/test/integration-test/src/tests/ring_buf.rs index 927d80a9..18e38de9 100644 --- a/test/integration-test/src/tests/ring_buf.rs +++ b/test/integration-test/src/tests/ring_buf.rs @@ -13,7 +13,7 @@ use assert_matches::assert_matches; use aya::{ maps::{array::PerCpuArray, ring_buf::RingBuf, MapData}, programs::UProbe, - Bpf, BpfLoader, Pod, + Ebpf, EbpfLoader, Pod, }; use aya_obj::generated::BPF_RINGBUF_HDR_SZ; use rand::Rng as _; @@ -50,7 +50,7 @@ impl<'a> std::iter::Sum<&'a Registers> for Registers { unsafe impl Pod for Registers {} struct RingBufTest { - _bpf: Bpf, + _bpf: Ebpf, ring_buf: RingBuf, regs: PerCpuArray, } @@ -67,7 +67,7 @@ impl RingBufTest { (RING_BUF_MAX_ENTRIES * (mem::size_of::() + BPF_RINGBUF_HDR_SZ as usize)) as u32; // Use the loader API to control the size of the ring_buf. - let mut bpf = BpfLoader::new() + let mut bpf = EbpfLoader::new() .set_max_entries("RING_BUF", RING_BUF_BYTE_SIZE) .load(crate::RING_BUF) .unwrap(); diff --git a/test/integration-test/src/tests/smoke.rs b/test/integration-test/src/tests/smoke.rs index 13204557..708b889b 100644 --- a/test/integration-test/src/tests/smoke.rs +++ b/test/integration-test/src/tests/smoke.rs @@ -2,7 +2,7 @@ use aya::{ maps::loaded_maps, programs::{loaded_programs, Extension, TracePoint, Xdp, XdpFlags}, util::KernelVersion, - Bpf, BpfLoader, + Ebpf, EbpfLoader, }; use test_log::test; @@ -18,7 +18,7 @@ fn xdp() { let _netns = NetNsGuard::new(); - let mut bpf = Bpf::load(crate::PASS).unwrap(); + let mut bpf = Ebpf::load(crate::PASS).unwrap(); let dispatcher: &mut Xdp = bpf.program_mut("pass").unwrap().try_into().unwrap(); dispatcher.load().unwrap(); dispatcher.attach("lo", XdpFlags::default()).unwrap(); @@ -26,7 +26,7 @@ fn xdp() { #[test] fn two_progs() { - let mut bpf = Bpf::load(crate::TWO_PROGS).unwrap(); + let mut bpf = Ebpf::load(crate::TWO_PROGS).unwrap(); let prog_one: &mut TracePoint = bpf .program_mut("test_tracepoint_one") @@ -56,12 +56,12 @@ fn extension() { let _netns = NetNsGuard::new(); - let mut bpf = Bpf::load(crate::MAIN).unwrap(); + let mut bpf = Ebpf::load(crate::MAIN).unwrap(); let pass: &mut Xdp = bpf.program_mut("xdp_pass").unwrap().try_into().unwrap(); pass.load().unwrap(); pass.attach("lo", XdpFlags::default()).unwrap(); - let mut bpf = BpfLoader::new() + let mut bpf = EbpfLoader::new() .extension("xdp_drop") .load(crate::EXT) .unwrap(); @@ -74,7 +74,7 @@ fn extension() { #[test] fn list_loaded_programs() { // Load a program. - let mut bpf = Bpf::load(crate::PASS).unwrap(); + let mut bpf = Ebpf::load(crate::PASS).unwrap(); let dispatcher: &mut Xdp = bpf.program_mut("pass").unwrap().try_into().unwrap(); dispatcher.load().unwrap(); dispatcher.attach("lo", XdpFlags::default()).unwrap(); @@ -103,7 +103,7 @@ fn list_loaded_programs() { #[test] fn list_loaded_maps() { // Load a program with maps. - let mut bpf = Bpf::load(crate::MAP_TEST).unwrap(); + let mut bpf = Ebpf::load(crate::MAP_TEST).unwrap(); let dispatcher: &mut Xdp = bpf.program_mut("pass").unwrap().try_into().unwrap(); dispatcher.load().unwrap(); dispatcher.attach("lo", XdpFlags::default()).unwrap(); diff --git a/test/integration-test/src/tests/xdp.rs b/test/integration-test/src/tests/xdp.rs index bd694287..fb137d89 100644 --- a/test/integration-test/src/tests/xdp.rs +++ b/test/integration-test/src/tests/xdp.rs @@ -3,7 +3,7 @@ use std::{ffi::CStr, mem::MaybeUninit, net::UdpSocket, num::NonZeroU32, time::Du use aya::{ maps::{Array, CpuMap, XskMap}, programs::{Xdp, XdpFlags}, - Bpf, + Ebpf, }; use object::{Object, ObjectSection, ObjectSymbol, SymbolSection}; use test_log::test; @@ -15,7 +15,7 @@ use crate::utils::NetNsGuard; fn af_xdp() { let _netns = NetNsGuard::new(); - let mut bpf = Bpf::load(crate::REDIRECT).unwrap(); + let mut bpf = Ebpf::load(crate::REDIRECT).unwrap(); let mut socks: XskMap<_> = bpf.take_map("SOCKS").unwrap().try_into().unwrap(); let xdp: &mut Xdp = bpf @@ -122,7 +122,7 @@ fn ensure_symbol(obj_file: &object::File, sec_name: &str, sym_name: &str) { #[test] fn map_load() { - let bpf = Bpf::load(crate::XDP_SEC).unwrap(); + let bpf = Ebpf::load(crate::XDP_SEC).unwrap(); bpf.program("xdp_plain").unwrap(); bpf.program("xdp_frags").unwrap(); @@ -136,7 +136,7 @@ fn map_load() { fn cpumap_chain() { let _netns = NetNsGuard::new(); - let mut bpf = Bpf::load(crate::REDIRECT).unwrap(); + let mut bpf = Ebpf::load(crate::REDIRECT).unwrap(); // Load our cpumap and our canary map let mut cpus: CpuMap<_> = bpf.take_map("CPUS").unwrap().try_into().unwrap();