Skip to content

Commit 4ef97d2

Browse files
committed
chore: Update aya to 0.13.1
1 parent d135aa5 commit 4ef97d2

File tree

8 files changed

+72
-34
lines changed

8 files changed

+72
-34
lines changed

Cargo.lock

Lines changed: 35 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ rules-engine = { path = "crates/modules/rules-engine" }
114114
smtp-notifier = { path = "crates/modules/smtp-notifier" }
115115
# External
116116
anyhow = "1.0.75"
117-
aya = { version = "0.12.0", features = ["async_tokio"] }
117+
aya = { version = "0.13.1", features = ["async_tokio"] }
118118
aya-ebpf-bindings = "0.1.0"
119119
aya-obj = "0.1.0"
120120
axum = { version = "0.8.1", features = ["ws"] }

crates/bpf-common/src/program.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ use aya::{
1212
perf::{AsyncPerfEventArray, PerfBufferError},
1313
Array, HashMap, Map, MapData,
1414
},
15-
programs::{CgroupSkb, CgroupSkbAttachType, KProbe, Lsm, RawTracePoint, TracePoint},
15+
programs::{
16+
CgroupAttachMode, CgroupSkb, CgroupSkbAttachType, KProbe, Lsm, RawTracePoint, TracePoint,
17+
},
1618
util::{online_cpus, KernelVersion},
17-
Bpf, BpfLoader, Btf, BtfError, Pod,
19+
Btf, BtfError, Ebpf, EbpfLoader, Pod,
1820
};
1921
use bpf_feature_autodetect::autodetect_features;
2022
use bpf_features::BpfFeatures;
@@ -151,7 +153,7 @@ macro_rules! ebpf_program {
151153
#[derive(Error, Debug)]
152154
pub enum ProgramError {
153155
#[error("loading probe")]
154-
LoadingProbe(#[from] aya::BpfError),
156+
LoadingProbe(#[from] aya::EbpfError),
155157
#[error("program not found {0}")]
156158
ProgramNotFound(String),
157159
#[error("incorrect program type {0}")]
@@ -270,7 +272,7 @@ impl ProgramBuilder {
270272

271273
let bpf = tokio::task::spawn_blocking(move || {
272274
let _ = std::fs::create_dir(&self.ctx.pinning_path);
273-
let mut bpf = BpfLoader::new()
275+
let mut bpf = EbpfLoader::new()
274276
.map_pin_path(&self.ctx.pinning_path)
275277
.btf(Some(btf.as_ref()))
276278
.set_global("log_level", &(self.ctx.log_level as i32), true)
@@ -283,7 +285,7 @@ impl ProgramBuilder {
283285
for program in self.programs {
284286
program.attach(&mut bpf, &btf)?;
285287
}
286-
Result::<Bpf, ProgramError>::Ok(bpf)
288+
Result::<Ebpf, ProgramError>::Ok(bpf)
287289
})
288290
.await
289291
.expect("join error")?;
@@ -327,7 +329,7 @@ impl Display for ProgramType {
327329
}
328330

329331
impl ProgramType {
330-
fn attach(&self, bpf: &mut Bpf, btf: &Btf) -> Result<(), ProgramError> {
332+
fn attach(&self, bpf: &mut Ebpf, btf: &Btf) -> Result<(), ProgramError> {
331333
let load_err = |program_error| ProgramError::ProgramLoadError {
332334
program: self.to_string(),
333335
program_error: Box::new(program_error),
@@ -364,7 +366,11 @@ impl ProgramType {
364366
.map_err(|source| MountinfoError::ReadFile { source, path })?;
365367
program.load().map_err(load_err)?;
366368
program
367-
.attach(cgroup, CgroupSkbAttachType::Egress)
369+
.attach(
370+
cgroup,
371+
CgroupSkbAttachType::Egress,
372+
CgroupAttachMode::Single,
373+
)
368374
.map_err(attach_err)?;
369375
}
370376
ProgramType::CgroupSkbIngress(cgroup_skb) => {
@@ -374,15 +380,19 @@ impl ProgramType {
374380
.map_err(|source| MountinfoError::ReadFile { source, path })?;
375381
program.load().map_err(load_err)?;
376382
program
377-
.attach(cgroup, CgroupSkbAttachType::Ingress)
383+
.attach(
384+
cgroup,
385+
CgroupSkbAttachType::Ingress,
386+
CgroupAttachMode::Single,
387+
)
378388
.map_err(attach_err)?;
379389
}
380390
}
381391
Ok(())
382392
}
383393
}
384394

385-
fn extract_program<'a, T>(bpf: &'a mut Bpf, program: &str) -> Result<&'a mut T, ProgramError>
395+
fn extract_program<'a, T>(bpf: &'a mut Ebpf, program: &str) -> Result<&'a mut T, ProgramError>
386396
where
387397
T: 'a,
388398
&'a mut T: TryFrom<&'a mut aya::programs::Program>,
@@ -399,7 +409,7 @@ pub struct Program {
399409
tx_exit: watch::Sender<()>,
400410
ctx: BpfContext,
401411
name: String,
402-
bpf: Bpf,
412+
bpf: Ebpf,
403413
used_maps: HashSet<String>,
404414
}
405415

@@ -412,7 +422,7 @@ impl Drop for Program {
412422
}
413423

414424
impl Program {
415-
pub fn bpf(&mut self) -> &mut Bpf {
425+
pub fn bpf(&mut self) -> &mut Ebpf {
416426
&mut self.bpf
417427
}
418428
/// Poll a BPF_MAP_TYPE_HASH with a certain interval

crates/bpf-feature-autodetect/src/bpf_loop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use aya::{include_bytes_aligned, programs::TracePoint, Bpf, BpfError};
1+
use aya::{include_bytes_aligned, programs::TracePoint, Ebpf, EbpfError};
22
use log::warn;
33

4-
fn load_probe() -> Result<(), BpfError> {
5-
let mut bpf = Bpf::load(include_bytes_aligned!(concat!(
4+
fn load_probe() -> Result<(), EbpfError> {
5+
let mut bpf = Ebpf::load(include_bytes_aligned!(concat!(
66
env!("OUT_DIR"),
77
"/test_bpf_loop.none.bpf.o"
88
)))?;

crates/bpf-feature-autodetect/src/lsm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::{anyhow, Context, Result};
2-
use aya::{include_bytes_aligned, programs::Lsm, BpfLoader, Btf};
2+
use aya::{include_bytes_aligned, programs::Lsm, Btf, EbpfLoader};
33

44
/// Check if the system supports eBPF LSM programs.
55
/// The kernel must be build with CONFIG_BPF_LSM=y, which is available
@@ -40,7 +40,7 @@ fn try_load() -> Result<()> {
4040
.ok_or_else(|| anyhow!("eBPF LSM programs disabled"))?;
4141

4242
// Check if we can load a program
43-
let mut bpf = BpfLoader::new()
43+
let mut bpf = EbpfLoader::new()
4444
.load(TEST_LSM_PROBE)
4545
.context("LSM enabled, but initial loading failed")?;
4646
let program: &mut Lsm = bpf

crates/bpf-filtering/src/initializer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{os::unix::prelude::OsStringExt, time::Duration};
22

33
use anyhow::{Context, Result};
4-
use bpf_common::{aya::Bpf, Pid};
4+
use bpf_common::{aya::Ebpf, Pid};
55
use pulsar_core::{
66
pdk::process_tracker::{ProcessTrackerHandle, TrackerUpdate},
77
Timestamp,
@@ -32,7 +32,7 @@ const INIT_TIMEOUT: Duration = Duration::from_millis(100);
3232
/// this makes sure the eBPF code didn't fill map_interest with wrong data
3333
/// because of unitialized entries.
3434
pub async fn setup_events_filter(
35-
bpf: &mut Bpf,
35+
bpf: &mut Ebpf,
3636
mut config: Config,
3737
process_tracker: &ProcessTrackerHandle,
3838
rx_processes: &mut mpsc::UnboundedReceiver<TrackerUpdate>,
@@ -137,7 +137,7 @@ struct Initializer {
137137
}
138138

139139
impl Initializer {
140-
fn new(bpf: &mut Bpf, config: Config) -> Result<Self> {
140+
fn new(bpf: &mut Ebpf, config: Config) -> Result<Self> {
141141
let mut interest_map = InterestMap::load(bpf, &config.interest_map_name)?;
142142
// clear interest map
143143
interest_map.clear()?;

crates/bpf-filtering/src/maps.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub const DEFAULT_CGROUP_RULES: &str = "m_cgroup_rules";
1919

2020
impl InterestMap {
2121
/// Try to load the map from eBPF
22-
pub fn load(bpf: &mut aya::Bpf, name: &str) -> Result<Self> {
22+
pub fn load(bpf: &mut aya::Ebpf, name: &str) -> Result<Self> {
2323
Map::load(bpf, name).map(Self)
2424
}
2525

@@ -62,7 +62,7 @@ pub struct RuleMap(Map<Image, u8>);
6262

6363
impl RuleMap {
6464
/// Try to load the rule map
65-
pub fn load(bpf: &mut aya::Bpf, name: &str) -> Result<Self> {
65+
pub fn load(bpf: &mut aya::Ebpf, name: &str) -> Result<Self> {
6666
Map::load(bpf, name).map(Self)
6767
}
6868

@@ -96,7 +96,7 @@ pub(crate) struct Map<K, V> {
9696

9797
impl<K: aya::Pod, V: aya::Pod> Map<K, V> {
9898
/// Try to load the eBPF hash map with the given name
99-
pub(crate) fn load(bpf: &mut aya::Bpf, name: &str) -> Result<Self> {
99+
pub(crate) fn load(bpf: &mut aya::Ebpf, name: &str) -> Result<Self> {
100100
let map = aya::maps::HashMap::try_from(
101101
bpf.take_map(name)
102102
.with_context(|| format!("Error finding eBPF map {name}"))?,

crates/bpf-filtering/src/test_suite.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::config::Rule;
22
use crate::maps::{Cgroup, InterestMap, Map, PolicyDecision, RuleMap};
33
use bpf_common::aya::programs::RawTracePoint;
4-
use bpf_common::aya::{self, Bpf, BpfLoader};
4+
use bpf_common::aya::{self, Ebpf, EbpfLoader};
55
use bpf_common::program::BpfContext;
66
use bpf_common::test_runner::{TestCase, TestReport, TestSuite};
77
use bpf_common::test_utils::cgroup::fork_in_temp_cgroup;
@@ -278,7 +278,7 @@ fn cgroups_tracked() -> TestCase {
278278
}
279279

280280
// attach a single tracepoint for test purposes
281-
fn attach_raw_tracepoint(bpf: &mut Bpf, tp: &str) {
281+
fn attach_raw_tracepoint(bpf: &mut Ebpf, tp: &str) {
282282
let tracepoint: &mut RawTracePoint = bpf
283283
.program_mut(tp)
284284
.ok_or_else(|| ProgramError::ProgramNotFound(tp.to_string()))
@@ -357,7 +357,7 @@ fn exit_cleans_up_resources() -> TestCase {
357357
})
358358
}
359359

360-
fn load_ebpf() -> Bpf {
360+
fn load_ebpf() -> Ebpf {
361361
let ctx = BpfContext::new(
362362
bpf_common::program::Pinning::Disabled,
363363
bpf_common::program::PERF_PAGES_DEFAULT,
@@ -366,7 +366,7 @@ fn load_ebpf() -> Bpf {
366366
.unwrap();
367367
const PIN_PATH: &str = "/sys/fs/bpf/filtering-test";
368368
let _ = std::fs::create_dir(PIN_PATH);
369-
let bpf = BpfLoader::new()
369+
let bpf = EbpfLoader::new()
370370
.map_pin_path(PIN_PATH)
371371
.load(ebpf_program!(&ctx, "filtering_example").as_slice())
372372
.unwrap();

0 commit comments

Comments
 (0)