Browse Source

aya: kprobe: remove pid argument

Kprobes can only be attached globally. Per-pid logic needs to be
implemented on the BPF side with bpf_get_current_pid_tgid.
Alessandro Decina 3 years ago
parent
commit
08c71dfeb1
2 changed files with 5 additions and 12 deletions
  1. 4 11
      aya/src/programs/kprobe.rs
  2. 1 1
      aya/src/programs/mod.rs

+ 4 - 11
aya/src/programs/kprobe.rs

@@ -1,5 +1,4 @@
 //! Kernel space probes.
-use libc::pid_t;
 use std::io;
 use thiserror::Error;
 
@@ -33,7 +32,7 @@ use crate::{
 ///
 /// let program: &mut KProbe = bpf.program_mut("intercept_wakeups")?.try_into()?;
 /// program.load()?;
-/// program.attach("try_to_wake_up", 0, None)?;
+/// program.attach("try_to_wake_up", 0)?;
 /// # Ok::<(), aya::BpfError>(())
 /// ```
 #[derive(Debug)]
@@ -66,19 +65,13 @@ impl KProbe {
     ///
     /// Attaches the probe to the given function name inside the kernel. If
     /// `offset` is non-zero, it is added to the address of the target
-    /// function. If `pid` is not `None`, the program executes only when the
-    /// target function is triggered by the given `pid`.
+    /// function.
     ///
     /// If the program is a `kprobe`, it is attached to the *start* address of the target function.
     /// Conversely if the program is a `kretprobe`, it is attached to the return address of the
     /// target function.
-    pub fn attach(
-        &mut self,
-        fn_name: &str,
-        offset: u64,
-        pid: Option<pid_t>,
-    ) -> Result<LinkRef, ProgramError> {
-        attach(&mut self.data, self.kind, fn_name, offset, pid)
+    pub fn attach(&mut self, fn_name: &str, offset: u64) -> Result<LinkRef, ProgramError> {
+        attach(&mut self.data, self.kind, fn_name, offset, None)
     }
 }
 

+ 1 - 1
aya/src/programs/mod.rs

@@ -23,7 +23,7 @@
 //! program.load()?;
 //! // intercept_wakeups will be called every time try_to_wake_up() is called
 //! // inside the kernel
-//! program.attach("try_to_wake_up", 0, None)?;
+//! program.attach("try_to_wake_up", 0)?;
 //! # Ok::<(), aya::BpfError>(())
 //! ```
 //!