[iscsi-initiator-utils: 57/109] Resolves: #624437

Chris Leech cleech at fedoraproject.org
Tue Dec 10 21:24:10 UTC 2013


commit 657d74971cbe874c88af5ce74985a3ba258a761a
Author: mchristi <mchristi at redhat.com>
Date:   Tue Feb 1 08:12:56 2011 +0000

    Resolves: #624437

 iscsi-initiator-utils-node-mode-hostname.patch |  122 ++++++++++++++++++++++++
 iscsi-initiator-utils.spec                     |    4 +
 2 files changed, 126 insertions(+), 0 deletions(-)
---
diff --git a/iscsi-initiator-utils-node-mode-hostname.patch b/iscsi-initiator-utils-node-mode-hostname.patch
new file mode 100644
index 0000000..de8cca4
--- /dev/null
+++ b/iscsi-initiator-utils-node-mode-hostname.patch
@@ -0,0 +1,122 @@
+diff -aurp open-iscsi-2.0-872-rc4-bnx2i/doc/iscsiadm.8 open-iscsi-2.0-872-rc4-bnx2i.work/doc/iscsiadm.8
+--- open-iscsi-2.0-872-rc4-bnx2i/doc/iscsiadm.8	2011-02-01 02:10:05.000000000 -0600
++++ open-iscsi-2.0-872-rc4-bnx2i.work/doc/iscsiadm.8	2011-02-01 02:10:16.000000000 -0600
+@@ -171,8 +171,14 @@ sid is passed in.
+ 
+ .TP
+ \fB\-p\fR, \fB\-\-portal=\fIip[:port]\fR
+-Use target portal with ip-address \fIip\fR and \fIport\fR, the default
+-\fIport\fR value is 3260.
++Use target portal with ip-address \fIip\fR and \fIport\fR. If port is not passed
++in the default \fIport\fR value is 3260.
++.IP
++IPv6 addresses can bs specified as [ddd.ddd.ddd.ddd]:port or
++ddd.ddd.ddd.ddd.
++.IP
++Hostnames can also be used for the ip argument.
++
+ .IP
+ This option is only valid for discovery, or for node operations with
+ the \fInew\fR operator.
+diff -aurp open-iscsi-2.0-872-rc4-bnx2i/README open-iscsi-2.0-872-rc4-bnx2i.work/README
+--- open-iscsi-2.0-872-rc4-bnx2i/README	2011-02-01 02:10:05.000000000 -0600
++++ open-iscsi-2.0-872-rc4-bnx2i.work/README	2011-02-01 02:11:37.000000000 -0600
+@@ -646,6 +646,9 @@ To now log into targets it is the same a
+ 	If a record does not exist, it will be created using the iscsid.conf
+ 	discovery settings.
+ 
++	The argument to -p may also be a hostname instead of an address.
++	     ./iscsiadm -m discoverydb -t st -p somehost --discover
++
+ 	For the ifaces, iscsiadm will first search /var/lib/iscsi/ifaces for
+ 	interfaces using software iscsi. If any are found then nodes found
+ 	during discovery will be setup so that they can logged in through
+@@ -770,6 +773,10 @@ To now log into targets it is the same a
+ 	    ./iscsiadm -m node -T iqn.2005-03.com.max \
+ 				-p [2001:c90::211:9ff:feb8:a9e9]:3260 -l
+ 
++	To specify a hostname the following can be used:
++
++	    ./iscsiadm -m node -T iqn.2005-03.com.max -p somehost -l
++
+     - iSCSI Login to a specific portal through the NIC setup as iface0:
+ 
+ 	    ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 \
+diff -aurp open-iscsi-2.0-872-rc4-bnx2i/usr/iscsi_util.c open-iscsi-2.0-872-rc4-bnx2i.work/usr/iscsi_util.c
+--- open-iscsi-2.0-872-rc4-bnx2i/usr/iscsi_util.c	2011-02-01 02:10:05.000000000 -0600
++++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/iscsi_util.c	2011-02-01 02:10:16.000000000 -0600
+@@ -217,6 +217,64 @@ char *cfg_get_string_param(char *pathnam
+ 	return value;
+ }
+ 
++/**
++ * iscsi_addr_match - check if the addrs are to the same ip
++ * @address1: pattern
++ * @address2: address to check
++ *
++ * If address1 is blank then it matches any string passed in.
++ */
++static int iscsi_addr_match(char *address1, char *address2)
++{
++	struct addrinfo hints1, hints2, *res1, *res2;
++	int rc;
++
++	if (!strlen(address1))
++		return 1;
++
++	if (!strcmp(address1, address2))
++		return 1;
++
++	memset(&hints1, 0, sizeof(struct addrinfo));
++	hints1.ai_family = AF_UNSPEC;
++	hints1.ai_socktype = SOCK_STREAM;
++
++	memset(&hints2, 0, sizeof(struct addrinfo));
++	hints2.ai_family = AF_UNSPEC;
++	hints2.ai_socktype = SOCK_STREAM;
++
++	/*
++	 * didn't match so we have to resolve to see if one is a dnsname
++	 * that matches a ip address.
++	 */
++	rc = getaddrinfo(address1, NULL, &hints1, &res1);
++	if (rc) {
++		log_debug(1, "Match error. Could not resolve %s: %s", address1,
++			  gai_strerror(rc));
++		return 0;
++
++	}
++
++	rc = getaddrinfo(address2, NULL, &hints2, &res2);
++	if (rc) {
++		log_debug(1, "Match error. Could not resolve %s: %s", address2,
++			  gai_strerror(rc));
++		rc = 0;
++		goto free_res1;
++	}
++
++	if ((res1->ai_addrlen != res2->ai_addrlen) ||
++	    memcmp(res1->ai_addr, res2->ai_addr, res2->ai_addrlen))
++		rc = 0;
++	else
++		rc = 1;
++
++	freeaddrinfo(res2);
++free_res1:
++	freeaddrinfo(res1);
++	return rc;
++}
++
+ int __iscsi_match_session(node_rec_t *rec, char *targetname,
+ 			  char *address, int port, struct iface_rec *iface)
+ {
+@@ -240,8 +298,7 @@ int __iscsi_match_session(node_rec_t *re
+ 	if (strlen(rec->name) && strcmp(rec->name, targetname))
+ 		return 0;
+ 
+-	if (strlen(rec->conn[0].address) &&
+-	    strcmp(rec->conn[0].address, address))
++	if (!iscsi_addr_match(rec->conn[0].address, address))
+ 		return 0;
+ 
+ 	if (rec->conn[0].port != -1 && port != rec->conn[0].port)
diff --git a/iscsi-initiator-utils.spec b/iscsi-initiator-utils.spec
index b09a6db..4e087d2 100644
--- a/iscsi-initiator-utils.spec
+++ b/iscsi-initiator-utils.spec
@@ -37,6 +37,8 @@ Patch11: iscsi-initiator-utils-uio-handle-different-iface_rec.patch
 Patch12: iscsi-initiator-utils-brcm-man.patch
 # Don't build unused isns dsa code.
 Patch13: iscsi-initiator-utils-disable-dsa-code.patch
+# support hostnames in node mode
+Patch14: iscsi-initiator-utils-node-mode-hostname.patch
 
 Group: System Environment/Daemons
 License: GPLv2+
@@ -78,6 +80,7 @@ developing applications that use %{name}.
 %patch11 -p1 -b .uio-handle-different-iface_rec
 %patch12 -p1 -b .brcm-man
 %patch13 -p1 -b .disable-dsa-code
+%patch14 -p1 -b .node-mode-hostname
 
 %build
 cd utils/open-isns
@@ -211,6 +214,7 @@ using them and should not fail startup on all iscsiadm login failures.
 57711E, and 57712 hardware.
 - 640115 fix hang caused due to race in ISCSI_ERR_INVALID_HOST handling.
 - 640340 fix iscsiadm exit codes.
+- 624437 support hostnames in node mode.
 
 * Fri Dec 3 2010 Ales Kozumplik <akozumpl at redhat.com> 6.2.0.872.13
 - 442980 libiscsi: reimplement fw discovery so partial devices are used properly.


More information about the scm-commits mailing list