From f0c143b3565abdc53ee387429473d2df7c7716f7 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 20 Dec 2022 11:38:07 -0800 Subject: [PATCH] ktls_tests: Ignore spurious errors from shutdown(2). For some of the "bad size" tests, the remote end can notice the error and drop the connection before the test program returns from write to call shutdown. In that case, shutdown fails with ENOTCONN. Permit these ENOTCONN errors without failing the test. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D37693 --- tests/sys/kern/ktls_test.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/sys/kern/ktls_test.c b/tests/sys/kern/ktls_test.c index 9488ac24f4c..85998fcbdf8 100644 --- a/tests/sys/kern/ktls_test.c +++ b/tests/sys/kern/ktls_test.c @@ -1893,7 +1893,13 @@ test_ktls_receive_bad_size(const atf_tc_t *tc, struct tls_enable *en, rv = write(sockets[1], outbuf, outbuf_len); ATF_REQUIRE_INTEQ((ssize_t)outbuf_len, rv); - ATF_REQUIRE(shutdown(sockets[1], SHUT_WR) == 0); + /* + * 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. + */ + if (shutdown(sockets[1], SHUT_WR) != 0) + ATF_REQUIRE_ERRNO(ENOTCONN, true); ktls_receive_tls_error(sockets[0], EMSGSIZE);