]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
fabrics: add default port number for NVMe/TCP I/O controllers
authorMartin George <marting@netapp.com>
Fri, 6 Aug 2021 12:05:20 +0000 (17:35 +0530)
committerKeith Busch <kbusch@kernel.org>
Fri, 6 Aug 2021 20:09:24 +0000 (14:09 -0600)
As per section 7.4.9.3 "Transport Service Identifier" of the NVMe over
Fabrics 1.1 specification, the default IANA port number for a NVMe/TCP
discovery controller is 8009. But at the same time, it also clearly
states that NVMe/TCP I/O controllers should not use TCP port number
8009, but may instead use 4420 as the default here.

So make sure to fill these values appropriately, and pass it down.

Signed-off-by: Martin George <marting@netapp.com>
fabrics.c

index 4d75ced1af8fba2fa8f44203fb202d3eddc16597..39bee97c008ec6549c1ad0f2a3eeb0d02215e735 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -1064,11 +1064,16 @@ static void set_discovery_kato(struct fabrics_config *cfg)
                cfg->keep_alive_tmo = 0;
 }
 
-static void discovery_trsvcid(struct fabrics_config *fabrics_cfg)
+static void discovery_trsvcid(struct fabrics_config *fabrics_cfg, bool discover)
 {
        if (!strcmp(fabrics_cfg->transport, "tcp")) {
-               /* Default port for NVMe/TCP discovery controllers */
-               fabrics_cfg->trsvcid = __stringify(NVME_DISC_IP_PORT);
+               if (discover) {
+                       /* Default port for NVMe/TCP discovery controllers */
+                       fabrics_cfg->trsvcid = __stringify(NVME_DISC_IP_PORT);
+               } else {
+                       /* Default port for NVMe/TCP io controllers */
+                       fabrics_cfg->trsvcid = __stringify(NVME_RDMA_IP_PORT);
+               }
        } else if (!strcmp(fabrics_cfg->transport, "rdma")) {
                /* Default port for NVMe/RDMA controllers */
                fabrics_cfg->trsvcid = __stringify(NVME_RDMA_IP_PORT);
@@ -1581,7 +1586,7 @@ static int discover_from_conf_file(const char *desc, char *argstr,
                }
 
                if (!fabrics_cfg.trsvcid)
-                       discovery_trsvcid(&fabrics_cfg);
+                       discovery_trsvcid(&fabrics_cfg, true);
 
                err = build_options(argstr, BUF_SIZE, true);
                if (err) {
@@ -1677,7 +1682,7 @@ int fabrics_discover(const char *desc, int argc, char **argv, bool connect)
                }
 
                if (!fabrics_cfg.trsvcid)
-                       discovery_trsvcid(&fabrics_cfg);
+                       discovery_trsvcid(&fabrics_cfg, true);
 
                ret = build_options(argstr, BUF_SIZE, true);
                if (ret)
@@ -1745,6 +1750,9 @@ int fabrics_connect(const char *desc, int argc, char **argv)
                        goto out;
        }
 
+       if (!fabrics_cfg.trsvcid)
+               discovery_trsvcid(&fabrics_cfg, false);
+
        ret = build_options(argstr, BUF_SIZE, false);
        if (ret)
                goto out;