Skip to content

Commit 517017e

Browse files
committed
selftests/bpf: Fix size calculation in bpf_xdp_pull_data
The test employs 'sizeof(struct xdp_frame)' on the BPF side, which is not portable and results in test failures when run on 32-bit systems: root@qemu-armhf:/usr/libexec/kselftests-bpf# test_progs -a xdp_pull_data [...] run_test:PASS:calloc buf 0 nsec run_test:PASS:bpf_prog_test_run_opts 0 nsec run_test:FAIL:xdp_pull_data_prog retval unexpected xdp_pull_data_prog retval: actual 2 != expected 1 run_test:PASS:calloc buf 0 nsec run_test:PASS:bpf_prog_test_run_opts 0 nsec run_test:FAIL:xdp_pull_data_prog retval unexpected xdp_pull_data_prog retval: actual 2 != expected 1 run_test:PASS:calloc buf 0 nsec run_test:PASS:bpf_prog_test_run_opts 0 nsec run_test:FAIL:xdp_pull_data_prog retval unexpected xdp_pull_data_prog retval: actual 2 != expected 1 run_test:PASS:calloc buf 0 nsec run_test:PASS:bpf_prog_test_run_opts 0 nsec run_test:FAIL:xdp_pull_data_prog retval unexpected xdp_pull_data_prog retval: actual 2 != expected 1 #639/1 xdp_pull_data/xdp_pull_data:FAIL Fix by using 'bpf_core_type_size(struct xdp_frame)' instead. Fixes: 323302f ("selftests/bpf: Test bpf_xdp_pull_data") Signed-off-by: Tony Ambardar <[email protected]>
1 parent 6af0dad commit 517017e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "vmlinux.h"
44
#include <bpf/bpf_helpers.h>
5+
#include <bpf/bpf_core_read.h>
56

67
int xdpf_sz;
78
int sinfo_sz;
@@ -13,7 +14,7 @@ int pull_len;
1314
SEC("xdp.frags")
1415
int xdp_find_sizes(struct xdp_md *ctx)
1516
{
16-
xdpf_sz = sizeof(struct xdp_frame);
17+
xdpf_sz = bpf_core_type_size(struct xdp_frame);
1718
sinfo_sz = __PAGE_SIZE - XDP_PACKET_HEADROOM -
1819
(ctx->data_end - ctx->data);
1920

0 commit comments

Comments
 (0)