aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/test_xdp_with_cpumap_helpers.c
diff options
context:
space:
mode:
authorAlexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>2024-10-09 12:12:09 +0200
committerMartin KaFai Lau <martin.lau@kernel.org>2024-10-10 18:01:52 -0700
commitd124d984c8a2d677e1cea6740a01ccdd0371a38d (patch)
treeb58ef040904b5fb94737ffe3135e6d14ea170106 /tools/testing/selftests/bpf/progs/test_xdp_with_cpumap_helpers.c
parentselftests/bpf: make xdp_cpumap_attach keep redirect prog attached (diff)
downloadlinux-d124d984c8a2d677e1cea6740a01ccdd0371a38d.tar.gz
linux-d124d984c8a2d677e1cea6740a01ccdd0371a38d.zip
selftests/bpf: check program redirect in xdp_cpumap_attach
xdp_cpumap_attach, in its current form, only checks that an xdp cpumap program can be executed, but not that it performs correctly the cpu redirect as configured by userspace (bpf_prog_test_run_opts will return success even if the redirect program returns an error) Add a check to ensure that the program performs the configured redirect as well. The check is based on a global variable incremented by a chained program executed only if the redirect program properly executes. Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com> Link: https://lore.kernel.org/r/20241009-convert_xdp_tests-v3-3-51cea913710c@bootlin.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_xdp_with_cpumap_helpers.c')
-rw-r--r--tools/testing/selftests/bpf/progs/test_xdp_with_cpumap_helpers.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_xdp_with_cpumap_helpers.c b/tools/testing/selftests/bpf/progs/test_xdp_with_cpumap_helpers.c
index d848fe96924e..3619239b01b7 100644
--- a/tools/testing/selftests/bpf/progs/test_xdp_with_cpumap_helpers.c
+++ b/tools/testing/selftests/bpf/progs/test_xdp_with_cpumap_helpers.c
@@ -12,6 +12,8 @@ struct {
__uint(max_entries, 4);
} cpu_map SEC(".maps");
+__u32 redirect_count = 0;
+
SEC("xdp")
int xdp_redir_prog(struct xdp_md *ctx)
{
@@ -27,6 +29,9 @@ int xdp_dummy_prog(struct xdp_md *ctx)
SEC("xdp/cpumap")
int xdp_dummy_cm(struct xdp_md *ctx)
{
+ if (bpf_get_smp_processor_id() == 0)
+ redirect_count++;
+
if (ctx->ingress_ifindex == IFINDEX_LO)
return XDP_DROP;