Skip to content

Commit 0e34bd9

Browse files
igawkeithbusch
authored andcommitted
nvme: do not retry authentication failures
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 <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent adfde7e commit 0e34bd9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

drivers/nvme/host/auth.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
730730
NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE);
731731
if (ret) {
732732
chap->status = ret;
733-
chap->error = -ECONNREFUSED;
733+
chap->error = -EKEYREJECTED;
734734
return;
735735
}
736736

@@ -797,7 +797,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
797797
NVME_AUTH_DHCHAP_MESSAGE_SUCCESS1);
798798
if (ret) {
799799
chap->status = ret;
800-
chap->error = -ECONNREFUSED;
800+
chap->error = -EKEYREJECTED;
801801
return;
802802
}
803803

@@ -818,7 +818,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
818818
ret = nvme_auth_process_dhchap_success1(ctrl, chap);
819819
if (ret) {
820820
/* Controller authentication failed */
821-
chap->error = -ECONNREFUSED;
821+
chap->error = -EKEYREJECTED;
822822
goto fail2;
823823
}
824824

drivers/nvme/host/fabrics.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,18 @@ EXPORT_SYMBOL_GPL(nvmf_connect_io_queue);
567567
*
568568
* - the DNR bit is set and the specification states no further connect
569569
* attempts with the same set of paramenters should be attempted.
570+
*
571+
* - when the authentication attempt fails, because the key was invalid.
572+
* This error code is set on the host side.
570573
*/
571574
bool nvmf_should_reconnect(struct nvme_ctrl *ctrl, int status)
572575
{
573576
if (status > 0 && (status & NVME_SC_DNR))
574577
return false;
575578

579+
if (status == -EKEYREJECTED)
580+
return false;
581+
576582
if (ctrl->opts->max_reconnects == -1 ||
577583
ctrl->nr_reconnects < ctrl->opts->max_reconnects)
578584
return true;

0 commit comments

Comments
 (0)