[PATCH 3/8] Store iscsi initiator alias in connection, copy it to iscsi session, show it in session info

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

 



From: Alexander Nezhinsky <alexandern@xxxxxxxxxxxx>


Signed-off-by: Alexander Nezhinsky <alexandern@xxxxxxxxxxxx>
---
 usr/iscsi/conn.c      |    2 ++
 usr/iscsi/iscsid.c    |    3 +++
 usr/iscsi/iscsid.h    |    2 ++
 usr/iscsi/iser_text.c |    4 ++++
 usr/iscsi/session.c   |   16 ++++++++++++++--
 5 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/usr/iscsi/conn.c b/usr/iscsi/conn.c
index 9015610..6111566 100644
--- a/usr/iscsi/conn.c
+++ b/usr/iscsi/conn.c
@@ -76,6 +76,8 @@ void conn_exit(struct iscsi_connection *conn)
 	free(conn->req_buffer);
 	free(conn->rsp_buffer);
 	free(conn->initiator);
+	if (conn->initiator_alias)
+		free(conn->initiator_alias);
 
 	if (session)
 		session_put(session);
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 144d2bd..ae249cd 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -457,7 +457,10 @@ static void login_start(struct iscsi_connection *conn)
 		return;
 	}
 	conn->initiator = strdup(name);
+
 	alias = text_key_find(conn, "InitiatorAlias");
+	if (alias)
+		conn->initiator_alias = strdup(alias);
 
 	session_type = text_key_find(conn, "SessionType");
 	target_name = text_key_find(conn, "TargetName");
diff --git a/usr/iscsi/iscsid.h b/usr/iscsi/iscsid.h
index bed83c0..b815b8c 100644
--- a/usr/iscsi/iscsid.h
+++ b/usr/iscsi/iscsid.h
@@ -74,6 +74,7 @@ struct iscsi_session {
 	struct list_head hlist;
 
 	char *initiator;
+	char *initiator_alias;
 	struct iscsi_target *target;
 	uint8_t isid[6];
 	uint16_t tsih;
@@ -150,6 +151,7 @@ struct iscsi_connection {
 	struct param session_param[ISCSI_PARAM_MAX];
 
 	char *initiator;
+	char *initiator_alias;
 	uint8_t isid[6];
 	uint16_t tsih;
 	uint16_t cid;
diff --git a/usr/iscsi/iser_text.c b/usr/iscsi/iser_text.c
index c703492..b931f34 100644
--- a/usr/iscsi/iser_text.c
+++ b/usr/iscsi/iser_text.c
@@ -439,7 +439,11 @@ static void iser_login_start(struct iscsi_connection *iscsi_conn,
 		return;
 	}
 	iscsi_conn->initiator = strdup(name);
+
 	alias = iser_text_key_find(req_data, req_datasize, "InitiatorAlias");
+	if (alias)
+		iscsi_conn->initiator_alias = strdup(alias);
+
 	session_type = iser_text_key_find(req_data, req_datasize, "SessionType");
 	target_name = iser_text_key_find(req_data, req_datasize, "TargetName");
 
diff --git a/usr/iscsi/session.c b/usr/iscsi/session.c
index 46864c7..2c675b8 100644
--- a/usr/iscsi/session.c
+++ b/usr/iscsi/session.c
@@ -95,9 +95,19 @@ int session_create(struct iscsi_connection *conn)
 		return -ENOMEM;
 	}
 
+	if (conn->initiator_alias) {
+		session->initiator_alias = strdup(conn->initiator_alias);
+		if (!session->initiator_alias) {
+			free(session);
+			return -ENOMEM;
+		}
+	}
+
 	session->info = zalloc(1024);
 	if (!session->info) {
 		free(session->initiator);
+		if (session->initiator_alias)
+			free(session->initiator_alias);
 		free(session);
 		return -ENOMEM;
 	}
@@ -105,9 +115,11 @@ int session_create(struct iscsi_connection *conn)
 	memset(addr, 0, sizeof(addr));
 	conn->tp->ep_show(conn, addr, sizeof(addr));
 
-	snprintf(session->info, 1024, _TAB3 "Initiator: %s\n"
+	snprintf(session->info, 1024, _TAB3 "Initiator: %s alias: %s\n"
 		 _TAB3 "Connection: %u\n"
-		 _TAB4 "%s\n", session->initiator, conn->cid, addr);
+		 _TAB4 "%s\n", session->initiator,
+		session->initiator_alias ? session->initiator_alias : "none",
+		conn->cid, addr);
 
 	err = it_nexus_create(target->tid, tsih, 0, session->info);
 	if (err) {
-- 
1.7.9.6

--
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