From 809be99b01578965b96152340d3e575f2a268574 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Wed, 1 Apr 2026 10:31:32 +0200 Subject: [PATCH] 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 --- libnvme/src/nvme/tree.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libnvme/src/nvme/tree.c b/libnvme/src/nvme/tree.c index 81686d1a00..2a05b1e6ec 100644 --- a/libnvme/src/nvme/tree.c +++ b/libnvme/src/nvme/tree.c @@ -1766,6 +1766,21 @@ static void libnvme_read_sysfs_tls(struct libnvme_global_ctx *ctx, free(key); } +static void libnvme_read_sysfs_tls_mode(struct libnvme_global_ctx *ctx, + libnvme_ctrl_t c) +{ + _cleanup_free_ char *mode = NULL; + + mode = libnvme_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 int libnvme_reconfigure_ctrl(struct libnvme_global_ctx *ctx, libnvme_ctrl_t c, const char *path, const char *name) { @@ -1814,6 +1829,7 @@ static int libnvme_reconfigure_ctrl(struct libnvme_global_ctx *ctx, libnvme_ctrl_lookup_phy_slot(ctx, c); libnvme_read_sysfs_dhchap(ctx, c); libnvme_read_sysfs_tls(ctx, c); + libnvme_read_sysfs_tls_mode(ctx, c); return 0; }