Skip to content

Commit b083d24

Browse files
0x7f454c46Paolo Abeni
authored and
Paolo Abeni
committed
selftests/net: Amend per-netns counter checks
Selftests here check not only that connect()/accept() for TCP-AO/TCP-MD5/non-signed-TCP combinations do/don't establish connections, but also counters: those are per-AO-key, per-socket and per-netns. The counters are checked on the server's side, as the server listener has TCP-AO/TCP-MD5/no keys for different peers. All tests run in the same namespaces with the same veth pair, created in test_init(). After close() in both client and server, the sides go through the regular FIN/ACK + FIN/ACK sequence, which goes in the background. If the selftest has already started a new testing scenario, read per-netns counters - it may fail in the end iff it doesn't expect the TCPAOGood per-netns counters go up during the test. Let's just kill both TCP-AO sides - that will avoid any asynchronous background TCP-AO segments going to either sides. Reported-by: Jakub Kicinski <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/T/#u Fixes: 6f0c472 ("selftests/net: Add TCP-AO + TCP-MD5 + no sign listen socket tests") Signed-off-by: Dmitry Safonov <[email protected]> Link: https://lore.kernel.org/r/20240202-unsigned-md5-netns-counters-v1-1-8b90c37c0566@arista.com Signed-off-by: Paolo Abeni <[email protected]>
1 parent 3871aa0 commit b083d24

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tools/testing/selftests/net/tcp_ao/unsigned-md5.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ static void try_accept(const char *tst_name, unsigned int port,
110110
test_tcp_ao_counters_cmp(tst_name, &ao_cnt1, &ao_cnt2, cnt_expected);
111111

112112
out:
113-
synchronize_threads(); /* close() */
113+
synchronize_threads(); /* test_kill_sk() */
114114
if (sk > 0)
115-
close(sk);
115+
test_kill_sk(sk);
116116
}
117117

118118
static void server_add_routes(void)
@@ -302,10 +302,10 @@ static void try_connect(const char *tst_name, unsigned int port,
302302
test_ok("%s: connected", tst_name);
303303

304304
out:
305-
synchronize_threads(); /* close() */
305+
synchronize_threads(); /* test_kill_sk() */
306306
/* _test_connect_socket() cleans up on failure */
307307
if (ret > 0)
308-
close(sk);
308+
test_kill_sk(sk);
309309
}
310310

311311
#define PREINSTALL_MD5_FIRST BIT(0)
@@ -486,10 +486,10 @@ static void try_to_add(const char *tst_name, unsigned int port,
486486
}
487487

488488
out:
489-
synchronize_threads(); /* close() */
489+
synchronize_threads(); /* test_kill_sk() */
490490
/* _test_connect_socket() cleans up on failure */
491491
if (ret > 0)
492-
close(sk);
492+
test_kill_sk(sk);
493493
}
494494

495495
static void client_add_ip(union tcp_addr *client, const char *ip)

0 commit comments

Comments
 (0)