-
Notifications
You must be signed in to change notification settings - Fork 169
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
Update(driver): Introduce the BPF commands name #1545
Changes from all commits
da49823
c16ba20
38b40a4
d98fb8a
aa9abc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.16.0 | ||
2.17.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6733,7 +6733,7 @@ int f_sys_bpf_e(struct event_filler_arguments *args) | |
unsigned long val = 0; | ||
syscall_get_arguments_deprecated(args, 0, 1, &val); | ||
|
||
/* Parameter 1: cmd (type: PT_INT64) */ | ||
/* Parameter 1: cmd (type: PT_ENUMFLAGS32) */ | ||
cmd = (int32_t)val; | ||
res = val_to_ring(args, (int64_t)cmd, 0, false, 0); | ||
CHECK_RES(res); | ||
|
@@ -6754,7 +6754,7 @@ int f_sys_bpf_x(struct event_filler_arguments *args) | |
|
||
/* Parameter 2: cmd (type: PT_INT64) */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could update the comments throughout. |
||
syscall_get_arguments_deprecated(args, 0, 1, &val); | ||
cmd = (int32_t)val; | ||
cmd = (int32_t)bpf_cmd_to_scap(val); | ||
res = val_to_ring(args, cmd, 0, false, 0); | ||
CHECK_RES(res); | ||
return add_sentinel(args); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2222,4 +2222,15 @@ static __always_inline uint32_t mknod_mode_to_scap(uint32_t modes) | |
return res; | ||
} | ||
|
||
#endif /* PPM_FLAG_HELPERS_H_ */ | ||
static __always_inline uint32_t bpf_cmd_to_scap (unsigned long cmd){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This helper was already written as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can also do what eg: we did for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this makes sense!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I liked @FedeDP suggestion, but now I wonder why we even touch the driver code at all, and why we don't just do userspace conversions? Adding this statement to the userspace parsing would be nice! |
||
/* | ||
* bpf opcodes are defined via enum in uapi/linux/bpf.h. | ||
* It is userspace API (thus stable) and arch-independent. | ||
* Therefore we map them 1:1; if any unmapped flag arrives, | ||
* we will just print its value to userspace without mapping it to a string flag. | ||
* We then need to append new flags to both flags_table and ppm_events_public PPM_ flags. | ||
*/ | ||
|
||
return cmd; | ||
} | ||
#endif /* PPM_FLAG_HELPERS_H_ */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,4 +66,17 @@ TEST_F(sinsp_with_test_input, EVT_FILTER_rawarg_str) | |
sinsp_evt* evt = add_event_advance_ts(increasing_ts(), 1, PPME_SYSCALL_OPEN_E, 3, path.c_str(), | ||
(uint32_t)0, (uint32_t)0); | ||
ASSERT_EQ(get_field_as_string(evt, "evt.rawarg.name"), path); | ||
} | ||
|
||
TEST_F(sinsp_with_test_input, EVT_FILTER_cmd_str) | ||
{ | ||
add_default_init_thread(); | ||
|
||
open_inspector(); | ||
|
||
int fd = 1; | ||
|
||
sinsp_evt* evt = add_event_advance_ts(increasing_ts(), 1, PPME_SYSCALL_BPF_2_X, 2, fd, (uint64_t)PPM_BPF_PROG_LOAD); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is really weird :/ I don't like passing a wrong-sized parameter here since it is working fine until we add a parameter after this one, then everything breaks apart. Can you share the build error? |
||
|
||
ASSERT_EQ(get_field_as_string(evt, "evt.arg.cmd"), "BPF_PROG_LOAD"); | ||
} |
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.
cmd
isint
why are we changing this? https://man7.org/linux/man-pages/man2/bpf.2.html