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

Signed-off-by: Eddie Wai <eddie....@broadcom.com>
---
 include/iscsi_if.h |    3 +++
 usr/iscsi_sysfs.c  |   25 ++++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/include/iscsi_if.h b/include/iscsi_if.h
index dad9fd8..498117d 100644
--- a/include/iscsi_if.h
+++ b/include/iscsi_if.h
@@ -460,6 +460,9 @@ enum iscsi_param {
 
        ISCSI_PARAM_TGT_RESET_TMO,
        ISCSI_PARAM_TARGET_ALIAS,
+
+       ISCSI_PARAM_BOOT_NIC,
+
        /* must always be last */
        ISCSI_PARAM_MAX,
 };
diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
index 4015b35..a4095b5 100644
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -53,6 +53,7 @@
 #define ISCSI_IFACE_SUBSYS             "iscsi_iface"
 #define SCSI_HOST_SUBSYS               "scsi_host"
 #define SCSI_SUBSYS                    "scsi"
+#define ISCSI_IBFT_SUBSYS              "ibft"
 
 #define ISCSI_SESSION_ID               "session%d"
 #define ISCSI_CONN_ID                  "connection%d:0"
@@ -793,7 +794,7 @@ int iscsi_sysfs_get_sid_from_path(char *session)
 
 int iscsi_sysfs_get_sessioninfo_by_id(struct session_info *info, char *session)
 {
-       char id[NAME_SIZE];
+       char id[NAME_SIZE], boot_nic[NAME_SIZE];
        int ret, pers_failed = 0;
        uint32_t host_no;
 
@@ -920,6 +921,28 @@ int iscsi_sysfs_get_sessioninfo_by_id(struct session_info 
*info, char *session)
 
        iscsi_sysfs_read_iface(&info->iface, host_no, session, NULL);
 
+       ret = sysfs_get_str(session, ISCSI_SESSION_SUBSYS, "boot_nic",
+                           boot_nic, NAME_SIZE);
+       if (!ret) {
+               /* If boot_nic exist, then extract the info from the boot nic */
+               ret = sysfs_get_str(boot_nic, ISCSI_IBFT_SUBSYS,
+                                   "vlan", id, NAME_SIZE);
+               if (ret)
+                       log_debug(5, "could not read %s/vlan: %d",
+                                 boot_nic, ret);
+               else
+                       info->iface.vlan_id = atoi(id);
+
+               ret = sysfs_get_str(boot_nic, ISCSI_IBFT_SUBSYS,
+                                   "subnet-mask", info->iface.subnet_mask,
+                                   NI_MAXHOST);
+               if (ret)
+                       log_debug(5, "could not read %s/subnet: %d",
+                                 boot_nic, ret);
+       } else {
+               log_debug(5, "could not read boot_nic: %d", ret);
+       }
+
        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 open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

Reply via email to