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
43 changes: 40 additions & 3 deletions src/nvme/fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,16 @@

ctrlkey = nvme_ctrl_get_dhchap_key(c);

if (cfg->tls && cfg->concat) {
nvme_msg(h->r, LOG_ERR, "cannot specify --tls and --concat together\n");
return -ENVME_CONNECT_INVAL;
}

if (cfg->concat && !hostkey) {
nvme_msg(h->r, LOG_ERR, "required argument [--dhchap-secret | -S] not specified with --concat\n");

Check failure on line 636 in src/nvme/fabrics.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 114 exceeds 100 columns
return -ENVME_CONNECT_INVAL;
}

if (cfg->tls) {
ret = __nvme_import_keys_from_config(h, c, &keyring_id, &key_id);
if (ret) {
Expand Down Expand Up @@ -1001,6 +1011,34 @@
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->r, 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->r, 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;
}
}

nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,
struct nvmf_disc_log_entry *e,
const struct nvme_fabrics_config *cfg,
Expand Down Expand Up @@ -1075,11 +1113,11 @@
case NVME_NQN_DISC:
if (discover)
*discover = true;
nvme_ctrl_set_discovery_ctrl(c, true);

Check failure on line 1116 in src/nvme/fabrics.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 103 exceeds 100 columns
nvme_ctrl_set_unique_discovery_ctrl(c,
strcmp(e->subnqn, NVME_DISC_SUBSYS_NAME));
break;

Check failure on line 1119 in src/nvme/fabrics.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 101 exceeds 100 columns
default:

Check failure on line 1120 in src/nvme/fabrics.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 103 exceeds 100 columns
nvme_msg(h->r, LOG_ERR, "unsupported subtype %d\n",
e->subtype);
fallthrough;
Expand All @@ -1099,9 +1137,8 @@
nvmf_check_option(h->r, disable_sqflow))
c->cfg.disable_sqflow = true;

if (e->trtype == NVMF_TRTYPE_TCP &&
e->tsas.tcp.sectype != NVMF_TCP_SECTYPE_NONE)
c->cfg.tls = true;
/* update tls or concat */
nvmf_update_tls_concat(e, c, h);

ret = nvmf_add_ctrl(h, c, cfg);
if (!ret)
Expand Down
18 changes: 16 additions & 2 deletions src/nvme/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,20 @@ static char *nvme_ctrl_lookup_phy_slot(nvme_root_t r, const char *address)
return NULL;
}

static void nvme_read_sysfs_tls_mode(nvme_root_t r, nvme_ctrl_t c)
{
_cleanup_free_ char *mode = NULL;

mode = nvme_get_ctrl_attr(c, "tls_mode");
if (!mode)
return;

if (!strcmp(mode, "tls"))
c->cfg.tls = true;
else if (!strcmp(mode, "concat"))
c->cfg.concat = true;
}

static void nvme_read_sysfs_dhchap(nvme_root_t r, nvme_ctrl_t c)
{
char *host_key, *ctrl_key;
Expand Down Expand Up @@ -2013,10 +2027,9 @@ static void nvme_read_sysfs_tls(nvme_root_t r, 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 Expand Up @@ -2089,6 +2102,7 @@ static int nvme_reconfigure_ctrl(nvme_root_t r, nvme_ctrl_t c, const char *path,
c->phy_slot = nvme_ctrl_lookup_phy_slot(r, c->address);
nvme_read_sysfs_dhchap(r, c);
nvme_read_sysfs_tls(r, c);
nvme_read_sysfs_tls_mode(r, c);

errno = 0; /* cleanup after nvme_get_ctrl_attr() */
return 0;
Expand Down
Loading