Commit 24f4c99e authored by Paolo Abeni's avatar Paolo Abeni

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: default avatarDmitry Safonov <0x7f454c46@gmail.com>
====================

Link: https://lore.kernel.org/r/20240413-tcp-ao-selftests-fixes-v1-0-f9c41c96949d@gmail.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 75ce9506 b476c936
...@@ -86,7 +86,7 @@ static void netstat_read_type(FILE *fnetstat, struct netstat **dest, char *line) ...@@ -86,7 +86,7 @@ static void netstat_read_type(FILE *fnetstat, struct netstat **dest, char *line)
pos = strchr(line, ' ') + 1; pos = strchr(line, ' ') + 1;
if (fscanf(fnetstat, type->header_name) == EOF) if (fscanf(fnetstat, "%[^ :]", type->header_name) == EOF)
test_error("fscanf(%s)", type->header_name); test_error("fscanf(%s)", type->header_name);
if (fread(&tmp, 1, 1, fnetstat) != 1 || tmp != ':') if (fread(&tmp, 1, 1, fnetstat) != 1 || tmp != ':')
test_error("Unexpected netstat format (%c)", tmp); test_error("Unexpected netstat format (%c)", tmp);
......
...@@ -17,37 +17,37 @@ static pthread_mutex_t ksft_print_lock = PTHREAD_MUTEX_INITIALIZER; ...@@ -17,37 +17,37 @@ static pthread_mutex_t ksft_print_lock = PTHREAD_MUTEX_INITIALIZER;
void __test_msg(const char *buf) void __test_msg(const char *buf)
{ {
pthread_mutex_lock(&ksft_print_lock); pthread_mutex_lock(&ksft_print_lock);
ksft_print_msg(buf); ksft_print_msg("%s", buf);
pthread_mutex_unlock(&ksft_print_lock); pthread_mutex_unlock(&ksft_print_lock);
} }
void __test_ok(const char *buf) void __test_ok(const char *buf)
{ {
pthread_mutex_lock(&ksft_print_lock); pthread_mutex_lock(&ksft_print_lock);
ksft_test_result_pass(buf); ksft_test_result_pass("%s", buf);
pthread_mutex_unlock(&ksft_print_lock); pthread_mutex_unlock(&ksft_print_lock);
} }
void __test_fail(const char *buf) void __test_fail(const char *buf)
{ {
pthread_mutex_lock(&ksft_print_lock); pthread_mutex_lock(&ksft_print_lock);
ksft_test_result_fail(buf); ksft_test_result_fail("%s", buf);
pthread_mutex_unlock(&ksft_print_lock); pthread_mutex_unlock(&ksft_print_lock);
} }
void __test_xfail(const char *buf) void __test_xfail(const char *buf)
{ {
pthread_mutex_lock(&ksft_print_lock); pthread_mutex_lock(&ksft_print_lock);
ksft_test_result_xfail(buf); ksft_test_result_xfail("%s", buf);
pthread_mutex_unlock(&ksft_print_lock); pthread_mutex_unlock(&ksft_print_lock);
} }
void __test_error(const char *buf) void __test_error(const char *buf)
{ {
pthread_mutex_lock(&ksft_print_lock); pthread_mutex_lock(&ksft_print_lock);
ksft_test_result_error(buf); ksft_test_result_error("%s", buf);
pthread_mutex_unlock(&ksft_print_lock); pthread_mutex_unlock(&ksft_print_lock);
} }
void __test_skip(const char *buf) void __test_skip(const char *buf)
{ {
pthread_mutex_lock(&ksft_print_lock); pthread_mutex_lock(&ksft_print_lock);
ksft_test_result_skip(buf); ksft_test_result_skip("%s", buf);
pthread_mutex_unlock(&ksft_print_lock); pthread_mutex_unlock(&ksft_print_lock);
} }
......
...@@ -256,8 +256,6 @@ static int test_wait_fds(int sk[], size_t nr, bool is_writable[], ...@@ -256,8 +256,6 @@ static int test_wait_fds(int sk[], size_t nr, bool is_writable[],
static void test_client_active_rst(unsigned int port) static void test_client_active_rst(unsigned int port)
{ {
/* one in queue, another accept()ed */
unsigned int wait_for = backlog + 2;
int i, sk[3], err; int i, sk[3], err;
bool is_writable[ARRAY_SIZE(sk)] = {false}; bool is_writable[ARRAY_SIZE(sk)] = {false};
unsigned int last = ARRAY_SIZE(sk) - 1; unsigned int last = ARRAY_SIZE(sk) - 1;
...@@ -275,16 +273,20 @@ static void test_client_active_rst(unsigned int port) ...@@ -275,16 +273,20 @@ static void test_client_active_rst(unsigned int port)
for (i = 0; i < last; i++) { for (i = 0; i < last; i++) {
err = _test_connect_socket(sk[i], this_ip_dest, port, err = _test_connect_socket(sk[i], this_ip_dest, port,
(i == 0) ? TEST_TIMEOUT_SEC : -1); (i == 0) ? TEST_TIMEOUT_SEC : -1);
if (err < 0) if (err < 0)
test_error("failed to connect()"); test_error("failed to connect()");
} }
synchronize_threads(); /* 2: connection accept()ed, another queued */ synchronize_threads(); /* 2: two connections: one accept()ed, another queued */
err = test_wait_fds(sk, last, is_writable, wait_for, TEST_TIMEOUT_SEC); err = test_wait_fds(sk, last, is_writable, last, TEST_TIMEOUT_SEC);
if (err < 0) if (err < 0)
test_error("test_wait_fds(): %d", err); test_error("test_wait_fds(): %d", err);
/* async connect() with third sk to get into request_sock_queue */
err = _test_connect_socket(sk[last], this_ip_dest, port, -1);
if (err < 0)
test_error("failed to connect()");
synchronize_threads(); /* 3: close listen socket */ synchronize_threads(); /* 3: close listen socket */
if (test_client_verify(sk[0], packet_sz, quota / packet_sz, TEST_TIMEOUT_SEC)) if (test_client_verify(sk[0], packet_sz, quota / packet_sz, TEST_TIMEOUT_SEC))
test_fail("Failed to send data on connected socket"); test_fail("Failed to send data on connected socket");
...@@ -292,13 +294,14 @@ static void test_client_active_rst(unsigned int port) ...@@ -292,13 +294,14 @@ static void test_client_active_rst(unsigned int port)
test_ok("Verified established tcp connection"); test_ok("Verified established tcp connection");
synchronize_threads(); /* 4: finishing up */ synchronize_threads(); /* 4: finishing up */
err = _test_connect_socket(sk[last], this_ip_dest, port, -1);
if (err < 0)
test_error("failed to connect()");
synchronize_threads(); /* 5: closed active sk */ synchronize_threads(); /* 5: closed active sk */
err = test_wait_fds(sk, ARRAY_SIZE(sk), NULL, /*
wait_for, TEST_TIMEOUT_SEC); * Wait for 2 connections: one accepted, another in the accept queue,
* the one in request_sock_queue won't get fully established, so
* doesn't receive an active RST, see inet_csk_listen_stop().
*/
err = test_wait_fds(sk, last, NULL, last, TEST_TIMEOUT_SEC);
if (err < 0) if (err < 0)
test_error("select(): %d", err); test_error("select(): %d", err);
......
...@@ -21,7 +21,7 @@ static void make_listen(int sk) ...@@ -21,7 +21,7 @@ static void make_listen(int sk)
static void test_vefify_ao_info(int sk, struct tcp_ao_info_opt *info, static void test_vefify_ao_info(int sk, struct tcp_ao_info_opt *info,
const char *tst) const char *tst)
{ {
struct tcp_ao_info_opt tmp; struct tcp_ao_info_opt tmp = {};
socklen_t len = sizeof(tmp); socklen_t len = sizeof(tmp);
if (getsockopt(sk, IPPROTO_TCP, TCP_AO_INFO, &tmp, &len)) if (getsockopt(sk, IPPROTO_TCP, TCP_AO_INFO, &tmp, &len))
......
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