nvme: do not retry authentication failures
authorDaniel Wagner <dwagner@suse.de>
Tue, 30 Apr 2024 13:19:28 +0000 (15:19 +0200)
committerKeith Busch <kbusch@kernel.org>
Wed, 1 May 2024 10:07:20 +0000 (03:07 -0700)
When the key is invalid there is no point in retrying. Because the auth
code returns kernel error codes only, we can't test on the DNR bit.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/auth.c
drivers/nvme/host/fabrics.c

index a264b3ae078b8c4c28382c7d8f8757c7e3eec594..371e14f0a20392d9e43ed45084f6a8f04dc87949 100644 (file)
@@ -730,7 +730,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
                                         NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE);
        if (ret) {
                chap->status = ret;
-               chap->error = -ECONNREFUSED;
+               chap->error = -EKEYREJECTED;
                return;
        }
 
@@ -797,7 +797,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
                                         NVME_AUTH_DHCHAP_MESSAGE_SUCCESS1);
        if (ret) {
                chap->status = ret;
-               chap->error = -ECONNREFUSED;
+               chap->error = -EKEYREJECTED;
                return;
        }
 
@@ -818,7 +818,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
        ret = nvme_auth_process_dhchap_success1(ctrl, chap);
        if (ret) {
                /* Controller authentication failed */
-               chap->error = -ECONNREFUSED;
+               chap->error = -EKEYREJECTED;
                goto fail2;
        }
 
index 36d3e2ff27f3f31638b4e832413d771d8e2159f1..c6ad2148c2e04d9aef648d54f76f9db4cfc94ba4 100644 (file)
@@ -567,12 +567,18 @@ EXPORT_SYMBOL_GPL(nvmf_connect_io_queue);
  *
  * - the DNR bit is set and the specification states no further connect
  *   attempts with the same set of paramenters should be attempted.
+ *
+ * - when the authentication attempt fails, because the key was invalid.
+ *   This error code is set on the host side.
  */
 bool nvmf_should_reconnect(struct nvme_ctrl *ctrl, int status)
 {
        if (status > 0 && (status & NVME_SC_DNR))
                return false;
 
+       if (status == -EKEYREJECTED)
+               return false;
+
        if (ctrl->opts->max_reconnects == -1 ||
            ctrl->nr_reconnects < ctrl->opts->max_reconnects)
                return true;