Skip to content

Commit 24f4c99

Browse files
author
Paolo Abeni
committed
Merge branch 'selftests-net-tcp_ao-a-bunch-of-fixes-for-tcp-ao-selftests'
Dmitry Safonov via says: ==================== selftests/net/tcp_ao: A bunch of fixes for TCP-AO selftests Started as addressing the flakiness issues in rst_ipv*, that affect netdev dashboard. Signed-off-by: Dmitry Safonov <[email protected]> ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 75ce950 + b476c93 commit 24f4c99

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

tools/testing/selftests/net/tcp_ao/lib/proc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static void netstat_read_type(FILE *fnetstat, struct netstat **dest, char *line)
8686

8787
pos = strchr(line, ' ') + 1;
8888

89-
if (fscanf(fnetstat, type->header_name) == EOF)
89+
if (fscanf(fnetstat, "%[^ :]", type->header_name) == EOF)
9090
test_error("fscanf(%s)", type->header_name);
9191
if (fread(&tmp, 1, 1, fnetstat) != 1 || tmp != ':')
9292
test_error("Unexpected netstat format (%c)", tmp);

tools/testing/selftests/net/tcp_ao/lib/setup.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,37 @@ static pthread_mutex_t ksft_print_lock = PTHREAD_MUTEX_INITIALIZER;
1717
void __test_msg(const char *buf)
1818
{
1919
pthread_mutex_lock(&ksft_print_lock);
20-
ksft_print_msg(buf);
20+
ksft_print_msg("%s", buf);
2121
pthread_mutex_unlock(&ksft_print_lock);
2222
}
2323
void __test_ok(const char *buf)
2424
{
2525
pthread_mutex_lock(&ksft_print_lock);
26-
ksft_test_result_pass(buf);
26+
ksft_test_result_pass("%s", buf);
2727
pthread_mutex_unlock(&ksft_print_lock);
2828
}
2929
void __test_fail(const char *buf)
3030
{
3131
pthread_mutex_lock(&ksft_print_lock);
32-
ksft_test_result_fail(buf);
32+
ksft_test_result_fail("%s", buf);
3333
pthread_mutex_unlock(&ksft_print_lock);
3434
}
3535
void __test_xfail(const char *buf)
3636
{
3737
pthread_mutex_lock(&ksft_print_lock);
38-
ksft_test_result_xfail(buf);
38+
ksft_test_result_xfail("%s", buf);
3939
pthread_mutex_unlock(&ksft_print_lock);
4040
}
4141
void __test_error(const char *buf)
4242
{
4343
pthread_mutex_lock(&ksft_print_lock);
44-
ksft_test_result_error(buf);
44+
ksft_test_result_error("%s", buf);
4545
pthread_mutex_unlock(&ksft_print_lock);
4646
}
4747
void __test_skip(const char *buf)
4848
{
4949
pthread_mutex_lock(&ksft_print_lock);
50-
ksft_test_result_skip(buf);
50+
ksft_test_result_skip("%s", buf);
5151
pthread_mutex_unlock(&ksft_print_lock);
5252
}
5353

tools/testing/selftests/net/tcp_ao/rst.c

+13-10
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ static int test_wait_fds(int sk[], size_t nr, bool is_writable[],
256256

257257
static void test_client_active_rst(unsigned int port)
258258
{
259-
/* one in queue, another accept()ed */
260-
unsigned int wait_for = backlog + 2;
261259
int i, sk[3], err;
262260
bool is_writable[ARRAY_SIZE(sk)] = {false};
263261
unsigned int last = ARRAY_SIZE(sk) - 1;
@@ -275,30 +273,35 @@ static void test_client_active_rst(unsigned int port)
275273
for (i = 0; i < last; i++) {
276274
err = _test_connect_socket(sk[i], this_ip_dest, port,
277275
(i == 0) ? TEST_TIMEOUT_SEC : -1);
278-
279276
if (err < 0)
280277
test_error("failed to connect()");
281278
}
282279

283-
synchronize_threads(); /* 2: connection accept()ed, another queued */
284-
err = test_wait_fds(sk, last, is_writable, wait_for, TEST_TIMEOUT_SEC);
280+
synchronize_threads(); /* 2: two connections: one accept()ed, another queued */
281+
err = test_wait_fds(sk, last, is_writable, last, TEST_TIMEOUT_SEC);
285282
if (err < 0)
286283
test_error("test_wait_fds(): %d", err);
287284

285+
/* async connect() with third sk to get into request_sock_queue */
286+
err = _test_connect_socket(sk[last], this_ip_dest, port, -1);
287+
if (err < 0)
288+
test_error("failed to connect()");
289+
288290
synchronize_threads(); /* 3: close listen socket */
289291
if (test_client_verify(sk[0], packet_sz, quota / packet_sz, TEST_TIMEOUT_SEC))
290292
test_fail("Failed to send data on connected socket");
291293
else
292294
test_ok("Verified established tcp connection");
293295

294296
synchronize_threads(); /* 4: finishing up */
295-
err = _test_connect_socket(sk[last], this_ip_dest, port, -1);
296-
if (err < 0)
297-
test_error("failed to connect()");
298297

299298
synchronize_threads(); /* 5: closed active sk */
300-
err = test_wait_fds(sk, ARRAY_SIZE(sk), NULL,
301-
wait_for, TEST_TIMEOUT_SEC);
299+
/*
300+
* Wait for 2 connections: one accepted, another in the accept queue,
301+
* the one in request_sock_queue won't get fully established, so
302+
* doesn't receive an active RST, see inet_csk_listen_stop().
303+
*/
304+
err = test_wait_fds(sk, last, NULL, last, TEST_TIMEOUT_SEC);
302305
if (err < 0)
303306
test_error("select(): %d", err);
304307

tools/testing/selftests/net/tcp_ao/setsockopt-closed.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static void make_listen(int sk)
2121
static void test_vefify_ao_info(int sk, struct tcp_ao_info_opt *info,
2222
const char *tst)
2323
{
24-
struct tcp_ao_info_opt tmp;
24+
struct tcp_ao_info_opt tmp = {};
2525
socklen_t len = sizeof(tmp);
2626

2727
if (getsockopt(sk, IPPROTO_TCP, TCP_AO_INFO, &tmp, &len))

0 commit comments

Comments
 (0)