Skip to content

Commit d0c4d3a

Browse files
committed
nvme: expose tls mode in use
It is not possible to determine the active TLS mode from the presence or absence of sysfs attributes like tls_key, tls_configured_key, or dhchap_secret. With the introduction of the concat mode and optional DH-CHAP authentication, different configurations can result in identical sysfs state. This makes user space detection unreliable. Read the TLS mode used from the newly added sysfs entry. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 14a15f4 commit d0c4d3a

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

libnvme/src/nvme/tree.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,21 @@ static void libnvme_read_sysfs_tls(struct libnvme_global_ctx *ctx,
17661766
free(key);
17671767
}
17681768

1769+
static void libnvme_read_sysfs_tls_mode(struct libnvme_global_ctx *ctx,
1770+
libnvme_ctrl_t c)
1771+
{
1772+
_cleanup_free_ char *mode = NULL;
1773+
1774+
mode = libnvme_get_ctrl_attr(c, "tls_mode");
1775+
if (!mode)
1776+
return;
1777+
1778+
if (!strcmp(mode, "tls"))
1779+
c->cfg.tls = true;
1780+
else if (!strcmp(mode, "concat"))
1781+
c->cfg.concat = true;
1782+
}
1783+
17691784
static int libnvme_reconfigure_ctrl(struct libnvme_global_ctx *ctx,
17701785
libnvme_ctrl_t c, const char *path, const char *name)
17711786
{
@@ -1814,6 +1829,7 @@ static int libnvme_reconfigure_ctrl(struct libnvme_global_ctx *ctx,
18141829
libnvme_ctrl_lookup_phy_slot(ctx, c);
18151830
libnvme_read_sysfs_dhchap(ctx, c);
18161831
libnvme_read_sysfs_tls(ctx, c);
1832+
libnvme_read_sysfs_tls_mode(ctx, c);
18171833

18181834
return 0;
18191835
}

0 commit comments

Comments
 (0)