From ae8a95b0ee513b220b0b5ff1332ca24059ed3e7e Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Thu, 27 Apr 2023 16:46:01 -0400 Subject: [PATCH] build(deps): update bitflags requirement from 1.2.1 to 2.2.1 Updates the requirements on [bitflags](https://github.com/bitflags/bitflags) to permit the latest version. - [Release notes](https://github.com/bitflags/bitflags/releases) - [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md) - [Commits](https://github.com/bitflags/bitflags/compare/1.2.1...2.2.1) --- aya/Cargo.toml | 2 +- aya/src/bpf.rs | 9 ++++----- aya/src/programs/xdp.rs | 10 +++++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/aya/Cargo.toml b/aya/Cargo.toml index 8e407fa1..f12ebf27 100644 --- a/aya/Cargo.toml +++ b/aya/Cargo.toml @@ -15,7 +15,7 @@ libc = { version = "0.2.105" } aya-obj = { path = "../aya-obj", version = "0.1.0", features = ["std"] } thiserror = "1" object = { version = "0.31", default-features = false, features = ["std", "read_core", "elf"] } -bitflags = "1.2.1" +bitflags = "2.2.1" bytes = "1" lazy_static = "1" parking_lot = { version = "0.12.0", features = ["send_guard"] } diff --git a/aya/src/bpf.rs b/aya/src/bpf.rs index 859ee16d..84026a4b 100644 --- a/aya/src/bpf.rs +++ b/aya/src/bpf.rs @@ -125,13 +125,14 @@ pub struct BpfLoader<'a> { bitflags! { /// Used to set the verifier log level flags in [BpfLoader](BpfLoader::verifier_log_level()). + #[derive(Debug)] pub struct VerifierLogLevel: u32 { /// Sets no verifier logging. const DISABLE = 0; /// Enables debug verifier logging. const DEBUG = 1; /// Enables verbose verifier logging. - const VERBOSE = 2 | Self::DEBUG.bits; + const VERBOSE = 2 | Self::DEBUG.bits(); /// Enables verifier stats. const STATS = 4; } @@ -139,9 +140,7 @@ bitflags! { impl Default for VerifierLogLevel { fn default() -> Self { - Self { - bits: Self::DEBUG.bits | Self::STATS.bits, - } + Self::DEBUG | Self::STATS } } @@ -339,7 +338,7 @@ impl<'a> BpfLoader<'a> { /// # Ok::<(), aya::BpfError>(()) /// ``` pub fn load(&mut self, data: &[u8]) -> Result { - let verifier_log_level = self.verifier_log_level.bits; + let verifier_log_level = self.verifier_log_level.bits(); let mut obj = Object::parse(data)?; obj.patch_map_data(self.globals.clone())?; diff --git a/aya/src/programs/xdp.rs b/aya/src/programs/xdp.rs index 63f00987..1fad9da1 100644 --- a/aya/src/programs/xdp.rs +++ b/aya/src/programs/xdp.rs @@ -35,7 +35,7 @@ pub enum XdpError { bitflags! { /// Flags passed to [`Xdp::attach()`]. - #[derive(Default)] + #[derive(Clone, Copy, Debug, Default)] pub struct XdpFlags: u32 { /// Skb mode. const SKB_MODE = XDP_FLAGS_SKB_MODE; @@ -128,7 +128,7 @@ impl Xdp { let k_ver = kernel_version().unwrap(); if k_ver >= (5, 9, 0) { - let link_fd = bpf_link_create(prog_fd, if_index, BPF_XDP, None, flags.bits).map_err( + let link_fd = bpf_link_create(prog_fd, if_index, BPF_XDP, None, flags.bits()).map_err( |(_, io_error)| ProgramError::SyscallError { call: "bpf_link_create".to_owned(), io_error, @@ -138,7 +138,7 @@ impl Xdp { .links .insert(XdpLink::new(XdpLinkInner::FdLink(FdLink::new(link_fd)))) } else { - unsafe { netlink_set_xdp_fd(if_index, prog_fd, None, flags.bits) } + unsafe { netlink_set_xdp_fd(if_index, prog_fd, None, flags.bits()) } .map_err(|io_error| XdpError::NetlinkError { io_error })?; self.data @@ -226,9 +226,9 @@ impl Link for NlLink { fn detach(self) -> Result<(), ProgramError> { let k_ver = kernel_version().unwrap(); let flags = if k_ver >= (5, 7, 0) { - self.flags.bits | XDP_FLAGS_REPLACE + self.flags.bits() | XDP_FLAGS_REPLACE } else { - self.flags.bits + self.flags.bits() }; let _ = unsafe { netlink_set_xdp_fd(self.if_index, -1, Some(self.prog_fd), flags) }; Ok(())