git: 76363a797043 - main - Revert "tests/ktls: merge two sysctl checking helpers into one"

Gleb Smirnoff <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a68112e.4545e.3dfe4148__45892.1946630412$1785205057$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=76363a797043aa2dbbcb0e589146b5002033905a

commit 76363a797043aa2dbbcb0e589146b5002033905a
Author:     Gleb Smirnoff <[email protected]>
AuthorDate: 2026-07-28 02:16:39 +0000
Commit:     Gleb Smirnoff <[email protected]>
CommitDate: 2026-07-28 02:16:39 +0000

    Revert "tests/ktls: merge two sysctl checking helpers into one"
    
    With certain sysctl configuration the test will fail.
    
    This reverts commit 801c0f383c0a719165c21ff5c29f231fb7b920c4.
---
 tests/sys/kern/ktls_test.c | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/tests/sys/kern/ktls_test.c b/tests/sys/kern/ktls_test.c
index 5cb1a084271b..e0bcf17262f2 100644
--- a/tests/sys/kern/ktls_test.c
+++ b/tests/sys/kern/ktls_test.c
@@ -51,26 +51,45 @@
 #include <openssl/hmac.h>
 
 static void
-require_ktls(bool need_rx)
+require_ktls(void)
 {
-	const char *name = need_rx ? "kern.ipc.tls.rx_enable" :
-	    "kern.ipc.tls.enable";
 	size_t len;
 	bool enable;
 
 	len = sizeof(enable);
-	if (sysctlbyname(name, &enable, &len, NULL, 0) == -1) {
+	if (sysctlbyname("kern.ipc.tls.enable", &enable, &len, NULL, 0) == -1) {
 		if (errno == ENOENT)
 			atf_tc_skip("kernel does not support TLS offload");
-		atf_libc_error(errno, "Failed to read %s", name);
+		atf_libc_error(errno, "Failed to read kern.ipc.tls.enable");
 	}
 
 	if (!enable)
-		atf_tc_skip("Kernel TLS%s is disabled", need_rx ? " RX" : "");
+		atf_tc_skip("Kernel TLS is disabled");
 }
 
-#define	ATF_REQUIRE_KTLS()	require_ktls(false)
-#define	ATF_REQUIRE_KTLS_RX()	require_ktls(true)
+#define	ATF_REQUIRE_KTLS()	require_ktls()
+
+static void
+require_ktls_rx(void)
+{
+	size_t len;
+	bool enable;
+
+	ATF_REQUIRE_KTLS();
+
+	len = sizeof(enable);
+	if (sysctlbyname("kern.ipc.tls.rx_enable", &enable, &len, NULL, 0) ==
+	    -1) {
+		if (errno == ENOENT)
+			atf_tc_skip("kernel does not support TLS offload");
+		atf_libc_error(errno, "Failed to read kern.ipc.tls.rx_enable");
+	}
+
+	if (!enable)
+		atf_tc_skip("Kernel TLS receive is disabled");
+}
+
+#define	ATF_REQUIRE_KTLS_RX()	require_ktls_rx()
 
 static void
 check_tls_mode(const atf_tc_t *tc, int s, int sockopt)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.