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

Sagi Grimberg <[email protected]>
Newsgroups org.infradead.lists.linux-nvme
Message-ID <[email protected]>
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 <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.