[PATCH] nvme: fix cntlid uniqueness check for different hosts

Sagi Grimberg sagi at grimberg.me
Sat Aug 22 17:15:09 PDT 2026


A single physical host may use a separate {hostnqn, hostid} identifiers
when connecting to a controller. It is possible that the a distributed
nvmf controller may generate unique cntlid per hostnqn and not globally
unique. Hence, validate the cntlid is unique per nvmf host.

Fixes: 1b1031ca63b2 ("nvme: validate cntlid during controller initialisation")
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
 drivers/nvme/host/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 11c24f89f4fd..86c59144da74 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3265,6 +3265,10 @@ static bool nvme_validate_cntlid(struct nvme_subsystem *subsys,
 		if (nvme_state_terminal(tmp))
 			continue;
 
+		if ((ctrl->ops->flags & NVME_F_FABRICS) &&
+		    !nvmf_ctlr_matches_baseopts(tmp, ctrl->opts))
+			continue;
+
 		if (tmp->cntlid == ctrl->cntlid) {
 			dev_err(ctrl->device,
 				"Duplicate cntlid %u with %s, subsys %s, rejecting\n",
-- 
2.43.0




More information about the Linux-nvme mailing list