[PATCH 1/2] nvme: Do not re-authenticate queues with no prior authentication
Hannes Reinecke
hare at kernel.org
Wed Jul 17 04:03:37 PDT 2024
When sending 'connect' the queues can figure out whether authentication
is required. But reauthentication doesn't disconnect the queues, so this
check is not available. Rather we need to check whether the queue had
been authenticated initially to figure out if we need to reauthenticate.
Signed-off-by: Hannes Reinecke <hare at kernel.org>
---
drivers/nvme/host/auth.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
index 23ff3df27e80..66828742586c 100644
--- a/drivers/nvme/host/auth.c
+++ b/drivers/nvme/host/auth.c
@@ -31,6 +31,7 @@ struct nvme_dhchap_queue_context {
u32 s1;
u32 s2;
bool bi_directional;
+ bool authenticated;
u16 transaction;
u8 status;
u8 dhgroup_id;
@@ -915,6 +916,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
goto fail2;
if (chap->qid || !ctrl->opts->concat) {
chap->error = 0;
+ chap->authenticated = true;
return;
}
ret = nvme_auth_secure_concat(ctrl, chap);
@@ -923,8 +925,10 @@ static void nvme_queue_auth_work(struct work_struct *work)
"%s: qid %d failed to enable secure concatenation\n",
__func__, chap->qid);
chap->error = ret;
- } else
+ } else {
chap->error = 0;
+ chap->authenticated = true;
+ }
return;
fail2:
@@ -940,6 +944,8 @@ static void nvme_queue_auth_work(struct work_struct *work)
*/
if (ret && !chap->error)
chap->error = ret;
+ if (chap->error)
+ chap->authenticated = false;
}
int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid)
@@ -1011,6 +1017,14 @@ static void nvme_ctrl_auth_work(struct work_struct *work)
return;
for (q = 1; q < ctrl->queue_count; q++) {
+ /*
+ * Skip re-authentication if the queue had
+ * not been authenticated initially.
+ */
+ if (!ctrl->dhchap_ctxs[q].authenticated) {
+ ctrl->dhchap_ctxs[q].error = 0;
+ continue;
+ }
ret = nvme_auth_negotiate(ctrl, q);
if (ret) {
dev_warn(ctrl->device,
@@ -1064,6 +1078,7 @@ int nvme_auth_init_ctrl(struct nvme_ctrl *ctrl)
chap = &ctrl->dhchap_ctxs[i];
chap->qid = i;
chap->ctrl = ctrl;
+ chap->authenticated = false;
INIT_WORK(&chap->auth_work, nvme_queue_auth_work);
}
--
2.35.3
More information about the Linux-nvme
mailing list