]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests/bpf: Fix test dynptr/test_dynptr_copy_xdp failure
authorYonghong Song <yonghong.song@linux.dev>
Fri, 25 Jul 2025 04:34:35 +0000 (21:34 -0700)
committerMartin KaFai Lau <martin.lau@kernel.org>
Sat, 26 Jul 2025 01:20:43 +0000 (18:20 -0700)
For arm64 64K page size, the bpf_dynptr_copy() in test dynptr/test_dynptr_copy_xdp
will succeed, but the test will failure with 4K page size. This patch made a change
so the test will fail expectedly for both 4K and 64K page sizes.

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Acked-by: Mykyta Yatsenko <yatsenko@meta.com>
Link: https://patch.msgid.link/20250725043435.208974-1-yonghong.song@linux.dev
tools/testing/selftests/bpf/progs/dynptr_success.c

index 7d7081d05d476a929abfbaf4147dda1acf4d2c75..3094a1e4ee91e5730639196c50929bcdb52a70fc 100644 (file)
@@ -611,11 +611,12 @@ int test_dynptr_copy_xdp(struct xdp_md *xdp)
        struct bpf_dynptr ptr_buf, ptr_xdp;
        char data[] = "qwertyuiopasdfghjkl";
        char buf[32] = {'\0'};
-       __u32 len = sizeof(data);
+       __u32 len = sizeof(data), xdp_data_size;
        int i, chunks = 200;
 
        /* ptr_xdp is backed by non-contiguous memory */
        bpf_dynptr_from_xdp(xdp, 0, &ptr_xdp);
+       xdp_data_size = bpf_dynptr_size(&ptr_xdp);
        bpf_ringbuf_reserve_dynptr(&ringbuf, len * chunks, 0, &ptr_buf);
 
        /* Destination dynptr is backed by non-contiguous memory */
@@ -673,7 +674,7 @@ int test_dynptr_copy_xdp(struct xdp_md *xdp)
                        goto out;
        }
 
-       if (bpf_dynptr_copy(&ptr_xdp, 2000, &ptr_xdp, 0, len * chunks) != -E2BIG)
+       if (bpf_dynptr_copy(&ptr_xdp, xdp_data_size - 3000, &ptr_xdp, 0, len * chunks) != -E2BIG)
                err = 1;
 
 out: