mirror of
https://github.com/eunomia-bpf/bpf-developer-tutorial.git
synced 2026-02-03 10:14:44 +08:00
17 lines
390 B
C
17 lines
390 B
C
#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"; |