File 0036-fabrics-mask-out-invalid-options-during-discovery.patch of Package nvme-cli.11415
From 8ea2622aa79feff9b68570c15efa3dc514cbc42a Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 12 Feb 2019 13:40:43 +0100
Subject: [PATCH] fabrics: mask out invalid options during discovery
When compiling the option string in build_options() we should ensure
to not add invalid options when doing a discovery. So add an additional
option 'discovery' to build_options() to identify these cases.
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
fabrics.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/fabrics.c b/fabrics.c
index fb00382..fc0dde5 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -552,7 +552,7 @@ add_argument(char **argstr, int *max_len, char *arg_str, char *arg)
return 0;
}
-static int build_options(char *argstr, int max_len)
+static int build_options(char *argstr, int max_len, bool discover)
{
int len;
@@ -583,11 +583,15 @@ static int build_options(char *argstr, int max_len)
add_argument(&argstr, &max_len, "hostnqn", cfg.hostnqn)) ||
((cfg.hostid || nvmf_hostid_file()) &&
add_argument(&argstr, &max_len, "hostid", cfg.hostid)) ||
- add_int_argument(&argstr, &max_len, "nr_io_queues",
- cfg.nr_io_queues) ||
- add_int_argument(&argstr, &max_len, "queue_size", cfg.queue_size) ||
- add_int_argument(&argstr, &max_len, "keep_alive_tmo",
- cfg.keep_alive_tmo) ||
+ (!discover &&
+ add_int_argument(&argstr, &max_len, "nr_io_queues",
+ cfg.nr_io_queues)) ||
+ (!discover &&
+ add_int_argument(&argstr, &max_len, "queue_size",
+ cfg.queue_size)) ||
+ (!discover &&
+ add_int_argument(&argstr, &max_len, "keep_alive_tmo",
+ cfg.keep_alive_tmo)) ||
add_int_argument(&argstr, &max_len, "reconnect_delay",
cfg.reconnect_delay) ||
add_int_argument(&argstr, &max_len, "ctrl_loss_tmo",
@@ -835,7 +839,7 @@ static int discover_from_conf_file(const char *desc, char *argstr,
argconfig_parse(argc, argv, desc, opts, &cfg, sizeof(cfg));
- err = build_options(argstr, BUF_SIZE);
+ err = build_options(argstr, BUF_SIZE, true);
if (err) {
ret = err;
continue;
@@ -885,7 +889,7 @@ int discover(const char *desc, int argc, char **argv, bool connect)
return discover_from_conf_file(desc, argstr,
command_line_options, connect);
} else {
- ret = build_options(argstr, BUF_SIZE);
+ ret = build_options(argstr, BUF_SIZE, true);
if (ret)
return ret;
@@ -917,7 +921,7 @@ int connect(const char *desc, int argc, char **argv)
argconfig_parse(argc, argv, desc, command_line_options, &cfg,
sizeof(cfg));
- ret = build_options(argstr, BUF_SIZE);
+ ret = build_options(argstr, BUF_SIZE, false);
if (ret)
return ret;
--
2.13.7