hc
2024-10-09 05e59e5fb0064c97a1c10921ecd549f2d4a58565
kernel/samples/bpf/xdp_sample_pkts_kern.c
....@@ -2,24 +2,15 @@
22 #include <linux/ptrace.h>
33 #include <linux/version.h>
44 #include <uapi/linux/bpf.h>
5
-#include "bpf_helpers.h"
5
+#include <bpf/bpf_helpers.h>
66
77 #define SAMPLE_SIZE 64ul
8
-#define MAX_CPUS 128
98
10
-#define bpf_printk(fmt, ...) \
11
-({ \
12
- char ____fmt[] = fmt; \
13
- bpf_trace_printk(____fmt, sizeof(____fmt), \
14
- ##__VA_ARGS__); \
15
-})
16
-
17
-struct bpf_map_def SEC("maps") my_map = {
18
- .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
19
- .key_size = sizeof(int),
20
- .value_size = sizeof(u32),
21
- .max_entries = MAX_CPUS,
22
-};
9
+struct {
10
+ __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
11
+ __uint(key_size, sizeof(int));
12
+ __uint(value_size, sizeof(u32));
13
+} my_map SEC(".maps");
2314
2415 SEC("xdp_sample")
2516 int xdp_sample_prog(struct xdp_md *ctx)