Skip to content

Commit 2092581

Browse files
igawkeithbusch
authored andcommitted
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>
1 parent ba9d308 commit 2092581

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

drivers/nvme/host/sysfs.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,10 +883,26 @@ static ssize_t tls_keyring_show(struct device *dev,
883883
}
884884
static DEVICE_ATTR_RO(tls_keyring);
885885

886+
static ssize_t tls_mode_show(struct device *dev,
887+
struct device_attribute *attr, char *buf)
888+
{
889+
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
890+
const char *mode;
891+
892+
if (ctrl->opts->tls)
893+
mode = "tls";
894+
else
895+
mode = "concat";
896+
897+
return sysfs_emit(buf, "%s\n", mode);
898+
}
899+
static DEVICE_ATTR_RO(tls_mode);
900+
886901
static struct attribute *nvme_tls_attrs[] = {
887902
&dev_attr_tls_key.attr,
888903
&dev_attr_tls_configured_key.attr,
889904
&dev_attr_tls_keyring.attr,
905+
&dev_attr_tls_mode.attr,
890906
NULL,
891907
};
892908

@@ -908,6 +924,9 @@ static umode_t nvme_tls_attrs_are_visible(struct kobject *kobj,
908924
if (a == &dev_attr_tls_keyring.attr &&
909925
!ctrl->opts->keyring)
910926
return 0;
927+
if (a == &dev_attr_tls_mode.attr &&
928+
!ctrl->opts->tls && !ctrl->opts->concat)
929+
return 0;
911930

912931
return a->mode;
913932
}

0 commit comments

Comments
 (0)