Skip to content

Commit 44df9e0

Browse files
Yonghong SongAlexei Starovoitov
authored andcommitted
selftests/bpf: Fix xdp_do_redirect failure with 64KB page size
On arm64 with 64KB page size, the selftest xdp_do_redirect failed like below: ... test_xdp_do_redirect:PASS:pkt_count_tc 0 nsec test_max_pkt_size:PASS:prog_run_max_size 0 nsec test_max_pkt_size:FAIL:prog_run_too_big unexpected prog_run_too_big: actual -28 != expected -22 With 64KB page size, the xdp frame size will be much bigger so the existing test will fail. Adjust various parameters so the test can also work on 64K page size. Signed-off-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 96fcf7e commit 44df9e0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,25 @@ static int attach_tc_prog(struct bpf_tc_hook *hook, int fd)
6666
#else
6767
#define MAX_PKT_SIZE 3408
6868
#endif
69+
70+
#define PAGE_SIZE_4K 4096
71+
#define PAGE_SIZE_64K 65536
72+
6973
static void test_max_pkt_size(int fd)
7074
{
71-
char data[MAX_PKT_SIZE + 1] = {};
75+
char data[PAGE_SIZE_64K + 1] = {};
7276
int err;
7377
DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts,
7478
.data_in = &data,
75-
.data_size_in = MAX_PKT_SIZE,
7679
.flags = BPF_F_TEST_XDP_LIVE_FRAMES,
7780
.repeat = 1,
7881
);
82+
83+
if (getpagesize() == PAGE_SIZE_64K)
84+
opts.data_size_in = MAX_PKT_SIZE + PAGE_SIZE_64K - PAGE_SIZE_4K;
85+
else
86+
opts.data_size_in = MAX_PKT_SIZE;
87+
7988
err = bpf_prog_test_run_opts(fd, &opts);
8089
ASSERT_OK(err, "prog_run_max_size");
8190

0 commit comments

Comments
 (0)