Merge pull request #94 from liyan-ah/main

Allow process to lock memory for eBPF resources.
reviewable/pr95/r1
Alessandro Decina 1 year ago committed by GitHub
commit d65e6d2bb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,9 +13,7 @@ clap = { version = "4.1", features = ["derive"] }
{{project-name}}-common = { path = "../{{project-name}}-common", features = ["user"] } {{project-name}}-common = { path = "../{{project-name}}-common", features = ["user"] }
anyhow = "1" anyhow = "1"
env_logger = "0.10" env_logger = "0.10"
{%- if program_type == "uprobe" %}
libc = "0.2" libc = "0.2"
{%- endif %}
log = "0.4" log = "0.4"
tokio = { version = "1.25", features = ["macros", "rt", "rt-multi-thread", "net", "signal"] } tokio = { version = "1.25", features = ["macros", "rt", "rt-multi-thread", "net", "signal"] }

@ -45,7 +45,7 @@ use aya_log::BpfLogger;
{% if program_types_with_opts contains program_type -%} {% if program_types_with_opts contains program_type -%}
use clap::Parser; use clap::Parser;
{% endif -%} {% endif -%}
use log::{info, warn}; use log::{info, warn, debug};
use tokio::signal; use tokio::signal;
{% if program_types_with_opts contains program_type -%} {% if program_types_with_opts contains program_type -%}
@ -71,6 +71,17 @@ async fn main() -> Result<(), anyhow::Error> {
{% endif %} {% endif %}
env_logger::init(); env_logger::init();
// Bump the memlock rlimit. This is needed for older kernels that don't use the
// new memcg based accounting, see https://lwn.net/Articles/837122/
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 {
debug!("remove limit on locked memory failed, ret is: {}", ret);
}
// This will include your eBPF object file as raw bytes at compile-time and load it at // 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 // 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 // like to specify the eBPF program at runtime rather than at compile-time, you can

Loading…
Cancel
Save