[iscsi-initiator-utils: 77/109] Resolves: #736116

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


commit eaa26054bb4ade398b06ae47243fc4c1c21e0ca1
Author: mchristi <mchristi at redhat.com>
Date:   Wed Oct 12 14:32:58 2011 +0000

    Resolves: #736116

 ...ls-Add-Netconfig-support-through-libiscsi.patch |   85 ++++
 iscsi-initiator-utils-add-rh-ver.patch             |    2 +-
 iscsi-initiator-utils-fix-ipv6-boot.patch          |   65 +++
 ...itiator-utils-libiscsi-to-support-offload.patch |  237 ++++++++++
 iscsi-initiator-utils-ofl-iface-fixes.patch        |  471 ++++++++++++++++++++
 iscsi-initiator-utils.spec                         |    4 +-
 6 files changed, 861 insertions(+), 3 deletions(-)
---
diff --git a/iscsi-initiator-utils-Add-Netconfig-support-through-libiscsi.patch b/iscsi-initiator-utils-Add-Netconfig-support-through-libiscsi.patch
new file mode 100644
index 0000000..1696d02
--- /dev/null
+++ b/iscsi-initiator-utils-Add-Netconfig-support-through-libiscsi.patch
@@ -0,0 +1,85 @@
+From e35bdee97477e65866b2c110f0e4b1affe4e983d Mon Sep 17 00:00:00 2001
+From: Harish Zunjarrao <harish.zunjarrao at qlogic.com> 
+Date: Wed, 12 Oct 2011 19:12:03 +0530
+Subject: [PATCH 1/2] iscsi tools: Add Netconfig support through libiscsi
+
+Signed-off-by: Harish Zunjarrao <harish.zunjarrao at qlogic.com>
+Signed-off-by: Vikas Chaudhary <vikas.chaudhary at qlogic.com>
+---
+ libiscsi/libiscsi.c |   25 +++++++++++++++++++++++++
+ libiscsi/libiscsi.h |   16 ++++++++++++++++
+ 2 files changed, 41 insertions(+), 0 deletions(-)
+
+diff --git a/libiscsi/libiscsi.c b/libiscsi/libiscsi.c
+index 42f2e3b..dc63fcd 100644
+--- a/libiscsi/libiscsi.c
++++ b/libiscsi/libiscsi.c
+@@ -38,9 +38,13 @@
+ #include "fw_context.h"
+ #include "iscsid_req.h"
+ #include "iscsi_err.h"
++#include "iscsi_ipc.h"
++#include "transport.h"
+ 
+ #define CHECK(a) { context->error_str[0] = 0; rc = a; if (rc) goto leave; }
+ 
++extern struct iscsi_ipc *ipc;
++
+ /* UGLY, not thread safe :( */
+ static int sysfs_initialized = 0;
+ 
+@@ -610,3 +614,24 @@ int libiscsi_get_firmware_initiator_name(char *initiatorname)
+ 
+ 	return 0;
+ }
++
++int libiscsi_set_netconfig(struct libiscsi_context *context,
++			   uint32_t host_no, char *transport_name,
++			    struct iovec *iovs, int param_count)
++{
++	struct iscsi_transport *t = NULL;
++	int fd;
++	int rc = 1;
++
++	t = iscsi_sysfs_get_transport_by_name(transport_name);
++	if (!t)
++		return ENODEV;
++
++	fd = ipc->ctldev_open();
++	if (fd < 0)
++		return ENODEV;
++
++	rc = ipc->set_net_config(t->handle, host_no, iovs, param_count);
++	ipc->ctldev_close();
++	return rc;
++}
+diff --git a/libiscsi/libiscsi.h b/libiscsi/libiscsi.h
+index 756590e..61ce0ea 100644
+--- a/libiscsi/libiscsi.h
++++ b/libiscsi/libiscsi.h
+@@ -335,6 +335,22 @@ PUBLIC int libiscsi_get_firmware_network_config(
+  */
+ PUBLIC int libiscsi_get_firmware_initiator_name(char *initiatorname);
+ 
++/** \brief Set Network Configuration Settings
++ *
++ * Set Network Configuration Settings
++ *
++ * \param context              libiscsi context to operate on.
++ * \param host_no              Host number of the port.
++ * \param transport_name       Transport Class Name.
++ * \param iovs                 Pointer to IO Vectors of Netconfig paramaters.
++ * \param param_count          Number to IO Vectors.
++ *
++ * \return              0 on success, ENODEV when set netconfig failed.
++ */
++PUBLIC int libiscsi_set_netconfig(struct libiscsi_context *context,
++				  uint32_t host_no, char *transport_name,
++				  struct iovec *iovs, int param_count);
++
+ #undef PUBLIC
+ 
+ #ifdef __cplusplus
+-- 
+1.7.1
+
diff --git a/iscsi-initiator-utils-add-rh-ver.patch b/iscsi-initiator-utils-add-rh-ver.patch
index 2db41c0..b463c72 100644
--- a/iscsi-initiator-utils-add-rh-ver.patch
+++ b/iscsi-initiator-utils-add-rh-ver.patch
@@ -5,7 +5,7 @@
   * some other maintainer could merge a patch without going through us
   */
 -#define ISCSI_VERSION_STR	"2.0-872"
-+#define ISCSI_VERSION_STR	"2.0-872.25.el6"
++#define ISCSI_VERSION_STR	"2.0-872.28.el6"
  #define ISCSI_VERSION_FILE	"/sys/module/scsi_transport_iscsi/version"
  
  #endif
diff --git a/iscsi-initiator-utils-fix-ipv6-boot.patch b/iscsi-initiator-utils-fix-ipv6-boot.patch
new file mode 100644
index 0000000..3c8b4f8
--- /dev/null
+++ b/iscsi-initiator-utils-fix-ipv6-boot.patch
@@ -0,0 +1,65 @@
+diff -aurp open-iscsi-2.0-872-rc4-bnx2i/include/fw_context.h open-iscsi-2.0-872-rc4-bnx2i.work/include/fw_context.h
+--- open-iscsi-2.0-872-rc4-bnx2i/include/fw_context.h	2011-10-10 13:57:38.000000000 -0500
++++ open-iscsi-2.0-872-rc4-bnx2i.work/include/fw_context.h	2011-10-12 01:03:30.000000000 -0500
+@@ -21,6 +21,7 @@
+ #ifndef FWPARAM_CONTEXT_H_
+ #define FWPARAM_CONTEXT_H_
+ 
++#include <netdb.h>
+ #include <net/if.h>
+ 
+ #include "iscsi_proto.h"
+@@ -33,7 +34,7 @@ struct boot_context {
+ 	/* target settings */
+ 	int target_port;
+ 	char targetname[TARGET_NAME_MAXLEN + 1];
+-	char target_ipaddr[32];
++	char target_ipaddr[NI_MAXHOST];
+ 	char chap_name[AUTH_STR_MAX_LEN];
+ 	char chap_password[AUTH_STR_MAX_LEN];
+ 	char chap_name_in[AUTH_STR_MAX_LEN];
+@@ -44,14 +45,14 @@ struct boot_context {
+ 	char initiatorname[TARGET_NAME_MAXLEN + 1];
+ 
+ 	/* network settings */
+-	char dhcp[18];
++	char dhcp[NI_MAXHOST];
+ 	char iface[IF_NAMESIZE];
+ 	char mac[18];
+-	char ipaddr[18];
+-	char gateway[18];
+-	char primary_dns[18];
+-	char secondary_dns[18];
+-	char mask[18];
++	char ipaddr[NI_MAXHOST];
++	char gateway[NI_MAXHOST];
++	char primary_dns[NI_MAXHOST];
++	char secondary_dns[NI_MAXHOST];
++	char mask[NI_MAXHOST];
+ 	char lun[17];
+ 	char vlan[15];
+ 
+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-10-10 13:57:38.000000000 -0500
++++ open-iscsi-2.0-872-rc4-bnx2i.work/README	2011-10-11 00:39:46.000000000 -0500
+@@ -161,7 +161,7 @@ term node to refer to a portal on a targ
+ require that --targetname and --portal argument be used when in node mode.
+ 
+ For session mode, a session id (sid) is used. The sid of a session can be
+-found by running iscsiadm -m session -i. The session id is not currently
++found by running iscsiadm -m session -P 1. The session id is not currently
+ persistent and is partially determined by when the session is setup.
+ 
+ Note that some of the iSCSI Node and iSCSI Discovery operations 
+diff -aurp open-iscsi-2.0-872-rc4-bnx2i/utils/fwparam_ibft/Makefile open-iscsi-2.0-872-rc4-bnx2i.work/utils/fwparam_ibft/Makefile
+--- open-iscsi-2.0-872-rc4-bnx2i/utils/fwparam_ibft/Makefile	2011-10-10 13:57:38.000000000 -0500
++++ open-iscsi-2.0-872-rc4-bnx2i.work/utils/fwparam_ibft/Makefile	2011-10-12 01:03:30.000000000 -0500
+@@ -28,7 +28,7 @@ CLEANFILES = $(OBJS) *.output *~
+ 
+ OPTFLAGS ?= -O2 -g -fPIC
+ WARNFLAGS ?= -Wall -Wstrict-prototypes
+-CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -I../../include -I../../usr
++CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -I../../include -I../../usr -D_GNU_SOURCE
+ 
+ all: $(OBJS)
+ 
diff --git a/iscsi-initiator-utils-libiscsi-to-support-offload.patch b/iscsi-initiator-utils-libiscsi-to-support-offload.patch
new file mode 100644
index 0000000..5d8631f
--- /dev/null
+++ b/iscsi-initiator-utils-libiscsi-to-support-offload.patch
@@ -0,0 +1,237 @@
+From 1971024a7c6c2c2cf848aba93bd85a707875f216 Mon Sep 17 00:00:00 2001
+From: Manish Rangankar <manish.rangankar at qlogic.com>
+Date: Wed, 12 Oct 2011 18:57:25 +0530
+Subject: [PATCH 2/2] iscsi tools: Modified libisci to support offload.
+
+For an offload solution like qla4xxx requires to do discovery on per port
+basis from application. To do that libiscsi need to be modified to take
+iSCSI HW address as a input parameter and find out the current active
+iface for a given port. Using this iface we can do discovery to a
+given port.
+
+Signed-off-by: Manish Rangankar <manish.rangankar at qlogic.com>
+---
+ libiscsi/libiscsi.c |  148 +++++++++++++++++++++++++++++++++++++++++++++++++++
+ libiscsi/libiscsi.h |   33 +++++++++++
+ usr/iface.c         |    2 +-
+ 3 files changed, 182 insertions(+), 1 deletions(-)
+
+diff --git a/libiscsi/libiscsi.c b/libiscsi/libiscsi.c
+index dc63fcd..9b15f01 100644
+--- a/libiscsi/libiscsi.c
++++ b/libiscsi/libiscsi.c
+@@ -202,6 +202,154 @@ leave:
+ 	return rc;
+ }
+ 
++static int get_active_ifaces_form_host(struct list_head *ifaces, char *hw_addr,
++				       const char *address, int *nr_iface)
++{
++	int iptype = ISCSI_IFACE_TYPE_IPV4;
++	struct iface_rec *usr_iface, *tmp_iface;
++	struct list_head t_ifaces;
++	int rc = 0;
++
++	INIT_LIST_HEAD(&t_ifaces);
++
++	iface_link_ifaces(&t_ifaces);
++	list_for_each_entry_safe(usr_iface, tmp_iface, &t_ifaces, list) {
++		(*nr_iface)++;
++		if (strcmp(usr_iface->hwaddress, hw_addr)) {
++			(*nr_iface)--;
++			list_del(&usr_iface->list);
++			free(usr_iface);
++		}
++	}
++
++	if (!strstr(address, ".") && strstr(address, ":"))
++		iptype = ISCSI_IFACE_TYPE_IPV6;
++	else if (strstr(address, ".") && !strstr(address, ":"))
++		iptype = ISCSI_IFACE_TYPE_IPV4;
++
++	list_for_each_entry_safe(usr_iface, tmp_iface, &t_ifaces, list) {
++		if (iptype == ISCSI_IFACE_TYPE_IPV4) {
++			if (strstr(usr_iface->name, "ipv4")) {
++				iface_link(ifaces, usr_iface);
++				goto exit_iface;
++			}
++		} else if (iptype == ISCSI_IFACE_TYPE_IPV6) {
++			if (strstr(usr_iface->name, "ipv6")) {
++				iface_link(ifaces, usr_iface);
++				goto exit_iface;
++			}
++		}
++	}
++
++exit_iface:
++	free_iface_list(&t_ifaces);
++	return rc;
++}
++
++int libiscsi_discover_sendtargets_by_hwaddr(struct libiscsi_context *context,
++	const char *address, int port,
++	const struct libiscsi_auth_info *auth_info, char *hw_addr,
++	int *nr_found, struct libiscsi_node **found_nodes)
++{
++	struct discovery_rec drec;
++	LIST_HEAD(bound_rec_list);
++	struct list_head *ifaces, tmp;
++	struct node_rec *rec;
++	int rc = 0, found = 0, nr_iface = 0;
++
++	INIT_LIST_HEAD(&bound_rec_list);
++	INIT_LIST_HEAD(&tmp);
++
++	if (hw_addr == NULL) {
++		strcpy(context->error_str, "Invalid argument");
++		rc = EINVAL;
++		return rc;
++	}
++
++	rc = get_active_ifaces_form_host(&tmp, hw_addr, address,
++					 &nr_iface);
++	if (rc == EINVAL) {
++		strcpy(context->error_str, "Invalid argument");
++		return rc;
++	} else if (nr_iface == 0) {
++		strcpy(context->error_str, "No iface record");
++		return ENODEV;
++	}
++	ifaces = &tmp;
++
++	if (nr_found)
++		*nr_found = 0;
++	if (found_nodes)
++		*found_nodes = NULL;
++
++	CHECK(libiscsi_verify_auth_info(context, auth_info))
++
++	/* Fill the drec struct with all needed info */
++	memset(&drec, 0, sizeof drec);
++	idbm_sendtargets_defaults(&drec.u.sendtargets);
++	drec.type = DISCOVERY_TYPE_SENDTARGETS;
++	strlcpy(drec.address, address, sizeof(drec.address));
++	drec.port = port ? port : ISCSI_LISTEN_PORT;
++	switch (auth_info ? auth_info->method : libiscsi_auth_none) {
++	case libiscsi_auth_chap:
++		drec.u.sendtargets.auth.authmethod = AUTH_METHOD_CHAP;
++		strlcpy(drec.u.sendtargets.auth.username,
++			auth_info->chap.username, AUTH_STR_MAX_LEN);
++		strlcpy((char *)drec.u.sendtargets.auth.password,
++			auth_info->chap.password, AUTH_STR_MAX_LEN);
++		drec.u.sendtargets.auth.password_length =
++			strlen((char *)drec.u.sendtargets.auth.password);
++		strlcpy(drec.u.sendtargets.auth.username_in,
++			auth_info->chap.reverse_username, AUTH_STR_MAX_LEN);
++		strlcpy((char *)drec.u.sendtargets.auth.password_in,
++			auth_info->chap.reverse_password, AUTH_STR_MAX_LEN);
++		drec.u.sendtargets.auth.password_in_length =
++			strlen((char *)drec.u.sendtargets.auth.password_in);
++		break;
++	}
++
++	CHECK(idbm_add_discovery(&drec))
++	CHECK(idbm_bind_ifaces_to_nodes(discovery_sendtargets,
++					&drec, ifaces, &bound_rec_list))
++
++	/* now add/update records */
++	list_for_each_entry(rec, &bound_rec_list, list) {
++		CHECK(idbm_add_node(rec, &drec, 1 /* overwrite */))
++		found++;
++	}
++
++	if (nr_found)
++		*nr_found = found;
++
++	if (found_nodes && found) {
++		*found_nodes = calloc(found, sizeof **found_nodes);
++		if (*found_nodes == NULL) {
++			snprintf(context->error_str,
++				 sizeof(context->error_str), strerror(ENOMEM));
++			rc = ENOMEM;
++			goto leave;
++		}
++		found = 0;
++		list_for_each_entry(rec, &bound_rec_list, list) {
++			strlcpy((*found_nodes)[found].name, rec->name,
++				 LIBISCSI_VALUE_MAXLEN);
++			(*found_nodes)[found].tpgt = rec->tpgt;
++			strlcpy((*found_nodes)[found].address,
++				 rec->conn[0].address, NI_MAXHOST);
++			(*found_nodes)[found].port = rec->conn[0].port;
++			strlcpy((*found_nodes)[found].iface,
++				 rec->iface.name, LIBISCSI_VALUE_MAXLEN);
++			found++;
++		}
++	}
++
++leave:
++	free_iface_list(ifaces);
++	free_rec_list(&bound_rec_list);
++	return rc;
++}
++
++
+ int libiscsi_discover_firmware(struct libiscsi_context *context,
+ 	int *nr_found, struct libiscsi_node **found_nodes)
+ {
+diff --git a/libiscsi/libiscsi.h b/libiscsi/libiscsi.h
+index 61ce0ea..1d8ae7c 100644
+--- a/libiscsi/libiscsi.h
++++ b/libiscsi/libiscsi.h
+@@ -142,6 +142,39 @@ PUBLIC int libiscsi_discover_sendtargets(struct libiscsi_context *context,
+     const char *address, int port, const struct libiscsi_auth_info *auth_info,
+     int *nr_found, struct libiscsi_node **found_nodes);
+ 
++/** \brief Discover iSCSI nodes using sendtargets and add them to the node db.
++ *
++ * This function connects to the given address and port and then tries to
++ * discover iSCSI nodes for a given iSCSI port using the sendtargets protocol.
++ * Any found nodes are added to the local iSCSI node database and are returned
++ * in a dynamically allocated array.
++ *
++ * Note that the (optional) authentication info is for authenticating the
++ * discovery, and is not for the found nodes! If the connection(s) to the
++ * node(s) need authentication too, you can set the username / password for
++ * those (which can be different!) using the libiscsi_node_set_auth() function.
++ *
++ * \param context                libiscsi context to operate on.
++ * \param address                Hostname or IP-address to connect to.
++ * \param port                   Port to connect to, or 0 for the default port.
++ * \param auth_info              Authentication information, or NULL.
++ * \param hw_addr                iSCSI iface mac address.
++ * \param nr_found		 The number of found nodes will be returned
++ *                               through this pointer if not NULL.
++ * \param found_nodes            The address of the dynamically allocated array
++ *                               of found nodes will be returned through this
++ *                               pointer if not NULL. The caller must free this
++ *                               array using free().
++ * \return                       0 on success, otherwise a standard error code
++ *                               (from errno.h).
++ */
++PUBLIC int libiscsi_discover_sendtargets_by_hwaddr(
++				struct libiscsi_context *context,
++				const char *address, int port,
++				const struct libiscsi_auth_info *auth_info,
++				char *hw_addr, int *nr_found,
++				struct libiscsi_node **found_nodes);
++
+ /** \brief Read iSCSI node info from firmware and add them to the node db.
+  *
+  * This function discovers iSCSI nodes using firmware (ppc or ibft). Any found
+diff --git a/usr/iface.c b/usr/iface.c
+index 9431a97..1531291 100644
+--- a/usr/iface.c
++++ b/usr/iface.c
+@@ -789,7 +789,7 @@ int iface_for_each_iface(void *data, int skip_def, int *nr_found,
+ 	return err;
+ }
+ 
+-static int iface_link(void *data, struct iface_rec *iface)
++int iface_link(void *data, struct iface_rec *iface)
+ {
+ 	struct list_head *ifaces = data;
+ 	struct iface_rec *iface_copy;
+-- 
+1.7.1
+
diff --git a/iscsi-initiator-utils-ofl-iface-fixes.patch b/iscsi-initiator-utils-ofl-iface-fixes.patch
new file mode 100644
index 0000000..12a5b35
--- /dev/null
+++ b/iscsi-initiator-utils-ofl-iface-fixes.patch
@@ -0,0 +1,471 @@
+diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/include/iscsi_if.h open-iscsi-2.0-872-rc4-bnx2i.work/include/iscsi_if.h
+--- open-iscsi-2.0-872-rc4-bnx2i/include/iscsi_if.h	2011-10-10 13:57:38.000000000 -0500
++++ open-iscsi-2.0-872-rc4-bnx2i.work/include/iscsi_if.h	2011-10-11 00:40:49.000000000 -0500
+@@ -320,10 +320,11 @@ enum iscsi_net_param {
+ 	ISCSI_NET_PARAM_VLAN_ID			= 13,
+ 	ISCSI_NET_PARAM_VLAN_PRIORITY		= 14,
+ 	ISCSI_NET_PARAM_VLAN_ENABLED		= 15,
+-	ISCSI_NET_PARAM_IFACE_TYPE		= 16,
+-	ISCSI_NET_PARAM_IFACE_NAME		= 17,
+-	ISCSI_NET_PARAM_MTU			= 18,
+-	ISCSI_NET_PARAM_PORT			= 19,
++	ISCSI_NET_PARAM_VLAN_TAG		= 16,
++	ISCSI_NET_PARAM_IFACE_TYPE		= 17,
++	ISCSI_NET_PARAM_IFACE_NAME		= 18,
++	ISCSI_NET_PARAM_MTU			= 19,
++	ISCSI_NET_PARAM_PORT			= 20,
+ };
+ 
+ enum iscsi_conn_state {
+diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/usr/host.c open-iscsi-2.0-872-rc4-bnx2i.work/usr/host.c
+--- open-iscsi-2.0-872-rc4-bnx2i/usr/host.c	2011-10-10 13:57:38.000000000 -0500
++++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/host.c	2011-10-11 00:41:01.000000000 -0500
+@@ -132,22 +132,67 @@ static int print_host_iface(void *data, 
+ 		printf("%sIPaddress: %s\n", prefix, UNKNOWN_VALUE);
+ 	else if (strchr(iface->ipaddress, '.')) {
+ 		printf("%sIPaddress: %s\n", prefix, iface->ipaddress);
+-		printf("%sGateway: %s\n", prefix, iface->gateway);
+-		printf("%sSubnet: %s\n", prefix, iface->subnet_mask);
+-		printf("%sBootProto: %s\n", prefix, iface->bootproto);
++
++		if (!strlen(iface->gateway))
++			printf("%sGateway: %s\n", prefix, UNKNOWN_VALUE);
++		else
++			printf("%sGateway: %s\n", prefix, iface->gateway);
++		if (!strlen(iface->subnet_mask))
++			printf("%sSubnet: %s\n", prefix, UNKNOWN_VALUE);
++		else
++			printf("%sSubnet: %s\n", prefix, iface->subnet_mask);
++		if (!strlen(iface->bootproto))
++			printf("%sBootProto: %s\n", prefix, UNKNOWN_VALUE);
++		else
++			printf("%sBootProto: %s\n", prefix, iface->bootproto);
+ 	} else {
+ 		printf("%sIPaddress: [%s]\n", prefix, iface->ipaddress);
+-		printf("%sIPaddress Autocfg: %s\n", prefix, iface->ipv6_autocfg);
+-		printf("%sLink Local Address: [%s]\n", prefix,
+-		       iface->ipv6_linklocal);
+-		printf("%sLink Local Autocfg: %s\n", prefix,
+-		       iface->linklocal_autocfg);
+-		printf("%sRouter Address: [%s]\n", prefix, iface->ipv6_router);
++
++		if (!strlen(iface->ipv6_autocfg))
++			printf("%sIPaddress Autocfg: %s\n", prefix,
++			       UNKNOWN_VALUE);
++		else
++			printf("%sIPaddress Autocfg: %s\n", prefix,
++			       iface->ipv6_autocfg);
++		if (!strlen(iface->ipv6_linklocal))
++			printf("%sLink Local Address: %s\n", prefix,
++			       UNKNOWN_VALUE);
++		else
++			printf("%sLink Local Address: [%s]\n", prefix,
++			       iface->ipv6_linklocal);
++		if (!strlen(iface->linklocal_autocfg))
++			printf("%sLink Local Autocfg: %s\n", prefix,
++			       UNKNOWN_VALUE);
++		else
++			printf("%sLink Local Autocfg: %s\n", prefix,
++			       iface->linklocal_autocfg);
++		if (!strlen(iface->ipv6_router))
++			printf("%sRouter Address: %s\n", prefix,
++			      UNKNOWN_VALUE);
++		else
++			printf("%sRouter Address: [%s]\n", prefix,
++			       iface->ipv6_router);
+ 	}
+ 
+-	printf("%sMTU: %u\n", prefix, iface->mtu);
+-	printf("%svlan ID: %u\n", prefix, iface->vlan_id);
+-	printf("%svlan priority: %u\n", prefix, iface->vlan_priority);
++	if (!iface->port)
++		printf("%sPort: %s\n", prefix, UNKNOWN_VALUE);
++	else
++		printf("%sPort: %u\n", prefix, iface->port);
++
++	if (!iface->mtu)
++		printf("%sMTU: %s\n", prefix, UNKNOWN_VALUE);
++	else
++		printf("%sMTU: %u\n", prefix, iface->mtu);
++
++	if (iface->vlan_id == UINT16_MAX)
++		printf("%sVLAN ID: %s\n", prefix, UNKNOWN_VALUE);
++	else
++		printf("%sVLAN ID: %u\n", prefix, iface->vlan_id);
++
++	if (iface->vlan_priority == UINT8_MAX)
++		printf("%sVLAN priority: %s\n", prefix, UNKNOWN_VALUE);
++	else
++		printf("%sVLAN priority: %u\n", prefix, iface->vlan_priority);
+ 	return 0;
+ }
+ 
+diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/usr/iface.c open-iscsi-2.0-872-rc4-bnx2i.work/usr/iface.c
+--- open-iscsi-2.0-872-rc4-bnx2i/usr/iface.c	2011-10-10 13:57:38.000000000 -0500
++++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/iface.c	2011-10-11 00:40:49.000000000 -0500
+@@ -41,6 +41,7 @@
+ #include "fw_context.h"
+ #include "sysdeps.h"
+ #include "iscsi_err.h"
++#include "iscsi_netlink.h"
+ 
+ /*
+  * Default ifaces for use with transports that do not bind to hardware
+@@ -1141,14 +1142,16 @@ static int iface_fill_port(struct iovec 
+ 	int len;
+ 	struct iscsi_iface_param_info *net_param;
+ 	uint16_t port = 3260;
++	struct nlattr *attr;
+ 
+-	len = sizeof(struct iscsi_iface_param_info) + 2;
+-	iov->iov_base = calloc(len, sizeof(char));
+-	if (!(iov->iov_base))
++	len = sizeof(struct iscsi_iface_param_info) + sizeof(port);
++	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_PORT, len);
++	if (!iov->iov_base)
+ 		return 1;
++	attr = iov->iov_base;
++	iov->iov_len = NLA_ALIGN(attr->nla_len);
+ 
+-	iov->iov_len = len;
+-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
++	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
+ 	net_param->param = ISCSI_NET_PARAM_PORT;
+ 	net_param->iface_type = iface_type;
+ 	net_param->iface_num = iface->iface_num;
+@@ -1166,14 +1169,16 @@ static int iface_fill_mtu(struct iovec *
+ 	int len;
+ 	struct iscsi_iface_param_info *net_param;
+ 	uint16_t mtu = 0;
++	struct nlattr *attr;
+ 
+ 	len = sizeof(struct iscsi_iface_param_info) + 2;
+-	iov->iov_base = calloc(len, sizeof(char));
++	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_MTU, len);
+ 	if (!(iov->iov_base))
+ 		return 1;
++	attr = iov->iov_base;
++	iov->iov_len = NLA_ALIGN(attr->nla_len);
+ 
+-	iov->iov_len = len;
+-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
++	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
+ 	net_param->param = ISCSI_NET_PARAM_MTU;
+ 	net_param->iface_type = iface_type;
+ 	net_param->iface_num = iface->iface_num;
+@@ -1191,15 +1196,17 @@ static int iface_fill_vlan_id(struct iov
+ 	int len;
+ 	struct iscsi_iface_param_info *net_param;
+ 	uint16_t vlan = 0;
++	struct nlattr *attr;
+ 
+ 	len = sizeof(struct iscsi_iface_param_info) + 2;
+-	iov->iov_base = calloc(len, sizeof(char));
++	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_VLAN_TAG, len);
+ 	if (!(iov->iov_base))
+ 		return 1;
+ 
+-	iov->iov_len = len;
+-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
+-	net_param->param = ISCSI_NET_PARAM_VLAN_ID;
++	attr = iov->iov_base;
++	iov->iov_len = NLA_ALIGN(attr->nla_len);
++	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
++	net_param->param = ISCSI_NET_PARAM_VLAN_TAG;
+ 	net_param->iface_type = iface_type;
+ 	net_param->iface_num = iface->iface_num;
+ 	net_param->param_type = ISCSI_NET_PARAM;
+@@ -1222,14 +1229,16 @@ static int iface_fill_vlan_state(struct 
+ {
+ 	int len;
+ 	struct iscsi_iface_param_info *net_param;
++	struct nlattr *attr;
+ 
+ 	len = sizeof(struct iscsi_iface_param_info) + 1;
+-	iov->iov_base = calloc(len, sizeof(char));
++	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_VLAN_ENABLED, len);
+ 	if (!(iov->iov_base))
+ 		return 1;
+ 
+-	iov->iov_len = len;
+-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
++	attr = iov->iov_base;
++	iov->iov_len = NLA_ALIGN(attr->nla_len);
++	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
+ 	net_param->param = ISCSI_NET_PARAM_VLAN_ENABLED;
+ 	net_param->iface_type = iface_type;
+ 	net_param->iface_num = iface->iface_num;
+@@ -1248,14 +1257,16 @@ static int iface_fill_net_state(struct i
+ {
+ 	int len;
+ 	struct iscsi_iface_param_info *net_param;
++	struct nlattr *attr;
+ 
+ 	len = sizeof(struct iscsi_iface_param_info) + 1;
+-	iov->iov_base = calloc(len, sizeof(char));
++	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_IFACE_ENABLE, len);
+ 	if (!(iov->iov_base))
+ 		return 1;
+ 
+-	iov->iov_len = len;
+-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
++	attr = iov->iov_base;
++	iov->iov_len = NLA_ALIGN(attr->nla_len);
++	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
+ 	net_param->param = ISCSI_NET_PARAM_IFACE_ENABLE;
+ 	net_param->iface_type = iface_type;
+ 	net_param->iface_num = iface->iface_num;
+@@ -1273,14 +1284,16 @@ static int iface_fill_net_bootproto(stru
+ {
+ 	int len;
+ 	struct iscsi_iface_param_info *net_param;
++	struct nlattr *attr;
+ 
+ 	len = sizeof(struct iscsi_iface_param_info) + 1;
+-	iov->iov_base = calloc(len, sizeof(char));
++	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_IPV4_BOOTPROTO, len);
+ 	if (!(iov->iov_base))
+ 		return 1;
+ 
+-	iov->iov_len = len;
+-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
++	attr = iov->iov_base;
++	iov->iov_len = NLA_ALIGN(attr->nla_len);
++	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
+ 	net_param->param = ISCSI_NET_PARAM_IPV4_BOOTPROTO;
+ 	net_param->iface_type = ISCSI_IFACE_TYPE_IPV4;
+ 	net_param->iface_num = iface->iface_num;
+@@ -1298,14 +1311,16 @@ static int iface_fill_net_autocfg(struct
+ {
+ 	int len;
+ 	struct iscsi_iface_param_info *net_param;
++	struct nlattr *attr;
+ 
+ 	len = sizeof(struct iscsi_iface_param_info) + 1;
+-	iov->iov_base = calloc(len, sizeof(char));
++	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG, len);
+ 	if (!(iov->iov_base))
+ 		return 1;
+ 
+-	iov->iov_len = len;
+-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
++	attr = iov->iov_base;
++	iov->iov_len = NLA_ALIGN(attr->nla_len);
++	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
+ 	net_param->param = ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG;
+ 	net_param->iface_type = ISCSI_IFACE_TYPE_IPV6;
+ 	net_param->param_type = ISCSI_NET_PARAM;
+@@ -1327,14 +1342,17 @@ static int iface_fill_linklocal_autocfg(
+ {
+ 	int len;
+ 	struct iscsi_iface_param_info *net_param;
++	struct nlattr *attr;
+ 
+ 	len = sizeof(struct iscsi_iface_param_info) + 1;
+-	iov->iov_base = calloc(len, sizeof(char));
++	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG,
++					len);
+ 	if (!(iov->iov_base))
+ 		return 1;
+ 
+-	iov->iov_len = len;
+-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
++	attr = iov->iov_base;
++	iov->iov_len = NLA_ALIGN(attr->nla_len);
++	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
+ 	net_param->param = ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG;
+ 	net_param->iface_type = ISCSI_IFACE_TYPE_IPV6;
+ 	net_param->param_type = ISCSI_NET_PARAM;
+@@ -1353,14 +1371,17 @@ static int iface_fill_router_autocfg(str
+ {
+ 	int len;
+ 	struct iscsi_iface_param_info *net_param;
++	struct nlattr *attr;
+ 
+ 	len = sizeof(struct iscsi_iface_param_info) + 1;
+-	iov->iov_base = calloc(len, sizeof(char));
++	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG,
++					len);
+ 	if (!(iov->iov_base))
+ 		return 1;
+ 
+-	iov->iov_len = len;
+-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
++	attr = iov->iov_base;
++	iov->iov_len = NLA_ALIGN(attr->nla_len);
++	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
+ 	net_param->param = ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG;
+ 	net_param->iface_type = ISCSI_IFACE_TYPE_IPV6;
+ 	net_param->param_type = ISCSI_NET_PARAM;
+@@ -1381,14 +1402,16 @@ static int iface_fill_net_ipv4_addr(stru
+ 	int rc = 1;
+ 	int len;
+ 	struct iscsi_iface_param_info *net_param;
++	struct nlattr *attr;
+ 
+ 	len = sizeof(struct iscsi_iface_param_info) + 4;
+-	iov->iov_base = calloc(len, sizeof(char));
++	iov->iov_base = iscsi_nla_alloc(param, len);
+ 	if (!(iov->iov_base))
+ 		return 1;
+ 
+-	iov->iov_len = len;
+-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
++	attr = iov->iov_base;
++	iov->iov_len = NLA_ALIGN(attr->nla_len);
++	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
+ 	net_param->param = param;
+ 	net_param->iface_type = ISCSI_IFACE_TYPE_IPV4;
+ 	net_param->iface_num = iface->iface_num;
+@@ -1435,14 +1458,16 @@ static int iface_fill_net_ipv6_addr(stru
+ 	int rc;
+ 	int len;
+ 	struct iscsi_iface_param_info *net_param;
++	struct nlattr *attr;
+ 
+ 	len = sizeof(struct iscsi_iface_param_info) + 16;
+-	iov->iov_base = calloc(len, sizeof(char));
++	iov->iov_base = iscsi_nla_alloc(param, len);
+ 	if (!(iov->iov_base))
+ 		return 1;
+ 
+-	iov->iov_len = len;
+-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
++	attr = iov->iov_base;
++	iov->iov_len = NLA_ALIGN(attr->nla_len);
++	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
+ 	net_param->param = param;
+ 	net_param->iface_type = ISCSI_IFACE_TYPE_IPV6;
+ 	net_param->iface_num = iface->iface_num;
+diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/usr/initiator.c open-iscsi-2.0-872-rc4-bnx2i.work/usr/initiator.c
+--- open-iscsi-2.0-872-rc4-bnx2i/usr/initiator.c	2011-10-10 13:57:38.000000000 -0500
++++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/initiator.c	2011-10-11 00:39:57.000000000 -0500
+@@ -1682,9 +1682,10 @@ static void session_conn_process_login(v
+ 			    session->nrec.conn[conn->id].address,
+ 			    session->nrec.conn[conn->id].port,
+ 			    session->nrec.iface.name);
+-	} else
++	} else {
+ 		session->notify_qtask = NULL;
+-
++		mgmt_ipc_write_rsp(c->qtask, ISCSI_SUCCESS);
++	}
+ 
+ 	/*
+ 	 * reset ERL=0 reopen counter
+diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/usr/iscsi_netlink.h open-iscsi-2.0-872-rc4-bnx2i.work/usr/iscsi_netlink.h
+--- open-iscsi-2.0-872-rc4-bnx2i/usr/iscsi_netlink.h	1969-12-31 18:00:00.000000000 -0600
++++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/iscsi_netlink.h	2011-10-11 00:40:34.000000000 -0500
+@@ -0,0 +1,33 @@
++/*
++ * iSCSI Netlink attr helpers
++ *
++ * Copyright (C) 2011 Red Hat, Inc. All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published
++ * by the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * See the file COPYING included with this distribution for more details.
++ */
++
++#ifndef ISCSI_NLA_H
++#define ISCSI_NLA_H
++
++#include <linux/netlink.h>
++
++struct iovec;
++
++#define ISCSI_NLA_HDRLEN	((int) NLA_ALIGN(sizeof(struct nlattr)))
++#define ISCSI_NLA_DATA(nla)	((void *)((char*)(nla) + ISCSI_NLA_HDRLEN))
++#define ISCSI_NLA_LEN(len) 	((len) + NLA_ALIGN(ISCSI_NLA_HDRLEN))
++#define ISCSI_NLA_TOTAL_LEN(len) (NLA_ALIGN(ISCSI_NLA_LEN(len)))
++
++extern struct nlattr *iscsi_nla_alloc(uint16_t type, uint16_t len);
++
++#endif
+diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/usr/iscsi_sysfs.c open-iscsi-2.0-872-rc4-bnx2i.work/usr/iscsi_sysfs.c
+--- open-iscsi-2.0-872-rc4-bnx2i/usr/iscsi_sysfs.c	2011-10-10 13:57:38.000000000 -0500
++++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/iscsi_sysfs.c	2011-10-11 00:41:01.000000000 -0500
+@@ -561,28 +561,28 @@ static int iscsi_sysfs_read_iface(struct
+ 			      "link_local_addr", iface->ipv6_linklocal,
+ 			      sizeof(iface->ipv6_linklocal));
+ 
+-		if (sysfs_get_str(iface_kern_id, ISCSI_IFACE_SUBSYS,
+-				  "linklocal_autocfg",
+-				   iface->linklocal_autocfg,
+-				   sizeof(iface->linklocal_autocfg))) {
+-			/* misspelled in some test kernels */
+-			sysfs_get_str(iface_kern_id, ISCSI_IFACE_SUBSYS,
+-				      "link_local_autocfg",
+-				      iface->linklocal_autocfg,
+-				      sizeof(iface->linklocal_autocfg));
+-		}
++		sysfs_get_str(iface_kern_id, ISCSI_IFACE_SUBSYS,
++			      "link_local_autocfg", iface->linklocal_autocfg,
++			      sizeof(iface->linklocal_autocfg));
+ 
+ 		sysfs_get_str(iface_kern_id, ISCSI_IFACE_SUBSYS, "router_addr",
+ 			      iface->ipv6_router,
+ 			      sizeof(iface->ipv6_router));
+ 	}
+ 
+-	sysfs_get_uint16(iface_kern_id, ISCSI_IFACE_SUBSYS, "mtu",
+-			 &iface->mtu);
+-	sysfs_get_uint16(iface_kern_id, ISCSI_IFACE_SUBSYS, "vlan",
+-			 &iface->vlan_id);
+-	sysfs_get_uint8(iface_kern_id, ISCSI_IFACE_SUBSYS, "vlan_priority",
+-			 &iface->vlan_priority);
++	if (sysfs_get_uint16(iface_kern_id, ISCSI_IFACE_SUBSYS, "port",
++			     &iface->port))
++		iface->port = 0;
++	if (sysfs_get_uint16(iface_kern_id, ISCSI_IFACE_SUBSYS, "mtu",
++			     &iface->mtu))
++		iface->mtu = 0;
++	if (sysfs_get_uint16(iface_kern_id, ISCSI_IFACE_SUBSYS, "vlan_id",
++			     &iface->vlan_id))
++		iface->vlan_id = UINT16_MAX;
++
++	if (sysfs_get_uint8(iface_kern_id, ISCSI_IFACE_SUBSYS, "vlan_priority",
++			    &iface->vlan_priority))
++		iface->vlan_priority = UINT8_MAX;
+ 
+ 	if (sscanf(iface_kern_id, "ipv%d-iface-%u-%u", &iface_type,
+ 		   &tmp_host_no, &iface_num) == 3)
+diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/usr/netlink.c open-iscsi-2.0-872-rc4-bnx2i.work/usr/netlink.c
+--- open-iscsi-2.0-872-rc4-bnx2i/usr/netlink.c	2011-10-10 13:57:38.000000000 -0500
++++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/netlink.c	2011-10-11 00:40:34.000000000 -0500
+@@ -38,6 +38,7 @@
+ #include "initiator.h"
+ #include "iscsi_sysfs.h"
+ #include "transport.h"
++#include "iscsi_netlink.h"
+ 
+ static int ctrl_fd;
+ static struct sockaddr_nl src_addr, dest_addr;
+@@ -63,6 +64,19 @@ static int ctldev_handle(void);
+ 
+ #define NLM_SETPARAM_DEFAULT_MAX (NI_MAXHOST + 1 + sizeof(struct iscsi_uevent))
+ 
++struct nlattr *iscsi_nla_alloc(uint16_t type, uint16_t len)
++{
++	struct nlattr *attr;
++
++	attr = calloc(1, ISCSI_NLA_TOTAL_LEN(len));
++	if (!attr)
++		return NULL; 
++
++	attr->nla_len = ISCSI_NLA_LEN(len);
++	attr->nla_type = type;
++	return attr;
++}
++
+ static int
+ kread(char *data, int count)
+ {
diff --git a/iscsi-initiator-utils.spec b/iscsi-initiator-utils.spec
index 59a2a9f..f4b5e84 100644
--- a/iscsi-initiator-utils.spec
+++ b/iscsi-initiator-utils.spec
@@ -223,8 +223,8 @@ fi
 %changelog
 * Tue Oct 11 2011 Mike Christie <mcrhsit at redhat.com> 6.2.0.872.28
 - 736116 (again) fix aligment for iface nl msgs.
-- Fix iscsid restart issue when using qla4xxx.
-- 688965 Fix ipv6 boot.
+- Fix iscsid restart issue when using qla4xxx boot.
+- Fix ipv6 boot when using ibft.
 
 * Thu Sep 20 2011 Mike Christie <mcrhsit at redhat.com> 6.2.0.872.27
 - 736116 Fix netlink msg len


More information about the scm-commits mailing list