* [PATCH v4] nvme-tcp: Print actual source IP address through sysfs "address" attr
@ 2022-09-07 12:27 Martin Belanger
2022-09-07 14:52 ` Chaitanya Kulkarni
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Martin Belanger @ 2022-09-07 12:27 UTC (permalink / raw)
To: linux-nvme; +Cc: kbusch, hare, axboe, hch, sagi, Martin Belanger
From: Martin Belanger <martin.belanger@dell.com>
TCP transport relies on the routing table to determine which source
address and interface to use when making a connection. Currently, there
is no way to tell from userspace where a connection was made. This
patch exposes the actual source address using a new field named
"src_addr=" in the "address" attribute.
This is needed to diagnose and identify connectivity issues. With the
source address we can infer the interface associated with each
connection.
This was tested with nvme-cli 2.0 to verify it does not have any
adverse effect. The new "src_addr=" field will simply be displayed in
the output of the "list-subsys" or "list -v" commands as shown here.
$ nvme list-subsys
nvme-subsys0 - NQN=nqn.2014-08.org.nvmexpress.discovery
\
+- nvme0 tcp traddr=192.168.56.1,trsvcid=8009,src_addr=192.168.56.101 live
Changes to v3:
Per Chaitanya review comments: Change the order of the variables
declaration. And although len can never be 0, for completeness add a
check (lev > 0) before decrementing its value.
Changes to v2:
Taken Sagi's comments into account
Changes to original submission:
Reword comments per Chaitanya's suggestion
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
---
drivers/nvme/host/tcp.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 044da18c06f5..e1e77de17f66 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -2532,6 +2532,25 @@ static int nvme_tcp_poll(struct blk_mq_hw_ctx *hctx, struct io_comp_batch *iob)
return queue->nr_cqe;
}
+static int nvme_tcp_get_address(struct nvme_ctrl *ctrl, char *buf, int size)
+{
+ struct nvme_tcp_queue *queue = &to_tcp_ctrl(ctrl)->queues[0];
+ struct sockaddr_storage src_addr;
+ int ret, len;
+
+ len = nvmf_get_address(ctrl, buf, size);
+
+ ret = kernel_getsockname(queue->sock, (struct sockaddr *)&src_addr);
+ if (ret > 0) {
+ if (len > 0)
+ len--; /* strip trailing newline */
+ len += scnprintf(buf + len, size - len, "%ssrc_addr=%pISc\n",
+ (len) ? "," : "", &src_addr);
+ }
+
+ return len;
+}
+
static const struct blk_mq_ops nvme_tcp_mq_ops = {
.queue_rq = nvme_tcp_queue_rq,
.commit_rqs = nvme_tcp_commit_rqs,
@@ -2563,7 +2582,7 @@ static const struct nvme_ctrl_ops nvme_tcp_ctrl_ops = {
.free_ctrl = nvme_tcp_free_ctrl,
.submit_async_event = nvme_tcp_submit_async_event,
.delete_ctrl = nvme_tcp_delete_ctrl,
- .get_address = nvmf_get_address,
+ .get_address = nvme_tcp_get_address,
.stop_ctrl = nvme_tcp_stop_ctrl,
};
--
2.37.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4] nvme-tcp: Print actual source IP address through sysfs "address" attr
2022-09-07 12:27 [PATCH v4] nvme-tcp: Print actual source IP address through sysfs "address" attr Martin Belanger
@ 2022-09-07 14:52 ` Chaitanya Kulkarni
2022-09-08 7:18 ` Hannes Reinecke
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Chaitanya Kulkarni @ 2022-09-07 14:52 UTC (permalink / raw)
To: Martin Belanger, linux-nvme@lists.infradead.org
Cc: kbusch@kernel.org, hare@suse.de, axboe@fb.com, hch@lst.de,
sagi@grimberg.me, Martin Belanger
On 9/7/22 05:27, Martin Belanger wrote:
> From: Martin Belanger <martin.belanger@dell.com>
>
> TCP transport relies on the routing table to determine which source
> address and interface to use when making a connection. Currently, there
> is no way to tell from userspace where a connection was made. This
> patch exposes the actual source address using a new field named
> "src_addr=" in the "address" attribute.
>
> This is needed to diagnose and identify connectivity issues. With the
> source address we can infer the interface associated with each
> connection.
>
> This was tested with nvme-cli 2.0 to verify it does not have any
> adverse effect. The new "src_addr=" field will simply be displayed in
> the output of the "list-subsys" or "list -v" commands as shown here.
>
> $ nvme list-subsys
> nvme-subsys0 - NQN=nqn.2014-08.org.nvmexpress.discovery
> \
> +- nvme0 tcp traddr=192.168.56.1,trsvcid=8009,src_addr=192.168.56.101 live
>
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
-ck
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] nvme-tcp: Print actual source IP address through sysfs "address" attr
2022-09-07 12:27 [PATCH v4] nvme-tcp: Print actual source IP address through sysfs "address" attr Martin Belanger
2022-09-07 14:52 ` Chaitanya Kulkarni
@ 2022-09-08 7:18 ` Hannes Reinecke
2022-09-12 12:24 ` Sagi Grimberg
2022-09-19 15:41 ` Christoph Hellwig
3 siblings, 0 replies; 5+ messages in thread
From: Hannes Reinecke @ 2022-09-08 7:18 UTC (permalink / raw)
To: Martin Belanger, linux-nvme; +Cc: kbusch, axboe, hch, sagi, Martin Belanger
On 9/7/22 14:27, Martin Belanger wrote:
> From: Martin Belanger <martin.belanger@dell.com>
>
> TCP transport relies on the routing table to determine which source
> address and interface to use when making a connection. Currently, there
> is no way to tell from userspace where a connection was made. This
> patch exposes the actual source address using a new field named
> "src_addr=" in the "address" attribute.
>
> This is needed to diagnose and identify connectivity issues. With the
> source address we can infer the interface associated with each
> connection.
>
> This was tested with nvme-cli 2.0 to verify it does not have any
> adverse effect. The new "src_addr=" field will simply be displayed in
> the output of the "list-subsys" or "list -v" commands as shown here.
>
> $ nvme list-subsys
> nvme-subsys0 - NQN=nqn.2014-08.org.nvmexpress.discovery
> \
> +- nvme0 tcp traddr=192.168.56.1,trsvcid=8009,src_addr=192.168.56.101 live
>
> Changes to v3:
> Per Chaitanya review comments: Change the order of the variables
> declaration. And although len can never be 0, for completeness add a
> check (lev > 0) before decrementing its value.
>
> Changes to v2:
> Taken Sagi's comments into account
>
> Changes to original submission:
> Reword comments per Chaitanya's suggestion
>
> Signed-off-by: Martin Belanger <martin.belanger@dell.com>
> ---
> drivers/nvme/host/tcp.c | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] nvme-tcp: Print actual source IP address through sysfs "address" attr
2022-09-07 12:27 [PATCH v4] nvme-tcp: Print actual source IP address through sysfs "address" attr Martin Belanger
2022-09-07 14:52 ` Chaitanya Kulkarni
2022-09-08 7:18 ` Hannes Reinecke
@ 2022-09-12 12:24 ` Sagi Grimberg
2022-09-19 15:41 ` Christoph Hellwig
3 siblings, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2022-09-12 12:24 UTC (permalink / raw)
To: Martin Belanger, linux-nvme; +Cc: kbusch, hare, axboe, hch, Martin Belanger
OK...
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] nvme-tcp: Print actual source IP address through sysfs "address" attr
2022-09-07 12:27 [PATCH v4] nvme-tcp: Print actual source IP address through sysfs "address" attr Martin Belanger
` (2 preceding siblings ...)
2022-09-12 12:24 ` Sagi Grimberg
@ 2022-09-19 15:41 ` Christoph Hellwig
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2022-09-19 15:41 UTC (permalink / raw)
To: Martin Belanger
Cc: linux-nvme, kbusch, hare, axboe, hch, sagi, Martin Belanger
Thanks,
applied to nvme-6.1.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-09-19 15:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-07 12:27 [PATCH v4] nvme-tcp: Print actual source IP address through sysfs "address" attr Martin Belanger
2022-09-07 14:52 ` Chaitanya Kulkarni
2022-09-08 7:18 ` Hannes Reinecke
2022-09-12 12:24 ` Sagi Grimberg
2022-09-19 15:41 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox