1// SPDX-License-Identifier: GPL-2.0
2#include <linux/bpf.h>
3#include <bpf/bpf_helpers.h>
4
5SEC("xdp")
6int xdp_context(struct xdp_md *xdp)
7{
8 void *data = (void *)(long)xdp->data;
9 __u32 *metadata = (void *)(long)xdp->data_meta;
10 __u32 ret;
11
12 if (metadata + 1 > data)
13 return XDP_ABORTED;
14 ret = *metadata;
15 if (bpf_xdp_adjust_meta(xdp, 4))
16 return XDP_ABORTED;
17 return ret;
18}
19
20char _license[] SEC("license") = "GPL";
21

source code of linux/tools/testing/selftests/bpf/progs/test_xdp_context_test_run.c