diff options
author | Daniel T. Lee <danieltimlee@gmail.com> | 2022-12-24 10:15:26 +0300 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2022-12-30 01:22:34 +0300 |
commit | c5ffb26375ad309c858453f17e777b716723d527 (patch) | |
tree | 6314268028d2aa23ce0cb14dd57de1153cc8cbdd /samples/bpf/test_current_task_under_cgroup.bpf.c | |
parent | 2e5c4dd7f81545a98e9f06317347e760749c020b (diff) | |
download | linux-c5ffb26375ad309c858453f17e777b716723d527.tar.xz |
samples/bpf: Use BPF_KSYSCALL macro in syscall tracing programs
This commit enhances the syscall tracing programs by using the
BPF_SYSCALL macro to reduce the inconvenience of parsing arguments from
pt_regs. By simplifying argument extraction, bpf program will become
clear to understand.
Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20221224071527.2292-6-danieltimlee@gmail.com
Diffstat (limited to 'samples/bpf/test_current_task_under_cgroup.bpf.c')
-rw-r--r-- | samples/bpf/test_current_task_under_cgroup.bpf.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/samples/bpf/test_current_task_under_cgroup.bpf.c b/samples/bpf/test_current_task_under_cgroup.bpf.c index 0b059cee3cba..58b9cf7ed659 100644 --- a/samples/bpf/test_current_task_under_cgroup.bpf.c +++ b/samples/bpf/test_current_task_under_cgroup.bpf.c @@ -8,6 +8,8 @@ #include "vmlinux.h" #include <linux/version.h> #include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> +#include <bpf/bpf_core_read.h> struct { __uint(type, BPF_MAP_TYPE_CGROUP_ARRAY); @@ -25,7 +27,7 @@ struct { /* Writes the last PID that called sync to a map at index 0 */ SEC("ksyscall/sync") -int bpf_prog1(struct pt_regs *ctx) +int BPF_KSYSCALL(bpf_prog1) { u64 pid = bpf_get_current_pid_tgid(); int idx = 0; |