]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: add fabrics discovery controller default port number
authorSagi Grimberg <sagi@grimberg.me>
Fri, 14 Aug 2020 20:42:37 +0000 (13:42 -0700)
committerKeith Busch <kbusch@kernel.org>
Wed, 19 Aug 2020 16:54:31 +0000 (09:54 -0700)
The IANA port number for a discovery controller is 8009
for NVMe/TCP and 4420 for any NVMe/RDMA port number. So make
sure to fill it and pass it down, it will help us as we
track and match connection arguments for filtering purposes.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>
common.h
fabrics.c
linux/nvme.h

index aed2a9918b2356b502e168b68de442c792bf1460..1c214a447fd36cb393f08b84317ac23312fc6184 100644 (file)
--- a/common.h
+++ b/common.h
@@ -9,4 +9,7 @@
 #define min(x, y) ((x) > (y) ? (y) : (x))
 #define max(x, y) ((x) > (y) ? (x) : (y))
 
+#define __stringify_1(x...) #x
+#define __stringify(x...)  __stringify_1(x)
+
 #endif
index 78ed6251f8a62eff719005568c8b19712b4fade5..17d969b17dd59694febcb7ac4b05416a36b2f000 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -863,6 +863,17 @@ static int build_options(char *argstr, int max_len, bool discover)
        return 0;
 }
 
+static void discovery_trsvcid(struct config *cfg)
+{
+       if (!strcmp(cfg->transport, "tcp")) {
+               /* Default port for NVMe/TCP discovery controllers */
+               cfg->trsvcid = __stringify(NVME_DISC_IP_PORT);
+       } else if (!strcmp(cfg->transport, "rdma")) {
+               /* Default port for NVMe/RDMA controllers */
+               cfg->trsvcid = __stringify(NVME_RDMA_IP_PORT);
+       }
+}
+
 static bool traddr_is_hostname(struct config *cfg)
 {
        char addrstr[NVMF_TRADDR_SIZE];
@@ -1320,6 +1331,9 @@ static int discover_from_conf_file(const char *desc, char *argstr,
                                goto out;
                }
 
+               if (!cfg.trsvcid)
+                       discovery_trsvcid(&cfg);
+
                err = build_options(argstr, BUF_SIZE, true);
                if (err) {
                        ret = err;
@@ -1392,6 +1406,9 @@ int fabrics_discover(const char *desc, int argc, char **argv, bool connect)
                                goto out;
                }
 
+               if (!cfg.trsvcid)
+                       discovery_trsvcid(&cfg);
+
                ret = build_options(argstr, BUF_SIZE, true);
                if (ret)
                        goto out;
index a7ab85d03067b312144d5a5fbcbd94898a5f9f69..de2502929ebb67b06f92d6a46e69d446723536a4 100644 (file)
@@ -70,6 +70,7 @@ static inline uint64_t le64_to_cpu(__le64 x)
 #define NVME_DISC_SUBSYS_NAME  "nqn.2014-08.org.nvmexpress.discovery"
 
 #define NVME_RDMA_IP_PORT      4420
+#define NVME_DISC_IP_PORT      8009
 
 #define NVME_NSID_ALL          0xffffffff