Skip to content

Commit 90f791a

Browse files
Yonghong SongMartin KaFai Lau
authored andcommitted
selftests/bpf: Fix test dynptr/test_dynptr_copy_xdp failure
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 <[email protected]> Signed-off-by: Martin KaFai Lau <[email protected]> Acked-by: Mykyta Yatsenko <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 4c82768 commit 90f791a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/testing/selftests/bpf/progs/dynptr_success.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,12 @@ int test_dynptr_copy_xdp(struct xdp_md *xdp)
611611
struct bpf_dynptr ptr_buf, ptr_xdp;
612612
char data[] = "qwertyuiopasdfghjkl";
613613
char buf[32] = {'\0'};
614-
__u32 len = sizeof(data);
614+
__u32 len = sizeof(data), xdp_data_size;
615615
int i, chunks = 200;
616616

617617
/* ptr_xdp is backed by non-contiguous memory */
618618
bpf_dynptr_from_xdp(xdp, 0, &ptr_xdp);
619+
xdp_data_size = bpf_dynptr_size(&ptr_xdp);
619620
bpf_ringbuf_reserve_dynptr(&ringbuf, len * chunks, 0, &ptr_buf);
620621

621622
/* Destination dynptr is backed by non-contiguous memory */
@@ -673,7 +674,7 @@ int test_dynptr_copy_xdp(struct xdp_md *xdp)
673674
goto out;
674675
}
675676

676-
if (bpf_dynptr_copy(&ptr_xdp, 2000, &ptr_xdp, 0, len * chunks) != -E2BIG)
677+
if (bpf_dynptr_copy(&ptr_xdp, xdp_data_size - 3000, &ptr_xdp, 0, len * chunks) != -E2BIG)
677678
err = 1;
678679

679680
out:

0 commit comments

Comments
 (0)