Skip to content

Commit e056a30

Browse files
committed
Minor cleanup
1 parent c491386 commit e056a30

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

fact/src/bpf.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ use libc::c_char;
1010
use log::{debug, error, info};
1111
use tokio::{
1212
io::unix::AsyncFd,
13-
sync::{
14-
broadcast,
15-
watch::{self, Receiver},
16-
},
13+
sync::{broadcast, watch},
1714
task::JoinHandle,
1815
};
1916

@@ -147,20 +144,13 @@ impl Bpf {
147144
self.load_lsm_prog("trace_path_unlink", "path_unlink", &btf)
148145
}
149146

150-
fn attach_lsm_prog(&mut self, name: &str) -> anyhow::Result<()> {
151-
let Some(prog) = self.obj.program_mut(name) else {
152-
bail!("{name} program not found");
153-
};
154-
let prog: &mut Lsm = prog.try_into()?;
155-
let id = prog.attach()?;
156-
self.links.push(prog.take_link(id)?);
157-
158-
Ok(())
159-
}
160-
161147
fn attach_progs(&mut self) -> anyhow::Result<()> {
162-
self.attach_lsm_prog("trace_file_open")?;
163-
self.attach_lsm_prog("trace_path_unlink")
148+
for (_, prog) in self.obj.programs_mut() {
149+
let prog: &mut Lsm = prog.try_into()?;
150+
let id = prog.attach()?;
151+
self.links.push(prog.take_link(id)?);
152+
}
153+
Ok(())
164154
}
165155

166156
fn detach_progs(&mut self) {
@@ -170,7 +160,7 @@ impl Bpf {
170160
// Gather events from the ring buffer and print them out.
171161
pub fn start(
172162
mut self,
173-
mut running: Receiver<bool>,
163+
mut running: watch::Receiver<bool>,
174164
event_counter: EventCounter,
175165
) -> JoinHandle<anyhow::Result<()>> {
176166
info!("Starting BPF worker...");

0 commit comments

Comments
 (0)