nvme: consider also host_iface when checking ip options

It's perfectly fine to use the same traddr and trsvcid more than once
as long we use different host interface. This is used in setups where
the host has more than one interface but the target exposes only one
traddr/trsvcid combination.

Use the same acceptance rules for host_iface as we have for
host_traddr.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Chao Leng <lengchao@huawei.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Daniel Wagner 2022-07-29 16:26:30 +02:00 committed by Christoph Hellwig
parent 1c467e2595
commit 4cde03d82e
1 changed files with 18 additions and 5 deletions

View File

@ -971,13 +971,17 @@ bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
return false; return false;
/* /*
* Checking the local address is rough. In most cases, none is specified * Checking the local address or host interfaces is rough.
* and the host port is selected by the stack. *
* In most cases, none is specified and the host port or
* host interface is selected by the stack.
* *
* Assume no match if: * Assume no match if:
* - local address is specified and address is not the same * - local address or host interface is specified and address
* - local address is not specified but remote is, or vice versa * or host interface is not the same
* (admin using specific host_traddr when it matters). * - local address or host interface is not specified but
* remote is, or vice versa (admin using specific
* host_traddr/host_iface when it matters).
*/ */
if ((opts->mask & NVMF_OPT_HOST_TRADDR) && if ((opts->mask & NVMF_OPT_HOST_TRADDR) &&
(ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) { (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) {
@ -988,6 +992,15 @@ bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
return false; return false;
} }
if ((opts->mask & NVMF_OPT_HOST_IFACE) &&
(ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) {
if (strcmp(opts->host_iface, ctrl->opts->host_iface))
return false;
} else if ((opts->mask & NVMF_OPT_HOST_IFACE) ||
(ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) {
return false;
}
return true; return true;
} }
EXPORT_SYMBOL_GPL(nvmf_ip_options_match); EXPORT_SYMBOL_GPL(nvmf_ip_options_match);