]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Retry for EAGAIN in udp_redir_to_connected()
authorCong Wang <cong.wang@bytedance.com>
Tue, 15 Jun 2021 02:13:36 +0000 (19:13 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 21 Jun 2021 14:48:21 +0000 (16:48 +0200)
commitf9c0fadb6bf5c0c066f241e5cfe13e5383313707
treef55160923e736894333c38a294daa3a420115bdd
parente21c8cc7b0d8b8c4026c2104353bbb874d122734
selftests/bpf: Retry for EAGAIN in udp_redir_to_connected()

We use non-blocking sockets for testing sockmap redirections,
and got some random EAGAIN errors from UDP tests.

There is no guarantee the packet would be immediately available
to receive as soon as it is sent out, even on the local host.
For UDP, this is especially true because it does not lock the
sock during BH (unlike the TCP path). This is probably why we
only saw this error in UDP cases.

No matter how hard we try to make the queue empty check accurate,
it is always possible for recvmsg() to beat ->sk_data_ready().
Therefore, we should just retry in case of EAGAIN.

Fixes: e39e68157eeb2 ("selftests/bpf: Add a test case for udp sockmap")
Reported-by: Jiang Wang <jiang.wang@bytedance.com>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20210615021342.7416-3-xiyou.wangcong@gmail.com
tools/testing/selftests/bpf/prog_tests/sockmap_listen.c