WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / test_xdp_adjust_tail_grow.c
blob3d66599eee2ec9e0332e3270722f4581d2c80963
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/bpf.h>
3 #include <bpf/bpf_helpers.h>
5 SEC("xdp_adjust_tail_grow")
6 int _xdp_adjust_tail_grow(struct xdp_md *xdp)
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;
13 /* Data length determine test case */
14 data_len = data_end - data;
16 if (data_len == 54) { /* sizeof(pkt_v4) */
17 offset = 4096; /* test too large offset */
18 } else if (data_len == 74) { /* sizeof(pkt_v6) */
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; /* Max tail grow 3520 */
24 } else {
25 return XDP_ABORTED; /* No matching test */
28 if (bpf_xdp_adjust_tail(xdp, offset))
29 return XDP_DROP;
30 return XDP_TX;
33 char _license[] SEC("license") = "GPL";