Re: git: 801c0f383c0a - main - tests/ktls: merge two sysctl checking helpers into one
Mark Johnston <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.cvs.src |
|---|---|
| Message-ID | <amejLHdPuiAQ6rpE__25443.7083889329$1785176892$gmane$org@nuc> |
On Mon, Jul 27, 2026 at 05:32:02PM +0000, Gleb Smirnoff wrote: > The branch main has been updated by glebius: > > URL: https://cgit.FreeBSD.org/src/commit/?id=801c0f383c0a719165c21ff5c29f231fb7b920c4 > > commit 801c0f383c0a719165c21ff5c29f231fb7b920c4 > Author: Gleb Smirnoff <[email protected]> > AuthorDate: 2026-07-27 17:31:24 +0000 > Commit: Gleb Smirnoff <[email protected]> > CommitDate: 2026-07-27 17:31:24 +0000 > > tests/ktls: merge two sysctl checking helpers into one > > No functional change. > --- > tests/sys/kern/ktls_test.c | 35 ++++++++--------------------------- > 1 file changed, 8 insertions(+), 27 deletions(-) > > diff --git a/tests/sys/kern/ktls_test.c b/tests/sys/kern/ktls_test.c > index e0bcf17262f2..5cb1a084271b 100644 > --- a/tests/sys/kern/ktls_test.c > +++ b/tests/sys/kern/ktls_test.c > @@ -51,45 +51,26 @@ > #include <openssl/hmac.h> > > static void > -require_ktls(void) > +require_ktls(bool need_rx) > { > + const char *name = need_rx ? "kern.ipc.tls.rx_enable" : > + "kern.ipc.tls.enable"; > size_t len; > bool enable; > > len = sizeof(enable); > - if (sysctlbyname("kern.ipc.tls.enable", &enable, &len, NULL, 0) == -1) { > + if (sysctlbyname(name, &enable, &len, NULL, 0) == -1) { Now, if someone sets kern.ipc.tls.enable=0 to disable both RX and TX KTLS, but leaves kern.ipc.tls.rx_enable set to the default value, all of the tests will fail instead of being skipped. > if (errno == ENOENT) > atf_tc_skip("kernel does not support TLS offload"); > - atf_libc_error(errno, "Failed to read kern.ipc.tls.enable"); > + atf_libc_error(errno, "Failed to read %s", name); > } > > if (!enable) > - atf_tc_skip("Kernel TLS is disabled"); > + atf_tc_skip("Kernel TLS%s is disabled", need_rx ? " RX" : ""); > } > > -#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() > +#define ATF_REQUIRE_KTLS() require_ktls(false) > +#define ATF_REQUIRE_KTLS_RX() require_ktls(true) > > static void > check_tls_mode(const atf_tc_t *tc, int s, int sockopt) >