From: Martin George Date: Mon, 29 May 2023 07:40:33 +0000 (+0530) Subject: fabrics: prevent 'nvme connect' to well-known discovery NQN X-Git-Tag: v2.5~73 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9077d042c04af1f845efbdad0351f87c45b12345;p=users%2Fsagi%2Fnvme-cli.git fabrics: prevent 'nvme connect' to well-known discovery NQN 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 --- diff --git a/fabrics.c b/fabrics.c index 54808e2e..8004b4ae 100644 --- 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;