Support simple XDP

This commit is contained in:
2025-09-13 19:58:01 +05:30
parent 9f858bd159
commit cc5f720406
9 changed files with 148 additions and 18 deletions

View File

@ -1,5 +1,5 @@
BPF_CLANG := clang
CFLAGS := -O0 -emit-llvm -target bpf -c
CFLAGS := -O2 -emit-llvm -target bpf -c
SRC := $(wildcard *.bpf.c)
LL := $(SRC:.bpf.c=.bpf.ll)

View File

@ -3,20 +3,10 @@
#define u64 unsigned long long
#define u32 unsigned int
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 1);
__type(key, u32);
__type(value, u64);
} last SEC(".maps");
SEC("tracepoint/syscalls/sys_enter_execve")
int hello(struct pt_regs *ctx) {
SEC("xdp")
int hello(struct xdp_md *ctx) {
bpf_printk("Hello, World!\n");
u64 b;
u64 a = 3 * b;
bpf_printk("%d", a);
return 0;
return XDP_PASS;
}
char LICENSE[] SEC("license") = "GPL";