Merge pull request #592 from probulate/update-bitflags

build(deps): update bitflags requirement from 1.2.1 to 2.2.1
pull/597/head
Alessandro Decina 2 years ago committed by GitHub
commit 67f480eb8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,7 +15,7 @@ libc = { version = "0.2.105" }
aya-obj = { path = "../aya-obj", version = "0.1.0", features = ["std"] } aya-obj = { path = "../aya-obj", version = "0.1.0", features = ["std"] }
thiserror = "1" thiserror = "1"
object = { version = "0.31", default-features = false, features = ["std", "read_core", "elf"] } object = { version = "0.31", default-features = false, features = ["std", "read_core", "elf"] }
bitflags = "1.2.1" bitflags = "2.2.1"
bytes = "1" bytes = "1"
lazy_static = "1" lazy_static = "1"
parking_lot = { version = "0.12.0", features = ["send_guard"] } parking_lot = { version = "0.12.0", features = ["send_guard"] }

@ -125,13 +125,14 @@ pub struct BpfLoader<'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 [BpfLoader](BpfLoader::verifier_log_level()).
#[derive(Debug)]
pub struct VerifierLogLevel: u32 { pub struct VerifierLogLevel: u32 {
/// Sets no verifier logging. /// Sets no verifier logging.
const DISABLE = 0; const DISABLE = 0;
/// Enables debug verifier logging. /// Enables debug verifier logging.
const DEBUG = 1; const DEBUG = 1;
/// Enables verbose verifier logging. /// Enables verbose verifier logging.
const VERBOSE = 2 | Self::DEBUG.bits; const VERBOSE = 2 | Self::DEBUG.bits();
/// Enables verifier stats. /// Enables verifier stats.
const STATS = 4; const STATS = 4;
} }
@ -139,9 +140,7 @@ bitflags! {
impl Default for VerifierLogLevel { impl Default for VerifierLogLevel {
fn default() -> Self { fn default() -> Self {
Self { Self::DEBUG | Self::STATS
bits: Self::DEBUG.bits | Self::STATS.bits,
}
} }
} }
@ -339,7 +338,7 @@ impl<'a> BpfLoader<'a> {
/// # Ok::<(), aya::BpfError>(()) /// # Ok::<(), aya::BpfError>(())
/// ``` /// ```
pub fn load(&mut self, data: &[u8]) -> Result<Bpf, BpfError> { pub fn load(&mut self, data: &[u8]) -> Result<Bpf, BpfError> {
let verifier_log_level = self.verifier_log_level.bits; let verifier_log_level = self.verifier_log_level.bits();
let mut obj = Object::parse(data)?; let mut obj = Object::parse(data)?;
obj.patch_map_data(self.globals.clone())?; obj.patch_map_data(self.globals.clone())?;

@ -35,7 +35,7 @@ pub enum XdpError {
bitflags! { bitflags! {
/// Flags passed to [`Xdp::attach()`]. /// Flags passed to [`Xdp::attach()`].
#[derive(Default)] #[derive(Clone, Copy, Debug, Default)]
pub struct XdpFlags: u32 { pub struct XdpFlags: u32 {
/// Skb mode. /// Skb mode.
const SKB_MODE = XDP_FLAGS_SKB_MODE; const SKB_MODE = XDP_FLAGS_SKB_MODE;
@ -128,7 +128,7 @@ impl Xdp {
let k_ver = kernel_version().unwrap(); let k_ver = kernel_version().unwrap();
if k_ver >= (5, 9, 0) { 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 { |(_, io_error)| ProgramError::SyscallError {
call: "bpf_link_create".to_owned(), call: "bpf_link_create".to_owned(),
io_error, io_error,
@ -138,7 +138,7 @@ impl Xdp {
.links .links
.insert(XdpLink::new(XdpLinkInner::FdLink(FdLink::new(link_fd)))) .insert(XdpLink::new(XdpLinkInner::FdLink(FdLink::new(link_fd))))
} else { } 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 })?; .map_err(|io_error| XdpError::NetlinkError { io_error })?;
self.data self.data
@ -226,9 +226,9 @@ impl Link for NlLink {
fn detach(self) -> Result<(), ProgramError> { fn detach(self) -> Result<(), ProgramError> {
let k_ver = kernel_version().unwrap(); let k_ver = kernel_version().unwrap();
let flags = if k_ver >= (5, 7, 0) { let flags = if k_ver >= (5, 7, 0) {
self.flags.bits | XDP_FLAGS_REPLACE self.flags.bits() | XDP_FLAGS_REPLACE
} else { } else {
self.flags.bits self.flags.bits()
}; };
let _ = unsafe { netlink_set_xdp_fd(self.if_index, -1, Some(self.prog_fd), flags) }; let _ = unsafe { netlink_set_xdp_fd(self.if_index, -1, Some(self.prog_fd), flags) };
Ok(()) Ok(())

Loading…
Cancel
Save