]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
nvme-cli: mask out invalid options during discovery
authorHannes Reinecke <hare@suse.de>
Thu, 1 Aug 2019 08:47:41 +0000 (10:47 +0200)
committerSimon Schricker <sschricker@suse.de>
Thu, 1 Aug 2019 09:08:03 +0000 (11:08 +0200)
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

index c889e4978bcbc00508ea484be7e5f4511ed295d5..5cbc84c7f4bf7cc3732b3133a42a535e455b86e4 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -589,7 +589,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;
 
@@ -620,15 +620,19 @@ 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) ||
+           (!discover &&
+             add_int_argument(&argstr, &max_len, "nr_io_queues",
+                               cfg.nr_io_queues)) ||
            add_int_argument(&argstr, &max_len, "nr_write_queues",
                                cfg.nr_write_queues) ||
            add_int_argument(&argstr, &max_len, "nr_poll_queues",
                                cfg.nr_poll_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, "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",
@@ -957,7 +961,7 @@ static int discover_from_conf_file(const char *desc, char *argstr,
                if (err)
                        continue;
 
-               err = build_options(argstr, BUF_SIZE);
+               err = build_options(argstr, BUF_SIZE, true);
                if (err) {
                        ret = err;
                        continue;
@@ -1013,7 +1017,7 @@ int discover(const char *desc, int argc, char **argv, bool connect)
                ret = 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)
                        goto out;
 
@@ -1055,7 +1059,7 @@ int connect(const char *desc, int argc, char **argv)
        if (ret)
                goto out;
 
-       ret = build_options(argstr, BUF_SIZE);
+       ret = build_options(argstr, BUF_SIZE, false);
        if (ret)
                goto out;