brintos

brintos / linux-shallow public Read only

0
0
Text · 732 B · 20ec672 Raw
43 lines · c
1// SPDX-License-Identifier: GPL-2.02 3#include <linux/bpf.h>4#include <bpf/bpf_helpers.h>5 6#define IFINDEX_LO	17 8struct {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");14 15SEC("xdp")16int xdp_redir_prog(struct xdp_md *ctx)17{18	return bpf_redirect_map(&cpu_map, 1, 0);19}20 21SEC("xdp")22int xdp_dummy_prog(struct xdp_md *ctx)23{24	return XDP_PASS;25}26 27SEC("xdp/cpumap")28int xdp_dummy_cm(struct xdp_md *ctx)29{30	if (ctx->ingress_ifindex == IFINDEX_LO)31		return XDP_DROP;32 33	return XDP_PASS;34}35 36SEC("xdp.frags/cpumap")37int xdp_dummy_cm_frags(struct xdp_md *ctx)38{39	return XDP_PASS;40}41 42char _license[] SEC("license") = "GPL";43