File 0012-fabrics-add-default-port-number-for-NVMe-TCP-I-O-con.patch of Package nvme-cli.20721

From: Martin George <marting@netapp.com>
Date: Fri, 6 Aug 2021 17:35:20 +0530
Subject: fabrics: add default port number for NVMe/TCP I/O controllers
References: bsc#1189195 bsc#1187858
Git-commit: 362c90f364a8e96a2551e83e9fc5746bf4aed859

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 |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

--- a/fabrics.c
+++ b/fabrics.c
@@ -944,11 +944,16 @@ static void set_discovery_kato(struct co
 		cfg->keep_alive_tmo = 0;
 }
 
-static void discovery_trsvcid(struct config *cfg)
+static void discovery_trsvcid(struct config *cfg, bool discover)
 {
 	if (!strcmp(cfg->transport, "tcp")) {
-		/* Default port for NVMe/TCP discovery controllers */
-		cfg->trsvcid = __stringify(NVME_DISC_IP_PORT);
+		if (discover) {
+			/* Default port for NVMe/TCP discovery controllers */
+			cfg->trsvcid = __stringify(NVME_DISC_IP_PORT);
+		} else {
+			/* Default port for NVMe/TCP io controllers */
+			cfg->trsvcid = __stringify(NVME_RDMA_IP_PORT);
+		}
 	} else if (!strcmp(cfg->transport, "rdma")) {
 		/* Default port for NVMe/RDMA controllers */
 		cfg->trsvcid = __stringify(NVME_RDMA_IP_PORT);
@@ -1426,7 +1431,7 @@ static int discover_from_conf_file(const
 		}
 
 		if (!cfg.trsvcid)
-			discovery_trsvcid(&cfg);
+			discovery_trsvcid(&cfg, true);
 
 		err = build_options(argstr, BUF_SIZE, true);
 		if (err) {
@@ -1500,7 +1505,7 @@ int fabrics_discover(const char *desc, i
 		}
 
 		if (!cfg.trsvcid)
-			discovery_trsvcid(&cfg);
+			discovery_trsvcid(&cfg, true);
 
 		ret = build_options(argstr, BUF_SIZE, true);
 		if (ret)
@@ -1552,6 +1557,9 @@ int fabrics_connect(const char *desc, in
 			goto out;
 	}
 
+	if (!cfg.trsvcid)
+		discovery_trsvcid(&cfg, false);
+
 	ret = build_options(argstr, BUF_SIZE, false);
 	if (ret)
 		goto out;
openSUSE Build Service is sponsored by