Skip to content

Commit 4a5dcb3

Browse files
Yonghong SongMartin KaFai Lau
authored andcommitted
selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure
For arm64 64K page size, the xdp data size was set to be more than 64K in one of previous patches. This will cause failure for bpf_dynptr_memset(). Since the failure of bpf_dynptr_memset() is expected with 64K page size, return success. Signed-off-by: Yonghong Song <[email protected]> Signed-off-by: Martin KaFai Lau <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 90f791a commit 4a5dcb3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "bpf_misc.h"
1010
#include "errno.h"
1111

12+
#define PAGE_SIZE_64K 65536
13+
1214
char _license[] SEC("license") = "GPL";
1315

1416
int pid, err, val;
@@ -821,8 +823,17 @@ int test_dynptr_memset_xdp_chunks(struct xdp_md *xdp)
821823
data_sz = bpf_dynptr_size(&ptr_xdp);
822824

823825
err = bpf_dynptr_memset(&ptr_xdp, 0, data_sz, DYNPTR_MEMSET_VAL);
824-
if (err)
826+
if (err) {
827+
/* bpf_dynptr_memset() eventually called bpf_xdp_pointer()
828+
* where if data_sz is greater than 0xffff, -EFAULT will be
829+
* returned. For 64K page size, data_sz is greater than
830+
* 64K, so error is expected and let us zero out error and
831+
* return success.
832+
*/
833+
if (data_sz >= PAGE_SIZE_64K)
834+
err = 0;
825835
goto out;
836+
}
826837

827838
bpf_for(i, 0, max_chunks) {
828839
offset = i * sizeof(buf);

0 commit comments

Comments
 (0)