25 lines · c
1// SPDX-License-Identifier: GPL-2.02#include <linux/bpf.h>3#include <bpf/bpf_helpers.h>4 5struct {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 12SEC("xdp/cpumap")13int xdp_drop_prog(struct xdp_md *ctx)14{15 return XDP_DROP;16}17 18SEC("freplace")19int xdp_cpumap_prog(struct xdp_md *ctx)20{21 return bpf_redirect_map(&cpu_map, 0, XDP_PASS);22}23 24char _license[] SEC("license") = "GPL";25