Skip to content

Commit f06b3a5

Browse files
Yonghong SongKernel Patches Daemon
authored andcommitted
selftests/bpf: Fix xdp_pull_data failure with 64K page
If the argument 'pull_len' of run_test() is 'PULL_MAX' or 'PULL_MAX | PULL_PLUS_ONE', the eventual pull_len size will close to the page size. On arm64 systems with 64K pages, the pull_len size will be close to 64K. But the existing buffer will be close to 9000 which is not enough to pull. For those failed run_tests(), make buff size to pg_sz + (pg_sz / 2) This way, there will be enough buffer space to pull regardless of page size. Tested-by: Alan Maguire <[email protected]> Cc: Amery Hung <[email protected]> Signed-off-by: Yonghong Song <[email protected]>
1 parent 83282d8 commit f06b3a5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,14 @@ static void test_xdp_pull_data_basic(void)
114114
{
115115
u32 pg_sz, max_meta_len, max_data_len;
116116
struct test_xdp_pull_data *skel;
117+
int buff_len;
117118

118119
skel = test_xdp_pull_data__open_and_load();
119120
if (!ASSERT_OK_PTR(skel, "test_xdp_pull_data__open_and_load"))
120121
return;
121122

122123
pg_sz = sysconf(_SC_PAGE_SIZE);
124+
buff_len = pg_sz + pg_sz / 2;
123125

124126
if (find_xdp_sizes(skel, pg_sz))
125127
goto out;
@@ -140,32 +142,32 @@ static void test_xdp_pull_data_basic(void)
140142
run_test(skel, XDP_PASS, pg_sz, 9000, 0, 1025, 1025);
141143

142144
/* multi-buf pkt, empty linear data area, pull requires memmove */
143-
run_test(skel, XDP_PASS, pg_sz, 9000, 0, 0, PULL_MAX);
145+
run_test(skel, XDP_PASS, pg_sz, buff_len, 0, 0, PULL_MAX);
144146

145147
/* multi-buf pkt, no headroom */
146-
run_test(skel, XDP_PASS, pg_sz, 9000, max_meta_len, 1024, PULL_MAX);
148+
run_test(skel, XDP_PASS, pg_sz, buff_len, max_meta_len, 1024, PULL_MAX);
147149

148150
/* multi-buf pkt, no tailroom, pull requires memmove */
149-
run_test(skel, XDP_PASS, pg_sz, 9000, 0, max_data_len, PULL_MAX);
151+
run_test(skel, XDP_PASS, pg_sz, buff_len, 0, max_data_len, PULL_MAX);
150152

151153
/* Test cases with invalid pull length */
152154

153155
/* linear xdp pkt, pull more than total data len */
154156
run_test(skel, XDP_DROP, pg_sz, 2048, 0, 2048, 2049);
155157

156158
/* multi-buf pkt with no space left in linear data area */
157-
run_test(skel, XDP_DROP, pg_sz, 9000, max_meta_len, max_data_len,
159+
run_test(skel, XDP_DROP, pg_sz, buff_len, max_meta_len, max_data_len,
158160
PULL_MAX | PULL_PLUS_ONE);
159161

160162
/* multi-buf pkt, empty linear data area */
161-
run_test(skel, XDP_DROP, pg_sz, 9000, 0, 0, PULL_MAX | PULL_PLUS_ONE);
163+
run_test(skel, XDP_DROP, pg_sz, buff_len, 0, 0, PULL_MAX | PULL_PLUS_ONE);
162164

163165
/* multi-buf pkt, no headroom */
164-
run_test(skel, XDP_DROP, pg_sz, 9000, max_meta_len, 1024,
166+
run_test(skel, XDP_DROP, pg_sz, buff_len, max_meta_len, 1024,
165167
PULL_MAX | PULL_PLUS_ONE);
166168

167169
/* multi-buf pkt, no tailroom */
168-
run_test(skel, XDP_DROP, pg_sz, 9000, 0, max_data_len,
170+
run_test(skel, XDP_DROP, pg_sz, buff_len, 0, max_data_len,
169171
PULL_MAX | PULL_PLUS_ONE);
170172

171173
out:

0 commit comments

Comments
 (0)