This commit is contained in:
yunwei37
2023-05-19 14:32:55 +00:00
parent 450388d509
commit 7ba4f1607b
2 changed files with 27 additions and 0 deletions

10
21-xdp/.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
.vscode
package.json
*.wasm
ewasm-skel.h
ecli
ewasm
*.o
*.skel.json
*.skel.yaml
package.yaml

17
21-xdp/xdp.bpf.c Normal file
View File

@@ -0,0 +1,17 @@
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
/// @ifindex 1
/// @flags 0
/// @xdpopts {"old_prog_fd":0}
SEC("xdp")
int xdp_pass(struct xdp_md* ctx) {
void* data = (void*)(long)ctx->data;
void* data_end = (void*)(long)ctx->data_end;
int pkt_sz = data_end - data;
bpf_printk("packet size is %d", pkt_sz);
return XDP_PASS;
}
char __license[] SEC("license") = "GPL";