Skip to content

Commit

Permalink
misc: rename status_map to init_map
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoNardi committed Feb 2, 2023
1 parent 52c82b2 commit 8105ff4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions crates/bpf-common/include/output.bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct {
__uint(max_entries, 1);
} temp_map SEC(".maps");

// The status map contains configuration status for the eBPF program:
// The init map contains configuration status for the eBPF program:
// - The STATUS_INITIALIZED entry indicates the perf event array initialization
// status. On startup it's set to 0, when the userspace program opens the perf
// event array it's set to 1. The eBPF program emits events only when it's 1.
Expand All @@ -57,7 +57,7 @@ struct {
__type(key, u32);
__type(value, u32);
__uint(max_entries, 1);
} status_map SEC(".maps");
} init_map SEC(".maps");

// Get the temporary buffer inside temp_map as a void pointer, this can be cast
// to the required event type and filled before submitting it for output. The
Expand All @@ -76,7 +76,7 @@ static __always_inline void output_event(void *ctx, void *output_map,
void *event, int struct_len,
int buffer_len) {
u32 key = STATUS_INITIALIZED;
u32 *initialization_status = bpf_map_lookup_elem(&status_map, &key);
u32 *initialization_status = bpf_map_lookup_elem(&init_map, &key);
if (!initialization_status || !*initialization_status) {
// The userspace is not ready yet for events on the perf event array
return;
Expand Down
8 changes: 4 additions & 4 deletions crates/bpf-common/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ impl Program {
.take_map(map_name)
.ok_or_else(|| ProgramError::MapNotFound(map_name.to_string()))?;
let mut perf_array: AsyncPerfEventArray<_> = AsyncPerfEventArray::try_from(map_resource)?;
let mut status_map = Array::try_from(
let mut init_map = Array::try_from(
self.bpf
.take_map("status_map")
.ok_or_else(|| ProgramError::MapNotFound("status_map".to_string()))?,
.take_map("init_map")
.ok_or_else(|| ProgramError::MapNotFound("init_map".to_string()))?,
)?;

let buffers = online_cpus()
Expand Down Expand Up @@ -401,7 +401,7 @@ impl Program {
}

// Signal eBPF program we're ready by setting STATUS_INITIALIZED
if let Err(err) = status_map.set(0, 1_u32, 0) {
if let Err(err) = init_map.set(0, 1_u32, 0) {
log::warn!(
"Error setting STATUS_INITIALIZED for {}: {:?}",
self.name,
Expand Down

0 comments on commit 8105ff4

Please sign in to comment.