Skip to content

Commit 6e382e4

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 99dd46f commit 6e382e4

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

libnvme/src/nvme/tree.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,20 @@ static void nvme_read_sysfs_tls(struct nvme_global_ctx *ctx, nvme_ctrl_t c)
17291729
free(key);
17301730
}
17311731

1732+
static void nvme_read_sysfs_tls_mode(struct nvme_global_ctx *ctx, nvme_ctrl_t c)
1733+
{
1734+
_cleanup_free_ char *mode = NULL;
1735+
1736+
mode = nvme_get_ctrl_attr(c, "tls_mode");
1737+
if (!mode)
1738+
return;
1739+
1740+
if (!strcmp(mode, "tls"))
1741+
c->cfg.tls = true;
1742+
else if (!strcmp(mode, "concat"))
1743+
c->cfg.concat = true;
1744+
}
1745+
17321746
static int nvme_reconfigure_ctrl(struct nvme_global_ctx *ctx, nvme_ctrl_t c, const char *path,
17331747
const char *name)
17341748
{
@@ -1777,6 +1791,7 @@ static int nvme_reconfigure_ctrl(struct nvme_global_ctx *ctx, nvme_ctrl_t c, con
17771791
nvme_ctrl_lookup_phy_slot(ctx, c);
17781792
nvme_read_sysfs_dhchap(ctx, c);
17791793
nvme_read_sysfs_tls(ctx, c);
1794+
nvme_read_sysfs_tls_mode(ctx, c);
17801795

17811796
return 0;
17821797
}

0 commit comments

Comments
 (0)