From 5cde509ee656141b88498726478df5c57a394926 Mon Sep 17 00:00:00 2001 From: Sagi Grimberg Date: Fri, 14 Aug 2020 13:42:37 -0700 Subject: [PATCH] nvme: add fabrics discovery controller default port number 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 Signed-off-by: Keith Busch --- common.h | 3 +++ fabrics.c | 17 +++++++++++++++++ linux/nvme.h | 1 + 3 files changed, 21 insertions(+) diff --git a/common.h b/common.h index aed2a991..1c214a44 100644 --- 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 diff --git a/fabrics.c b/fabrics.c index 78ed6251..17d969b1 100644 --- 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; diff --git a/linux/nvme.h b/linux/nvme.h index a7ab85d0..de250292 100644 --- a/linux/nvme.h +++ b/linux/nvme.h @@ -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 -- 2.50.1