From 530728a4dc68528d8c89d1c4da36a385581fda53 Mon Sep 17 00:00:00 2001 From: Martin Belanger Date: Fri, 10 Feb 2023 11:56:36 -0500 Subject: [PATCH] fabrics: Ensure host-traddr/iface consistency for "connect-all" When using "connect-all --device" without specifying the options --host-traddr and --host-iface, the children connections may not have the same host-traddr/host-iface as the connection to the discovery controller (DC). This is specific to the --device option where one reuses a persistent connection to a discovery controller to update the discovery log pages (DLP) and connect to new controllers listed in the new DLP. If --device is used w/o also specifying --host-traddr and --host-iface, then the new connections may not use the same attributes that were used for the DC connection. This patch checks if --host-traddr and --host-iface have been provided, and if not, it will use the DC's --host-traddr and --host-iface for the new connections made as a result of changes to the DLP. Signed-off-by: Martin Belanger --- fabrics.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fabrics.c b/fabrics.c index b39e67a7..1349042d 100644 --- a/fabrics.c +++ b/fabrics.c @@ -823,6 +823,20 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) * on exit. */ persistent = true; + /* + * When --host-traddr/--host-iface are not specified on the + * command line, use the discovery controller's (c) host- + * traddr/host-iface for the connections to controllers + * returned in the Discovery Log Pages. This is essential + * when invoking "connect-all" with --device to reuse an + * existing persistent discovery controller (as is done + * for the udev rules). This ensures that host-traddr/ + * host-iface are consistent with the discovery controller (c). + */ + if (!cfg.host_traddr) + cfg.host_traddr = (char *)nvme_ctrl_get_host_traddr(c); + if (!cfg.host_iface) + cfg.host_iface = (char *)nvme_ctrl_get_host_iface(c); } } else { /* -- 2.50.1