Skip to content

Commit a0c1114

Browse files
mrpreMartin KaFai Lau
authored andcommitted
selftests/bpf: Fix invalid flag of recv()
SOCK_NONBLOCK flag is only effective during socket creation, not during recv. Use MSG_DONTWAIT instead. Signed-off-by: Jiayuan Chen <[email protected]> Signed-off-by: Martin KaFai Lau <[email protected]> Acked-by: Jakub Sitnicki <[email protected]> Acked-by: John Fastabend <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 5459cce commit a0c1114

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,8 @@ static void test_sockmap_skb_verdict_shutdown(void)
522522
if (!ASSERT_EQ(err, 1, "epoll_wait(fd)"))
523523
goto out_close;
524524

525-
n = recv(c1, &b, 1, SOCK_NONBLOCK);
526-
ASSERT_EQ(n, 0, "recv_timeout(fin)");
525+
n = recv(c1, &b, 1, MSG_DONTWAIT);
526+
ASSERT_EQ(n, 0, "recv(fin)");
527527
out_close:
528528
close(c1);
529529
close(p1);
@@ -628,7 +628,7 @@ static void test_sockmap_skb_verdict_fionread(bool pass_prog)
628628
ASSERT_EQ(avail, expected, "ioctl(FIONREAD)");
629629
/* On DROP test there will be no data to read */
630630
if (pass_prog) {
631-
recvd = recv_timeout(c1, &buf, sizeof(buf), SOCK_NONBLOCK, IO_TIMEOUT_SEC);
631+
recvd = recv_timeout(c1, &buf, sizeof(buf), MSG_DONTWAIT, IO_TIMEOUT_SEC);
632632
ASSERT_EQ(recvd, sizeof(buf), "recv_timeout(c0)");
633633
}
634634

0 commit comments

Comments
 (0)