]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
fabrics: prevent 'nvme connect' to well-known discovery NQN
authorMartin George <marting@netapp.com>
Mon, 29 May 2023 07:40:33 +0000 (13:10 +0530)
committerDaniel Wagner <wagi@monom.org>
Thu, 1 Jun 2023 17:47:34 +0000 (19:47 +0200)
Using 'nvme connect' to connect to the well-known discovery NQN
could result in a few problems with the current implementation:

1) It does not explicitly disconnect from the discovery subsystem
after usage, thereby leading to a spurious discovery controller
on the host.

2) Multiple 'nvme connect' invocations to the well-known discovery
NQN would result in duplicate discovery controllers on the host.

All this is already handled in 'nvme discover'. So it would be
better to avoid using 'nvme connect' to connect to the well-known
discovery NQN in the first place, and use 'nvme discover' instead
for the same.

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

index 54808e2ed5b7483cd2bf52df43e24e58918d97d4..8004b4aeb2c4414f4a961ad7fe92afe8e216d9b0 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -966,6 +966,13 @@ int nvmf_connect(const char *desc, int argc, char **argv)
                }
        }
 
+       if (!strcmp(subsysnqn, NVME_DISC_SUBSYS_NAME)) {
+               fprintf(stderr,
+                       "avoiding connect to %s, use nvme discover instead\n",
+                       NVME_DISC_SUBSYS_NAME);
+               return -EINVAL;
+       }
+
        if (!strcmp(config_file, "none"))
                config_file = NULL;