[PATCH rfc libnvme 7/6] fabrics: pass traddr dns name if the kernel supports it

Sagi Grimberg sagi at grimberg.me
Mon Jul 24 02:20:23 PDT 2023


If the kernel supports dns names as traddr (i.e. able to query the dns to
resolve the ip address), pass the dns name down to the kernel.

The advantage is that if the dns resolution changes to a different ip
address, the kernel will be able to reconnect.

Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
 src/nvme/fabrics.c | 10 ++++++----
 src/nvme/private.h |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c
index 2a9d8dc7f23a..0e9b4a15858b 100644
--- a/src/nvme/fabrics.c
+++ b/src/nvme/fabrics.c
@@ -736,6 +736,7 @@ static  int __nvmf_supported_options(nvme_root_t r)
 		parse_option(r, v, traddr);
 		parse_option(r, v, transport);
 		parse_option(r, v, trsvcid);
+		parse_option(r, v, dns_ip_traddr);
 	}
 	nvme_msg(r, LOG_DEBUG, "\n");
 	ret = 0;
@@ -900,8 +901,12 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,
 		}
 	}
 
+	ret = __nvmf_supported_options(h->r);
+	if (ret)
+		return ret;
+
 	nvme_ctrl_set_discovered(c, true);
-	if (traddr_is_hostname(h->r, c)) {
+	if (traddr_is_hostname(h->r, c) && !h->r->options->dns_ip_traddr) {
 		char *traddr = c->traddr;
 
 		c->traddr = hostname2traddr(h->r, traddr);
@@ -913,9 +918,6 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,
 		free(traddr);
 	}
 
-	ret = __nvmf_supported_options(h->r);
-	if (ret)
-		return ret;
 	ret = build_options(h, c, &argstr);
 	if (ret)
 		return ret;
diff --git a/src/nvme/private.h b/src/nvme/private.h
index f4992a48a41e..e58736b1e18d 100644
--- a/src/nvme/private.h
+++ b/src/nvme/private.h
@@ -152,6 +152,7 @@ struct nvme_fabric_options {
 	bool traddr;
 	bool transport;
 	bool trsvcid;
+	bool dns_ip_traddr;
 };
 
 struct nvme_root {
-- 
2.41.0




More information about the Linux-nvme mailing list