Skip to content

Commit c6df7b2

Browse files
0x7f454c46davem330
authored andcommitted
selftests/net: Add TCP-AO RST test
Check that both active and passive reset works and correctly sign segments with TCP-AO or don't send RSTs if not possible to sign. A listening socket with backlog = 0 gets one connection in accept queue, another in syn queue. Once the server/listener socket is forcibly closed, client sockets aren't connected to anything. In regular situation they would receive RST on any segment, but with TCP-AO as there's no listener, no AO-key and unknown ISNs, no RST should be sent. And "passive" reset, where RST is sent on reply for some segment (tcp_v{4,6}_send_reset()) - there use TCP_REPAIR to corrupt SEQ numbers, which later results in TCP-AO signed RST, which will be verified and client socket will get EPIPE. No TCPAORequired/TCPAOBad segments are expected during these tests. Sample of the output: > # ./rst_ipv4 > 1..15 > # 1462[lib/setup.c:254] rand seed 1686611171 > TAP version 13 > ok 1 servered 1000 bytes > ok 2 Verified established tcp connection > ok 3 sk[0] = 7, connection was reset > ok 4 sk[1] = 8, connection was reset > ok 5 sk[2] = 9 > ok 6 MKT counters are good on server > ok 7 Verified established tcp connection > ok 8 client connection broken post-seq-adjust > ok 9 client connection was reset > ok 10 No segments without AO sign (server) > ok 11 Signed AO segments (server): 0 => 30 > ok 12 No segments with bad AO sign (server) > ok 13 No segments without AO sign (client) > ok 14 Signed AO segments (client): 0 => 30 > ok 15 No segments with bad AO sign (client) > # Totals: pass:15 fail:0 xfail:0 xpass:0 skip:0 error:0 Signed-off-by: Dmitry Safonov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0d16eae commit c6df7b2

File tree

3 files changed

+417
-1
lines changed

3 files changed

+417
-1
lines changed

tools/testing/selftests/net/tcp_ao/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ TEST_BOTH_AF += connect
44
TEST_BOTH_AF += connect-deny
55
TEST_BOTH_AF += icmps-accept icmps-discard
66
TEST_BOTH_AF += restore
7+
TEST_BOTH_AF += rst
78
TEST_BOTH_AF += seq-ext
89
TEST_BOTH_AF += setsockopt-closed
910
TEST_BOTH_AF += unsigned-md5

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ ssize_t test_client_loop(int sk, char *buf, size_t buf_sz,
566566

567567
got = recv(sk, msg + bytes, sizeof(msg) - bytes, 0);
568568
if (got <= 0)
569-
test_error("recv(): %zd", got);
569+
return i;
570570
bytes += got;
571571
} while (bytes < sent);
572572
if (bytes > sent)

0 commit comments

Comments
 (0)