From: Adheer Chandravanshi <adheer.chandravan...@qlogic.com>

Currently bnx2i sets up its interface as part of login/discovery
process. Adding this support will help to setup bnx2i interfaces
independent of any other operation.

Signed-off-by: Adheer Chandravanshi <adheer.chandravan...@qlogic.com>
---
 usr/iscsiadm.c |   43 +++++++++++++++++++++++++++++--------------
 1 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 9081ac8..6f96755 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -1277,7 +1277,7 @@ static int iface_apply_net_config(struct iface_rec 
*iface, int op)
        int rc = ISCSI_ERR;
        uint32_t host_no;
        int param_count;
-       int param_used;
+       int param_used = 0;
        int iface_all = 0;
        int i;
        struct iovec *iovs = NULL;
@@ -1291,10 +1291,24 @@ static int iface_apply_net_config(struct iface_rec 
*iface, int op)
        if (op == OP_APPLY_ALL)
                iface_all = 1;
 
+       t = iscsi_sysfs_get_transport_by_name(iface->transport_name);
+       if (!t) {
+               log_error("Can't find transport %s", iface->transport_name);
+               rc = ISCSI_ERR_TRANS_NOT_FOUND;
+               goto apply_done;
+       }
+
+       /* iface config from transport hook, if applicable */
+       if (t->template->set_net_config) {
+               rc = iscsi_set_net_config(t, NULL, iface);
+               goto apply_done;
+       }
+
        param_count = iface_get_param_count(iface, iface_all);
        if (!param_count) {
                log_error("Nothing to configure.");
-               return ISCSI_SUCCESS;
+               rc = ISCSI_SUCCESS;
+               goto apply_done;
        }
 
        /*
@@ -1308,38 +1322,39 @@ static int iface_apply_net_config(struct iface_rec 
*iface, int op)
                       sizeof(char));
        if (!iovs) {
                log_error("Out of Memory.");
-               return ISCSI_ERR_NOMEM;
+               rc = ISCSI_ERR_NOMEM;
+               goto apply_done;
        }
 
        /* param_used gives actual number of iovecs used for netconfig */
        param_used = iface_build_net_config(iface, iface_all, iovs);
        if (!param_used) {
                log_error("Build netconfig failed.");
-               goto free_buf;
-       }
-
-       t = iscsi_sysfs_get_transport_by_name(iface->transport_name);
-       if (!t) {
-               log_error("Can't find transport.");
+               rc = ISCSI_ERR_INVAL;
                goto free_buf;
        }
 
        host_no = iscsi_sysfs_get_host_no_from_hwinfo(iface, &rc);
        if (host_no == -1) {
                log_error("Can't find host_no.");
+               rc = ISCSI_ERR_HOST_NOT_FOUND;
                goto free_buf;
        }
-       rc = ISCSI_ERR;
 
        fd = ipc->ctldev_open();
        if (fd < 0) {
                log_error("Netlink open failed.");
+               rc = ISCSI_ERR_INTERNAL;
                goto free_buf;
        }
 
        rc = ipc->set_net_config(t->handle, host_no, iovs, param_count);
-       if (rc < 0)
+       if (rc < 0) {
                log_error("Set net_config failed. errno=%d", errno);
+               rc = ISCSI_ERR;
+       } else {
+               rc = ISCSI_SUCCESS;
+       }
 
        ipc->ctldev_close();
 
@@ -1352,9 +1367,9 @@ free_buf:
        }
 
        free(iovs);
-       if (rc)
-               return ISCSI_ERR;
-       return ISCSI_SUCCESS;
+
+apply_done:
+       return rc;
 }
 
 static int get_host_chap_info(uint32_t host_no)
-- 
1.7.1

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to