This patch does the work to extract the corresponding
<boot_root>->ethernetN net params as specified from the kernel
session boot_nic sysfs entry.

Signed-off-by: Eddie Wai <[email protected]>
---
 usr/iscsi_sysfs.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
index 4015b35..deea3d3 100644
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -439,6 +439,43 @@ uint32_t iscsi_sysfs_get_host_no_from_hwinfo(struct 
iface_rec *iface, int *rc)
        return host_no;
 }
 
+static int iscsi_sysfs_read_boot(struct iface_rec *iface, char *session)
+{
+       char boot_root[BOOT_NAME_MAXLEN], boot_nic[BOOT_NAME_MAXLEN];
+       char boot_name[BOOT_NAME_MAXLEN], boot_content[BOOT_NAME_MAXLEN];
+
+       /* Extract boot info */
+       strlcpy(boot_name, "boot_target", sizeof(boot_name));
+       if (sysfs_get_str(session, ISCSI_SESSION_SUBSYS, boot_name,
+                         boot_content, BOOT_NAME_MAXLEN))
+               return -1;
+       strlcpy(boot_name, "boot_nic", sizeof(boot_name));
+       if (sysfs_get_str(session, ISCSI_SESSION_SUBSYS, boot_name, boot_nic,
+                         BOOT_NAME_MAXLEN))
+               return -1;
+       strlcpy(boot_name, "boot_root", sizeof(boot_name));
+       if (sysfs_get_str(session, ISCSI_SESSION_SUBSYS, boot_name, boot_root,
+                         BOOT_NAME_MAXLEN))
+               return -1;
+
+       /* If all boot_root/boot_target/boot_nic exist, then extract the
+          info from the boot nic */
+       if (sysfs_get_str(boot_nic, boot_root, "vlan", boot_content,
+                         BOOT_NAME_MAXLEN))
+               log_debug(5, "could not read %s/%s/vlan", boot_root, boot_nic);
+       else
+               iface->vlan_id = atoi(boot_content);
+
+       if (sysfs_get_str(boot_nic, boot_root, "subnet-mask",
+                         iface->subnet_mask, NI_MAXHOST))
+               log_debug(5, "could not read %s/%s/subnet", boot_root,
+                         boot_nic);
+
+       log_debug(5, "sysfs read boot returns %s/%s/ vlan = %d subnet = %s",
+                 boot_root, boot_nic, iface->vlan_id, iface->subnet_mask);
+       return 0;
+}
+
 /*
  * Read in iface settings based on host and session values. If
  * session is not passed in, then the ifacename will not be set. And
@@ -920,6 +957,8 @@ int iscsi_sysfs_get_sessioninfo_by_id(struct session_info 
*info, char *session)
 
        iscsi_sysfs_read_iface(&info->iface, host_no, session, NULL);
 
+       iscsi_sysfs_read_boot(&info->iface, session);
+
        log_debug(7, "found targetname %s address %s pers address %s port %d "
                 "pers port %d driver %s iface name %s ipaddress %s "
                 "netdev %s hwaddress %s iname %s",
-- 
1.7.7.4


-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

Reply via email to