705c81
From 2966a9262df88fcfa971f988f93a9bf168600331 Mon Sep 17 00:00:00 2001
705c81
From: Chris Leech <cleech@redhat.com>
705c81
Date: Sun, 11 Jan 2015 21:36:24 -0800
705c81
Subject: [PATCH] fix regression in iscsi_tcp iface binding
705c81
705c81
The changes in "retry login for ISCSI_ERR_HOST_NOT_FOUND" caused
705c81
sessions using the iscsi_tcp transport bound to a network iface to fail
705c81
to connect due to the host lookup failing (iscsi_tcp hosts are
705c81
dynamically allocated per-session).
705c81
705c81
This marks transports that use a host fixed to a hardware offload device
705c81
with "bind_ep_required" and only requires a host lookup before starting
705c81
the connection if this flag is set.
705c81
705c81
Signed-off-by: Chris Leech <cleech@redhat.com>
705c81
---
705c81
 usr/initiator.c | 30 ++++++++++++++++--------------
705c81
 usr/transport.c |  6 ++++++
705c81
 usr/transport.h |  1 +
705c81
 3 files changed, 23 insertions(+), 14 deletions(-)
705c81
705c81
diff --git a/usr/initiator.c b/usr/initiator.c
705c81
index f54b708..1aadc9b 100644
705c81
--- a/usr/initiator.c
705c81
+++ b/usr/initiator.c
705c81
@@ -398,20 +398,22 @@ __session_create(node_rec_t *rec, struct iscsi_transport *t, int *rc)
705c81
 
705c81
 	iscsi_session_init_params(session);
705c81
 
705c81
-	hostno = iscsi_sysfs_get_host_no_from_hwinfo(&rec->iface, rc);
705c81
-	if (!*rc) {
705c81
-		/*
705c81
-		 * if the netdev or mac was set, then we are going to want
705c81
-		 * to want to bind the all the conns/eps to a specific host
705c81
-		 * if offload is used.
705c81
-		 */
705c81
-		session->conn[0].bind_ep = 1;
705c81
-		session->hostno = hostno;
705c81
-	} else if (*rc == ISCSI_ERR_HOST_NOT_FOUND) {
705c81
-		goto free_session;	
705c81
-	} else {
705c81
-		 *rc = 0;
705c81
-	}
705c81
+        if (t->template->bind_ep_required) {
705c81
+                hostno = iscsi_sysfs_get_host_no_from_hwinfo(&rec->iface, rc);
705c81
+                if (!*rc) {
705c81
+                        /*
705c81
+                         * if the netdev or mac was set, then we are going to want
705c81
+                         * to want to bind the all the conns/eps to a specific host
705c81
+                         * if offload is used.
705c81
+                         */
705c81
+                        session->conn[0].bind_ep = 1;
705c81
+                        session->hostno = hostno;
705c81
+                } else if (*rc == ISCSI_ERR_HOST_NOT_FOUND) {
705c81
+                        goto free_session;	
705c81
+                } else {
705c81
+                         *rc = 0;
705c81
+                }
705c81
+        }
705c81
 
705c81
 	list_add_tail(&session->list, &t->sessions);
705c81
 	return session;
705c81
diff --git a/usr/transport.c b/usr/transport.c
705c81
index 630f163..e778a6e 100644
705c81
--- a/usr/transport.c
705c81
+++ b/usr/transport.c
705c81
@@ -59,6 +59,7 @@ struct iscsi_transport_template iscsi_iser = {
705c81
 struct iscsi_transport_template cxgb3i = {
705c81
 	.name		= "cxgb3i",
705c81
 	.set_host_ip	= SET_HOST_IP_OPT,
705c81
+        .bind_ep_required = 1,
705c81
 	.ep_connect	= ktransport_ep_connect,
705c81
 	.ep_poll	= ktransport_ep_poll,
705c81
 	.ep_disconnect	= ktransport_ep_disconnect,
705c81
@@ -68,6 +69,7 @@ struct iscsi_transport_template cxgb3i = {
705c81
 struct iscsi_transport_template cxgb4i = {
705c81
 	.name		= "cxgb4i",
705c81
 	.set_host_ip	= SET_HOST_IP_NOT_REQ,
705c81
+        .bind_ep_required = 1,
705c81
 	.ep_connect	= ktransport_ep_connect,
705c81
 	.ep_poll	= ktransport_ep_poll,
705c81
 	.ep_disconnect	= ktransport_ep_disconnect,
705c81
@@ -78,6 +80,7 @@ struct iscsi_transport_template bnx2i = {
705c81
 	.name		= "bnx2i",
705c81
 	.set_host_ip	= SET_HOST_IP_REQ,
705c81
 	.use_boot_info	= 1,
705c81
+        .bind_ep_required = 1,
705c81
 	.ep_connect	= ktransport_ep_connect,
705c81
 	.ep_poll	= ktransport_ep_poll,
705c81
 	.ep_disconnect	= ktransport_ep_disconnect,
705c81
@@ -86,6 +89,7 @@ struct iscsi_transport_template bnx2i = {
705c81
 
705c81
 struct iscsi_transport_template be2iscsi = {
705c81
 	.name		= "be2iscsi",
705c81
+        .bind_ep_required = 1,
705c81
 	.create_conn	= be2iscsi_create_conn,
705c81
 	.ep_connect	= ktransport_ep_connect,
705c81
 	.ep_poll	= ktransport_ep_poll,
705c81
@@ -95,6 +99,7 @@ struct iscsi_transport_template be2iscsi = {
705c81
 struct iscsi_transport_template qla4xxx = {
705c81
 	.name		= "qla4xxx",
705c81
 	.set_host_ip	= SET_HOST_IP_NOT_REQ,
705c81
+        .bind_ep_required = 1,
705c81
 	.ep_connect	= ktransport_ep_connect,
705c81
 	.ep_poll	= ktransport_ep_poll,
705c81
 	.ep_disconnect	= ktransport_ep_disconnect,
705c81
@@ -102,6 +107,7 @@ struct iscsi_transport_template qla4xxx = {
705c81
 
705c81
 struct iscsi_transport_template ocs = {
705c81
 	.name		= "ocs",
705c81
+        .bind_ep_required = 1,
705c81
 	.ep_connect	= ktransport_ep_connect,
705c81
 	.ep_poll	= ktransport_ep_poll,
705c81
 	.ep_disconnect	= ktransport_ep_disconnect,
705c81
diff --git a/usr/transport.h b/usr/transport.h
705c81
index 73041fa..831403b 100644
705c81
--- a/usr/transport.h
705c81
+++ b/usr/transport.h
705c81
@@ -38,6 +38,7 @@ struct iscsi_transport_template {
705c81
 	 */
705c81
 	uint8_t set_host_ip;
705c81
 	uint8_t use_boot_info;
705c81
+        uint8_t bind_ep_required;
705c81
 	int (*ep_connect) (struct iscsi_conn *conn, int non_blocking);
705c81
 	int (*ep_poll) (struct iscsi_conn *conn, int timeout_ms);
705c81
 	void (*ep_disconnect) (struct iscsi_conn *conn);
705c81
-- 
705c81
2.1.0
705c81