Merge pull request #61 from vadorovsky/aya-log-dont-unwrap

Don't fail on `BpfLogger::init()` error
pull/62/head
Alessandro Decina 2 years ago committed by GitHub
commit 864e1995f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -38,7 +38,7 @@ use aya::programs::SocketFilter;
{%- endcase %} {%- endcase %}
use aya_log::BpfLogger; use aya_log::BpfLogger;
use clap::Parser; use clap::Parser;
use log::info; use log::{info, warn};
use tokio::signal; use tokio::signal;
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
@ -73,7 +73,10 @@ async fn main() -> Result<(), anyhow::Error> {
let mut bpf = Bpf::load(include_bytes_aligned!( let mut bpf = Bpf::load(include_bytes_aligned!(
"../../target/bpfel-unknown-none/release/{{project-name}}" "../../target/bpfel-unknown-none/release/{{project-name}}"
))?; ))?;
BpfLogger::init(&mut bpf)?; if let Err(e) = BpfLogger::init(&mut bpf) {
// This can happen if you remove all log statements from your eBPF program.
warn!("failed to initialize eBPF logger: {}", e);
}
{% case program_type -%} {% case program_type -%}
{%- when "kprobe", "kretprobe" -%} {%- when "kprobe", "kretprobe" -%}
let program: &mut KProbe = bpf.program_mut("{{crate_name}}").unwrap().try_into()?; let program: &mut KProbe = bpf.program_mut("{{crate_name}}").unwrap().try_into()?;

Loading…
Cancel
Save