Skip to content

Commit

Permalink
better version also working
Browse files Browse the repository at this point in the history
  • Loading branch information
dmah42 committed May 14, 2024
1 parent f07f026 commit 5764358
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 3 additions & 5 deletions auraed/src/ebpf/perf_buffer_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* *
\* -------------------------------------------------------------------------- */

use anyhow::Context;
use aya::{
maps::perf::AsyncPerfEventArray,
util::{nr_cpus, online_cpus},
Expand Down Expand Up @@ -75,12 +76,9 @@ pub trait PerfBufferReader<T: Clone + Send + 'static> {
// kernel to userspace. This array contains the per-CPU buffers and is
// indexed by CPU id.
// https://libbpf.readthedocs.io/en/latest/api.html
//let perf_array: &mut AsyncPerfEventArray<&mut MapData> = bpf
// .map_mut(perf_buffer)
// .ok_or_else(|| anyhow::anyhow!("failed to get perf event array"))?
// .try_into()?;
let mut perf_array = AsyncPerfEventArray::try_from(
bpf.take_map(perf_buffer).expect("Failed to find perf event array"),
bpf.take_map(perf_buffer)
.context("Failed to find '{perf_buffer}' perf event array")?,
)?;

// Spawn a thread per CPU to listen for events from the kernel.
Expand Down
4 changes: 3 additions & 1 deletion auraed/src/ebpf/tracepoint/tracepoint_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* *
\* -------------------------------------------------------------------------- */

use anyhow::Context;
use aya::programs::{ProgramError, TracePoint};
use aya::Bpf;
use tracing::{trace, warn};
Expand All @@ -44,7 +45,8 @@ pub trait TracepointProgram<T: Clone + Send + 'static> {
// Load the eBPF TracePoint program
let program: &mut TracePoint = bpf
.program_mut(Self::PROGRAM_NAME)
.ok_or_else(|| anyhow::anyhow!("failed to get eBPF program"))?
.context("failed to get eBPF program")?
//.ok_or_else(|| anyhow::anyhow!("failed to get eBPF program"))?
.try_into()?;

// Load the program
Expand Down

0 comments on commit 5764358

Please sign in to comment.