Applied cargo fmt to fix formatting

pull/968/head
martinsoees 7 months ago
parent c3084fd6a7
commit b05ab1599d

@ -228,7 +228,6 @@ fn relocate_maps<'a, I: Iterator<Item = &'a Relocation>>(
index: rel.symbol_index,
})?;
let Some(section_index) = sym.section_index else {
// this is not a map relocation
continue;
@ -240,7 +239,7 @@ fn relocate_maps<'a, I: Iterator<Item = &'a Relocation>>(
}
let (_name, fd, map) = if ignored_by_symbol.contains(&rel.symbol_index) {
continue
continue;
} else if let Some(m) = maps_by_symbol.get(&rel.symbol_index) {
let map = &m.2;
debug!(
@ -252,7 +251,7 @@ fn relocate_maps<'a, I: Iterator<Item = &'a Relocation>>(
debug_assert_eq!(map.symbol_index().unwrap(), rel.symbol_index);
m
} else if ignored_by_section.contains(&section_index) {
continue
continue;
} else {
let Some(m) = maps_by_section.get(&section_index) else {
debug!("failed relocating map by section index {}", section_index);

@ -21,8 +21,8 @@ use thiserror::Error;
use crate::{
generated::{
bpf_map_type::{self, *}, AYA_PERF_EVENT_IOC_DISABLE, AYA_PERF_EVENT_IOC_ENABLE,
AYA_PERF_EVENT_IOC_SET_BPF,
bpf_map_type::{self, *},
AYA_PERF_EVENT_IOC_DISABLE, AYA_PERF_EVENT_IOC_ENABLE, AYA_PERF_EVENT_IOC_SET_BPF,
},
maps::{Map, MapData, MapError},
obj::{
@ -531,7 +531,9 @@ 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_type.contains(&map_type)
|| 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

@ -11,13 +11,15 @@ enum DisableMapRelocation<'a> {
#[test]
fn test_ignored_map_relocation_by_type() {
let mut ebpf = relocation_load_and_attach("test_ignored_map_relocation", crate::IGNORE_MAP, DisableMapRelocation::ByType(bpf_map_type::BPF_MAP_TYPE_RINGBUF));
let mut ebpf = relocation_load_and_attach(
"test_ignored_map_relocation",
crate::IGNORE_MAP,
DisableMapRelocation::ByType(bpf_map_type::BPF_MAP_TYPE_RINGBUF),
);
let perf = ebpf
.take_map("PERFBUF");
let perf = ebpf.take_map("PERFBUF");
let ring = ebpf
.take_map("RINGBUF");
let ring = ebpf.take_map("RINGBUF");
assert!(perf.is_some());
assert!(ring.is_none());
@ -25,13 +27,15 @@ fn test_ignored_map_relocation_by_type() {
#[test]
fn test_ignored_map_relocation_by_name() {
let mut ebpf = relocation_load_and_attach("test_ignored_map_relocation", crate::IGNORE_MAP, DisableMapRelocation::ByName("RINGBUF"));
let mut ebpf = relocation_load_and_attach(
"test_ignored_map_relocation",
crate::IGNORE_MAP,
DisableMapRelocation::ByName("RINGBUF"),
);
let perf = ebpf
.take_map("PERFBUF");
let perf = ebpf.take_map("PERFBUF");
let ring = ebpf
.take_map("RINGBUF");
let ring = ebpf.take_map("RINGBUF");
assert!(perf.is_some());
assert!(ring.is_none());
@ -69,7 +73,11 @@ fn text_64_64_reloc() {
assert_eq!(m.get(&1, 0).unwrap(), 3);
}
fn relocation_load_and_attach(name: &str, bytes: &[u8], disable_type: DisableMapRelocation) -> Ebpf {
fn relocation_load_and_attach(
name: &str,
bytes: &[u8],
disable_type: DisableMapRelocation,
) -> Ebpf {
let mut ebpf = match disable_type {
DisableMapRelocation::ByType(bmt) => {
let mut set = HashSet::new();
@ -80,13 +88,11 @@ fn relocation_load_and_attach(name: &str, bytes: &[u8], disable_type: DisableMap
.load(bytes)
.unwrap()
}
DisableMapRelocation::ByName(name) => {
EbpfLoader::new()
DisableMapRelocation::ByName(name) => EbpfLoader::new()
.ignore_maps_by_name(&[name])
.set_global("RINGBUF_SUPPORTED", &0, true)
.load(bytes)
.unwrap()
}
.unwrap(),
};
let prog: &mut UProbe = ebpf.program_mut(name).unwrap().try_into().unwrap();

Loading…
Cancel
Save