summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Duncan <lduncan@suse.com>2022-03-20 14:26:52 -0700
committerGitHub <noreply@github.com>2022-03-20 14:26:52 -0700
commit53c51a7525435c539697da128081e54fad13df09 (patch)
tree6f2cd89a256b3e11ee66504b39bf2094548b04f1
parentf64890f2b90b53389e528559115a726072f71844 (diff)
parent70b9e55dce7b57a344975d7c3992b5bcf2ef8b16 (diff)
downloadopen-iscsi-53c51a7525435c539697da128081e54fad13df09.tar.gz
Merge pull request #321 from gonzoleeman/fw-login-add-nv-pairs-v2
Firmware login: add nv pairs and default values
-rw-r--r--doc/iscsiadm.811
-rw-r--r--usr/iscsiadm.c77
2 files changed, 77 insertions, 11 deletions
diff --git a/doc/iscsiadm.8 b/doc/iscsiadm.8
index a14a02b..599a8fd 100644
--- a/doc/iscsiadm.8
+++ b/doc/iscsiadm.8
@@ -123,6 +123,10 @@ iscsiadm \- open-iscsi administration utility
.IR debug_level ]
.RB [ \-l ]
.RB [ \-W ]
+.RB [ \-n
+.IR name ]
+.RB [ \-v
+.IR value ]
.PP
.B iscsiadm
.B \-m host
@@ -295,6 +299,9 @@ For \fInode\fR and \fIfw\fR modes, login to a specified record. For \fIdiscovery
login to all discovered targets.
.IP
This option is only valid for \fIdiscovery\fR, \fInode\fR, and \fIfw\fR modes.
+For \fIfw\fR mode only, \fIname\fR and \fIvalue\fR pairs can optionally be passed in,
+so that those values get used for the sessions created. In this case, no \fIop\fR
+is needed, since \fIupdate\fR is assumed.
.TP
\fB\-L\fR, \fB\-\-loginall=\fI[all|manual|automatic|onboot]\fR
For \fInode\fR mode, login to all sessions with the node or conn startup values passed
@@ -362,7 +369,7 @@ Setting \fIop\fR to \fIupdate\fR will update the \fIrecid\fR with \fIname\fR to
\fIvalue\fR. In discovery mode, if iscsiadm is performing discovery the
\fIrecid\fR, \fIname\fR and \fIvalue\fR arguments are not needed. The
update operation will operate on the portals returned by the target,
-and will update the node records with info from the configuration file and
+and will update the node records with information from the configuration file and
command line.
.IP
The \fIop\fR value of \fIshow\fR is the default behaviour for \fInode\fR,
@@ -459,7 +466,7 @@ This option is only valid for \fInode\fR mode (it is valid but not functional
for \fIsession\fR mode).
.TP
\fB\-v\fR, \fB\-\-value=\fIvalue\fR
-Specify a \fIvalue\fR for use with the \fIupdate\fR operator.
+Specify a \fIvalue\fR for use with the \fIupdate\fR operator, or for firmware login mode.
.IP
This option is only valid for \fInode\fR mode and \fIflashnode\fR submode of \fIhost\fR mode.
.TP
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 0467db5..2a86068 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -114,7 +114,7 @@ static const struct verify_mode_t mode_paras[] = {
[MODE_SESSION] = {"session", "PiRdrmusonuSv", 1},
[MODE_HOST] = {"host", "CHdmPotnvxA", 0},
[MODE_IFACE] = {"iface", "HIdnvmPoCabci", 0},
- [MODE_FW] = {"fw", "dmlW", 0},
+ [MODE_FW] = {"fw", "dmlWnv", 0},
};
static struct option const long_options[] =
@@ -165,10 +165,10 @@ iscsiadm -m discoverydb [-hV] [-d debug_level] [-P printlevel] [-t type -p ip:po
[-o operation] [-n name] [-v value] [-lD]] \n\
iscsiadm -m discovery [-hV] [-d debug_level] [-P printlevel] [-t type -p ip:port -I ifaceN ... [-l]] | [[-p ip:port] [-l | -D]] [-W]\n\
iscsiadm -m node [-hV] [-d debug_level] [-P printlevel] [-L all,manual,automatic,onboot] [-W] [-U all,manual,automatic,onboot] [-S] [[-T targetname -p ip:port -I ifaceN] [-l | -u | -R | -s]] \
-[[-o operation ] [-n name] [-v value]]\n\
-iscsiadm -m session [-hV] [-d debug_level] [-P printlevel] [-r sessionid | sysfsdir [-R | -u | -s] [-o operation] [-n name] [-v value]]\n\
-iscsiadm -m iface [-hV] [-d debug_level] [-P printlevel] [-I ifacename | -H hostno|MAC] [[-o operation ] [-n name] [-v value]] [-C ping [-a ip] [-b packetsize] [-c count] [-i interval]]\n\
-iscsiadm -m fw [-d debug_level] [-l] [-W]\n\
+[[-o operation ] [-n name] [-v value]]\n\
+iscsiadm -m session [-hV] [-d debug_level] [-P printlevel] [-r sessionid | sysfsdir [-R | -u | -s] [-o operation] [-n name] [-v value]]\n\
+iscsiadm -m iface [-hV] [-d debug_level] [-P printlevel] [-I ifacename | -H hostno|MAC] [[-o operation ] [-n name] [-v value]] [-C ping [-a ip] [-b packetsize] [-c count] [-i interval]]\n\
+iscsiadm -m fw [-d debug_level] [-l] [-W] [[-n name] [-v value]]\n\
iscsiadm -m host [-P printlevel] [-H hostno|MAC] [[-C chap [-x chap_tbl_idx]] | [-C flashnode [-A portal_type] [-x flashnode_idx]] | [-C stats]] [[-o operation] [-n name] [-v value]] \n\
iscsiadm -k priority\n");
}
@@ -3013,8 +3013,61 @@ done:
return rc;
}
+static int fill_in_default_fw_values(node_rec_t *rec, struct list_head *params)
+{
+ struct user_param *param;
+ int rc;
+
+ /* must init this so we can check if user overrode them */
+ rec->session.initial_login_retry_max = -1;
+ rec->conn[0].timeo.noop_out_interval = -1;
+ rec->conn[0].timeo.noop_out_timeout = -1;
+ rec->session.scan = -1;
+
+ list_for_each_entry(param, params, list) {
+ /*
+ * do not allow user to override iface parameters, since
+ * firmware/ibft values should be used and not overridden
+ */
+ if (!strcmp(param->name, IFACE_NETNAME) ||
+ !strcmp(param->name, IFACE_HWADDR) ||
+ !strcmp(param->name, IFACE_TRANSPORTNAME)) {
+ log_error("Cannot override interface parameters for firmware logins");
+ return ISCSI_ERR_INVAL;
+ }
+ }
+
+ if (!list_empty(params)) {
+ rc = idbm_node_set_rec_from_param(params, rec, 0);
+ if (rc)
+ return rc;
+ }
+
+ /*
+ * For root boot we could not change this in older versions so
+ * if user did not override then use the defaults.
+ *
+ * Increase to account for boot using static setup.
+ */
+ if (rec->session.initial_login_retry_max == -1)
+ rec->session.initial_login_retry_max = 30;
+
+ /* firmware logins are usually used for booting, so no NOPs */
+ if (rec->conn[0].timeo.noop_out_interval == -1)
+ rec->conn[0].timeo.noop_out_interval = 0;
+ if (rec->conn[0].timeo.noop_out_timeout == -1)
+ rec->conn[0].timeo.noop_out_timeout = 0;
+
+ /* default scan mode is "auto" */
+ if (rec->session.scan == -1)
+ rec->session.scan = DEF_INITIAL_SCAN;
+
+ return 0;
+}
+
static int exec_fw_op(discovery_rec_t *drec, struct list_head *ifaces,
- int info_level, int do_login, int op, bool wait)
+ int info_level, int do_login, int op, bool wait,
+ struct list_head *params)
{
struct boot_context *context;
LIST_HEAD(targets);
@@ -3042,6 +3095,12 @@ static int exec_fw_op(discovery_rec_t *drec, struct list_head *ifaces,
rc = ISCSI_ERR_NOMEM;
break;
}
+ /* update rec based on params and default values */
+ rc = fill_in_default_fw_values(rec, params);
+ if (rc) {
+ log_error("Could not merge user params");
+ break;
+ }
if (wait)
iscsi_login_portal(NULL, NULL, rec);
@@ -3205,7 +3264,7 @@ static int exec_disc2_op(int disc_type, char *ip, int port,
}
drec.type = DISCOVERY_TYPE_FW;
- rc = exec_fw_op(&drec, ifaces, info_level, do_login, op, true);
+ rc = exec_fw_op(&drec, ifaces, info_level, do_login, op, true, NULL);
goto done;
default:
rc = ISCSI_ERR_INVAL;
@@ -3323,7 +3382,7 @@ static int exec_disc_op(int disc_type,
break;
case DISCOVERY_TYPE_FW:
drec.type = DISCOVERY_TYPE_FW;
- rc = exec_fw_op(&drec, ifaces, info_level, do_login, op, wait);
+ rc = exec_fw_op(&drec, ifaces, info_level, do_login, op, wait, NULL);
break;
default:
if (ip) {
@@ -3806,7 +3865,7 @@ main(int argc, char **argv)
usage(ISCSI_ERR_INVAL);
if (mode == MODE_FW) {
- rc = exec_fw_op(NULL, NULL, info_level, do_login, op, wait);
+ rc = exec_fw_op(NULL, NULL, info_level, do_login, op, wait, &params);
goto out;
}