git: 34c7691f5320 - stable/14 - ktls tests: Relax error checking for shutdown(2) a bit

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 24 Nov 2023 16:37:57 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=34c7691f532064c5a3d61a115b4ea086b2da3179

commit 34c7691f532064c5a3d61a115b4ea086b2da3179
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-11-17 14:29:28 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-11-24 16:37:46 +0000

    ktls tests: Relax error checking for shutdown(2) a bit
    
    In my test suite runs I occasionally see shutdown(2) fail with
    ECONNRESET rather than ENOTCONN.  soshutdown(2) will return ENOTCONN if
    the socket has been disconnected (synchronized by the socket lock), and
    tcp_usr_shutdown() will return ECONNRESET if the inpcb has been dropped
    (synchronized by the inpcb lock).  I think it's possible to pass the
    first check in soshutdown() but fail the second check in
    tcp_usr_shutdown(), so modify the KTLS tests to permit this.
    
    Reviewed by:    jhb
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D42277
    
    (cherry picked from commit b08a9b86f581edf09c5a2729d877a0204499685b)
---
 tests/sys/kern/ktls_test.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/sys/kern/ktls_test.c b/tests/sys/kern/ktls_test.c
index a3d0c17d6d62..f57ae74112a2 100644
--- a/tests/sys/kern/ktls_test.c
+++ b/tests/sys/kern/ktls_test.c
@@ -1904,10 +1904,13 @@ test_ktls_receive_bad_size(const atf_tc_t *tc, struct tls_enable *en,
 	/*
 	 * The other end may notice the error and drop the connection
 	 * before this executes resulting in shutdown() failing with
-	 * ENOTCONN.  Ignore this error if it occurs.
+	 * either ENOTCONN or ECONNRESET.  Ignore this error if it
+	 * occurs.
 	 */
-	if (shutdown(sockets[1], SHUT_WR) != 0)
-		ATF_REQUIRE_ERRNO(ENOTCONN, true);
+	if (shutdown(sockets[1], SHUT_WR) != 0) {
+		ATF_REQUIRE_MSG(errno == ENOTCONN || errno == ECONNRESET,
+		    "shutdown() failed: %s", strerror(errno));
+	}
 
 	ktls_receive_tls_error(sockets[0], EMSGSIZE);