For the case when iscsid is invoked for the first time after pivot root
during iSCSI boot, the boot connection would fail to re-connect if the
ibft/iscsi_boot sysfs entry contains tagged vlan.

The problem was caused by the lack of such info in the iscsi_session sysfs
for sync_session to inherit from.

The proposed solution is as follows:
1. Utilize unique ifacename identifier for boot specific connections:
   old iface.name for the boot connection: <transport>.<MAC>
   new iface.name for the boot connection: <transport>.<MAC>.boot

2. Upon sync_session, the session's ifacename will then be used to compare
   against the MAC+'boot' ifacename as generated from the ibft/iscsi_boot
   sysfs entries.  Upon a match, the additional params from the boot nic will
   then get passed to the sync_session's iface record for the reconnection 
request.

Signed-off-by: Eddie Wai <eddie....@broadcom.com>
---
 usr/iface.c  |    2 +-
 usr/iscsid.c |   38 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/usr/iface.c b/usr/iface.c
index c86892e..98b1aed 100644
--- a/usr/iface.c
+++ b/usr/iface.c
@@ -956,7 +956,7 @@ int iface_setup_from_boot_context(struct iface_rec *iface,
        strcpy(iface->transport_name, t->name);
 
        memset(iface->name, 0, sizeof(iface->name));
-       snprintf(iface->name, sizeof(iface->name), "%s.%s",
+       snprintf(iface->name, sizeof(iface->name), "%s.%s.boot",
                 iface->transport_name, context->mac);
        strlcpy(iface->hwaddress, context->mac,
                sizeof(iface->hwaddress));
diff --git a/usr/iscsid.c b/usr/iscsid.c
index b4bb65b..295a29e 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -51,6 +51,7 @@
 #include "discoveryd.h"
 #include "iscsid_req.h"
 #include "iscsi_err.h"
+#include "fw_context.h"
 
 /* global config info */
 struct iscsi_daemon_config daemon_config;
@@ -186,6 +187,30 @@ setup_rec_from_negotiated_values(node_rec_t *rec, struct 
session_info *info)
        }
 }
 
+static int iscsi_match_boot(struct iface_rec *iface,
+                           struct list_head *targets)
+{
+       struct boot_context *context;
+       int rc = -ENODEV;
+
+       if (!iface)
+               return rc;
+       if (!strstr(iface->name, ".boot"))
+               return rc;
+
+       /* Find the matching boot nic */
+       list_for_each_entry(context, targets, list) {
+               if (strstr(iface->name, context->mac)) {
+                       iface->vlan_id = atoi(context->vlan);
+                       strlcpy(iface->gateway, context->gateway, NI_MAXHOST);
+                       strlcpy(iface->subnet_mask, context->mask, NI_MAXHOST);
+                       log_debug(1, "iscsi_match_boot found\n");
+                       return 0;
+               }
+       }
+       return rc;
+}
+
 static int sync_session(void *data, struct session_info *info)
 {
        node_rec_t rec, sysfsrec;
@@ -193,6 +218,7 @@ static int sync_session(void *data, struct session_info 
*info)
        iscsiadm_rsp_t rsp;
        struct iscsi_transport *t;
        int rc, retries = 0;
+       struct list_head *boot_targets = data;
 
        log_debug(7, "sync session [%d][%s,%s.%d][%s]\n", info->sid,
                  info->targetname, info->persistent_address,
@@ -269,6 +295,12 @@ static int sync_session(void *data, struct session_info 
*info)
         * app.
         */
        strcpy(rec.iface.iname, info->iface.iname);
+
+       /* In the case the session is from boot, extract the additional
+          boot iface info */
+       if (iscsi_match_boot(&rec.iface, boot_targets))
+               log_debug(1, "Could not get boot entry.\n");
+
        memset(&req, 0, sizeof(req));
        req.command = MGMT_IPC_SESSION_SYNC;
        req.u.session.sid = info->sid;
@@ -348,6 +380,7 @@ int main(int argc, char *argv[])
        struct sigaction sa_new;
        int control_fd;
        pid_t pid;
+       LIST_HEAD(boot_targets);
 
        while ((ch = getopt_long(argc, argv, "c:i:fd:nu:g:p:vh", long_options,
                                 &longindex)) >= 0) {
@@ -511,7 +544,10 @@ int main(int argc, char *argv[])
        if (pid == 0) {
                int nr_found = 0;
                /* child */
-               iscsi_sysfs_for_each_session(NULL, &nr_found, sync_session);
+               fw_get_targets(&boot_targets);
+               iscsi_sysfs_for_each_session(&boot_targets, &nr_found,
+                                            sync_session);
+               fw_free_targets(&boot_targets);
                exit(0);
        } else if (pid < 0) {
                log_error("Fork failed error %d: existing sessions"
-- 
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