Commit 3599bc51 authored by Yucong Sun's avatar Yucong Sun Committed by Alexei Starovoitov

selftests/bpf: Reduce more flakyness in sockmap_listen

This patch adds similar retry logic to more places where read() is used, to
reduce flakyness in slow CI environment.
Signed-off-by: default avatarYucong Sun <fallentree@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210825184745.2680830-1-fallentree@fb.com
parent eb529c5b
...@@ -949,6 +949,7 @@ static void redir_to_connected(int family, int sotype, int sock_mapfd, ...@@ -949,6 +949,7 @@ static void redir_to_connected(int family, int sotype, int sock_mapfd,
int err, n; int err, n;
u32 key; u32 key;
char b; char b;
int retries = 100;
zero_verdict_count(verd_mapfd); zero_verdict_count(verd_mapfd);
...@@ -1001,10 +1002,15 @@ static void redir_to_connected(int family, int sotype, int sock_mapfd, ...@@ -1001,10 +1002,15 @@ static void redir_to_connected(int family, int sotype, int sock_mapfd,
goto close_peer1; goto close_peer1;
if (pass != 1) if (pass != 1)
FAIL("%s: want pass count 1, have %d", log_prefix, pass); FAIL("%s: want pass count 1, have %d", log_prefix, pass);
again:
n = read(c0, &b, 1); n = read(c0, &b, 1);
if (n < 0) if (n < 0) {
if (errno == EAGAIN && retries--) {
usleep(1000);
goto again;
}
FAIL_ERRNO("%s: read", log_prefix); FAIL_ERRNO("%s: read", log_prefix);
}
if (n == 0) if (n == 0)
FAIL("%s: incomplete read", log_prefix); FAIL("%s: incomplete read", log_prefix);
...@@ -1926,6 +1932,7 @@ static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd, ...@@ -1926,6 +1932,7 @@ static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd,
int sfd[2]; int sfd[2];
u32 key; u32 key;
char b; char b;
int retries = 100;
zero_verdict_count(verd_mapfd); zero_verdict_count(verd_mapfd);
...@@ -1956,9 +1963,15 @@ static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd, ...@@ -1956,9 +1963,15 @@ static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd,
if (pass != 1) if (pass != 1)
FAIL("%s: want pass count 1, have %d", log_prefix, pass); FAIL("%s: want pass count 1, have %d", log_prefix, pass);
again:
n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1); n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
if (n < 0) if (n < 0) {
if (errno == EAGAIN && retries--) {
usleep(1000);
goto again;
}
FAIL_ERRNO("%s: read", log_prefix); FAIL_ERRNO("%s: read", log_prefix);
}
if (n == 0) if (n == 0)
FAIL("%s: incomplete read", log_prefix); FAIL("%s: incomplete read", log_prefix);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment