1 // SPDX-License-Identifier: GPL-2.0 2 #include <linux/bpf.h> 3 #include <bpf/bpf_helpers.h> 4 5 SEC("xdp") _xdp_adjust_tail_grow(struct xdp_md * xdp)6int _xdp_adjust_tail_grow(struct xdp_md *xdp) 7 { 8 int data_len = bpf_xdp_get_buff_len(xdp); 9 int offset = 0; 10 /* SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) */ 11 #if defined(__TARGET_ARCH_s390) 12 int tailroom = 512; 13 #else 14 int tailroom = 320; 15 #endif 16 17 /* Data length determine test case */ 18 19 if (data_len == 54) { /* sizeof(pkt_v4) */ 20 offset = 4096; /* test too large offset */ 21 } else if (data_len == 74) { /* sizeof(pkt_v6) */ 22 offset = 40; 23 } else if (data_len == 64) { 24 offset = 128; 25 } else if (data_len == 128) { 26 /* Max tail grow 3520 */ 27 offset = 4096 - 256 - tailroom - data_len; 28 } else if (data_len == 9000) { 29 offset = 10; 30 } else if (data_len == 9001) { 31 offset = 4096; 32 } else { 33 return XDP_ABORTED; /* No matching test */ 34 } 35 36 if (bpf_xdp_adjust_tail(xdp, offset)) 37 return XDP_DROP; 38 return XDP_TX; 39 } 40 41 char _license[] SEC("license") = "GPL"; 42