Skip to content

Commit f5eb739

Browse files
Hannes Reineckekeithbusch
authored andcommitted
nvme-sysfs: add 'tls_configured_key' sysfs attribute
There is a difference between the negotiated TLS key (which is always present for a TLS encrypted connection) and the configured TLS key (which is specified with the --tls_key command line option). To differentate between these two add a new sysfs attribute 'tls_configured_key' to hold the specified on the command line. Signed-off-by: Hannes Reinecke <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 1e48b34 commit f5eb739

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

drivers/nvme/host/sysfs.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,19 @@ static ssize_t tls_key_show(struct device *dev,
743743
}
744744
static DEVICE_ATTR_RO(tls_key);
745745

746+
static ssize_t tls_configured_key_show(struct device *dev,
747+
struct device_attribute *attr, char *buf)
748+
{
749+
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
750+
struct key *key = ctrl->opts->tls_key;
751+
752+
return sysfs_emit(buf, "%08x\n", key_serial(key));
753+
}
754+
static DEVICE_ATTR_RO(tls_configured_key);
755+
746756
static struct attribute *nvme_tls_attrs[] = {
747757
&dev_attr_tls_key.attr,
758+
&dev_attr_tls_configured_key.attr,
748759
};
749760

750761
static umode_t nvme_tls_attrs_are_visible(struct kobject *kobj,
@@ -759,6 +770,9 @@ static umode_t nvme_tls_attrs_are_visible(struct kobject *kobj,
759770
if (a == &dev_attr_tls_key.attr &&
760771
!ctrl->opts->tls)
761772
return 0;
773+
if (a == &dev_attr_tls_configured_key.attr &&
774+
!ctrl->opts->tls_key)
775+
return 0;
762776

763777
return a->mode;
764778
}

0 commit comments

Comments
 (0)