Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions examples/capable/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::mem::MaybeUninit;
use std::str;
use std::str::FromStr;

use anyhow::bail;
use anyhow::Result;
use clap::Parser;
use libbpf_rs::skel::OpenSkel;
Expand Down Expand Up @@ -110,19 +109,6 @@ struct Command {

unsafe impl Plain for capable::types::event {}

fn bump_memlock_rlimit() -> Result<()> {
let rlimit = libc::rlimit {
rlim_cur: 128 << 20,
rlim_max: 128 << 20,
};

if unsafe { libc::setrlimit(libc::RLIMIT_MEMLOCK, &rlimit) } != 0 {
bail!("Failed to increase rlimit");
}

Ok(())
}

fn print_banner(extra_fields: bool) {
#[allow(clippy::print_literal)]
if extra_fields {
Expand Down Expand Up @@ -187,8 +173,6 @@ fn main() -> Result<()> {
skel_builder.obj_builder.debug(true);
}

bump_memlock_rlimit()?;

let mut open_object = MaybeUninit::uninit();
let open_skel = skel_builder.open(&mut open_object)?;
//Pass configuration to BPF
Expand Down
15 changes: 0 additions & 15 deletions examples/runqslower/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::mem::MaybeUninit;
use std::str;
use std::time::Duration;

use anyhow::bail;
use anyhow::Result;
use clap::Parser;
use libbpf_rs::skel::OpenSkel;
Expand Down Expand Up @@ -43,19 +42,6 @@ struct Command {

unsafe impl Plain for runqslower::types::event {}

fn bump_memlock_rlimit() -> Result<()> {
let rlimit = libc::rlimit {
rlim_cur: 128 << 20,
rlim_max: 128 << 20,
};

if unsafe { libc::setrlimit(libc::RLIMIT_MEMLOCK, &rlimit) } != 0 {
bail!("Failed to increase rlimit");
}

Ok(())
}

fn handle_event(_cpu: i32, data: &[u8]) {
let mut event = runqslower::types::event::default();
plain::copy_from_bytes(&mut event, data).expect("Data buffer was too short");
Expand Down Expand Up @@ -91,7 +77,6 @@ fn main() -> Result<()> {
skel_builder.obj_builder.debug(true);
}

bump_memlock_rlimit()?;
let mut open_object = MaybeUninit::uninit();
let open_skel = skel_builder.open(&mut open_object)?;

Expand Down
15 changes: 0 additions & 15 deletions examples/tc_port_whitelist/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use std::mem::MaybeUninit;
use std::os::unix::io::AsFd as _;

use anyhow::bail;
use anyhow::Context as _;
use anyhow::Result;

Expand Down Expand Up @@ -54,23 +53,9 @@ struct Command {
iface: String,
}

fn bump_memlock_rlimit() -> Result<()> {
let rlimit = libc::rlimit {
rlim_cur: 128 << 20,
rlim_max: 128 << 20,
};

if unsafe { libc::setrlimit(libc::RLIMIT_MEMLOCK, &rlimit) } != 0 {
bail!("Failed to increase rlimit");
}

Ok(())
}
fn main() -> Result<()> {
let opts = Command::parse();

bump_memlock_rlimit()?;

let builder = TcSkelBuilder::default();
let mut open_object = MaybeUninit::uninit();
let open = builder.open(&mut open_object)?;
Expand Down
15 changes: 0 additions & 15 deletions examples/tcp_option/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use libc::c_void;
use libc::socklen_t;
use std::mem::size_of_val;

use anyhow::bail;
use anyhow::Result;
use clap::Parser;
use std::fs::OpenOptions;
Expand Down Expand Up @@ -54,19 +53,6 @@ struct Command {
verbose: bool,
}

fn bump_memlock_rlimit() -> Result<()> {
let rlimit = libc::rlimit {
rlim_cur: 128 << 20,
rlim_max: 128 << 20,
};

if unsafe { libc::setrlimit(libc::RLIMIT_MEMLOCK, &rlimit) } != 0 {
bail!("Failed to increase rlimit");
}

Ok(())
}

fn open_fd() -> Result<i32> {
unsafe {
match socket(
Expand All @@ -82,7 +68,6 @@ fn open_fd() -> Result<i32> {

fn main() -> Result<()> {
let opts = Command::parse();
bump_memlock_rlimit()?;

let running = Arc::new(AtomicBool::new(true));
let r = running.clone();
Expand Down
2 changes: 1 addition & 1 deletion libbpf-rs/src/btf/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ gen_collection_concrete_type! {
value: {
let hi: u64 = member.val_hi32.into();
let lo: u64 = member.val_lo32.into();
let val = hi << 32 | lo;
let val = (hi << 32) | lo;
if signed {
i64::from_ne_bytes(val.to_ne_bytes()).into()
} else {
Expand Down
16 changes: 0 additions & 16 deletions libbpf-rs/tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::io;
use std::path::PathBuf;

use libbpf_rs::Map;
Expand Down Expand Up @@ -28,21 +27,6 @@ pub fn open_test_object(filename: &str) -> OpenObject {
obj
}

pub fn bump_rlimit_mlock() {
let rlimit = libc::rlimit {
rlim_cur: 128 << 20,
rlim_max: 128 << 20,
};

let ret = unsafe { libc::setrlimit(libc::RLIMIT_MEMLOCK, &rlimit) };
assert_eq!(
ret,
0,
"Setting RLIMIT_MEMLOCK failed with errno: {}",
io::Error::last_os_error()
);
}

pub fn get_test_object(filename: &str) -> Object {
open_test_object(filename)
.load()
Expand Down
Loading