]> Git Repo - linux.git/blob - tools/testing/selftests/bpf/progs/test_xdp_context_test_run.c
Linux 6.14-rc3
[linux.git] / tools / testing / selftests / bpf / progs / test_xdp_context_test_run.c
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/bpf.h>
3 #include <bpf/bpf_helpers.h>
4
5 SEC("xdp")
6 int 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
20 char _license[] SEC("license") = "GPL";
This page took 0.025414 seconds and 4 git commands to generate.