[PATCH] handling errors in redirect command output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fixed handling of erroneous output from the dynamic redirect cmd.
Currently such failures don't not make their way up the call stack,
and the initiator is left in logged-in state.
This fix returns negative ret code if redir cmd processing failed,
and adds sending login target error when this happens, as the reaction
to the negative retcode.

Signed-off-by: Alexander Nezhinsky <alexandern@xxxxxxxxxxxx>
---
 usr/iscsi/iscsid.c |   11 +++++++++--
 usr/iscsi/target.c |    2 ++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 3a79d93..f739a12 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -431,7 +431,7 @@ static void login_start(struct iscsi_connection *conn)
 	char *name, *alias, *session_type, *target_name;
 	struct iscsi_target *target;
 	char buf[NI_MAXHOST + NI_MAXSERV + 4];
-	int reason;
+	int reason, redir;
 
 	conn->cid = be16_to_cpu(req->cid);
 	memcpy(conn->isid, req->isid, sizeof(req->isid));
@@ -491,7 +491,14 @@ static void login_start(struct iscsi_connection *conn)
 
 		conn->tid = target->tid;
 
-		if (target_redirected(target, conn, buf, &reason)) {
+		redir = target_redirected(target, conn, buf, &reason);
+		if (redir < 0) {
+			rsp->status_class = ISCSI_STATUS_CLS_TARGET_ERR;
+			rsp->status_detail = ISCSI_LOGIN_STATUS_TARGET_ERROR;
+			conn->state = STATE_EXIT;
+			return;
+		}
+		else if (redir) {
 			text_key_add(conn, "TargetAddress", buf);
 			rsp->status_class = ISCSI_STATUS_CLS_REDIRECT;
 			rsp->status_detail = reason;
diff --git a/usr/iscsi/target.c b/usr/iscsi/target.c
index a36d3d4..27bcdeb 100644
--- a/usr/iscsi/target.c
+++ b/usr/iscsi/target.c
@@ -261,6 +261,8 @@ int target_redirected(struct iscsi_target *target,
 		sprintf(p, "%s", dst);
 		ret = get_redirect_address(in_buf, buffer,
 					sizeof(buffer), &addr, &port, &rsn);
+		if (ret)
+			return -1;
 	}
 
 predefined:
--
1.7.3.2
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux