Commit fdd8cea2 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Jim Harris
Browse files

nvmf/auth: don't disconnect qpairs on reauth timeout



The spec says that a timeout during the reauthentication should only
clear the authentication state, but should not terminate the connection.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I40ad7cdca5842e248c0fb73dd5cd7124872e9bc8
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23799


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 07fb214e
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -139,6 +139,13 @@ nvmf_auth_dhgroup_allowed(struct spdk_nvmf_qpair *qpair, uint8_t dhgroup)
	return tgt->dhchap_dhgroups & SPDK_BIT(dhgroup);
}

static void
nvmf_auth_qpair_cleanup(struct spdk_nvmf_qpair_auth *auth)
{
	spdk_poller_unregister(&auth->poller);
	spdk_nvme_dhchap_dhkey_free(&auth->dhkey);
}

static int
nvmf_auth_timeout_poller(void *ctx)
{
@@ -146,9 +153,15 @@ nvmf_auth_timeout_poller(void *ctx)
	struct spdk_nvmf_qpair_auth *auth = qpair->auth;

	AUTH_ERRLOG(qpair, "authentication timed out\n");

	spdk_poller_unregister(&auth->poller);

	if (qpair->state == SPDK_NVMF_QPAIR_ENABLED) {
		/* Reauthentication timeout isn't considered to be a fatal failure */
		nvmf_auth_set_state(qpair, NVMF_QPAIR_AUTH_COMPLETED);
		nvmf_auth_qpair_cleanup(auth);
	} else {
		nvmf_auth_disconnect_qpair(qpair);
	}

	return SPDK_POLLER_BUSY;
}
@@ -173,13 +186,6 @@ nvmf_auth_rearm_poller(struct spdk_nvmf_qpair *qpair)
	return 0;
}

static void
nvmf_auth_qpair_cleanup(struct spdk_nvmf_qpair_auth *auth)
{
	spdk_poller_unregister(&auth->poller);
	spdk_nvme_dhchap_dhkey_free(&auth->dhkey);
}

static int
nvmf_auth_check_command(struct spdk_nvmf_request *req, uint8_t secp,
			uint8_t spsp0, uint8_t spsp1, uint32_t len)
+15 −0
Original line number Diff line number Diff line
@@ -597,6 +597,21 @@ test_auth_timeout(void)
	CU_ASSERT_EQUAL(qpair.state, SPDK_NVMF_QPAIR_ERROR);
	nvmf_qpair_auth_destroy(&qpair);
	MOCK_SET(spdk_get_ticks, 0);

	/* Check that a timeout during reauthentication doesn't disconnect the qpair, but only
	 * resets the state of the authentication */
	rc = nvmf_qpair_auth_init(&qpair);
	SPDK_CU_ASSERT_FATAL(rc == 0);
	auth = qpair.auth;
	auth->state = NVMF_QPAIR_AUTH_CHALLENGE;
	qpair.state = SPDK_NVMF_QPAIR_ENABLED;

	MOCK_SET(spdk_get_ticks, NVMF_AUTH_DEFAULT_KATO_US);
	poll_threads();
	CU_ASSERT_EQUAL(qpair.state, SPDK_NVMF_QPAIR_ENABLED);
	CU_ASSERT_EQUAL(auth->state, NVMF_QPAIR_AUTH_COMPLETED);
	nvmf_qpair_auth_destroy(&qpair);
	MOCK_SET(spdk_get_ticks, 0);
}

static void