Skip to content

Commit

Permalink
selftests/net: Amend per-netns counter checks
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
0x7f454c46 authored and Paolo Abeni committed Feb 6, 2024
1 parent 3871aa0 commit b083d24
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tools/testing/selftests/net/tcp_ao/unsigned-md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ static void try_accept(const char *tst_name, unsigned int port,
test_tcp_ao_counters_cmp(tst_name, &ao_cnt1, &ao_cnt2, cnt_expected);

out:
synchronize_threads(); /* close() */
synchronize_threads(); /* test_kill_sk() */
if (sk > 0)
close(sk);
test_kill_sk(sk);
}

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

out:
synchronize_threads(); /* close() */
synchronize_threads(); /* test_kill_sk() */
/* _test_connect_socket() cleans up on failure */
if (ret > 0)
close(sk);
test_kill_sk(sk);
}

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

out:
synchronize_threads(); /* close() */
synchronize_threads(); /* test_kill_sk() */
/* _test_connect_socket() cleans up on failure */
if (ret > 0)
close(sk);
test_kill_sk(sk);
}

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

0 comments on commit b083d24

Please sign in to comment.