Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/bpf.h>
0003 #include <bpf/bpf_helpers.h>
0004 
0005 SEC("xdp")
0006 int xdp_context(struct xdp_md *xdp)
0007 {
0008     void *data = (void *)(long)xdp->data;
0009     __u32 *metadata = (void *)(long)xdp->data_meta;
0010     __u32 ret;
0011 
0012     if (metadata + 1 > data)
0013         return XDP_ABORTED;
0014     ret = *metadata;
0015     if (bpf_xdp_adjust_meta(xdp, 4))
0016         return XDP_ABORTED;
0017     return ret;
0018 }
0019 
0020 char _license[] SEC("license") = "GPL";