linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagi@grimberg.me>
To: linux-nvme@lists.infradead.org
Cc: Christoph Hellwig <hch@lst.de>, Keith Busch <kbusch@kernel.org>,
	Daniel Wagner <dwagner@suse.de>, Hannes Reinecke <hare@suse.de>
Subject: [PATCH rfc 1/6] nvme-fabrics: add helper to resolve ipv4/ipv6 or dns name
Date: Mon, 24 Jul 2023 12:20:17 +0300	[thread overview]
Message-ID: <20230724092023.708335-2-sagi@grimberg.me> (raw)
In-Reply-To: <20230724092023.708335-1-sagi@grimberg.me>

Allow userspace to pass in traddr as a dns name as well. This may be
useful for a discovery service that may have a dns name, that may also
change in time (with an updated dns record).

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 drivers/nvme/host/fabrics.c | 28 ++++++++++++++++++++++++++++
 drivers/nvme/host/fabrics.h |  2 ++
 2 files changed, 30 insertions(+)

diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 8175d49f2909..fadd25538d1b 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -10,6 +10,7 @@
 #include <linux/mutex.h>
 #include <linux/parser.h>
 #include <linux/seq_file.h>
+#include <linux/dns_resolver.h>
 #include "nvme.h"
 #include "fabrics.h"
 
@@ -1133,6 +1134,33 @@ bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
 }
 EXPORT_SYMBOL_GPL(nvmf_ip_options_match);
 
+int nvmf_resolve_ip_address(struct nvmf_ctrl_options *opts,
+		struct sockaddr_storage *traddr)
+{
+	char *traddr_str = NULL;
+	int traddr_len;
+	int ret;
+
+	/* first check if traddr is ipv4/ipv6 address */
+	ret = inet_pton_with_scope(&init_net, AF_UNSPEC,
+			opts->traddr, opts->trsvcid, traddr);
+	if (!ret)
+		return ret;
+
+	/* second check if traddr is dns name */
+	traddr_len = dns_query(&init_net, NULL, opts->traddr,
+			strlen(opts->traddr), NULL, &traddr_str,
+			NULL, false);
+	if (traddr_len < 0)
+		return traddr_len;
+
+	ret = inet_pton_with_scope(&init_net, AF_UNSPEC,
+			traddr_str, opts->trsvcid, traddr);
+	kfree(traddr_str);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(nvmf_resolve_ip_address);
+
 static int nvmf_check_allowed_opts(struct nvmf_ctrl_options *opts,
 		unsigned int allowed_opts)
 {
diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h
index 82e7a27ffbde..603d8d176168 100644
--- a/drivers/nvme/host/fabrics.h
+++ b/drivers/nvme/host/fabrics.h
@@ -222,6 +222,8 @@ int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size);
 bool nvmf_should_reconnect(struct nvme_ctrl *ctrl);
 bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
 		struct nvmf_ctrl_options *opts);
+int nvmf_resolve_ip_address(struct nvmf_ctrl_options *opts,
+		struct sockaddr_storage *traddr);
 void nvmf_set_io_queues(struct nvmf_ctrl_options *opts, u32 nr_io_queues,
 			u32 io_queues[HCTX_MAX_TYPES]);
 void nvmf_map_queues(struct blk_mq_tag_set *set, struct nvme_ctrl *ctrl,
-- 
2.41.0



  reply	other threads:[~2023-07-24  9:20 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-24  9:20 [PATCH rfc 0/6] support traddr as dns names for ip based transports Sagi Grimberg
2023-07-24  9:20 ` Sagi Grimberg [this message]
2023-08-10 13:29   ` [PATCH rfc 1/6] nvme-fabrics: add helper to resolve ipv4/ipv6 or dns name Hannes Reinecke
2023-08-13 12:54     ` Sagi Grimberg
2023-07-24  9:20 ` [PATCH rfc 2/6] nvme-tcp: use nvmf_resolve_address helper Sagi Grimberg
2023-08-10 13:30   ` Hannes Reinecke
2023-08-13 12:55     ` Sagi Grimberg
2023-07-24  9:20 ` [PATCH rfc 3/6] nvme-tcp: re-resolve traddr upon reconnect in case it is a dns name Sagi Grimberg
2023-08-10 13:30   ` Hannes Reinecke
2023-07-24  9:20 ` [PATCH rfc 4/6] nvme-rdma: use nvmf_resolve_address helper Sagi Grimberg
2023-08-10 13:31   ` Hannes Reinecke
2023-07-24  9:20 ` [PATCH rfc 5/6] nvme-rdma: re-resolve traddr upon reconnect in case it is a dns name Sagi Grimberg
2023-08-10 13:31   ` Hannes Reinecke
2023-07-24  9:20 ` [PATCH rfc 6/6] nvme-fabrics: expose support for traddr as dns names to userspace Sagi Grimberg
2023-08-10 13:33   ` Hannes Reinecke
2023-08-13 13:07     ` Sagi Grimberg
2023-08-17  9:11       ` Sagi Grimberg
2023-08-17  9:41         ` Hannes Reinecke
2023-08-17 10:37           ` Sagi Grimberg
2023-08-17 10:48             ` Hannes Reinecke
2023-08-17 11:09               ` Sagi Grimberg
2023-08-17 14:39                 ` Daniel Wagner
2023-08-20 10:55                   ` Sagi Grimberg
2023-08-21  6:08                     ` Daniel Wagner
2023-08-21  7:44                       ` Sagi Grimberg
2023-07-24  9:20 ` [PATCH rfc libnvme 7/6] fabrics: pass traddr dns name if the kernel supports it Sagi Grimberg
2023-08-10 12:03 ` [PATCH rfc 0/6] support traddr as dns names for ip based transports Sagi Grimberg
2023-08-10 12:33   ` Daniel Wagner
2023-08-10 13:24   ` Hannes Reinecke
2023-08-10 13:29   ` Belanger, Martin
2023-08-10 13:30     ` Belanger, Martin
2023-08-10 13:34 ` Hannes Reinecke
2023-08-13 13:09   ` Sagi Grimberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230724092023.708335-2-sagi@grimberg.me \
    --to=sagi@grimberg.me \
    --cc=dwagner@suse.de \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).