Skip to content

Commit

Permalink
aya,int-test: revamp MapInfo be more friendly with older kernels
Browse files Browse the repository at this point in the history
Adds detection for whether a field is available in `MapInfo`:
- For `map_type()`, we treturn new enum `MapType` instead of the integer
  representation.
- For fields that can't be zero, we return `Option<NonZero*>` type.
- For `name_as_str()`, it now uses the feature probe `bpf_name()` to
  detect if field is available.
  Although the feature probe checks for program name, it can also be
  used for map name since they were both introduced in the same commit.
  • Loading branch information
tyrone-wu committed Sep 2, 2024
1 parent 88f5ac3 commit fbb0930
Show file tree
Hide file tree
Showing 6 changed files with 577 additions and 173 deletions.
2 changes: 1 addition & 1 deletion aya-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl EbpfLogger {
None => false,
})
.ok_or(Error::MapNotFound)?;
let map = MapData::from_id(map.id()).map_err(Error::MapError)?;
let map = MapData::from_id(map.id().unwrap().get()).map_err(Error::MapError)?;

Self::read_logs_async(Map::PerfEventArray(map), logger)?;

Expand Down
5 changes: 4 additions & 1 deletion aya-obj/src/obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ impl Features {
}
}

/// Returns whether BPF program names are supported.
/// Returns whether BPF program names and map names are supported.
///
/// Although the feature probe performs the check for program name, we can use this to also
/// detect if map name is supported since they were both introduced in the same commit.
pub fn bpf_name(&self) -> bool {
self.bpf_name
}
Expand Down
Loading

0 comments on commit fbb0930

Please sign in to comment.