From nobody Wed Jun 10 04:01:09 2026 X-Original-To: dev-commits-src-branches@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 4gZsX63FLwz6gv4v for ; Wed, 10 Jun 2026 04:01:10 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gZsX56HzHz3wGc for ; Wed, 10 Jun 2026 04:01:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781064069; 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=ZOw81gdieOO+3Q2tdRBNJ78ti7ubUtrt6rMF1E030vM=; b=SsQI0xlX03IYff4LBQkz0kYf5EHif2kw3MuUq3vPOqI8yh2GVeyFXvIaVmV+TcK08bz1Kb 19UoETZ3elIASX7a+ykS952UqwBr8OHB/r8m3CIUEftPlgGE94+o8dVWJZGCtSlsWE/LDJ zd24vFTps5BRu2G5fOuaM6BT1mQ+jg0ts/syhBaR+vvFzdYGLZQU1JCSXx6qkwui25PNxl UMbQHfYUuXgvTgw89HQcjzDjdzVzn2WXzRvZjCH/HtpB9Zsg8+0QHM/nWjTzhxw7U4icsY PVLqIblhs82ogUiyQe4ycL3FqV+seCjA7mb/BIPFWG88pIebKwDfl1hCOCA66Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781064069; a=rsa-sha256; cv=none; b=oxEqokJVdJI6+nrJx9iAXhY3F3X2tPMYXSjcvhKdzFyJiV8ijwkJBVov8i25icu2LNHZjO 6JbqZFtr6TP9ukflUimjS0u+JqjNrFFl9vspBpOG+zIaCurU2fKVIWitwAWhbxVKEcHfjR I40wTL7qWw84MonCnJZCTQYqvkmQRta8CjKfVDJiaHjy4RLtTJeD87PZUdxOkc0JzFtPYJ S4yJd54Im6jbfpVxmnXEw0ofN1wgWed8uw34G6sZD5iqNH6IROVnCNtSYZGXE42N9ns4Pm 4hkHmEMcTsCEqJCRNw/C5hYrK1hpizWkE2mneDNiap562DhWfKEx7GRA3e84XQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781064069; 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=ZOw81gdieOO+3Q2tdRBNJ78ti7ubUtrt6rMF1E030vM=; b=ECGW/y4zXD8qm/o+EjbQZHzKlud0mSAlERZp1EP8NZe92eJrwX2IEEKKdTz//M5SKqgxBK PESlIuFR5hFGUwzNHWKItI42UIuCdWnpNBLRXf6gCZbs2+PmYBWYpsBXnDO12AzzI918M+ ZVPxfCKduHnivqtB+/8lxx/TWemkNpxsBNOtBaE2CHvN3YK1qYror96hOhnF70R8b64Uxp 4ZPYvoJUyujJTfm5Q73wYhaP59jH6XMXNcT1YuwizzHuMcQbbkKijA7ThYJIGHH74N9/mD tmQeXYWkgpFh4SEQdX1iavTzfUZAhLHH3Jy81ddaWAVHpw+C9Dz1h5EcJ/gC9A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gZsX55rzqz13hk for ; Wed, 10 Jun 2026 04:01:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27f04 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 10 Jun 2026 04:01:09 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 4a56809bb9eb - stable/15 - ctld: kernel-sourced portal groups are not dummies List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 4a56809bb9eb59084025af83b5e3fe4e4478f143 Auto-Submitted: auto-generated Date: Wed, 10 Jun 2026 04:01:09 +0000 Message-Id: <6a28e185.27f04.7ba781d0@gitrepo.freebsd.org> The branch stable/15 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=4a56809bb9eb59084025af83b5e3fe4e4478f143 commit 4a56809bb9eb59084025af83b5e3fe4e4478f143 Author: Kyle Evans AuthorDate: 2026-04-28 20:51:50 +0000 Commit: Kyle Evans CommitDate: 2026-06-10 04:00:35 +0000 ctld: kernel-sourced portal groups are not dummies The current and historical versions of ctld would flag our initial set of kernel ports as dummies, because their portal groups were empty since portals come from the configuration on-disk. As a result, we would never try to remove a kernel port at startup that didn't exist in the configuration (possibly a feature if you wanted concurrent ctld(8)), and we would always try to port->kernel_add() on ports in the configuration (even if they actually did have an existing kernel port). Flag these portal groups as kernel groups so that we avoid trying to add ports that already exist. It may be the case that the kernel_remove() loop in conf::apply() needs to do something other than the current `oldport->is_dummy()` to avoid removing ports that it isn't supposed to be managing, but that wuld also seem to apply to LUNs that would be removed today. Reviewed by: jhb (cherry picked from commit d9c0594191f5c45d7f3c737350321ee59bfce9bf) --- usr.sbin/ctld/ctld.cc | 15 +++++++++++++++ usr.sbin/ctld/ctld.hh | 2 ++ usr.sbin/ctld/kernel.cc | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/usr.sbin/ctld/ctld.cc b/usr.sbin/ctld/ctld.cc index 331c029e282e..6ec64cc253d6 100644 --- a/usr.sbin/ctld/ctld.cc +++ b/usr.sbin/ctld/ctld.cc @@ -591,9 +591,18 @@ conf::find_transport_group(std::string_view name) return (it->second.get()); } +/* + * Foreign portal groups (which only redirect to other targets), and portal + * groups without any active portals are considered dummies and ports belonging + * to such groups are ignored. However, portal groups that exist in the kernel + * prior to ctld starting will contain real ports but no portals, so these are + * never considered dummies. + */ bool portal_group::is_dummy() const { + if (pg_kernel) + return (false); if (pg_foreign) return (true); if (pg_portals.empty()) @@ -710,6 +719,12 @@ portal_group::set_foreign() pg_foreign = true; } +void +portal_group::set_kernel() +{ + pg_kernel = true; +} + bool portal_group::set_offload(const char *offload) { diff --git a/usr.sbin/ctld/ctld.hh b/usr.sbin/ctld/ctld.hh index 3bf18f6a32c0..2e1ee7869ceb 100644 --- a/usr.sbin/ctld/ctld.hh +++ b/usr.sbin/ctld/ctld.hh @@ -220,6 +220,7 @@ struct portal_group { bool set_dscp(u_int dscp); virtual bool set_filter(const char *str) = 0; void set_foreign(); + void set_kernel(); bool set_offload(const char *offload); bool set_pcp(u_int pcp); bool set_redirection(const char *addr); @@ -248,6 +249,7 @@ protected: enum discovery_filter pg_discovery_filter = discovery_filter::UNKNOWN; bool pg_foreign = false; + bool pg_kernel = false; bool pg_assigned = false; std::list pg_portals; std::unordered_map pg_ports; diff --git a/usr.sbin/ctld/kernel.cc b/usr.sbin/ctld/kernel.cc index f2bdf53bd3ee..d1210079ca1a 100644 --- a/usr.sbin/ctld/kernel.cc +++ b/usr.sbin/ctld/kernel.cc @@ -483,6 +483,8 @@ add_iscsi_port(struct kports &kports, struct conf *conf, log_warnx("Failed to add portal-group \"%s\"", pg_name); return; } + + pg->set_kernel(); } pg->set_tag(port.cfiscsi_portal_group_tag); if (!conf->add_port(targ, pg, port.port_id)) { @@ -520,6 +522,8 @@ add_nvmf_port(struct conf *conf, const struct cctl_port &port, tg_name); return; } + + pg->set_kernel(); } pg->set_tag(port.portid); if (!conf->add_port(targ, pg, port.port_id)) {