git: 3845cce70dfe - main - ktls_tests: Ignore errors from close for receive error tests.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 20 Dec 2022 19:38:57 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=3845cce70dfea11775f7ccff5290e67ade2f13aa

commit 3845cce70dfea11775f7ccff5290e67ade2f13aa
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-12-20 19:38:28 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-12-20 19:38:28 +0000

    ktls_tests: Ignore errors from close for receive error tests.
    
    For tests that send invalid data to a TLS socket to trigger read
    errors the kernel may end up dropping the connection before close is
    called at the conclusion of the test resulting in spurious ECONNRESET
    errors from close.  Ignore any errors from close for these tests.
    
    PR:             268390
    Reported by:    olivier, Michal Gulbicki <michalx.gulbicki@intel.com>
    Reviewed by:    markj
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D37717
---
 tests/sys/kern/ktls_test.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/tests/sys/kern/ktls_test.c b/tests/sys/kern/ktls_test.c
index 85998fcbdf80..60f2218ae5f2 100644
--- a/tests/sys/kern/ktls_test.c
+++ b/tests/sys/kern/ktls_test.c
@@ -284,6 +284,14 @@ close_sockets(int sv[2])
 	ATF_REQUIRE(close(sv[0]) == 0);
 }
 
+static void
+close_sockets_ignore_errors(int sv[2])
+{
+	if (sv[0] != sv[1])
+		close(sv[1]);
+	close(sv[0]);
+}
+
 static void
 fd_set_blocking(int fd)
 {
@@ -1643,7 +1651,7 @@ test_ktls_receive_corrupted_record(const atf_tc_t *tc, struct tls_enable *en,
 	free(outbuf);
 	free(plaintext);
 
-	close_sockets(sockets);
+	close_sockets_ignore_errors(sockets);
 }
 
 static void
@@ -1729,7 +1737,7 @@ test_ktls_receive_truncated_record(const atf_tc_t *tc, struct tls_enable *en,
 	free(outbuf);
 	free(plaintext);
 
-	close_sockets(sockets);
+	close_sockets_ignore_errors(sockets);
 }
 
 static void
@@ -1771,7 +1779,7 @@ test_ktls_receive_bad_major(const atf_tc_t *tc, struct tls_enable *en,
 	free(outbuf);
 	free(plaintext);
 
-	close_sockets(sockets);
+	close_sockets_ignore_errors(sockets);
 }
 
 static void
@@ -1813,7 +1821,7 @@ test_ktls_receive_bad_minor(const atf_tc_t *tc, struct tls_enable *en,
 	free(outbuf);
 	free(plaintext);
 
-	close_sockets(sockets);
+	close_sockets_ignore_errors(sockets);
 }
 
 static void
@@ -1856,7 +1864,7 @@ test_ktls_receive_bad_type(const atf_tc_t *tc, struct tls_enable *en,
 	free(outbuf);
 	free(plaintext);
 
-	close_sockets(sockets);
+	close_sockets_ignore_errors(sockets);
 }
 
 static void
@@ -1905,7 +1913,7 @@ test_ktls_receive_bad_size(const atf_tc_t *tc, struct tls_enable *en,
 
 	free(outbuf);
 
-	close_sockets(sockets);
+	close_sockets_ignore_errors(sockets);
 }
 
 #define	TLS_10_TESTS(M)							\