[RFC 1/1] iscsi_tcp: Support the keyword "ANY" for the iscsi_portal_addr string.

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

 



Let the "ANY" keyword designate an INADDR_ANY/IN6ADDR_ANY_INIT when
specifying the --iscsi portal=XXX command option to the iscsi_tcp protocol
driver. (.i.e pass NULL as the first parameter to getaddrinfo());

This makes it easy to change just the port service number but
keep tgtd bind on all interfaces. It is useful when the ISCSI
default port is used by another demon and we want tgtd to export
an alternative iscsi-target.

example usage:
	tgtd --iscsi portal=ANY:3251

Signed-off-by: Boaz Harrosh <bharrosh@xxxxxxxxxxx>
---
 doc/tgtd.8.xml     |    6 ++++++
 usr/iscsi/iscsid.c |   18 ++++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/doc/tgtd.8.xml b/doc/tgtd.8.xml
index 33ef7f9..a6dd16c 100644
--- a/doc/tgtd.8.xml
+++ b/doc/tgtd.8.xml
@@ -100,12 +100,18 @@
       <para>
 	This option is used to bind tgtd to a specific ip-address/portal and/or
 	port. By default tgtd will bind to port 3260 on the wildcard address.
+	The keyword "ANY" can be used to designate the wildcard address with a
+	none-default port.
       </para>
       <para>
       Example: to bind tgtd to a specific address and port
       <screen format="linespecific">
 	tgtd --iscsi portal=192.0.2.1:3260
       </screen>
+      Example: to bind tgtd to any address but none-default port
+      <screen format="linespecific">
+	tgtd --iscsi portal=ANY:3251
+      </screen>
       </para>
     </refsect2>
   </refsect1>
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 2adc6a8..079acf3 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -2312,13 +2312,19 @@ static int iscsi_param_parser(char *p)
 			else
 				q = strchr(addr, ',');
 
-			if (q)
-				len = q - addr;
-			else
-				len = strlen(addr);
+			if (0 == strncmp("ANY", addr, 3)) {
+				if (iscsi_portal_addr)
+					free(iscsi_portal_addr);
+				iscsi_portal_addr = NULL;
+			} else {
+				if (q)
+					len = q - addr;
+				else
+					len = strlen(addr);
 
-			iscsi_portal_addr = zalloc(len + 1);
-			memcpy(iscsi_portal_addr, addr, len);
+				iscsi_portal_addr = zalloc(len + 1);
+				memcpy(iscsi_portal_addr, addr, len);
+			}
 		}
 
 		p += strcspn(p, ",");
-- 
1.6.6.1

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