diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index d25b8dcd781685..d6e4c3a3b13fbe 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -221,6 +221,7 @@ BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \ readelf -S ./llvm_btf_verify.o | grep BTF; \ /bin/rm -f ./llvm_btf_verify.o) +EXTRA_CFLAGS += -fno-stack-protector ifneq ($(BTF_LLVM_PROBE),) EXTRA_CFLAGS += -g else diff --git a/samples/bpf/xdplua_kern.c b/samples/bpf/xdplua_kern.c index 3567b3858bed6f..06135bcf365127 100644 --- a/samples/bpf/xdplua_kern.c +++ b/samples/bpf/xdplua_kern.c @@ -1,13 +1,31 @@ #define KBUILD_MODNAME "foo" #include #include "bpf_helpers.h" +#include SEC("xdp1") int xdp_prog1(struct xdp_md *ctx) { - char funcname[] = "callback"; + void *data_end = (void *)(long)ctx->data_end; + void *data = (void *)(long)ctx->data; + struct ethhdr *eth = data; + //int rc = XDP_PASS; + u16 h_proto; + u64 nh_off; + int i = 0; + int bla = 0; + char a[] = "oi %d\n"; - return bpf_lua_run(ctx, funcname); + nh_off = sizeof(*eth); + if (data + nh_off > data_end) + return XDP_PASS; + + h_proto = eth->h_proto; + for (int j = 0; j < h_proto; j++) { + bla++; + } + + return bla; } char _license[] SEC("license") = "GPL";