|
|
786c6d |
From ea05be3ff043efd44256283d968fa1bb9a371568 Mon Sep 17 00:00:00 2001
|
|
|
786c6d |
From: Mike Christie <michaelc@cs.wisc.edu>
|
|
|
786c6d |
Date: Thu, 13 Feb 2014 12:37:09 -0600
|
|
|
786c6d |
Subject: [PATCH] iscsi tools: set non negotiated params early.
|
|
|
786c6d |
|
|
|
786c6d |
This patch has the iscsi tools pass down the non-negotiated
|
|
|
786c6d |
iscsi settings before doing iscsi login. This allows the
|
|
|
786c6d |
drivers to get info that might be neede to setup the session
|
|
|
786c6d |
early.
|
|
|
786c6d |
|
|
|
786c6d |
This patch also adds the missing discovery_sess param to
|
|
|
786c6d |
the non negotiated params.
|
|
|
786c6d |
---
|
|
|
786c6d |
usr/discovery.c | 15 +++++++++--
|
|
|
786c6d |
usr/initiator.c | 22 +++++++++++-----
|
|
|
786c6d |
usr/initiator.h | 1 +
|
|
|
786c6d |
usr/initiator_common.c | 69 ++++++++++++++++++++++++++++++++++++++++++++------
|
|
|
786c6d |
4 files changed, 91 insertions(+), 16 deletions(-)
|
|
|
786c6d |
|
|
|
786c6d |
diff --git a/usr/discovery.c b/usr/discovery.c
|
|
|
786c6d |
index afce6c0..635ec8d 100644
|
|
|
786c6d |
--- a/usr/discovery.c
|
|
|
786c6d |
+++ b/usr/discovery.c
|
|
|
786c6d |
@@ -1403,6 +1403,17 @@ redirect_reconnect:
|
|
|
786c6d |
iscsi_copy_operational_params(&session->conn[0], &config->session_conf,
|
|
|
786c6d |
&config->conn_conf);
|
|
|
786c6d |
|
|
|
786c6d |
+ if (t->caps & CAP_TEXT_NEGO) {
|
|
|
786c6d |
+ log_debug(2, "%s discovery set params\n", __FUNCTION__);
|
|
|
786c6d |
+ rc = iscsi_session_set_params(conn);
|
|
|
786c6d |
+ if (rc) {
|
|
|
786c6d |
+ log_error("Could not set iscsi params for conn %d:%d "
|
|
|
786c6d |
+ "(err %d)\n", session->id, conn->id, rc);
|
|
|
786c6d |
+ rc = ISCSI_ERR_INTERNAL;
|
|
|
786c6d |
+ goto login_failed;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
if ((session->t->caps & CAP_LOGIN_OFFLOAD))
|
|
|
786c6d |
goto start_conn;
|
|
|
786c6d |
|
|
|
786c6d |
@@ -1509,8 +1520,8 @@ redirect_reconnect:
|
|
|
786c6d |
return 0;
|
|
|
786c6d |
|
|
|
786c6d |
start_conn:
|
|
|
786c6d |
- log_debug(2, "%s discovery set params\n", __FUNCTION__);
|
|
|
786c6d |
- rc = iscsi_session_set_params(conn);
|
|
|
786c6d |
+ log_debug(2, "%s discovery set neg params\n", __FUNCTION__);
|
|
|
786c6d |
+ rc = iscsi_session_set_neg_params(conn);
|
|
|
786c6d |
if (rc) {
|
|
|
786c6d |
log_error("Could not set iscsi params for conn %d:%d (err "
|
|
|
786c6d |
"%d)\n", session->id, conn->id, rc);
|
|
|
786c6d |
diff --git a/usr/initiator.c b/usr/initiator.c
|
|
|
786c6d |
index 79d1779..05a5b19 100644
|
|
|
786c6d |
--- a/usr/initiator.c
|
|
|
786c6d |
+++ b/usr/initiator.c
|
|
|
786c6d |
@@ -1048,12 +1048,7 @@ setup_full_feature_phase(iscsi_conn_t *conn)
|
|
|
786c6d |
|
|
|
786c6d |
actor_delete(&conn->login_timer);
|
|
|
786c6d |
|
|
|
786c6d |
- if (iscsi_session_set_params(conn)) {
|
|
|
786c6d |
- iscsi_login_eh(conn, c->qtask, ISCSI_ERR_LOGIN);
|
|
|
786c6d |
- return;
|
|
|
786c6d |
- }
|
|
|
786c6d |
-
|
|
|
786c6d |
- if (iscsi_host_set_params(session)) {
|
|
|
786c6d |
+ if (iscsi_session_set_neg_params(conn)) {
|
|
|
786c6d |
iscsi_login_eh(conn, c->qtask, ISCSI_ERR_LOGIN);
|
|
|
786c6d |
return;
|
|
|
786c6d |
}
|
|
|
786c6d |
@@ -1507,6 +1502,11 @@ static void setup_offload_login_phase(iscsi_conn_t *conn)
|
|
|
786c6d |
return;
|
|
|
786c6d |
}
|
|
|
786c6d |
|
|
|
786c6d |
+ if (iscsi_session_set_neg_params(conn)) {
|
|
|
786c6d |
+ iscsi_login_eh(conn, c->qtask, ISCSI_ERR_LOGIN);
|
|
|
786c6d |
+ return;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
if (iscsi_host_set_params(session)) {
|
|
|
786c6d |
iscsi_login_eh(conn, c->qtask, ISCSI_ERR_LOGIN);
|
|
|
786c6d |
return;
|
|
|
786c6d |
@@ -1618,6 +1618,16 @@ static void session_conn_poll(void *data)
|
|
|
786c6d |
return;
|
|
|
786c6d |
}
|
|
|
786c6d |
|
|
|
786c6d |
+ if (iscsi_session_set_params(conn)) {
|
|
|
786c6d |
+ iscsi_login_eh(conn, qtask, ISCSI_ERR_LOGIN);
|
|
|
786c6d |
+ return;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
+ if (iscsi_host_set_params(session)) {
|
|
|
786c6d |
+ iscsi_login_eh(conn, qtask, ISCSI_ERR_LOGIN);
|
|
|
786c6d |
+ return;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
if (iscsi_login_begin(session, c)) {
|
|
|
786c6d |
iscsi_login_eh(conn, qtask, ISCSI_ERR_LOGIN);
|
|
|
786c6d |
return;
|
|
|
786c6d |
diff --git a/usr/initiator.h b/usr/initiator.h
|
|
|
786c6d |
index 680640c..c34625b 100644
|
|
|
786c6d |
--- a/usr/initiator.h
|
|
|
786c6d |
+++ b/usr/initiator.h
|
|
|
786c6d |
@@ -344,6 +344,7 @@ extern void free_initiator(void);
|
|
|
786c6d |
extern void iscsi_initiator_init(void);
|
|
|
786c6d |
|
|
|
786c6d |
/* initiator code common to discovery and normal sessions */
|
|
|
786c6d |
+extern int iscsi_session_set_neg_params(struct iscsi_conn *conn);
|
|
|
786c6d |
extern int iscsi_session_set_params(struct iscsi_conn *conn);
|
|
|
786c6d |
extern int iscsi_host_set_params(struct iscsi_session *session);
|
|
|
786c6d |
extern int iscsi_host_set_net_params(struct iface_rec *iface,
|
|
|
786c6d |
diff --git a/usr/initiator_common.c b/usr/initiator_common.c
|
|
|
786c6d |
index e2e87a1..109e8d7 100644
|
|
|
786c6d |
--- a/usr/initiator_common.c
|
|
|
786c6d |
+++ b/usr/initiator_common.c
|
|
|
786c6d |
@@ -345,9 +345,9 @@ void iscsi_session_init_params(struct iscsi_session *session)
|
|
|
786c6d |
}
|
|
|
786c6d |
}
|
|
|
786c6d |
|
|
|
786c6d |
-#define MAX_SESSION_PARAMS 35
|
|
|
786c6d |
+#define MAX_SESSION_NEG_PARAMS 16
|
|
|
786c6d |
|
|
|
786c6d |
-int iscsi_session_set_params(struct iscsi_conn *conn)
|
|
|
786c6d |
+int iscsi_session_set_neg_params(struct iscsi_conn *conn)
|
|
|
786c6d |
{
|
|
|
786c6d |
struct iscsi_session *session = conn->session;
|
|
|
786c6d |
int i, rc;
|
|
|
786c6d |
@@ -357,7 +357,7 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
|
|
|
786c6d |
int type;
|
|
|
786c6d |
void *value;
|
|
|
786c6d |
int conn_only;
|
|
|
786c6d |
- } conntbl[MAX_SESSION_PARAMS] = {
|
|
|
786c6d |
+ } conntbl[MAX_SESSION_NEG_PARAMS] = {
|
|
|
786c6d |
{
|
|
|
786c6d |
.param = ISCSI_PARAM_MAX_RECV_DLENGTH,
|
|
|
786c6d |
.value = &conn->max_recv_dlength,
|
|
|
786c6d |
@@ -434,15 +434,58 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
|
|
|
786c6d |
.type = ISCSI_INT,
|
|
|
786c6d |
.conn_only = 1,
|
|
|
786c6d |
}, {
|
|
|
786c6d |
- .param = ISCSI_PARAM_TARGET_NAME,
|
|
|
786c6d |
- .conn_only = 0,
|
|
|
786c6d |
- .type = ISCSI_STRING,
|
|
|
786c6d |
- .value = session->target_name,
|
|
|
786c6d |
- }, {
|
|
|
786c6d |
.param = ISCSI_PARAM_TPGT,
|
|
|
786c6d |
.value = &session->portal_group_tag,
|
|
|
786c6d |
.type = ISCSI_INT,
|
|
|
786c6d |
.conn_only = 0,
|
|
|
786c6d |
+ },
|
|
|
786c6d |
+ };
|
|
|
786c6d |
+
|
|
|
786c6d |
+ iscsi_session_init_params(session);
|
|
|
786c6d |
+
|
|
|
786c6d |
+ /* Entered full-feature phase! */
|
|
|
786c6d |
+ for (i = 0; i < MAX_SESSION_NEG_PARAMS; i++) {
|
|
|
786c6d |
+ if (conn->id != 0 && !conntbl[i].conn_only)
|
|
|
786c6d |
+ continue;
|
|
|
786c6d |
+
|
|
|
786c6d |
+ if (!(session->param_mask & (1ULL << conntbl[i].param)))
|
|
|
786c6d |
+ continue;
|
|
|
786c6d |
+
|
|
|
786c6d |
+ rc = ipc->set_param(session->t->handle, session->id,
|
|
|
786c6d |
+ conn->id, conntbl[i].param, conntbl[i].value,
|
|
|
786c6d |
+ conntbl[i].type);
|
|
|
786c6d |
+ if (rc && rc != -ENOSYS) {
|
|
|
786c6d |
+ log_error("can't set operational parameter %d for "
|
|
|
786c6d |
+ "connection %d:%d, retcode %d (%d)",
|
|
|
786c6d |
+ conntbl[i].param, session->id, conn->id,
|
|
|
786c6d |
+ rc, errno);
|
|
|
786c6d |
+ return EPERM;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
+ print_param_value(conntbl[i].param, conntbl[i].value,
|
|
|
786c6d |
+ conntbl[i].type);
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
+ return 0;
|
|
|
786c6d |
+}
|
|
|
786c6d |
+
|
|
|
786c6d |
+#define MAX_SESSION_PARAMS 20
|
|
|
786c6d |
+
|
|
|
786c6d |
+int iscsi_session_set_params(struct iscsi_conn *conn)
|
|
|
786c6d |
+{
|
|
|
786c6d |
+ struct iscsi_session *session = conn->session;
|
|
|
786c6d |
+ int i, rc;
|
|
|
786c6d |
+ struct connparam {
|
|
|
786c6d |
+ int param;
|
|
|
786c6d |
+ int type;
|
|
|
786c6d |
+ void *value;
|
|
|
786c6d |
+ int conn_only;
|
|
|
786c6d |
+ } conntbl[MAX_SESSION_PARAMS] = {
|
|
|
786c6d |
+ {
|
|
|
786c6d |
+ .param = ISCSI_PARAM_TARGET_NAME,
|
|
|
786c6d |
+ .conn_only = 0,
|
|
|
786c6d |
+ .type = ISCSI_STRING,
|
|
|
786c6d |
+ .value = session->target_name,
|
|
|
786c6d |
}, {
|
|
|
786c6d |
.param = ISCSI_PARAM_PERSISTENT_ADDRESS,
|
|
|
786c6d |
.value = session->nrec.conn[conn->id].address,
|
|
|
786c6d |
@@ -512,22 +555,32 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
|
|
|
786c6d |
.param = ISCSI_PARAM_IFACE_NAME,
|
|
|
786c6d |
.value = session->nrec.iface.name,
|
|
|
786c6d |
.type = ISCSI_STRING,
|
|
|
786c6d |
+ .conn_only = 0,
|
|
|
786c6d |
}, {
|
|
|
786c6d |
.param = ISCSI_PARAM_INITIATOR_NAME,
|
|
|
786c6d |
.value = session->initiator_name,
|
|
|
786c6d |
.type = ISCSI_STRING,
|
|
|
786c6d |
+ .conn_only = 0,
|
|
|
786c6d |
}, {
|
|
|
786c6d |
.param = ISCSI_PARAM_BOOT_ROOT,
|
|
|
786c6d |
.value = session->nrec.session.boot_root,
|
|
|
786c6d |
.type = ISCSI_STRING,
|
|
|
786c6d |
+ .conn_only = 0,
|
|
|
786c6d |
}, {
|
|
|
786c6d |
.param = ISCSI_PARAM_BOOT_NIC,
|
|
|
786c6d |
.value = session->nrec.session.boot_nic,
|
|
|
786c6d |
.type = ISCSI_STRING,
|
|
|
786c6d |
+ .conn_only = 0,
|
|
|
786c6d |
}, {
|
|
|
786c6d |
.param = ISCSI_PARAM_BOOT_TARGET,
|
|
|
786c6d |
.value = session->nrec.session.boot_target,
|
|
|
786c6d |
.type = ISCSI_STRING,
|
|
|
786c6d |
+ .conn_only = 0,
|
|
|
786c6d |
+ }, {
|
|
|
786c6d |
+ .param = ISCSI_PARAM_DISCOVERY_SESS,
|
|
|
786c6d |
+ .value = &session->type,
|
|
|
786c6d |
+ .type = ISCSI_INT,
|
|
|
786c6d |
+ .conn_only = 0,
|
|
|
786c6d |
},
|
|
|
786c6d |
};
|
|
|
786c6d |
|
|
|
786c6d |
--
|
|
|
786c6d |
1.8.3.1
|
|
|
786c6d |
|