Blame SOURCES/0041-ISCSID-Added-the-extraction-of-the-session-boot-info.patch

6c64be
From d86ca42685620ad3263da098923308a3a00ac55a Mon Sep 17 00:00:00 2001
6c64be
From: Eddie Wai <eddie.wai@broadcom.com>
6c64be
Date: Fri, 12 Apr 2013 10:41:16 -0700
6c64be
Subject: ISCSID: Added the extraction of the session boot info
6c64be
6c64be
This patch does the work to extract the corresponding
6c64be
<boot_root>->ethernetN net params as specified from the kernel
6c64be
session boot_nic sysfs entry based on the transport param
6c64be
use_boot_info.
6c64be
6c64be
This is only populated for iscsi_tcp and bnx2i.
6c64be
6c64be
Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
6c64be
---
6c64be
 usr/iscsi_sysfs.c | 40 ++++++++++++++++++++++++++++++++++++++++
6c64be
 usr/transport.c   |  2 ++
6c64be
 usr/transport.h   |  1 +
6c64be
 3 files changed, 43 insertions(+)
6c64be
6c64be
diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
6c64be
index aed10a3..79ec79d 100644
6c64be
--- a/usr/iscsi_sysfs.c
6c64be
+++ b/usr/iscsi_sysfs.c
6c64be
@@ -674,6 +674,43 @@ free_fnode:
6c64be
 	return rc;
6c64be
 }
6c64be
 
6c64be
+static int iscsi_sysfs_read_boot(struct iface_rec *iface, char *session)
6c64be
+{
6c64be
+	char boot_root[BOOT_NAME_MAXLEN], boot_nic[BOOT_NAME_MAXLEN];
6c64be
+	char boot_name[BOOT_NAME_MAXLEN], boot_content[BOOT_NAME_MAXLEN];
6c64be
+
6c64be
+	/* Extract boot info */
6c64be
+	strlcpy(boot_name, "boot_target", sizeof(boot_name));
6c64be
+	if (sysfs_get_str(session, ISCSI_SESSION_SUBSYS, boot_name,
6c64be
+			  boot_content, BOOT_NAME_MAXLEN))
6c64be
+		return -1;
6c64be
+	strlcpy(boot_name, "boot_nic", sizeof(boot_name));
6c64be
+	if (sysfs_get_str(session, ISCSI_SESSION_SUBSYS, boot_name, boot_nic,
6c64be
+			  BOOT_NAME_MAXLEN))
6c64be
+		return -1;
6c64be
+	strlcpy(boot_name, "boot_root", sizeof(boot_name));
6c64be
+	if (sysfs_get_str(session, ISCSI_SESSION_SUBSYS, boot_name, boot_root,
6c64be
+			  BOOT_NAME_MAXLEN))
6c64be
+		return -1;
6c64be
+
6c64be
+	/* If all boot_root/boot_target/boot_nic exist, then extract the
6c64be
+	   info from the boot nic */
6c64be
+	if (sysfs_get_str(boot_nic, boot_root, "vlan", boot_content,
6c64be
+			  BOOT_NAME_MAXLEN))
6c64be
+		log_debug(5, "could not read %s/%s/vlan", boot_root, boot_nic);
6c64be
+	else
6c64be
+		iface->vlan_id = atoi(boot_content);
6c64be
+
6c64be
+	if (sysfs_get_str(boot_nic, boot_root, "subnet-mask",
6c64be
+			  iface->subnet_mask, NI_MAXHOST))
6c64be
+		log_debug(5, "could not read %s/%s/subnet", boot_root,
6c64be
+			  boot_nic);
6c64be
+
6c64be
+	log_debug(5, "sysfs read boot returns %s/%s/ vlan = %d subnet = %s",
6c64be
+		  boot_root, boot_nic, iface->vlan_id, iface->subnet_mask);
6c64be
+	return 0;
6c64be
+}
6c64be
+
6c64be
 /*
6c64be
  * Read in iface settings based on host and session values. If
6c64be
  * session is not passed in, then the ifacename will not be set. And
6c64be
@@ -802,6 +839,9 @@ static int iscsi_sysfs_read_iface(struct iface_rec *iface, int host_no,
6c64be
 		}
6c64be
 	}
6c64be
 
6c64be
+	if (t->template->use_boot_info && session)
6c64be
+		iscsi_sysfs_read_boot(iface, session);
6c64be
+
6c64be
 	if (!iface_kern_id)
6c64be
 		goto done;
6c64be
 
6c64be
diff --git a/usr/transport.c b/usr/transport.c
6c64be
index 52b7674..4d030a8 100644
6c64be
--- a/usr/transport.c
6c64be
+++ b/usr/transport.c
6c64be
@@ -42,6 +42,7 @@
6c64be
 
6c64be
 struct iscsi_transport_template iscsi_tcp = {
6c64be
 	.name		= "tcp",
6c64be
+	.use_boot_info	= 1,
6c64be
 	.ep_connect	= iscsi_io_tcp_connect,
6c64be
 	.ep_poll	= iscsi_io_tcp_poll,
6c64be
 	.ep_disconnect	= iscsi_io_tcp_disconnect,
6c64be
@@ -77,6 +78,7 @@ struct iscsi_transport_template cxgb4i = {
6c64be
 struct iscsi_transport_template bnx2i = {
6c64be
 	.name		= "bnx2i",
6c64be
 	.set_host_ip	= 1,
6c64be
+	.use_boot_info	= 1,
6c64be
 	.ep_connect	= ktransport_ep_connect,
6c64be
 	.ep_poll	= ktransport_ep_poll,
6c64be
 	.ep_disconnect	= ktransport_ep_disconnect,
6c64be
diff --git a/usr/transport.h b/usr/transport.h
6c64be
index 5dcf872..388e4b1 100644
6c64be
--- a/usr/transport.h
6c64be
+++ b/usr/transport.h
6c64be
@@ -31,6 +31,7 @@ struct iscsi_transport_template {
6c64be
 	 * the host's ip address.
6c64be
 	 */
6c64be
 	uint8_t set_host_ip;
6c64be
+	uint8_t use_boot_info;
6c64be
 	int (*ep_connect) (struct iscsi_conn *conn, int non_blocking);
6c64be
 	int (*ep_poll) (struct iscsi_conn *conn, int timeout_ms);
6c64be
 	void (*ep_disconnect) (struct iscsi_conn *conn);
6c64be
-- 
6c64be
1.8.1.4
6c64be