From 9c61b7894b002f63466feba358b1128def10336c Mon Sep 17 00:00:00 2001 From: Martin George Date: Fri, 20 Mar 2026 22:47:43 +0530 Subject: [PATCH 1/2] tree: avoid updating --tls in nvme_read_sysfs_tls() It is wrongly assumed that the presence of the sysfs tls_key attribute indicates --tls alone was invoked. But this can also happen if --concat was invoked as well. And both --tls and --concat are mutually exclusive. Also, both --tls and --concat are already appropriately set earlier during configured & generated PSK TLS workflows respectively. So avoid explicitly setting --tls again here in nvme_read_sysfs_tls() as that's unnecessary and incorrect too. Signed-off-by: Martin George --- libnvme/src/nvme/tree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libnvme/src/nvme/tree.c b/libnvme/src/nvme/tree.c index 010dd3ce93..1cae0bd8ac 100644 --- a/libnvme/src/nvme/tree.c +++ b/libnvme/src/nvme/tree.c @@ -1702,10 +1702,9 @@ static void nvme_read_sysfs_tls(struct nvme_global_ctx *ctx, nvme_ctrl_t c) key = nvme_get_ctrl_attr(c, "tls_key"); if (!key) { - /* tls_key is only present if --tls has been used. */ + /* tls_key is only present if --tls or --concat has been used */ return; } - c->cfg.tls = true; keyring = nvme_get_ctrl_attr(c, "tls_keyring"); nvme_ctrl_set_keyring(c, keyring); From 6a8e030ab41f2cf7d27fbca3b83eaca6a94754b0 Mon Sep 17 00:00:00 2001 From: Martin George Date: Tue, 24 Mar 2026 22:32:34 +0530 Subject: [PATCH 2/2] fabrics: add helper to update tls and concat Only --tls was properly updated in nbft_connect(), and not --concat. But this is properly done in nvmf_connect_disc_entry() already. So add a helper function to update both --tls and --concat and invoke the same from nvmf_connect_disc_entry() and nbft_connect() respectively. Signed-off-by: Martin George [wagi: reformated the function to improve readability] Signed-off-by: Daniel Wagner --- libnvme/src/nvme/fabrics.c | 49 +++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/libnvme/src/nvme/fabrics.c b/libnvme/src/nvme/fabrics.c index 129aa134d3..cd8062e176 100644 --- a/libnvme/src/nvme/fabrics.c +++ b/libnvme/src/nvme/fabrics.c @@ -1096,6 +1096,34 @@ __public int nvmf_connect_ctrl(nvme_ctrl_t c) return 0; } +static void nvmf_update_tls_concat(struct nvmf_disc_log_entry *e, + nvme_ctrl_t c, nvme_host_t h) +{ + if (e->trtype != NVMF_TRTYPE_TCP || + e->tsas.tcp.sectype == NVMF_TCP_SECTYPE_NONE) + return; + + if (e->treq & NVMF_TREQ_REQUIRED) { + nvme_msg(h->ctx, LOG_DEBUG, + "setting --tls due to treq %s and sectype %s\n", + nvmf_treq_str(e->treq), + nvmf_sectype_str(e->tsas.tcp.sectype)); + + c->cfg.tls = true; + return; + } + + if (e->treq & NVMF_TREQ_NOT_REQUIRED) { + nvme_msg(h->ctx, LOG_DEBUG, + "setting --concat due to treq %s and sectype %s\n", + nvmf_treq_str(e->treq), + nvmf_sectype_str(e->tsas.tcp.sectype)); + + c->cfg.concat = true; + return; + } +} + static int nvmf_connect_disc_entry(nvme_host_t h, struct nvmf_disc_log_entry *e, struct nvmf_context *fctx, @@ -1189,18 +1217,8 @@ static int nvmf_connect_disc_entry(nvme_host_t h, nvmf_check_option(h->ctx, disable_sqflow)) c->cfg.disable_sqflow = true; - if (e->trtype == NVMF_TRTYPE_TCP && - e->tsas.tcp.sectype != NVMF_TCP_SECTYPE_NONE) { - if (e->treq & NVMF_TREQ_REQUIRED) { - nvme_msg(h->ctx, LOG_DEBUG, "setting --tls due to treq %s and sectype %s\n", - nvmf_treq_str(e->treq), nvmf_sectype_str(e->tsas.tcp.sectype)); - c->cfg.tls = true; - } else if (e->treq & NVMF_TREQ_NOT_REQUIRED) { - nvme_msg(h->ctx, LOG_DEBUG, "setting --concat due to treq %s and sectype %s\n", - nvmf_treq_str(e->treq), nvmf_sectype_str(e->tsas.tcp.sectype)); - c->cfg.concat = true; - } - } + /* update tls or concat */ + nvmf_update_tls_concat(e, c, h); ret = nvmf_add_ctrl(h, c, cfg); if (!ret) { @@ -2552,11 +2570,8 @@ static int nbft_connect(struct nvme_global_ctx *ctx, if (ss && ss->unavailable && saved_log_level < 1) nvme_set_logging_level(ctx, -1, false, false); - if (e) { - if (e->trtype == NVMF_TRTYPE_TCP && - e->tsas.tcp.sectype != NVMF_TCP_SECTYPE_NONE) - cfg->tls = true; - } + /* Update tls or concat */ + nvmf_update_tls_concat(e, c, h); ret = nvmf_add_ctrl(h, c, cfg);