WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / test_xdp_devmap_helpers.c
blobb360ba2bd441148e10da51c5b96b8696b6f91442
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>
8 SEC("xdp_dm_log")
9 int xdpdm_devlog(struct xdp_md *ctx)
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;
16 bpf_trace_printk(fmt, sizeof(fmt),
17 ctx->ingress_ifindex, ctx->egress_ifindex, len);
19 return XDP_PASS;
22 char _license[] SEC("license") = "GPL";