Skip to content

Commit 02a3688

Browse files
Hannes Reineckekeithbusch
authored andcommitted
nvme-sysfs: add 'tls_keyring' attribute
Add a 'tls_keyring' attribute to display the contents of the --keyring option from the connect string. Adding this attribute allows us to recreate the original connect string from sysfs settings. Signed-off-by: Hannes Reinecke <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent f5eb739 commit 02a3688

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
@@ -753,9 +753,20 @@ static ssize_t tls_configured_key_show(struct device *dev,
753753
}
754754
static DEVICE_ATTR_RO(tls_configured_key);
755755

756+
static ssize_t tls_keyring_show(struct device *dev,
757+
struct device_attribute *attr, char *buf)
758+
{
759+
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
760+
struct key *keyring = ctrl->opts->keyring;
761+
762+
return sysfs_emit(buf, "%s\n", keyring->description);
763+
}
764+
static DEVICE_ATTR_RO(tls_keyring);
765+
756766
static struct attribute *nvme_tls_attrs[] = {
757767
&dev_attr_tls_key.attr,
758768
&dev_attr_tls_configured_key.attr,
769+
&dev_attr_tls_keyring.attr,
759770
};
760771

761772
static umode_t nvme_tls_attrs_are_visible(struct kobject *kobj,
@@ -773,6 +784,9 @@ static umode_t nvme_tls_attrs_are_visible(struct kobject *kobj,
773784
if (a == &dev_attr_tls_configured_key.attr &&
774785
!ctrl->opts->tls_key)
775786
return 0;
787+
if (a == &dev_attr_tls_keyring.attr &&
788+
!ctrl->opts->keyring)
789+
return 0;
776790

777791
return a->mode;
778792
}

0 commit comments

Comments
 (0)