From d1833a9f52aa81b3ec1687c4f1233bd0074ad313 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Sun, 1 Dec 2019 18:45:36 -0500 Subject: [PATCH] lib/iscsi: Move up iscsi_op_login_check_target in a file This patch series orders login related functions top down in iscsi.c. Signed-off-by: Shuhei Matsumoto Change-Id: I39431b213216b1e4e677f80de8c14c40dd7da150 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476414 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris --- lib/iscsi/iscsi.c | 86 +++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 72c6695b3..6f7246b4e 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -1406,6 +1406,49 @@ iscsi_op_login_session_type(struct spdk_iscsi_conn *conn, return 0; } +/* + * This function is used to check the target info + * return: + * 0: success + * otherwise: error + */ +static int +iscsi_op_login_check_target(struct spdk_iscsi_conn *conn, + struct spdk_iscsi_pdu *rsp_pdu, + const char *target_name, + struct spdk_iscsi_tgt_node **target) +{ + bool result; + struct iscsi_bhs_login_rsp *rsph; + + rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs; + *target = spdk_iscsi_find_tgt_node(target_name); + if (*target == NULL) { + SPDK_WARNLOG("target %s not found\n", target_name); + /* Not found */ + rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; + rsph->status_detail = ISCSI_LOGIN_TARGET_NOT_FOUND; + return SPDK_ISCSI_LOGIN_ERROR_RESPONSE; + } + if (spdk_iscsi_tgt_node_is_destructed(*target)) { + SPDK_ERRLOG("target %s is removed\n", target_name); + rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; + rsph->status_detail = ISCSI_LOGIN_TARGET_REMOVED; + return SPDK_ISCSI_LOGIN_ERROR_RESPONSE; + } + result = spdk_iscsi_tgt_node_access(conn, *target, + conn->initiator_name, + conn->initiator_addr); + if (!result) { + SPDK_ERRLOG("access denied\n"); + rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; + rsph->status_detail = ISCSI_LOGIN_AUTHORIZATION_FAIL; + return SPDK_ISCSI_LOGIN_ERROR_RESPONSE; + } + + return 0; +} + /* * This function is used to del the original param and update it with new * value @@ -1566,49 +1609,6 @@ iscsi_op_login_check_session(struct spdk_iscsi_conn *conn, return rc; } -/* - * This function is used to check the target info - * return: - * 0: success - * otherwise: error - */ -static int -iscsi_op_login_check_target(struct spdk_iscsi_conn *conn, - struct spdk_iscsi_pdu *rsp_pdu, - const char *target_name, - struct spdk_iscsi_tgt_node **target) -{ - bool result; - struct iscsi_bhs_login_rsp *rsph; - - rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs; - *target = spdk_iscsi_find_tgt_node(target_name); - if (*target == NULL) { - SPDK_WARNLOG("target %s not found\n", target_name); - /* Not found */ - rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; - rsph->status_detail = ISCSI_LOGIN_TARGET_NOT_FOUND; - return SPDK_ISCSI_LOGIN_ERROR_RESPONSE; - } - if (spdk_iscsi_tgt_node_is_destructed(*target)) { - SPDK_ERRLOG("target %s is removed\n", target_name); - rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; - rsph->status_detail = ISCSI_LOGIN_TARGET_REMOVED; - return SPDK_ISCSI_LOGIN_ERROR_RESPONSE; - } - result = spdk_iscsi_tgt_node_access(conn, *target, - conn->initiator_name, - conn->initiator_addr); - if (!result) { - SPDK_ERRLOG("access denied\n"); - rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; - rsph->status_detail = ISCSI_LOGIN_AUTHORIZATION_FAIL; - return SPDK_ISCSI_LOGIN_ERROR_RESPONSE; - } - - return 0; -} - /* * The function which is used to handle the part of normal login session * return: