From ac1584a5eac1bb97960d94e90e1dac026ea41b49 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Wed, 14 Jun 2023 14:19:10 +0200 Subject: [PATCH] fabrics: Filter discovery ctrls out during application context check We also need to filter out the well known discovery controllers when using the execution context filtering. Obviously, we can't use the subsystem name, thus match on the host and target address instead. Signed-off-by: Daniel Wagner --- src/nvme/fabrics.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index 76e1e429..ab6706bf 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -860,15 +860,33 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, } root_app = nvme_root_get_application(h->r); - app = nvme_subsystem_get_application(s); if (root_app) { + app = nvme_subsystem_get_application(s); + if (!app && nvme_ctrl_is_discovery_ctrl(c)) { + nvme_subsystem_t s; + nvme_ctrl_t fc; + + nvme_for_each_subsystem(h, s) { + fc = __nvme_lookup_ctrl(s, nvme_ctrl_get_transport(c), + nvme_ctrl_get_traddr(c), + nvme_ctrl_get_host_traddr(c), + nvme_ctrl_get_host_iface(c), + nvme_ctrl_get_trsvcid(c), + NULL); + + if (fc) { + app = nvme_subsystem_get_application(s); + break; + } + } + } /* * configuration is managed by an application, * refuse to act on subsystems which either have * no application set or which habe a different * application string. */ - if (!app || strcmp(app, root_app)) { + if (app && strcmp(app, root_app)) { nvme_msg(h->r, LOG_INFO, "skip %s, not managed by %s\n", nvme_subsystem_get_nqn(s), root_app); errno = ENVME_CONNECT_IGNORED; -- 2.50.1