WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / test_xdp_with_cpumap_helpers.c
blob59ee4f182ff800d7517fe4daeb681fbd59660c1e
1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/bpf.h>
4 #include <bpf/bpf_helpers.h>
6 #define IFINDEX_LO 1
8 struct {
9 __uint(type, BPF_MAP_TYPE_CPUMAP);
10 __uint(key_size, sizeof(__u32));
11 __uint(value_size, sizeof(struct bpf_cpumap_val));
12 __uint(max_entries, 4);
13 } cpu_map SEC(".maps");
15 SEC("xdp_redir")
16 int xdp_redir_prog(struct xdp_md *ctx)
18 return bpf_redirect_map(&cpu_map, 1, 0);
21 SEC("xdp_dummy")
22 int xdp_dummy_prog(struct xdp_md *ctx)
24 return XDP_PASS;
27 SEC("xdp_cpumap/dummy_cm")
28 int xdp_dummy_cm(struct xdp_md *ctx)
30 if (ctx->ingress_ifindex == IFINDEX_LO)
31 return XDP_DROP;
33 return XDP_PASS;
36 char _license[] SEC("license") = "GPL";