Skip to contentSkip to conversation

nvme: fix cntlid uniqueness check for different hosts

PATCH In review Sagi Grimberg 2 participants 4 messages Aug 23 – Sep 11 NVMe

lore
Share & tools
lore

Sagi Grimberg

author maintainer
#0 lore raw

PATCH 1/1 nvme: fix cntlid uniqueness check for different hosts

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")
---
 drivers/nvme/host/core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/nvme/host/core.c +4 -0
index 11c24f89f4fd..86c59144da74 100644
@@ -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",
Signature · 1 line
2.43.0
author maintainer
#1 lore raw
Quoted 7 lines · Sagi Grimberg

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")

Any thoughts on this one?

#2 lore raw
In reply to Sagi Grimberg
Quoted 2 lines · Sagi Grimberg

A single physical host may use a separate {hostnqn, hostid} identifiers when connecting to a controller.

Not really. As the hostid defines a host. Linux just might be able to implement multiple hosts when it say hosts multiple containers.

Quoted 3 lines

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.

If it does so it is not spec compliant, and we should not support it.

author maintainer
#3 lore raw
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Sagi Grimberg

A single physical host may use a separate {hostnqn, hostid} identifiers when connecting to a controller.

Not really. As the hostid defines a host. Linux just might be able to implement multiple hosts when it say hosts multiple containers.

Well, from the subsystem perspective, it is a separate host.

Quoted 5 lines
Quoted 4 lines

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.

If it does so it is not spec compliant, and we should not support it.

Hmm, interesting. It didn't occur to me that the cross-hosts controller IDs are meaningful in any way.. The issue is that if a host connects to multiple subsystem ports (say 16 for multipath), and also may use multiple hostnqn/hostid pairs, the available number of cntlids starts dropping very quickly given that there are only 16 bits in cntlid.

I am wandering if this issue was observed by others.