-
Notifications
You must be signed in to change notification settings - Fork 4
Harpoon port #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Harpoon port #6
Conversation
Signed-off-by: MinhPhan8803 <nhatminhvinh8803@gmail.com>
Signed-off-by: MinhPhan8803 <nhatminhvinh8803@gmail.com>
Signed-off-by: MinhPhan8803 <nhatminhvinh8803@gmail.com>
Signed-off-by: MinhPhan8803 <nhatminhvinh8803@gmail.com>
Signed-off-by: MinhPhan8803 <nhatminhvinh8803@gmail.com>
Signed-off-by: MinhPhan8803 <nhatminhvinh8803@gmail.com>
this looks awesome! |
Signed-off-by: MinhPhan8803 <nhatminhvinh8803@gmail.com>
Signed-off-by: MinhPhan8803 <nhatminhvinh8803@gmail.com>
Signed-off-by: MinhPhan8803 <nhatminhvinh8803@gmail.com>
Signed-off-by: MinhPhan8803 <nhatminhvinh8803@gmail.com>
e648081
to
182bf51
Compare
// Design decision: the equivalent BPF helper writes the program name to | ||
// a user-provided buffer, here we can take advantage of Rust's ownership by | ||
// just providing a reference to the CString instead | ||
pub fn get_comm(&self) -> Result<&CStr, ffi::FromBytesUntilNulError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this changes the function signature, the samples that use this function will need to be updated as well
rex-macros/src/kprobe.rs
Outdated
let fn_name = self.item.sig.ident.clone(); | ||
let item = &self.item; | ||
let function_name = format!("{}", fn_name); | ||
let prog_ident = | ||
format_ident!("PROG_{}", fn_name.to_string().to_uppercase()); | ||
|
||
let attached_function = if self.function.is_some() { | ||
format!("rex/kprobe/{}", self.function.as_ref().unwrap()) | ||
format!("rex/{}/{}", flavor, self.function.as_ref().unwrap()) | ||
} else { | ||
"rex/kprobe".to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not respect the kprobe flavor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we could put the flavor inside the KProbe struct
@@ -0,0 +1,31 @@ | |||
[package] | |||
name = "hello" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remember to change the sample name/metadata in all places.
rex-macros/src/kprobe.rs
Outdated
let fn_name = self.item.sig.ident.clone(); | ||
let item = &self.item; | ||
let function_name = format!("{}", fn_name); | ||
let prog_ident = | ||
format_ident!("PROG_{}", fn_name.to_string().to_uppercase()); | ||
|
||
let attached_function = if self.function.is_some() { | ||
format!("rex/kprobe/{}", self.function.as_ref().unwrap()) | ||
format!("rex/{}/{}", flavor, self.function.as_ref().unwrap()) | ||
} else { | ||
"rex/kprobe".to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we could put the flavor inside the KProbe struct
process.kill() | ||
std_out, std_err = process.communicate(timeout=7) | ||
re_match = re.findall( | ||
r"bpf_trace_printk: Rust triggered from PID \d+ on CPU .+", std_out, re.M |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will we have sanity test case for harpoon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I haven't started working on the backend for the userspace app yet so I haven't really thought about what tests will look like.
…method to grab pointer from tp_ctx, fix KproveFlavor use, fix TaskStruct::get_comm use Signed-off-by: MinhPhan8803 <nhatminhvinh8803@gmail.com>
81d75ef
to
30f8795
Compare
… app Signed-off-by: MinhPhan8803 <nhatminhvinh8803@gmail.com>
b451d02
to
6d23109
Compare
Currently WIP, not available to merge yet.
Add definition for
PerfEventArray
and its helper symbols. For thebpf_perf_event_output
symbol specifically, currently only thebpf_perf_event_output_tp
variant is supported.Add the
StreamableProgram
trait that program types that can stream events throughPerfEventArray
should implement. This allows unifying the various streaming symbols into a singleStreamableProgram::output_event()
method in a manner similar to the overloaded helperbpf_perf_event_output()
.Add a
rex_uprobe
macro and aKprobeFlavor
enum inrex-macros/src/kprobe.rs
to allow switching between kprobe variants inKProbe::expand()
.Misc changes:
TaskStruct::get_comm()
now returns a direct reference to the program name as a&CStr
.BPF_F_CURRENT_CPU
constant asCURRENT_CPU
.