Skip to content

Commit 9a11a1a

Browse files
committed
selftests/bpf: Fix sendto() message size in lwt_seg6local
This test_progs test fails on 32-bit armhf: root@qemu-armhf:/usr/libexec/kselftests-bpf# test_progs -a lwt_seg6local [...] test_lwt_seg6local:PASS:setup 0 nsec test_lwt_seg6local:PASS:open ns6 0 nsec test_lwt_seg6local:PASS:start server 0 nsec test_lwt_seg6local:PASS:open ns1 0 nsec test_lwt_seg6local:PASS:start client 0 nsec test_lwt_seg6local:PASS:build target addr 0 nsec test_lwt_seg6local:PASS:send packet 0 nsec test_lwt_seg6local:FAIL:receive packet unexpected receive packet: actual 4 != expected 7 torvalds#183 lwt_seg6local:FAIL This happens because a sendto() call mistakenly uses 'sizeof(char *)' as message length rather than the actual string ("foobar\0") size. e.g. bytes = sendto(cfd, foobar, sizeof(foobar), 0, ... This likely passed by accident till now because BPF CI only tests 64-bit targets. Fix by using strlen() to determine the message length. Fixes: 1041b8b ("selftests/bpf: lwt_seg6local: Move test to test_progs") Signed-off-by: Tony Ambardar <[email protected]>
1 parent c2db778 commit 9a11a1a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ void test_lwt_seg6local(void)
153153
"build target addr"))
154154
goto close_client;
155155

156-
bytes = sendto(cfd, foobar, sizeof(foobar), 0,
156+
bytes = sendto(cfd, foobar, strlen(foobar) + 1, 0,
157157
(struct sockaddr *)&server_addr, sizeof(server_addr));
158-
if (!ASSERT_EQ(bytes, sizeof(foobar), "send packet"))
158+
if (!ASSERT_EQ(bytes, strlen(foobar) + 1, "send packet"))
159159
goto close_client;
160160

161161
/* Verify we received all expected bytes */

0 commit comments

Comments
 (0)