]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Fix spurious failures in accept due to EAGAIN
authorJakub Sitnicki <jakub@cloudflare.com>
Fri, 13 Mar 2020 16:10:49 +0000 (17:10 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 13 Mar 2020 20:37:06 +0000 (21:37 +0100)
commit6110d381c0c89482917021e80bff82d57034bb81
tree0456ef00c35942b251b0780373ff2277109d6b21
parent178ee64527a8faf3704751415299a6bc0b9b09f8
selftests/bpf: Fix spurious failures in accept due to EAGAIN

Andrii Nakryiko reports that sockmap_listen test suite is frequently
failing due to accept() calls erroring out with EAGAIN:

  ./test_progs:connect_accept_thread:733: accept: Resource temporarily unavailable
  connect_accept_thread:FAIL:733

This is because we are using a non-blocking listening TCP socket to
accept() connections without polling on the socket.

While at first switching to blocking mode seems like the right thing to do,
this could lead to test process blocking indefinitely in face of a network
issue, like loopback interface being down, as Andrii pointed out.

Hence, stick to non-blocking mode for TCP listening sockets but with
polling for incoming connection for a limited time before giving up.

Apply this approach to all socket I/O calls in the test suite that we
expect to block indefinitely, that is accept() for TCP and recv() for UDP.

Fixes: 706caf6393a8 ("selftests/bpf: Tests for sockmap/sockhash holding listening sockets")
Reported-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200313161049.677700-1-jakub@cloudflare.com
tools/testing/selftests/bpf/prog_tests/sockmap_listen.c