Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions libnvme/src/nvme/fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions libnvme/src/nvme/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading