selftests/net: Delete timeout from test_connect_socket()

Unused: it's always either the default timeout or asynchronous
connect().

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
Link: https://patch.msgid.link/20250319-tcp-ao-selftests-polling-v2-6-da48040153d1@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Dmitry Safonov 2025-03-19 03:13:39 +00:00 committed by Jakub Kicinski
parent 266ed1ace8
commit 1e1738faa2
4 changed files with 13 additions and 21 deletions

View File

@ -289,7 +289,7 @@ extern int link_set_up(const char *intf);
extern const unsigned int test_server_port;
extern int test_wait_fd(int sk, time_t sec, bool write);
extern int __test_connect_socket(int sk, const char *device,
void *addr, size_t addr_sz, time_t timeout);
void *addr, size_t addr_sz, bool async);
extern int __test_listen_socket(int backlog, void *addr, size_t addr_sz);
static inline int test_listen_socket(const union tcp_addr taddr,
@ -338,19 +338,19 @@ static inline int test_listen_socket(const union tcp_addr taddr,
#endif
static inline int _test_connect_socket(int sk, const union tcp_addr taddr,
unsigned int port, time_t timeout)
unsigned int port, bool async)
{
sockaddr_af addr;
tcp_addr_to_sockaddr_in(&addr, &taddr, htons(port));
return __test_connect_socket(sk, veth_name,
(void *)&addr, sizeof(addr), timeout);
(void *)&addr, sizeof(addr), async);
}
static inline int test_connect_socket(int sk, const union tcp_addr taddr,
unsigned int port)
{
return _test_connect_socket(sk, taddr, port, TEST_TIMEOUT_SEC);
return _test_connect_socket(sk, taddr, port, false);
}
extern int __test_set_md5(int sk, void *addr, size_t addr_sz,

View File

@ -111,7 +111,7 @@ static int __test_skpair_poll(int sk, bool write, uint64_t timeout,
}
int __test_connect_socket(int sk, const char *device,
void *addr, size_t addr_sz, time_t timeout)
void *addr, size_t addr_sz, bool async)
{
long flags;
int err;
@ -123,15 +123,6 @@ int __test_connect_socket(int sk, const char *device,
test_error("setsockopt(SO_BINDTODEVICE, %s)", device);
}
if (!timeout) {
err = connect(sk, addr, addr_sz);
if (err) {
err = -errno;
goto out;
}
return 0;
}
flags = fcntl(sk, F_GETFL);
if ((flags < 0) || (fcntl(sk, F_SETFL, flags | O_NONBLOCK) < 0))
test_error("fcntl()");
@ -141,9 +132,9 @@ int __test_connect_socket(int sk, const char *device,
err = -errno;
goto out;
}
if (timeout < 0)
if (async)
return sk;
err = test_wait_fd(sk, timeout, 1);
err = test_wait_fd(sk, TEST_TIMEOUT_SEC, 1);
if (err)
goto out;
}
@ -181,12 +172,14 @@ int _test_skpair_connect_poll(int sk, const char *device,
if (test_get_tcp_counters(sk, &c))
test_error("test_get_tcp_counters()");
synchronize_threads(); /* 1: init skpair & read nscounters */
ret = __test_connect_socket(sk, device, addr, addr_sz, -1);
ret = __test_connect_socket(sk, device, addr, addr_sz, true);
if (ret < 0) {
test_tcp_counters_free(&c);
return (*err = ret);
}
ret = __test_skpair_poll(sk, 1, TEST_TIMEOUT_SEC, &c, condition, err);
if (ret < 0)
close(sk);
test_tcp_counters_free(&c);
return ret;
}

View File

@ -271,8 +271,7 @@ static void test_client_active_rst(unsigned int port)
synchronize_threads(); /* 1: MKT added */
for (i = 0; i < last; i++) {
err = _test_connect_socket(sk[i], this_ip_dest, port,
(i == 0) ? TEST_TIMEOUT_SEC : -1);
err = _test_connect_socket(sk[i], this_ip_dest, port, i != 0);
if (err < 0)
test_error("failed to connect()");
}
@ -283,7 +282,7 @@ static void test_client_active_rst(unsigned int port)
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);
err = _test_connect_socket(sk[last], this_ip_dest, port, 1);
if (err < 0)
test_error("failed to connect()");

View File

@ -64,7 +64,7 @@ static void tcp_self_connect(const char *tst, unsigned int port,
test_error("test_get_tcp_counters()");
if (__test_connect_socket(sk, "lo", (struct sockaddr *)&addr,
sizeof(addr), TEST_TIMEOUT_SEC) < 0) {
sizeof(addr), 0) < 0) {
ns_after = netstat_read();
netstat_print_diff(ns_before, ns_after);
test_error("failed to connect()");