1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/bpf.h>
3 #include <bpf/bpf_helpers.h>
4 
5 struct {
6 	__uint(type, BPF_MAP_TYPE_CPUMAP);
7 	__type(key, __u32);
8 	__type(value, struct bpf_cpumap_val);
9 	__uint(max_entries, 1);
10 } cpu_map SEC(".maps");
11 
12 SEC("xdp/cpumap")
xdp_drop_prog(struct xdp_md * ctx)13 int xdp_drop_prog(struct xdp_md *ctx)
14 {
15 	return XDP_DROP;
16 }
17 
18 SEC("freplace")
xdp_cpumap_prog(struct xdp_md * ctx)19 int xdp_cpumap_prog(struct xdp_md *ctx)
20 {
21 	return bpf_redirect_map(&cpu_map, 0, XDP_PASS);
22 }
23 
24 char _license[] SEC("license") = "GPL";
25