]> Git Repo - linux.git/blob - tools/testing/selftests/bpf/progs/test_xdp_devmap_helpers.c
Linux 6.14-rc3
[linux.git] / tools / testing / selftests / bpf / progs / test_xdp_devmap_helpers.c
1 // SPDX-License-Identifier: GPL-2.0
2 /* fails to load without expected_attach_type = BPF_XDP_DEVMAP
3  * because of access to egress_ifindex
4  */
5 #include <linux/bpf.h>
6 #include <bpf/bpf_helpers.h>
7
8 SEC("xdp")
9 int xdpdm_devlog(struct xdp_md *ctx)
10 {
11         char fmt[] = "devmap redirect: dev %u -> dev %u len %u\n";
12         void *data_end = (void *)(long)ctx->data_end;
13         void *data = (void *)(long)ctx->data;
14         unsigned int len = data_end - data;
15
16         bpf_trace_printk(fmt, sizeof(fmt),
17                          ctx->ingress_ifindex, ctx->egress_ifindex, len);
18
19         return XDP_PASS;
20 }
21
22 char _license[] SEC("license") = "GPL";
This page took 0.031579 seconds and 4 git commands to generate.