1
2#include <linux/bpf.h>
3#include <bpf/bpf_helpers.h>
4
5SEC("xdp")
6int _xdp_adjust_tail_grow(struct xdp_md *xdp)
7{
8 void *data_end = (void *)(long)xdp->data_end;
9 void *data = (void *)(long)xdp->data;
10 unsigned int data_len;
11 int offset = 0;
12
13
14 data_len = data_end - data;
15
16 if (data_len == 54) {
17 offset = 4096;
18 } else if (data_len == 74) {
19 offset = 40;
20 } else if (data_len == 64) {
21 offset = 128;
22 } else if (data_len == 128) {
23 offset = 4096 - 256 - 320 - data_len;
24 } else {
25 return XDP_ABORTED;
26 }
27
28 if (bpf_xdp_adjust_tail(xdp, offset))
29 return XDP_DROP;
30 return XDP_TX;
31}
32
33char _license[] SEC("license") = "GPL";
34