[PATCH] iscsi_tcp: Support INADDR_ANY in the iscsi portal= string.

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

 



Let a missing ip-address part designate an INADDR_ANY 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=:3251
                            ^ ip-address is missing

Above will bind to all interfaces at port 3251.

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

diff --git a/doc/tgtd.8.xml b/doc/tgtd.8.xml
index 33ef7f9..2635a8f 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 ip-address part (before the ":") can be missing 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 a none-default port
+      <screen format="linespecific">
+	tgtd --iscsi portal=:3251
+      </screen>
       </para>
     </refsect2>
   </refsect1>
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 2adc6a8..dcca384 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -2317,8 +2317,14 @@ static int iscsi_param_parser(char *p)
 			else
 				len = strlen(addr);
 
-			iscsi_portal_addr = zalloc(len + 1);
-			memcpy(iscsi_portal_addr, addr, len);
+			if (iscsi_portal_addr) {
+				free(iscsi_portal_addr);
+				iscsi_portal_addr = NULL;
+			}
+			if (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