linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] nvme: consider also host_iface when checking ip options
@ 2022-07-29 14:26 Daniel Wagner
  2022-07-30  0:41 ` Chao Leng
  2022-09-05 11:09 ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Wagner @ 2022-07-29 14:26 UTC (permalink / raw)
  To: linux-nvme; +Cc: Sagi Grimberg, Chao Leng, Daniel Wagner

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

tw:~ # nvme connect -t tcp -n nvmet-test -a 192.168.19.54 -s 4420 -f enp1s0
tw:~ # nvme connect -t tcp -n nvmet-test -a 192.168.19.54 -s 4420 -f enp1s0
Failed to write to /dev/nvme-fabrics: Operation already in progress
no controller found: failed to write to nvme-fabrics device
tw:~ # nvme connect -t tcp -n nvmet-test -a 192.168.19.54 -s 4420 
tw:~ # nvme connect -t tcp -n nvmet-test -a 192.168.19.54 -s 4420 -f enp7s0
tw:~ # nvme list-subsys
nvme-subsys0 - NQN=nvmet-test
\
 +- nvme0 tcp traddr=192.168.19.54,trsvcid=4420,host_iface=enp1s0 live optimized
 +- nvme1 tcp traddr=192.168.19.54,trsvcid=4420 live optimized
 +- nvme2 tcp traddr=192.168.19.54,trsvcid=4420,host_iface=enp7s0 live optimized

changes:
v3: same check rules as for local address
v2: added NVMF_OPT_HOST_TRADDR checks but to strict
v1: initial version

 drivers/nvme/host/fabrics.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 5207a2348257..2d948bcc31e0 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -965,13 +965,17 @@ bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
 		return false;
 
 	/*
-	 * Checking the local address is rough. In most cases, none is specified
-	 * and the host port is selected by the stack.
+	 * Checking the local address or host interfaces is rough.
+	 *
+	 * In most cases, none is specified and the host port or
+	 * host interface is selected by the stack.
 	 *
 	 * Assume no match if:
-	 * -  local address is specified and address is not the same
-	 * -  local address is not specified but remote is, or vice versa
-	 *    (admin using specific host_traddr when it matters).
+	 * -  local address or host interface is specified and address
+	 *    or host interface is not the same
+	 * -  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) &&
 	    (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) {
@@ -982,6 +986,15 @@ bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
 		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;
 }
 EXPORT_SYMBOL_GPL(nvmf_ip_options_match);
-- 
2.37.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] nvme: consider also host_iface when checking ip options
  2022-07-29 14:26 [PATCH v3] nvme: consider also host_iface when checking ip options Daniel Wagner
@ 2022-07-30  0:41 ` Chao Leng
  2022-08-23  7:47   ` Daniel Wagner
  2022-09-05 11:09 ` Christoph Hellwig
  1 sibling, 1 reply; 4+ messages in thread
From: Chao Leng @ 2022-07-30  0:41 UTC (permalink / raw)
  To: Daniel Wagner, linux-nvme; +Cc: Sagi Grimberg

Looks good to me.

Reviewed-by: Chao Leng <lengchao@huawei.com>

On 2022/7/29 22:26, Daniel Wagner wrote:
> 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>
> ---
> 
> tw:~ # nvme connect -t tcp -n nvmet-test -a 192.168.19.54 -s 4420 -f enp1s0
> tw:~ # nvme connect -t tcp -n nvmet-test -a 192.168.19.54 -s 4420 -f enp1s0
> Failed to write to /dev/nvme-fabrics: Operation already in progress
> no controller found: failed to write to nvme-fabrics device
> tw:~ # nvme connect -t tcp -n nvmet-test -a 192.168.19.54 -s 4420
> tw:~ # nvme connect -t tcp -n nvmet-test -a 192.168.19.54 -s 4420 -f enp7s0
> tw:~ # nvme list-subsys
> nvme-subsys0 - NQN=nvmet-test
> \
>   +- nvme0 tcp traddr=192.168.19.54,trsvcid=4420,host_iface=enp1s0 live optimized
>   +- nvme1 tcp traddr=192.168.19.54,trsvcid=4420 live optimized
>   +- nvme2 tcp traddr=192.168.19.54,trsvcid=4420,host_iface=enp7s0 live optimized
> 
> changes:
> v3: same check rules as for local address
> v2: added NVMF_OPT_HOST_TRADDR checks but to strict
> v1: initial version
> 
>   drivers/nvme/host/fabrics.c | 23 ++++++++++++++++++-----
>   1 file changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
> index 5207a2348257..2d948bcc31e0 100644
> --- a/drivers/nvme/host/fabrics.c
> +++ b/drivers/nvme/host/fabrics.c
> @@ -965,13 +965,17 @@ bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
>   		return false;
>   
>   	/*
> -	 * Checking the local address is rough. In most cases, none is specified
> -	 * and the host port is selected by the stack.
> +	 * Checking the local address or host interfaces is rough.
> +	 *
> +	 * In most cases, none is specified and the host port or
> +	 * host interface is selected by the stack.
>   	 *
>   	 * Assume no match if:
> -	 * -  local address is specified and address is not the same
> -	 * -  local address is not specified but remote is, or vice versa
> -	 *    (admin using specific host_traddr when it matters).
> +	 * -  local address or host interface is specified and address
> +	 *    or host interface is not the same
> +	 * -  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) &&
>   	    (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) {
> @@ -982,6 +986,15 @@ bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
>   		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;
>   }
>   EXPORT_SYMBOL_GPL(nvmf_ip_options_match);
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] nvme: consider also host_iface when checking ip options
  2022-07-30  0:41 ` Chao Leng
@ 2022-08-23  7:47   ` Daniel Wagner
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Wagner @ 2022-08-23  7:47 UTC (permalink / raw)
  To: linux-nvme; +Cc: Sagi Grimberg, Chao Leng

On Sat, Jul 30, 2022 at 08:41:51AM +0800, Chao Leng wrote:
> Looks good to me.
> 
> Reviewed-by: Chao Leng <lengchao@huawei.com>

ping


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] nvme: consider also host_iface when checking ip options
  2022-07-29 14:26 [PATCH v3] nvme: consider also host_iface when checking ip options Daniel Wagner
  2022-07-30  0:41 ` Chao Leng
@ 2022-09-05 11:09 ` Christoph Hellwig
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2022-09-05 11:09 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: linux-nvme, Sagi Grimberg, Chao Leng

Thanks,

applied to nvme-6.1.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-05 14:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-29 14:26 [PATCH v3] nvme: consider also host_iface when checking ip options Daniel Wagner
2022-07-30  0:41 ` Chao Leng
2022-08-23  7:47   ` Daniel Wagner
2022-09-05 11:09 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).