From: Hannes Reinecke <hare@kernel.org>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Hannes Reinecke <hare@suse.de>,
Chaitanya Kulkarni <kch@nvidia.com>
Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
Hannes Reinecke <hare@kernel.org>
Subject: [PATCH v5 8/9] nvme-fabrics: allow to pass in keyring by name
Date: Mon, 23 Nov 2026 13:14:53 +0100 [thread overview]
Message-ID: <20261123-dhchap-keyring-v4-v5-8-81eefb4c0724@kernel.org> (raw)
In-Reply-To: <20261123-dhchap-keyring-v4-v5-0-81eefb4c0724@kernel.org>
The current interface of passing in keyrings by serial number is very
impractical for configuration scripts, as the serial number is not
persistent across reboots, and so any configuration files will need
to be adjusted.
This patchs allows to specify the TLS keyring by name in addition to
the serial number to simplify configuration file handling.
Signed-off-by: Hannes Reinecke <hare@kernel.org>
---
drivers/nvme/host/fabrics.c | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 1277749c6e2e3012b5161a7d03589a6ced300a05..5dc1e1d5fb4629b82b2bce4d37fe9ce5d17acab6 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -14,6 +14,7 @@
#include "fabrics.h"
#include <linux/nvme-auth.h>
#include <linux/nvme-keyring.h>
+#include <linux/key-type.h>
static DECLARE_RWSEM(nvmf_transports_rwsem);
static LIST_HEAD_GUARDED(nvmf_transports, nvmf_transports_rwsem);
@@ -697,7 +698,7 @@ static const match_table_t opt_tokens = {
{ NVMF_OPT_NR_POLL_QUEUES, "nr_poll_queues=%d" },
{ NVMF_OPT_TOS, "tos=%d" },
#ifdef CONFIG_NVME_TCP_TLS
- { NVMF_OPT_KEYRING, "keyring=%d" },
+ { NVMF_OPT_KEYRING, "keyring=%s" },
{ NVMF_OPT_TLS_KEY, "tls_key=%d" },
#endif
{ NVMF_OPT_FAIL_FAST_TMO, "fast_io_fail_tmo=%d" },
@@ -992,17 +993,33 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
opts->tos = token;
break;
case NVMF_OPT_KEYRING:
+#ifdef CONFIG_NVME_KEYRING
if (match_int(args, &key_id) || key_id <= 0) {
- ret = -EINVAL;
- goto out;
- }
- key = nvmf_parse_key(key_id);
- if (IS_ERR(key)) {
- ret = PTR_ERR(key);
- goto out;
+ p = match_strdup(args);
+ if (!p) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ key = request_key(&key_type_keyring, p, NULL);
+ kfree(p);
+ if (IS_ERR(key)) {
+ ret = PTR_ERR(key);
+ goto out;
+ }
+ } else {
+ key = nvmf_parse_key(key_id);
+ if (IS_ERR(key)) {
+ ret = PTR_ERR(key);
+ goto out;
+ }
}
key_put(opts->keyring);
opts->keyring = key;
+#else
+ pr_warn("nvme keyring is disabled\n");
+ ret = -EINVAL;
+ goto out;
+#endif
break;
case NVMF_OPT_TLS_KEY:
if (match_int(args, &key_id) || key_id <= 0) {
--
2.51.0
next prev parent reply other threads:[~2026-11-23 12:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 12:14 [PATCH v5 0/9] nvme-auth: switch to use the kernel keyring Hannes Reinecke
2026-11-23 12:14 ` [PATCH v5 1/9] nvme-auth: modify nvme_auth_transform_key() to return status Hannes Reinecke
2026-11-23 12:14 ` [PATCH v5 2/9] nvme-keyring: add 'dhchap' key type Hannes Reinecke
2026-11-23 12:14 ` [PATCH v5 3/9] nvme-auth: switch to use 'struct key' Hannes Reinecke
2026-11-23 12:14 ` [PATCH v5 4/9] nvme: parse dhchap keys during option parsing Hannes Reinecke
2026-11-23 12:14 ` [PATCH v5 5/9] nvmet-auth: parse dhchap key from configfs attribute Hannes Reinecke
2026-11-23 12:14 ` [PATCH v5 6/9] nvme: allow to pass in key description as dhchap secret Hannes Reinecke
2026-11-23 12:14 ` [PATCH v5 7/9] nvme-auth: wait for authentication to finish when changing keys Hannes Reinecke
2026-11-23 12:14 ` Hannes Reinecke [this message]
2026-11-23 12:14 ` [PATCH v5 9/9] nvmet: add configfs attribute 'dhchap_keyring' Hannes Reinecke
2026-11-23 12:59 ` [PATCH v5 0/9] nvme-auth: switch to use the kernel keyring Martin Belanger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123-dhchap-keyring-v4-v5-8-81eefb4c0724@kernel.org \
--to=hare@kernel.org \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®