Blob Blame History Raw
From 96eaaacaeac39625508e6ec8022bb5e565c36a7c Mon Sep 17 00:00:00 2001
From: Anish Bhatt <anish@chelsio.com>
Date: Fri, 25 Jul 2014 12:42:27 -0700
Subject: [PATCH] iscsiadm : make iface.ipaddress optional in iface configs for
 transports that don't have a hard requirement on it.

v2: cxgb4i changed to NOT_REQ as set ipaddress is not supported
Signed-off-by: Anish Bhatt <anish@chelsio.com>
---
 usr/initiator_common.c | 15 ++++++++++++---
 usr/transport.c        |  8 ++++----
 usr/transport.h        |  6 ++++++
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/usr/initiator_common.c b/usr/initiator_common.c
index 50f8d41..8ff993d 100644
--- a/usr/initiator_common.c
+++ b/usr/initiator_common.c
@@ -685,9 +685,18 @@ int iscsi_host_set_net_params(struct iface_rec *iface,
 
 	/* if we need to set the ip addr then set all the iface net settings */
 	if (!iface_is_bound_by_ipaddr(iface)) {
-		log_warning("Please set the iface.ipaddress for iface %s, "
-			    "then retry the login command.\n", iface->name);
-		return EINVAL;
+		if (t->template->set_host_ip == SET_HOST_IP_REQ) {
+			log_warning("Please set the iface.ipaddress for iface "
+				    "%s, then retry the login command.\n",
+				    iface->name);
+			return EINVAL;
+		} else if (t->template->set_host_ip == SET_HOST_IP_OPT) {
+			log_info("Optional iface.ipaddress for iface %s "
+				 "not set.\n", iface->name);
+			return 0;
+		} else {
+			return EINVAL;
+		}
 	}
 
 	/* these type of drivers need the netdev upd */
diff --git a/usr/transport.c b/usr/transport.c
index 2f38519..630f163 100644
--- a/usr/transport.c
+++ b/usr/transport.c
@@ -58,7 +58,7 @@ struct iscsi_transport_template iscsi_iser = {
 
 struct iscsi_transport_template cxgb3i = {
 	.name		= "cxgb3i",
-	.set_host_ip	= 1,
+	.set_host_ip	= SET_HOST_IP_OPT,
 	.ep_connect	= ktransport_ep_connect,
 	.ep_poll	= ktransport_ep_poll,
 	.ep_disconnect	= ktransport_ep_disconnect,
@@ -67,7 +67,7 @@ struct iscsi_transport_template cxgb3i = {
 
 struct iscsi_transport_template cxgb4i = {
 	.name		= "cxgb4i",
-	.set_host_ip	= 1,
+	.set_host_ip	= SET_HOST_IP_NOT_REQ,
 	.ep_connect	= ktransport_ep_connect,
 	.ep_poll	= ktransport_ep_poll,
 	.ep_disconnect	= ktransport_ep_disconnect,
@@ -76,7 +76,7 @@ struct iscsi_transport_template cxgb4i = {
 
 struct iscsi_transport_template bnx2i = {
 	.name		= "bnx2i",
-	.set_host_ip	= 1,
+	.set_host_ip	= SET_HOST_IP_REQ,
 	.use_boot_info	= 1,
 	.ep_connect	= ktransport_ep_connect,
 	.ep_poll	= ktransport_ep_poll,
@@ -94,7 +94,7 @@ struct iscsi_transport_template be2iscsi = {
 
 struct iscsi_transport_template qla4xxx = {
 	.name		= "qla4xxx",
-	.set_host_ip	= 0,
+	.set_host_ip	= SET_HOST_IP_NOT_REQ,
 	.ep_connect	= ktransport_ep_connect,
 	.ep_poll	= ktransport_ep_poll,
 	.ep_disconnect	= ktransport_ep_disconnect,
diff --git a/usr/transport.h b/usr/transport.h
index 388e4b1..73041fa 100644
--- a/usr/transport.h
+++ b/usr/transport.h
@@ -20,6 +20,12 @@
 #include "types.h"
 #include "config.h"
 
+enum set_host_ip_opts {
+	SET_HOST_IP_NOT_REQ,	/* iface.ipaddress is not supported	*/
+	SET_HOST_IP_REQ,	/* iface.ipaddress must be specified	*/
+	SET_HOST_IP_OPT,	/* iface.ipaddress is not required	*/
+};
+
 struct iscsi_transport;
 struct iscsi_conn;
 
-- 
1.9.3