Divide node parameters into 3 categories:
 a. Immutable - properties that are not allowed to change at all.
 b. Immediate - properties that are allowed to change and take effect 
immediately.
 c. Deferred  - properties that are allowed to change but will take effect only 
next
 session.

Signed-off-by: Doron Shoham <[EMAIL PROTECTED]>
---
 usr/idbm.c     |  168 +++++++++++++++++++++++++++++--------------------------
 usr/idbm.h     |   15 +++--
 usr/iscsiadm.c |    9 +++
 3 files changed, 107 insertions(+), 85 deletions(-)

diff --git a/usr/idbm.c b/usr/idbm.c
index fff5536..c77042a 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -205,47 +205,47 @@ idbm_recinfo_discovery(discovery_rec_t *r, recinfo_t *ri)
        int num = 0;
 
        __recinfo_int_o2("discovery.startup", ri, r, startup, IDBM_SHOW,
-                       "manual", "automatic", num, 1);
+                       "manual", "automatic", num, ATTR_DEFERRED);
        __recinfo_int_o6("discovery.type", ri, r, type, IDBM_SHOW,
                        "sendtargets", "offload_send_targets", "slp", "isns",
-                       "static", "fw", num, 0);
+                       "static", "fw", num, ATTR_IMMUTABLE);
        if (r->type == DISCOVERY_TYPE_SENDTARGETS) {
                __recinfo_str("discovery.sendtargets.address", ri, r,
-                       address, IDBM_SHOW, num, 0);
+                       address, IDBM_SHOW, num, ATTR_IMMUTABLE);
                __recinfo_int("discovery.sendtargets.port", ri, r,
-                       port, IDBM_SHOW, num, 0);
+                       port, IDBM_SHOW, num, ATTR_IMMUTABLE);
                __recinfo_int_o2("discovery.sendtargets.auth.authmethod", ri, r,
                        u.sendtargets.auth.authmethod,
-                       IDBM_SHOW, "None", "CHAP", num, 1);
+                       IDBM_SHOW, "None", "CHAP", num, ATTR_DEFERRED);
                __recinfo_str("discovery.sendtargets.auth.username", ri, r,
-                       u.sendtargets.auth.username, IDBM_SHOW, num, 1);
+                       u.sendtargets.auth.username, IDBM_SHOW, num, 
ATTR_DEFERRED);
                __recinfo_str("discovery.sendtargets.auth.password", ri, r,
-                       u.sendtargets.auth.password, IDBM_MASKED, num, 1);
+                       u.sendtargets.auth.password, IDBM_MASKED, num, 
ATTR_DEFERRED);
                __recinfo_int("discovery.sendtargets.auth.password_length",
                        ri, r, u.sendtargets.auth.password_length,
-                       IDBM_HIDE, num, 1);
+                       IDBM_HIDE, num, ATTR_DEFERRED);
                __recinfo_str("discovery.sendtargets.auth.username_in", ri, r,
-                       u.sendtargets.auth.username_in, IDBM_SHOW, num, 1);
+                       u.sendtargets.auth.username_in, IDBM_SHOW, num, 
ATTR_DEFERRED);
                __recinfo_str("discovery.sendtargets.auth.password_in", ri, r,
-                       u.sendtargets.auth.password_in, IDBM_MASKED, num, 1);
+                       u.sendtargets.auth.password_in, IDBM_MASKED, num, 
ATTR_DEFERRED);
                __recinfo_int("discovery.sendtargets.auth.password_in_length",
                        ri, r, u.sendtargets.auth.password_in_length,
-                       IDBM_HIDE, num, 1);
+                       IDBM_HIDE, num, ATTR_DEFERRED);
                __recinfo_int("discovery.sendtargets.timeo.login_timeout",ri, r,
                        u.sendtargets.conn_timeo.login_timeout,
-                       IDBM_SHOW, num, 1);
+                       IDBM_SHOW, num, ATTR_IMMEDIATE);
                __recinfo_int("discovery.sendtargets.reopen_max",ri, r,
                        u.sendtargets.reopen_max,
-                       IDBM_SHOW, num, 1);
+                       IDBM_SHOW, num, ATTR_DEFERRED);
                __recinfo_int("discovery.sendtargets.timeo.auth_timeout", ri, r,
                        u.sendtargets.conn_timeo.auth_timeout,
-                       IDBM_SHOW, num, 1);
+                       IDBM_SHOW, num, ATTR_IMMEDIATE);
                __recinfo_int("discovery.sendtargets.timeo.active_timeout",ri,r,
                              u.sendtargets.conn_timeo.active_timeout,
-                             IDBM_SHOW, num, 1);
+                             IDBM_SHOW, num, ATTR_IMMEDIATE);
                
__recinfo_int("discovery.sendtargets.iscsi.MaxRecvDataSegmentLength",
                        ri, r, u.sendtargets.iscsi.MaxRecvDataSegmentLength,
-                       IDBM_SHOW, num, 1);
+                       IDBM_SHOW, num, ATTR_DEFERRED);
        }
 }
 
@@ -254,10 +254,10 @@ idbm_recinfo_node(node_rec_t *r, recinfo_t *ri)
 {
        int num = 0, i;
 
-       __recinfo_str("node.name", ri, r, name, IDBM_SHOW, num, 0);
-       __recinfo_int("node.tpgt", ri, r, tpgt, IDBM_SHOW, num, 0);
+       __recinfo_str("node.name", ri, r, name, IDBM_SHOW, num, ATTR_IMMUTABLE);
+       __recinfo_int("node.tpgt", ri, r, tpgt, IDBM_SHOW, num, ATTR_IMMUTABLE);
        __recinfo_int_o3("node.startup", ri, r, startup,
-                       IDBM_SHOW, "manual", "automatic", "onboot", num, 1);
+                       IDBM_SHOW, "manual", "automatic", "onboot", num, 
ATTR_DEFERRED);
        /*
         * Note: because we do not add the iface.iscsi_ifacename to
         * sysfs iscsiadm does some weird matching. We can change the iface
@@ -270,135 +270,135 @@ idbm_recinfo_node(node_rec_t *r, recinfo_t *ri)
         * needs some locking).
         */
        __recinfo_str("iface.hwaddress", ri, r, iface.hwaddress, IDBM_SHOW,
-                     num, 1);
+                     num, ATTR_DEFERRED);
 //     __recinfo_str("iface.ipaddress", ri, r, iface.ipaddress,
 //                  IDBM_SHOW, num);
        __recinfo_str("iface.iscsi_ifacename", ri, r, iface.name, IDBM_SHOW,
-                     num, 1);
+                     num, ATTR_DEFERRED);
        __recinfo_str("iface.net_ifacename", ri, r, iface.netdev, IDBM_SHOW,
-                     num, 1);
+                     num, ATTR_DEFERRED);
        /*
         * svn 780 compat: older versions used node.transport_name and
         * rec->transport_name
         */
        __recinfo_str("iface.transport_name", ri, r, iface.transport_name,
-                     IDBM_SHOW, num, 1);
+                     IDBM_SHOW, num, ATTR_DEFERRED);
        __recinfo_str("node.discovery_address", ri, r, disc_address, IDBM_SHOW,
-                     num, 0);
+                     num, ATTR_IMMUTABLE);
        __recinfo_int("node.discovery_port", ri, r, disc_port, IDBM_SHOW,
-                     num, 0);
+                     num, ATTR_IMMUTABLE);
        __recinfo_int_o6("node.discovery_type", ri, r, disc_type,
                         IDBM_SHOW, "send_targets", "offload_send_targets",
-                        "slp", "isns", "static", "fw", num, 0);
+                        "slp", "isns", "static", "fw", num, ATTR_IMMUTABLE);
        __recinfo_int("node.session.initial_cmdsn", ri, r,
-                     session.initial_cmdsn, IDBM_SHOW, num, 1);
+                     session.initial_cmdsn, IDBM_SHOW, num, ATTR_DEFERRED);
        __recinfo_int("node.session.initial_login_retry_max", ri, r,
-                     session.initial_login_retry_max, IDBM_SHOW, num, 1);
+                     session.initial_login_retry_max, IDBM_SHOW, num, 
ATTR_DEFERRED);
        __recinfo_int("node.session.cmds_max", ri, r,
-                     session.cmds_max, IDBM_SHOW, num, 1);
+                     session.cmds_max, IDBM_SHOW, num, ATTR_DEFERRED);
        __recinfo_int("node.session.queue_depth", ri, r,
-                      session.queue_depth, IDBM_SHOW, num, 1);
+                      session.queue_depth, IDBM_SHOW, num, ATTR_DEFERRED);
        __recinfo_int_o2("node.session.auth.authmethod", ri, r,
-               session.auth.authmethod, IDBM_SHOW, "None", "CHAP", num, 1);
+               session.auth.authmethod, IDBM_SHOW, "None", "CHAP", num, 
ATTR_DEFERRED);
        __recinfo_str("node.session.auth.username", ri, r,
-                     session.auth.username, IDBM_SHOW, num, 1);
+                     session.auth.username, IDBM_SHOW, num, ATTR_DEFERRED);
        __recinfo_str("node.session.auth.password", ri, r,
-                     session.auth.password, IDBM_MASKED, num, 1);
+                     session.auth.password, IDBM_MASKED, num, ATTR_DEFERRED);
        __recinfo_int("node.session.auth.password_length", ri, r,
-                     session.auth.password_length, IDBM_HIDE, num, 1);
+                     session.auth.password_length, IDBM_HIDE, num, 
ATTR_DEFERRED);
        __recinfo_str("node.session.auth.username_in", ri, r,
-                     session.auth.username_in, IDBM_SHOW, num, 1);
+                     session.auth.username_in, IDBM_SHOW, num, ATTR_DEFERRED);
        __recinfo_str("node.session.auth.password_in", ri, r,
-                     session.auth.password_in, IDBM_MASKED, num, 1);
+                     session.auth.password_in, IDBM_MASKED, num, 
ATTR_DEFERRED);
        __recinfo_int("node.session.auth.password_in_length", ri, r,
-                     session.auth.password_in_length, IDBM_HIDE, num, 1);
+                     session.auth.password_in_length, IDBM_HIDE, num, 
ATTR_DEFERRED);
        __recinfo_int("node.session.timeo.replacement_timeout", ri, r,
                      session.timeo.replacement_timeout,
-                     IDBM_SHOW, num, 1);
+                     IDBM_SHOW, num, ATTR_IMMEDIATE);
        __recinfo_int("node.session.err_timeo.abort_timeout", ri, r,
                      session.err_timeo.abort_timeout,
-                     IDBM_SHOW, num, 1);
+                     IDBM_SHOW, num, ATTR_IMMEDIATE);
        __recinfo_int("node.session.err_timeo.lu_reset_timeout", ri, r,
                      session.err_timeo.lu_reset_timeout,
-                     IDBM_SHOW, num, 1);
+                     IDBM_SHOW, num, ATTR_IMMEDIATE);
        __recinfo_int("node.session.err_timeo.host_reset_timeout", ri, r,
                      session.err_timeo.host_reset_timeout,
-                     IDBM_SHOW, num, 1);
+                     IDBM_SHOW, num, ATTR_IMMEDIATE);
        __recinfo_int_o2("node.session.iscsi.FastAbort", ri, r,
                         session.iscsi.FastAbort, IDBM_SHOW, "No", "Yes",
-                        num, 1);
+                        num, ATTR_DEFERRED);
        __recinfo_int_o2("node.session.iscsi.InitialR2T", ri, r,
                         session.iscsi.InitialR2T, IDBM_SHOW,
-                       "No", "Yes", num, 1);
+                       "No", "Yes", num, ATTR_DEFERRED);
        __recinfo_int_o2("node.session.iscsi.ImmediateData",
                         ri, r, session.iscsi.ImmediateData, IDBM_SHOW,
-                       "No", "Yes", num, 1);
+                       "No", "Yes", num, ATTR_DEFERRED);
        __recinfo_int("node.session.iscsi.FirstBurstLength", ri, r,
-                     session.iscsi.FirstBurstLength, IDBM_SHOW, num, 1);
+                     session.iscsi.FirstBurstLength, IDBM_SHOW, num, 
ATTR_DEFERRED);
        __recinfo_int("node.session.iscsi.MaxBurstLength", ri, r,
-                     session.iscsi.MaxBurstLength, IDBM_SHOW, num, 1);
+                     session.iscsi.MaxBurstLength, IDBM_SHOW, num, 
ATTR_DEFERRED);
        __recinfo_int("node.session.iscsi.DefaultTime2Retain", ri, r,
-                     session.iscsi.DefaultTime2Retain, IDBM_SHOW, num, 1);
+                     session.iscsi.DefaultTime2Retain, IDBM_SHOW, num, 
ATTR_DEFERRED);
        __recinfo_int("node.session.iscsi.DefaultTime2Wait", ri, r,
-                     session.iscsi.DefaultTime2Wait, IDBM_SHOW, num, 1);
+                     session.iscsi.DefaultTime2Wait, IDBM_SHOW, num, 
ATTR_DEFERRED);
        __recinfo_int("node.session.iscsi.MaxConnections", ri, r,
-                     session.iscsi.MaxConnections, IDBM_SHOW, num, 1);
+                     session.iscsi.MaxConnections, IDBM_SHOW, num, 
ATTR_DEFERRED);
        __recinfo_int("node.session.iscsi.MaxOutstandingR2T", ri, r,
-                     session.iscsi.MaxOutstandingR2T, IDBM_SHOW, num, 1);
+                     session.iscsi.MaxOutstandingR2T, IDBM_SHOW, num, 
ATTR_DEFERRED);
        __recinfo_int("node.session.iscsi.ERL", ri, r,
-                     session.iscsi.ERL, IDBM_SHOW, num, 1);
+                     session.iscsi.ERL, IDBM_SHOW, num, ATTR_DEFERRED);
 
        for (i = 0; i < ISCSI_CONN_MAX; i++) {
                char key[NAME_MAXVAL];
 
                sprintf(key, "node.conn[%d].address", i);
-               __recinfo_str(key, ri, r, conn[i].address, IDBM_SHOW, num, 0);
+               __recinfo_str(key, ri, r, conn[i].address, IDBM_SHOW, num, 
ATTR_IMMUTABLE);
                sprintf(key, "node.conn[%d].port", i);
-               __recinfo_int(key, ri, r, conn[i].port, IDBM_SHOW, num, 0);
+               __recinfo_int(key, ri, r, conn[i].port, IDBM_SHOW, num, 
ATTR_IMMUTABLE);
                sprintf(key, "node.conn[%d].startup", i);
                __recinfo_int_o3(key, ri, r, conn[i].startup, IDBM_SHOW,
-                                "manual", "automatic", "onboot", num, 1);
+                                "manual", "automatic", "onboot", num, 
ATTR_DEFERRED);
                sprintf(key, "node.conn[%d].tcp.window_size", i);
                __recinfo_int(key, ri, r, conn[i].tcp.window_size,
-                             IDBM_SHOW, num, 1);
+                             IDBM_SHOW, num, ATTR_DEFERRED);
                sprintf(key, "node.conn[%d].tcp.type_of_service", i);
                __recinfo_int(key, ri, r, conn[i].tcp.type_of_service,
-                               IDBM_SHOW, num, 1);
+                               IDBM_SHOW, num, ATTR_DEFERRED);
                sprintf(key, "node.conn[%d].timeo.logout_timeout", i);
                __recinfo_int(key, ri, r, conn[i].timeo.logout_timeout,
-                               IDBM_SHOW, num, 1);
+                               IDBM_SHOW, num, ATTR_IMMEDIATE);
                sprintf(key, "node.conn[%d].timeo.login_timeout", i);
                __recinfo_int(key, ri, r, conn[i].timeo.login_timeout,
-                               IDBM_SHOW, num, 1);
+                               IDBM_SHOW, num, ATTR_IMMEDIATE);
                sprintf(key, "node.conn[%d].timeo.auth_timeout", i);
                __recinfo_int(key, ri, r, conn[i].timeo.auth_timeout,
-                               IDBM_SHOW, num, 1);
+                               IDBM_SHOW, num, ATTR_IMMEDIATE);
 
                sprintf(key, "node.conn[%d].timeo.noop_out_interval", i);
                __recinfo_int(key, ri, r, conn[i].timeo.noop_out_interval,
-                               IDBM_SHOW, num, 1);
+                               IDBM_SHOW, num, ATTR_IMMEDIATE);
                sprintf(key, "node.conn[%d].timeo.noop_out_timeout", i);
                __recinfo_int(key, ri, r, conn[i].timeo.noop_out_timeout,
-                               IDBM_SHOW, num, 1);
+                               IDBM_SHOW, num, ATTR_IMMEDIATE);
 
                sprintf(key, "node.conn[%d].iscsi.MaxRecvDataSegmentLength", i);
                __recinfo_int(key, ri, r,
                        conn[i].iscsi.MaxRecvDataSegmentLength, IDBM_SHOW,
-                       num, 1);
+                       num, ATTR_DEFERRED);
                sprintf(key, "node.conn[%d].iscsi.HeaderDigest", i);
                __recinfo_int_o4(key, ri, r, conn[i].iscsi.HeaderDigest,
                                 IDBM_SHOW, "None", "CRC32C", "CRC32C,None",
-                                "None,CRC32C", num, 1);
+                                "None,CRC32C", num, ATTR_DEFERRED);
                sprintf(key, "node.conn[%d].iscsi.DataDigest", i);
                __recinfo_int_o4(key, ri, r, conn[i].iscsi.DataDigest, 
IDBM_SHOW,
                                 "None", "CRC32C", "CRC32C,None",
-                                "None,CRC32C", num, 1);
+                                "None,CRC32C", num, ATTR_DEFERRED);
                sprintf(key, "node.conn[%d].iscsi.IFMarker", i);
                __recinfo_int_o2(key, ri, r, conn[i].iscsi.IFMarker, IDBM_SHOW,
-                               "No", "Yes", num, 1);
+                               "No", "Yes", num, ATTR_DEFERRED);
                sprintf(key, "node.conn[%d].iscsi.OFMarker", i);
                __recinfo_int_o2(key, ri, r, conn[i].iscsi.OFMarker, IDBM_SHOW,
-                               "No", "Yes", num, 1);
+                               "No", "Yes", num, ATTR_DEFERRED);
        }
 }
 
@@ -407,12 +407,12 @@ idbm_recinfo_iface(iface_rec_t *r, recinfo_t *ri)
 {
        int num = 0;
 
-       __recinfo_str("iface.iscsi_ifacename", ri, r, name, IDBM_SHOW, num, 0);
-       __recinfo_str("iface.net_ifacename", ri, r, netdev, IDBM_SHOW, num, 1);
+       __recinfo_str("iface.iscsi_ifacename", ri, r, name, IDBM_SHOW, num, 
ATTR_IMMUTABLE);
+       __recinfo_str("iface.net_ifacename", ri, r, netdev, IDBM_SHOW, num, 
ATTR_DEFERRED);
 //     __recinfo_str("iface.ipaddress", ri, r, ipaddress, IDBM_SHOW, num, 1);
-       __recinfo_str("iface.hwaddress", ri, r, hwaddress, IDBM_SHOW, num, 1);
+       __recinfo_str("iface.hwaddress", ri, r, hwaddress, IDBM_SHOW, num, 
ATTR_DEFERRED);
        __recinfo_str("iface.transport_name", ri, r, transport_name,
-                     IDBM_SHOW, num, 1);
+                     IDBM_SHOW, num, ATTR_DEFERRED);
 }
 
 static recinfo_t*
@@ -579,7 +579,7 @@ updated:
 /*
  * TODO: we can also check for valid values here.
  */
-static int idbm_verify_param(recinfo_t *info, char *name)
+static int idbm_verify_param(recinfo_t *info, char *name, int is_active)
 {
        int i;
 
@@ -588,13 +588,22 @@ static int idbm_verify_param(recinfo_t *info, char *name)
                        continue;
 
                log_debug(7, "verify %s %d\n", name, info[i].can_modify);
-               if (info[i].can_modify)
+               if (info[i].can_modify == ATTR_IMMEDIATE)
                        return 0;
-               else {
-                       log_error("Cannot modify %s. It is used to look up "
-                                 "the record and cannot be changed.", name);
-                       return EINVAL;
+               else if (info[i].can_modify == ATTR_DEFERRED) {
+                       if (is_active == 0)
+                               return 0;
+                       else {
+                               log_error("Cannot modify %s. Please logout 
before modifing it", name);
+                               return EINVAL;
+                       }
+               }
+               else if (info[i].can_modify == ATTR_IMMUTABLE) {
+                       log_error("Cannot modify %s. This value is immutable "
+                       "and cannot be modified", name);
+                        return EINVAL;
                }
+
        }
 
        log_error("Cannot modify %s. Invalid param name.", name);
@@ -1022,7 +1031,7 @@ int iface_conf_update(idbm_t *db, struct db_set_param 
*param,
                return ENOMEM;
 
        idbm_recinfo_iface(iface, info);
-       rc = idbm_verify_param(info, param->name);
+       rc = idbm_verify_param(info, param->name, param->connected);
        if (rc)
                goto free_info;
 
@@ -2657,14 +2666,15 @@ int idbm_node_set_param(idbm_t *db, void *data, 
node_rec_t *rec)
        struct db_set_param *param = data;
        recinfo_t *info;
        int rc = 0;
+       int is_active = param->connected;
 
        info = idbm_recinfo_alloc(MAX_KEYS);
        if (!info)
                return ENOMEM;
 
        idbm_recinfo_node(rec, info);
-
-       rc = idbm_verify_param(info, param->name);
+       
+       rc = idbm_verify_param(info, param->name, is_active);
        if (rc)
                goto free_info;
        /*
diff --git a/usr/idbm.h b/usr/idbm.h
index 060a5a8..e8b5e08 100644
--- a/usr/idbm.h
+++ b/usr/idbm.h
@@ -41,6 +41,13 @@
 #define NAME_MAXVAL    128   /* the maximum length of key name */
 #define VALUE_MAXVAL   256   /* the maximum length of 223 bytes in the RFC. */
 #define OPTS_MAXVAL    8
+
+typedef enum modify_attr_e {
+    ATTR_IMMUTABLE,    /*can not be changed at all*/
+    ATTR_DEFERRED,     /*can be changed only when session is not active*/
+    ATTR_IMMEDIATE     /*can be changed while in session*/
+} modify_attr_e;
+
 typedef struct recinfo {
        int             type;
        char            name[NAME_MAXVAL];
@@ -50,12 +57,7 @@ typedef struct recinfo {
        int             visible;
        char*           opts[OPTS_MAXVAL];
        int             numopts;
-       /*
-        * bool indicating if we can change it or not.
-        * TODO: make it a enum that can indicate wheter it also requires
-        * a relogin to pick up if a session is running.
-        */
-       int             can_modify;
+       modify_attr_e   can_modify;
 } recinfo_t;
 
 typedef char *(idbm_get_config_file_fn)(void);
@@ -80,6 +82,7 @@ struct db_set_param {
        char *name;
        char *value;
        struct idbm *db;
+       int connected;
 };
 
 typedef int (idbm_iface_op_fn)(idbm_t *db, void *data, node_rec_t *rec);
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 591ae8c..847393d 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -1873,6 +1873,11 @@ delete_fail:
                set_param.value = value;
 
                /* pass rec's iface because it has the db values */
+               if (check_for_session_through_iface(rec))
+                       set_param.connected = 1;
+               else 
+                       set_param.connected = 0;
+
                rc = iface_conf_update(db, &set_param, &rec->iface);
                if (rc)
                        goto update_fail;
@@ -2006,6 +2011,10 @@ static int exec_node_op(idbm_t *db, int op, int 
do_login, int do_logout,
                set_param.db = db;
                set_param.name = name;
                set_param.value = value;
+               if (check_for_session_through_iface(rec))
+                       set_param.connected = 1;
+               else
+                       set_param.connected = 0;
 
                if (for_each_rec(db, rec, &set_param, idbm_node_set_param))     
                        rc = -1;
-- 
1.5.3.8



--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~----------~----~----~----~------~----~------~--~---

Reply via email to