git: 1a26ebd6d5b3 - stable/13 - ktls_test: Add a require_toe option similar to require_ifnet.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 25 Aug 2022 17:31:35 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=1a26ebd6d5b3d86870f91fac3e23573ae6e840ae

commit 1a26ebd6d5b3d86870f91fac3e23573ae6e840ae
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-08-08 18:21:54 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-08-25 16:33:57 +0000

    ktls_test: Add a require_toe option similar to require_ifnet.
    
    This skips tests that send and receive records that do not use TOE TLS.
    
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit cc13c98302f6d73ab0b0ea81e2b7ef84297057b3)
---
 tests/sys/kern/ktls_test.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tests/sys/kern/ktls_test.c b/tests/sys/kern/ktls_test.c
index b36de88adfa2..488b98725d09 100644
--- a/tests/sys/kern/ktls_test.c
+++ b/tests/sys/kern/ktls_test.c
@@ -81,6 +81,18 @@ check_tls_mode(const atf_tc_t *tc, int s, int sockopt)
 		if (mode != TCP_TLS_MODE_IFNET)
 			atf_tc_skip("connection did not use ifnet TLS");
 	}
+
+	if (atf_tc_get_config_var_as_bool_wd(tc, "ktls.require_toe", false)) {
+		socklen_t len;
+		int mode;
+
+		len = sizeof(mode);
+		if (getsockopt(s, IPPROTO_TCP, sockopt, &mode, &len) == -1)
+			atf_libc_error(errno, "Failed to fetch TLS mode");
+
+		if (mode != TCP_TLS_MODE_TOE)
+			atf_tc_skip("connection did not use TOE TLS");
+	}
 }
 
 static char