]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
fabrics: Filter discovery ctrls out during application context check
authorDaniel Wagner <dwagner@suse.de>
Wed, 14 Jun 2023 12:19:10 +0000 (14:19 +0200)
committerDaniel Wagner <wagi@monom.org>
Wed, 21 Jun 2023 07:34:46 +0000 (09:34 +0200)
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 <dwagner@suse.de>
src/nvme/fabrics.c

index 76e1e4295a490cb11f30e0b95f52aa137fd619e2..ab6706bff8be8cfcf4891697f9ea589be4127f59 100644 (file)
@@ -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;