From f874737792bb5761717c2f7388d4d164def1db01 Mon Sep 17 00:00:00 2001 From: GangCao Date: Thu, 13 Jun 2019 18:23:52 -0400 Subject: [PATCH] iscsi: set the rsph with correct error information In several error cases, the status_class and status_detail is not properly set. Change-Id: Ie9cf8ec13b971d7295862872e8c7e834d08e7f14 Signed-off-by: GangCao Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457932 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu --- lib/iscsi/iscsi.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index a3e8aa1f1f..fac2e952d5 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -1483,7 +1483,10 @@ iscsi_op_login_session_normal(struct spdk_iscsi_conn *conn, if (strlen(target_short_name) >= MAX_TARGET_NAME) { SPDK_ERRLOG("Target Short Name (%s) is more than %u characters\n", target_short_name, MAX_TARGET_NAME); - return rc; + /* Invalid request */ + rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; + rsph->status_detail = ISCSI_LOGIN_INVALID_LOGIN_REQUEST; + return SPDK_ISCSI_LOGIN_ERROR_RESPONSE; } snprintf(conn->target_short_name, MAX_TARGET_NAME, "%s", target_short_name); @@ -1513,11 +1516,17 @@ iscsi_op_login_session_normal(struct spdk_iscsi_conn *conn, rc = iscsi_op_login_negotiate_chap_param(conn, *target); pthread_mutex_unlock(&((*target)->mutex)); - if (rc != 0) { - return rc; + if (rc == 0) { + rc = iscsi_op_login_negotiate_digest_param(conn, *target); } - return iscsi_op_login_negotiate_digest_param(conn, *target); + if (rc != 0) { + /* Invalid request */ + rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; + rsph->status_detail = ISCSI_LOGIN_INVALID_LOGIN_REQUEST; + } + + return rc; } /*