Skip to content

Commit

Permalink
DONT PUSH
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorNogueiraRio committed Sep 9, 2019
1 parent 39a3f16 commit c4fdbfd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions samples/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 20 additions & 2 deletions samples/bpf/xdplua_kern.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
#define KBUILD_MODNAME "foo"
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
#include <linux/if_ether.h>

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";

0 comments on commit c4fdbfd

Please sign in to comment.