summaryrefslogtreecommitdiffstats
path: root/fabrics.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-11-20 07:04:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-11-20 07:04:39 +0000
commitb8210b1af6dd369a577b2ea2c2fa0f25bffaa3f4 (patch)
tree0f8475e9ba10b301bd87788e60d1759e8855e414 /fabrics.c
parentReleasing debian version 1.15-4. (diff)
downloadnvme-cli-b8210b1af6dd369a577b2ea2c2fa0f25bffaa3f4.tar.xz
nvme-cli-b8210b1af6dd369a577b2ea2c2fa0f25bffaa3f4.zip
Merging upstream version 1.16.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'fabrics.c')
-rw-r--r--fabrics.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/fabrics.c b/fabrics.c
index 39bee97..d691191 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -69,7 +69,7 @@ const char *conarg_host_traddr = "host_traddr";
const char *conarg_host_iface = "host_iface";
struct fabrics_config fabrics_cfg = {
- .ctrl_loss_tmo = -1,
+ .ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO,
.fast_io_fail_tmo = -1,
.output_format = "normal",
};
@@ -293,13 +293,14 @@ static bool ctrl_matches_connectargs(const char *name, struct connect_args *args
return found;
addr = nvme_get_ctrl_attr(path, "address");
- if (!addr) {
+ cargs.subsysnqn = nvme_get_ctrl_attr(path, "subsysnqn");
+ cargs.transport = nvme_get_ctrl_attr(path, "transport");
+
+ if (!addr || !cargs.subsysnqn || !cargs.transport) {
fprintf(stderr, "nvme_get_ctrl_attr failed\n");
- return found;
+ goto out;
}
- cargs.subsysnqn = nvme_get_ctrl_attr(path, "subsysnqn");
- cargs.transport = nvme_get_ctrl_attr(path, "transport");
cargs.traddr = parse_conn_arg(addr, ' ', conarg_traddr);
cargs.trsvcid = parse_conn_arg(addr, ' ', conarg_trsvcid);
cargs.host_traddr = parse_conn_arg(addr, ' ', conarg_host_traddr);
@@ -340,12 +341,13 @@ static bool ctrl_matches_connectargs(const char *name, struct connect_args *args
!strcmp(args->host_iface, "none")))
found = true;
- free(cargs.subsysnqn);
- free(cargs.transport);
free(cargs.traddr);
free(cargs.trsvcid);
free(cargs.host_traddr);
free(cargs.host_iface);
+out:
+ free(cargs.subsysnqn);
+ free(cargs.transport);
free(addr);
free(path);
@@ -852,9 +854,12 @@ static char *hostnqn_read_file(void)
goto out;
ret = strndup(hostnqn, strcspn(hostnqn, "\n"));
-
out:
fclose(f);
+ if (ret && strcmp(ret, "") == 0) {
+ free(ret);
+ ret = NULL;
+ }
return ret;
}
@@ -960,7 +965,7 @@ add_int_argument(char **argstr, int *max_len, char *arg_str, int arg,
{
int len;
- if ((arg && !allow_zero) || (arg != -1 && allow_zero)) {
+ if (arg || allow_zero) {
len = snprintf(*argstr, *max_len, ",%s=%d", arg_str, arg);
if (len < 0)
return -EINVAL;
@@ -1001,9 +1006,6 @@ int build_options(char *argstr, int max_len, bool discover)
msg(LOG_ERR, "need a address (-a) argument\n");
return -EINVAL;
}
- /* Use the default ctrl loss timeout if unset */
- if (fabrics_cfg.ctrl_loss_tmo == -1)
- fabrics_cfg.ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO;
}
/* always specify nqn as first arg - this will init the string */
@@ -1039,10 +1041,12 @@ int build_options(char *argstr, int max_len, bool discover)
(strncmp(fabrics_cfg.transport, "loop", 4) &&
add_int_argument(&argstr, &max_len, "ctrl_loss_tmo",
fabrics_cfg.ctrl_loss_tmo, true)) ||
+ (fabrics_cfg.fast_io_fail_tmo != -1 &&
add_int_argument(&argstr, &max_len, "fast_io_fail_tmo",
- fabrics_cfg.fast_io_fail_tmo, true) ||
+ fabrics_cfg.fast_io_fail_tmo, true)) ||
+ (fabrics_cfg.tos != -1 &&
add_int_argument(&argstr, &max_len, "tos",
- fabrics_cfg.tos, true) ||
+ fabrics_cfg.tos, true)) ||
add_bool_argument(&argstr, &max_len, "duplicate_connect",
fabrics_cfg.duplicate_connect) ||
add_bool_argument(&argstr, &max_len, "disable_sqflow",