|
|
|
@ -137,7 +137,6 @@ pub struct EbpfLoader<'a> {
|
|
|
|
|
extensions: HashSet<&'a str>,
|
|
|
|
|
verifier_log_level: VerifierLogLevel,
|
|
|
|
|
allow_unsupported_maps: bool,
|
|
|
|
|
ignore_maps_by_type: HashSet<bpf_map_type>,
|
|
|
|
|
ignore_maps_by_name: &'a [&'a str],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -177,7 +176,6 @@ impl<'a> EbpfLoader<'a> {
|
|
|
|
|
extensions: HashSet::new(),
|
|
|
|
|
verifier_log_level: VerifierLogLevel::default(),
|
|
|
|
|
allow_unsupported_maps: false,
|
|
|
|
|
ignore_maps_by_type: HashSet::new(),
|
|
|
|
|
ignore_maps_by_name: &[],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -234,37 +232,7 @@ impl<'a> EbpfLoader<'a> {
|
|
|
|
|
/// This is useful when you have a single ebpf program containing e.g. a `RingBuf`
|
|
|
|
|
/// and a `PerfEventArray` and you decide which one to use before loading the bytecode.
|
|
|
|
|
///
|
|
|
|
|
/// Must be used with `.set_global()` to signal if the map is supported in the ebpf program.
|
|
|
|
|
///
|
|
|
|
|
/// # Example
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// use aya::EbpfLoader;
|
|
|
|
|
/// use aya_obj::generated::bpf_map_type;
|
|
|
|
|
/// use std::collections::HashSet;
|
|
|
|
|
///
|
|
|
|
|
/// let ringbuf_supported = 0;
|
|
|
|
|
/// let mut set = HashSet::new();
|
|
|
|
|
/// set.insert(bpf_map_type::BPF_MAP_TYPE_RINGBUF);
|
|
|
|
|
/// let ebpf = EbpfLoader::new()
|
|
|
|
|
/// .ignore_maps_by_type(set)
|
|
|
|
|
/// .set_global("RINGBUF_SUPPORTED", &ringbuf_supported, true)
|
|
|
|
|
/// .load_file("file.o")?;
|
|
|
|
|
/// # Ok::<(), aya::EbpfError>(())
|
|
|
|
|
/// ```
|
|
|
|
|
///
|
|
|
|
|
pub fn ignore_maps_by_type(&mut self, set: HashSet<bpf_map_type>) -> &mut Self {
|
|
|
|
|
self.ignore_maps_by_type = set;
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Allows programs containing unsupported maps for the current kernel to be loaded
|
|
|
|
|
/// by skipping map creation and relocation before loading.
|
|
|
|
|
///
|
|
|
|
|
/// This is useful when you have a single ebpf program containing e.g. a `RingBuf`
|
|
|
|
|
/// and a `PerfEventArray` and you decide which one to use before loading the bytecode.
|
|
|
|
|
///
|
|
|
|
|
/// Must be used with `.set_global()` to signal if the map is supported in the ebpf program.
|
|
|
|
|
/// Must be used with [.set_global()] to signal if the map is supported in the ebpf program.
|
|
|
|
|
///
|
|
|
|
|
/// # Example
|
|
|
|
|
///
|
|
|
|
@ -454,7 +422,6 @@ impl<'a> EbpfLoader<'a> {
|
|
|
|
|
extensions,
|
|
|
|
|
verifier_log_level,
|
|
|
|
|
allow_unsupported_maps,
|
|
|
|
|
ignore_maps_by_type,
|
|
|
|
|
ignore_maps_by_name,
|
|
|
|
|
} = self;
|
|
|
|
|
let mut obj = Object::parse(data)?;
|
|
|
|
@ -531,9 +498,7 @@ impl<'a> EbpfLoader<'a> {
|
|
|
|
|
}
|
|
|
|
|
let map_type: bpf_map_type = obj.map_type().try_into().map_err(MapError::from)?;
|
|
|
|
|
|
|
|
|
|
if ignore_maps_by_type.contains(&map_type)
|
|
|
|
|
|| ignore_maps_by_name.contains(&name.as_str())
|
|
|
|
|
{
|
|
|
|
|
if ignore_maps_by_name.contains(&name.as_str()) {
|
|
|
|
|
ignored_maps.insert(name, obj);
|
|
|
|
|
// ignore map creation. The map is saved in `ignored_maps` and filtered out
|
|
|
|
|
// in `relocate_maps()` later on
|
|
|
|
|