diff --git a/{{project-name}}/Cargo.toml b/{{project-name}}/Cargo.toml index 9f6cdd2..56e094d 100644 --- a/{{project-name}}/Cargo.toml +++ b/{{project-name}}/Cargo.toml @@ -13,12 +13,9 @@ clap = { version = "4.1", features = ["derive"] } {{project-name}}-common = { path = "../{{project-name}}-common", features = ["user"] } anyhow = "1" env_logger = "0.10" -{%- if program_type == "uprobe" %} -libc = "0.2" -{%- endif %} log = "0.4" tokio = { version = "1.25", features = ["macros", "rt", "rt-multi-thread", "net", "signal"] } -rlimit = "0.9.1" +libc = "0.2" [[bin]] name = "{{project-name}}" diff --git a/{{project-name}}/src/main.rs b/{{project-name}}/src/main.rs index 7f16d7d..7169a78 100644 --- a/{{project-name}}/src/main.rs +++ b/{{project-name}}/src/main.rs @@ -72,14 +72,17 @@ async fn main() -> Result<(), anyhow::Error> { {% endif %} env_logger::init(); - if !Resource::MEMLOCK - .set(rlimit::INFINITY, rlimit::INFINITY) - .is_ok() - { + let rlim = libc::rlimit{ + rlim_cur: libc::RLIM_INFINITY, + rlim_max: libc::RLIM_INFINITY, + }; + let ret = unsafe { libc::setrlimit(libc::RLIMIT_MEMLOCK, &rlim) }; + if !ret == 0{ warn!("cannot remove mem lock"); } + // This will include your eBPF object file as raw bytes at compile-time and load it at // runtime. This approach is recommended for most real-world use cases. If you would // like to specify the eBPF program at runtime rather than at compile-time, you can