This adds a simple test for inserting an XDP program into a cpumap that is "owned" by an XDP program that was loaded as PROG_TYPE_EXT (as libxdp does). Prior to the kernel fix this would fail because the map type ownership would be set to PROG_TYPE_EXT instead of being resolved to PROG_TYPE_XDP. v5: - Fix a few nits from Andrii, add his ACK v4: - Use skeletons for selftest v3: - Update comment to better explain the cause - Add Yonghong's ACK Acked-by: Yonghong Song <yhs@fb.com> Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Link: https://lore.kernel.org/r/20221214230254.790066-2-toke@redhat.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
24 lines
473 B
C
24 lines
473 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/bpf.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
|
|
struct {
|
|
__uint(type, BPF_MAP_TYPE_CPUMAP);
|
|
__type(key, __u32);
|
|
__type(value, struct bpf_cpumap_val);
|
|
__uint(max_entries, 1);
|
|
} cpu_map SEC(".maps");
|
|
|
|
SEC("xdp/cpumap")
|
|
int xdp_drop_prog(struct xdp_md *ctx)
|
|
{
|
|
return XDP_DROP;
|
|
}
|
|
|
|
SEC("freplace")
|
|
int xdp_cpumap_prog(struct xdp_md *ctx)
|
|
{
|
|
return bpf_redirect_map(&cpu_map, 0, XDP_PASS);
|
|
}
|
|
|
|
char _license[] SEC("license") = "GPL";
|