Skip to content

Commit 3599bc5

Browse files
Yucong SunAlexei Starovoitov
authored andcommitted
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: Yucong Sun <fallentree@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20210825184745.2680830-1-fallentree@fb.com
1 parent eb529c5 commit 3599bc5

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

‎tools/testing/selftests/bpf/prog_tests/sockmap_listen.c‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,7 @@ static void redir_to_connected(int family, int sotype, int sock_mapfd,
949949
int err, n;
950950
u32 key;
951951
char b;
952+
int retries = 100;
952953

953954
zero_verdict_count(verd_mapfd);
954955

@@ -1001,10 +1002,15 @@ static void redir_to_connected(int family, int sotype, int sock_mapfd,
10011002
goto close_peer1;
10021003
if (pass != 1)
10031004
FAIL("%s: want pass count 1, have %d", log_prefix, pass);
1004-
1005+
again:
10051006
n = read(c0, &b, 1);
1006-
if (n < 0)
1007+
if (n < 0) {
1008+
if (errno == EAGAIN && retries--) {
1009+
usleep(1000);
1010+
goto again;
1011+
}
10071012
FAIL_ERRNO("%s: read", log_prefix);
1013+
}
10081014
if (n == 0)
10091015
FAIL("%s: incomplete read", log_prefix);
10101016

@@ -1926,6 +1932,7 @@ static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd,
19261932
int sfd[2];
19271933
u32 key;
19281934
char b;
1935+
int retries = 100;
19291936

19301937
zero_verdict_count(verd_mapfd);
19311938

@@ -1956,9 +1963,15 @@ static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd,
19561963
if (pass != 1)
19571964
FAIL("%s: want pass count 1, have %d", log_prefix, pass);
19581965

1966+
again:
19591967
n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
1960-
if (n < 0)
1968+
if (n < 0) {
1969+
if (errno == EAGAIN && retries--) {
1970+
usleep(1000);
1971+
goto again;
1972+
}
19611973
FAIL_ERRNO("%s: read", log_prefix);
1974+
}
19621975
if (n == 0)
19631976
FAIL("%s: incomplete read", log_prefix);
19641977

0 commit comments

Comments
 (0)