1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2018 Facebook
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 2 of the GNU General Public
6 * License as published by the Free Software Foundation.
9 #include <linux/if_ether.h>
10 #include <bpf/bpf_helpers.h>
13 int _xdp_adjust_tail_shrink(struct xdp_md *xdp)
15 __u8 *data_end = (void *)(long)xdp->data_end;
16 __u8 *data = (void *)(long)xdp->data;
19 switch (bpf_xdp_get_buff_len(xdp)) {
22 offset = 256; /* shrink too much */
25 /* non-linear buff test cases */
26 if (data + 1 > data_end)
47 if (bpf_xdp_adjust_tail(xdp, 0 - offset))
52 char _license[] SEC("license") = "GPL";