From nobody Mon Oct 13 19:49:16 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4clnwr27Qyz6CGNg; Mon, 13 Oct 2025 19:49:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4clnwr1VPWz3L0f; Mon, 13 Oct 2025 19:49:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760384956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MG2ZuDUzjW/vs6Kjy3GsFh/QTtxJNcwtADtCiDgatKw=; b=aHsO3ioo6U6UtIJ0QWg/Ur7K4cfigC/7YbN3I72/BAe5FIdwFAbsZKaxzdWamYWIkp475m zr7AHWmUHXhVqYX37+xLsLWSgs2OjbG7NyiUy48Udv8M0C/5HS2WvQyykegK0YBPTf+YSC I6S1xhLzLcSwe8/9laEboPUi8D+S9zoCRmaz9K0j7NfVGNNfD4s/aD3NLdSWkuhTx/vXSs GL4AV5trtFr5k9Zo4u76uSjJJ4RfNCZQ/908DGJquNbLyI/R2eBrZ8AEXrmg3ITmLQJ0T9 PQjuGwpu5otvlv/SGGypxMoiZlMTh3HBK+JOUn5lr+yiz2soppvdklmf/Ldc2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760384956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MG2ZuDUzjW/vs6Kjy3GsFh/QTtxJNcwtADtCiDgatKw=; b=ee4BV2iGjVoDOExvviBqlwbNKf7anoOmoKb605K5FHdasQok+QirY6XMU1mp3Xcgu77Uiy 8P6laD8N2sQG5ILKsstqj60w+GrQFAgUdTZ7HVIj12WBeHWWTxT/ImOjVglKbzZKNjIVPN dMqcs7v0pTjkDpzQiDsPpJ1fBIdmBiRQMhw/C/tPer4/exKdWItUF77jVIg6fI74OAUhHi HOHmkRYmWEbbqsZEDCHMr4f+5FGytn/sGq8yw5zWZR912gXxxWg3LKpEEhjsutitq5MyA+ 811NQWEoeq5ybLwPx50dFWlZvFdYKtadA6ZxhWn0Qe24N4P5FvRauojiGc3kiA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760384956; a=rsa-sha256; cv=none; b=ifrC3SNZu65mE3+1XvqJap80gbTKh7pv/WbCL819NcNnI+HvRVJ4pDvt/BgXxLFEzLTuPX 20pq7TQiMHJAnpnS3j+BzCPsT9E3UFU8iIppGQv63SJXkRHVbF0aNQsA5oVOzI1bwydHkm 4+2jd/HQwMKfMwMZSH3+VcVSI5n8AfSPVYuiM8XAL1yjuZ28Lm3/EktmEOaxetAsPKronP wEFPD+lcr5hU9LklhwuAJ2TEaTawcHgmuzo8Uqu2Ms5QKYv0qcGOyYFBFuJrlZVyjpyFhJ imtEszA77GphUFlCq0xNKMfoG7yH2mUKuTjA35bCMfPrGvIcdTqBhUH37WQ3EQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4clnwr12D3z5lK; Mon, 13 Oct 2025 19:49:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 59DJnGnd039288; Mon, 13 Oct 2025 19:49:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59DJnG0T039285; Mon, 13 Oct 2025 19:49:16 GMT (envelope-from git) Date: Mon, 13 Oct 2025 19:49:16 GMT Message-Id: <202510131949.59DJnG0T039285@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: be1ad90e6bb6 - main - tcp: Initial ktest for HPTS List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: be1ad90e6bb6ea915d122f7abe407dc18d38a673 Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=be1ad90e6bb6ea915d122f7abe407dc18d38a673 commit be1ad90e6bb6ea915d122f7abe407dc18d38a673 Author: Nick Banks AuthorDate: 2025-10-13 19:47:31 +0000 Commit: Michael Tuexen CommitDate: 2025-10-13 19:47:31 +0000 tcp: Initial ktest for HPTS Reviewed by: rrs, tuexen Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D52979 --- sys/modules/ktest/Makefile | 3 +- sys/modules/ktest/ktest_tcphpts/Makefile | 13 ++++++ sys/netinet/tcp_hpts_test.c | 76 ++++++++++++++++++++++++++++++++ sys/tests/ktest.h | 3 ++ tests/atf_python/ktest.py | 12 ++++- tests/sys/netinet/Makefile | 1 + tests/sys/netinet/tcp_hpts_test.py | 4 ++ 7 files changed, 109 insertions(+), 3 deletions(-) diff --git a/sys/modules/ktest/Makefile b/sys/modules/ktest/Makefile index a3052efa9ed9..d5f15576f38b 100644 --- a/sys/modules/ktest/Makefile +++ b/sys/modules/ktest/Makefile @@ -1,5 +1,6 @@ SUBDIR= ktest \ ktest_example \ - ktest_netlink_message_writer + ktest_netlink_message_writer \ + ktest_tcphpts .include diff --git a/sys/modules/ktest/ktest_tcphpts/Makefile b/sys/modules/ktest/ktest_tcphpts/Makefile new file mode 100644 index 000000000000..b642c0cb4209 --- /dev/null +++ b/sys/modules/ktest/ktest_tcphpts/Makefile @@ -0,0 +1,13 @@ +PACKAGE= tests +WARNS?= 6 + +SYSDIR?=${SRCTOP}/sys +.include "${SYSDIR}/conf/kern.opts.mk" + +.PATH: ${SYSDIR}/netinet + +KMOD= ktest_tcphpts +SRCS= tcp_hpts_test.c + +.include + diff --git a/sys/netinet/tcp_hpts_test.c b/sys/netinet/tcp_hpts_test.c new file mode 100644 index 000000000000..085da37e44c8 --- /dev/null +++ b/sys/netinet/tcp_hpts_test.c @@ -0,0 +1,76 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 Netflix, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#define _WANT_INPCB +#include +#include +#define _WANT_TCPCB +#include +#include +#include +#include + +#define KTEST_ERR(_ctx, _fmt, ...) \ + KTEST_LOG_LEVEL(_ctx, LOG_ERR, _fmt, ## __VA_ARGS__) + +#define KTEST_VERIFY(x) do { \ + if (!(x)) { \ + KTEST_ERR(ctx, "FAIL: %s", #x); \ + return (EINVAL); \ + } else { \ + KTEST_LOG(ctx, "PASS: %s", #x); \ + } \ +} while (0) + +static int +test_hpts_init(struct ktest_test_context *ctx) +{ + /* TODO: Refactor HPTS code so that it may be tested. */ + KTEST_VERIFY(tcp_min_hptsi_time != 0); + return (0); +} + +static const struct ktest_test_info tests[] = { + { + .name = "test_hpts_init", + .desc = "Tests HPTS initialization and cleanup", + .func = &test_hpts_init, + }, +}; + +KTEST_MODULE_DECLARE(ktest_tcphpts, tests); +KTEST_MODULE_DEPEND(ktest_tcphpts, tcphpts); diff --git a/sys/tests/ktest.h b/sys/tests/ktest.h index c767aa31e8e5..8af92f1e0c18 100644 --- a/sys/tests/ktest.h +++ b/sys/tests/ktest.h @@ -104,6 +104,9 @@ MODULE_VERSION(ktest_##_n, 1); \ MODULE_DEPEND(ktest_##_n, ktestmod, 1, 1, 1); \ MODULE_DEPEND(ktest_##_n, netlink, 1, 1, 1); \ +#define KTEST_MODULE_DEPEND(_n, _d) \ +MODULE_DEPEND(ktest_##_n, _d, 1, 1, 1); \ + #endif /* _KERNEL */ /* genetlink definitions */ diff --git a/tests/atf_python/ktest.py b/tests/atf_python/ktest.py index a18f47d1dd06..a671aaa1fd4c 100644 --- a/tests/atf_python/ktest.py +++ b/tests/atf_python/ktest.py @@ -67,6 +67,10 @@ class KtestLoader(object): def __init__(self, module_name: str, autoload: bool): self.module_name = module_name self.autoload = autoload + # Ensure the base ktest.ko module is loaded + result = libc.kldload("ktest") + if result != 0 and result != 17: # 17 is EEXIST (already loaded) + logger.debug(f"Failed to load base ktest module (error {result})") self.helper = NlHelper() self.nlsock = Nlsock(NlConst.NETLINK_GENERIC, self.helper) self.family_id = self._get_family_id() @@ -76,7 +80,9 @@ class KtestLoader(object): family_id = self.nlsock.get_genl_family_id(NETLINK_FAMILY) except ValueError: if self.autoload: - libc.kldload(self.module_name) + result = libc.kldload(self.module_name) + if result != 0 and result != 17: # 17 is EEXIST (already loaded) + raise RuntimeError(f"Failed to load kernel module '{self.module_name}' (error {result})") family_id = self.nlsock.get_genl_family_id(NETLINK_FAMILY) else: raise @@ -103,7 +109,9 @@ class KtestLoader(object): def load_ktests(self): ret = self._load_ktests() if not ret and self.autoload: - libc.kldload(self.module_name) + result = libc.kldload(self.module_name) + if result != 0 and result != 17: # 17 is EEXIST (already loaded) + raise RuntimeError(f"Failed to load kernel module '{self.module_name}' (error {result})") ret = self._load_ktests() return ret diff --git a/tests/sys/netinet/Makefile b/tests/sys/netinet/Makefile index b742342beecb..9739221676ce 100644 --- a/tests/sys/netinet/Makefile +++ b/tests/sys/netinet/Makefile @@ -30,6 +30,7 @@ ATF_TESTS_SH= arp \ ATF_TESTS_PYTEST+= carp.py ATF_TESTS_PYTEST+= igmp.py +ATF_TESTS_PYTEST+= tcp_hpts_test.py LIBADD.so_reuseport_lb_test= pthread LIBADD.udp_bindings= pthread diff --git a/tests/sys/netinet/tcp_hpts_test.py b/tests/sys/netinet/tcp_hpts_test.py new file mode 100644 index 000000000000..c56383fb310f --- /dev/null +++ b/tests/sys/netinet/tcp_hpts_test.py @@ -0,0 +1,4 @@ +from atf_python.ktest import BaseKernelTest + +class TestTcpHpts(BaseKernelTest): + KTEST_MODULE_NAME = "ktest_tcphpts"