git: 21e94133eb51 - main - ctld: Cleanup redundant handling of duplicate kernel ports
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 27 Jun 2026 16:07:09 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=21e94133eb51ef4eaea5bc37891741dd52d5933b
commit 21e94133eb51ef4eaea5bc37891741dd52d5933b
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-06-26 19:42:33 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-06-27 16:01:55 +0000
ctld: Cleanup redundant handling of duplicate kernel ports
Sponsored by: Chelsio Communications
---
usr.sbin/ctld/ctld.cc | 14 +-------------
usr.sbin/ctld/ctld.hh | 1 -
usr.sbin/ctld/kernel.cc | 7 +------
3 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/usr.sbin/ctld/ctld.cc b/usr.sbin/ctld/ctld.cc
index 19baa0486e44..6c027e513ee7 100644
--- a/usr.sbin/ctld/ctld.cc
+++ b/usr.sbin/ctld/ctld.cc
@@ -1069,19 +1069,7 @@ bool
kports::add_port(std::string &name, uint32_t ctl_port)
{
const auto &pair = pports.try_emplace(name, name, ctl_port);
- if (!pair.second) {
- log_warnx("duplicate kernel port \"%s\" (%u)", name.c_str(),
- ctl_port);
- return (false);
- }
-
- return (true);
-}
-
-bool
-kports::has_port(std::string_view name)
-{
- return (pports.count(std::string(name)) > 0);
+ return (pair.second);
}
struct pport *
diff --git a/usr.sbin/ctld/ctld.hh b/usr.sbin/ctld/ctld.hh
index 3bc92449e372..870e1f230c8a 100644
--- a/usr.sbin/ctld/ctld.hh
+++ b/usr.sbin/ctld/ctld.hh
@@ -574,7 +574,6 @@ private:
struct kports {
bool add_port(std::string &name, uint32_t ctl_port);
- bool has_port(std::string_view name);
struct pport *find_port(const std::string &name);
private:
diff --git a/usr.sbin/ctld/kernel.cc b/usr.sbin/ctld/kernel.cc
index 188d01052a1c..952159ee8e59 100644
--- a/usr.sbin/ctld/kernel.cc
+++ b/usr.sbin/ctld/kernel.cc
@@ -531,14 +531,9 @@ add_kernel_port(struct kports &kports, const struct cctl_port &port,
std::string &name)
{
log_debugx("CTL kernel port %u \"%s\"", port.port_id, name.c_str());
- if (kports.has_port(name)) {
+ if (!kports.add_port(name, port.port_id)) {
log_warnx("Ignoring duplicate kernel port \"%s\"",
name.c_str());
- return;
- }
-
- if (!kports.add_port(name, port.port_id)) {
- log_warnx("kports::add_port failed");
}
}