Skip to contentSkip to conversation

nvme-fabrics: restrict host_iface options match criteria

PATCH New Daniel Wagner 1 participant 1 message Jul 22, 2022 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-fabrics: restrict host_iface options match criteria

Enforce consistent use of host_iface in setups where the hosts has several networking interface and the target just one. That means the user needs to set the host_iface for all connections in such scenarios.

This keeps the match logic simple and also avoids passing in invalid pointers to strcmp.

Fixes 4e9499337d40 ("nvme-fabrics: consider also host_iface when checking ip options")
---
 drivers/nvme/host/fabrics.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/host/fabrics.c +3 -1
index 01e96322e363..fb054929553c 100644
@@ -962,7 +962,9 @@ bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
 	if (!nvmf_ctlr_matches_baseopts(ctrl, opts) ||
 	    strcmp(opts->traddr, ctrl->opts->traddr) ||
 	    strcmp(opts->trsvcid, ctrl->opts->trsvcid) ||
-	    strcmp(opts->host_iface, ctrl->opts->host_iface))
+	    (((opts->mask & NVMF_OPT_HOST_IFACE) &&
+	      (ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) &&
+	       strcmp(opts->host_iface, ctrl->opts->host_iface)))
 		return false;
 
 	/*
Signature · 1 line
2.37.1