summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Wagner <wagi@kernel.org>2026-04-08 19:19:56 +0300
committerKeith Busch <kbusch@kernel.org>2026-04-17 01:05:14 +0300
commit20925812de7bf5e6fdc133c691ef52b33f700fbc (patch)
treef08944972da106f5f43a71eb503f13fa1731e920
parentba9d308ccd6732dd97ed8080d834a4a89e758e14 (diff)
downloadlinux-20925812de7bf5e6fdc133c691ef52b33f700fbc.tar.xz
nvme: expose TLS mode
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. Expose the TLS mode explicitly to allow user space to unambiguously identify the active configuration and avoid fragile heuristics in nvme-cli. Reviewed-by: Chris Leech <cleech@redhat.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Daniel Wagner <wagi@kernel.org> Signed-off-by: Keith Busch <kbusch@kernel.org>
-rw-r--r--drivers/nvme/host/sysfs.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index 7bf2e972126b..e59758616f27 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -883,10 +883,26 @@ static ssize_t tls_keyring_show(struct device *dev,
}
static DEVICE_ATTR_RO(tls_keyring);
+static ssize_t tls_mode_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
+ const char *mode;
+
+ if (ctrl->opts->tls)
+ mode = "tls";
+ else
+ mode = "concat";
+
+ return sysfs_emit(buf, "%s\n", mode);
+}
+static DEVICE_ATTR_RO(tls_mode);
+
static struct attribute *nvme_tls_attrs[] = {
&dev_attr_tls_key.attr,
&dev_attr_tls_configured_key.attr,
&dev_attr_tls_keyring.attr,
+ &dev_attr_tls_mode.attr,
NULL,
};
@@ -908,6 +924,9 @@ static umode_t nvme_tls_attrs_are_visible(struct kobject *kobj,
if (a == &dev_attr_tls_keyring.attr &&
!ctrl->opts->keyring)
return 0;
+ if (a == &dev_attr_tls_mode.attr &&
+ !ctrl->opts->tls && !ctrl->opts->concat)
+ return 0;
return a->mode;
}