Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 48 lines 883 B view raw
1// SPDX-License-Identifier: GPL-2.0 2 3#include "vmlinux.h" 4#include <bpf/bpf_helpers.h> 5 6int xdpf_sz; 7int sinfo_sz; 8int data_len; 9int pull_len; 10 11#define XDP_PACKET_HEADROOM 256 12 13SEC("xdp.frags") 14int xdp_find_sizes(struct xdp_md *ctx) 15{ 16 xdpf_sz = sizeof(struct xdp_frame); 17 sinfo_sz = __PAGE_SIZE - XDP_PACKET_HEADROOM - 18 (ctx->data_end - ctx->data); 19 20 return XDP_PASS; 21} 22 23SEC("xdp.frags") 24int xdp_pull_data_prog(struct xdp_md *ctx) 25{ 26 __u8 *data_end = (void *)(long)ctx->data_end; 27 __u8 *data = (void *)(long)ctx->data; 28 __u8 *val_p; 29 int err; 30 31 if (data_len != data_end - data) 32 return XDP_DROP; 33 34 err = bpf_xdp_pull_data(ctx, pull_len); 35 if (err) 36 return XDP_DROP; 37 38 val_p = (void *)(long)ctx->data + 1024; 39 if (val_p + 1 > (void *)(long)ctx->data_end) 40 return XDP_DROP; 41 42 if (*val_p != 0xbb) 43 return XDP_DROP; 44 45 return XDP_PASS; 46} 47 48char _license[] SEC("license") = "GPL";