hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/samples/bpf/tracex2_kern.c
....@@ -8,14 +8,16 @@
88 #include <linux/netdevice.h>
99 #include <linux/version.h>
1010 #include <uapi/linux/bpf.h>
11
-#include "bpf_helpers.h"
11
+#include <bpf/bpf_helpers.h>
12
+#include <bpf/bpf_tracing.h>
13
+#include "trace_common.h"
1214
13
-struct bpf_map_def SEC("maps") my_map = {
14
- .type = BPF_MAP_TYPE_HASH,
15
- .key_size = sizeof(long),
16
- .value_size = sizeof(long),
17
- .max_entries = 1024,
18
-};
15
+struct {
16
+ __uint(type, BPF_MAP_TYPE_HASH);
17
+ __type(key, long);
18
+ __type(value, long);
19
+ __uint(max_entries, 1024);
20
+} my_map SEC(".maps");
1921
2022 /* kprobe is NOT a stable ABI. If kernel internals change this bpf+kprobe
2123 * example will no longer be meaningful
....@@ -69,14 +71,14 @@
6971 u64 index;
7072 };
7173
72
-struct bpf_map_def SEC("maps") my_hist_map = {
73
- .type = BPF_MAP_TYPE_PERCPU_HASH,
74
- .key_size = sizeof(struct hist_key),
75
- .value_size = sizeof(long),
76
- .max_entries = 1024,
77
-};
74
+struct {
75
+ __uint(type, BPF_MAP_TYPE_PERCPU_HASH);
76
+ __uint(key_size, sizeof(struct hist_key));
77
+ __uint(value_size, sizeof(long));
78
+ __uint(max_entries, 1024);
79
+} my_hist_map SEC(".maps");
7880
79
-SEC("kprobe/sys_write")
81
+SEC("kprobe/" SYSCALL(sys_write))
8082 int bpf_prog3(struct pt_regs *ctx)
8183 {
8284 long write_size = PT_REGS_PARM3(ctx);