On 1/26/14 8:03 AM, Or Gerlitz wrote:
For proper discovery support, the iser transport needs the
ISCSI_PARAM_DISCOVERY_SESS hint before the login PDU is sent.
For that end, issue the call to iscsi_session_set_params before
starting the login code in case the transport is iser.
Signed-off-by: Or Gerlitz <[email protected]>
---
usr/discovery.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/usr/discovery.c b/usr/discovery.c
index afce6c0..4f02aac 100644
--- a/usr/discovery.c
+++ b/usr/discovery.c
@@ -1116,7 +1116,7 @@ static int iscsi_create_leading_conn(struct iscsi_session
*session)
}
/* create interconnect endpoint */
- log_debug(2, "%s discovery ep connect\n", __FUNCTION__);
+ log_debug(2, "%s discovery ep connect transport %s caps %x\n", __FUNCTION__,
t->name, t->caps);
Formatting. You kept it one line here but you tried to break it up
below. You should try to follow the existing code.
rc = t->template->ep_connect(conn, 1);
if (rc < 0) {
rc = ISCSI_ERR_TRANS;
@@ -1406,6 +1406,17 @@ redirect_reconnect:
if ((session->t->caps & CAP_LOGIN_OFFLOAD))
goto start_conn;
+ if(!strcmp(session->t->name, "iser")) {
+ log_debug(2, "%s discovery set params\n", __FUNCTION__);
+ rc = iscsi_session_set_params(conn);
+ if (rc) {
+ log_error("Could not set iscsi params for conn %d:%d (err
"
+ "%d)\n", session->id, conn->id, rc);
+ rc = ISCSI_ERR_INTERNAL;
+ goto login_failed;
+ }
+ }
+
The check for specifically iser here is a little odd. The discovery type
is a generic iscsi attr so we should not have to special case it.
Do you just need that one setting at this time or do you need any other
settings?
There is a issue where during the initial login if you run iscsiadm -m
session then you will get some odd error messages for sessions that are
not yet logged in because the target name and some ips are not setup
yet. If we just pass them early, along with the discovery type attr,
then we can do this in a generic way and also fix that issue. I attached
a completely untested patch.
If you need other settings early let me know.
Also, I was not sure why in the other patch conn_only was set to 1 for
discovery session. It seems like a session level attr. I changed it to 0
in my patch.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/usr/discovery.c b/usr/discovery.c
index afce6c0..901b731 100644
--- a/usr/discovery.c
+++ b/usr/discovery.c
@@ -1406,6 +1406,15 @@ redirect_reconnect:
if ((session->t->caps & CAP_LOGIN_OFFLOAD))
goto start_conn;
+ log_debug(2, "%s discovery set params\n", __FUNCTION__);
+ rc = iscsi_session_set_params(conn);
+ if (rc) {
+ log_error("Could not set iscsi params for conn %d:%d (err "
+ "%d)\n", session->id, conn->id, rc);
+ rc = ISCSI_ERR_INTERNAL;
+ goto login_failed;
+ }
+
status_class = 0;
status_detail = 0;
rc = ISCSI_ERR_LOGIN;
@@ -1510,7 +1519,7 @@ redirect_reconnect:
start_conn:
log_debug(2, "%s discovery set params\n", __FUNCTION__);
- rc = iscsi_session_set_params(conn);
+ rc = iscsi_session_set_neg_params(conn);
if (rc) {
log_error("Could not set iscsi params for conn %d:%d (err "
"%d)\n", session->id, conn->id, rc);
diff --git a/usr/initiator.c b/usr/initiator.c
index 79d1779..05a5b19 100644
--- a/usr/initiator.c
+++ b/usr/initiator.c
@@ -1048,12 +1048,7 @@ setup_full_feature_phase(iscsi_conn_t *conn)
actor_delete(&conn->login_timer);
- if (iscsi_session_set_params(conn)) {
- iscsi_login_eh(conn, c->qtask, ISCSI_ERR_LOGIN);
- return;
- }
-
- if (iscsi_host_set_params(session)) {
+ if (iscsi_session_set_neg_params(conn)) {
iscsi_login_eh(conn, c->qtask, ISCSI_ERR_LOGIN);
return;
}
@@ -1507,6 +1502,11 @@ static void setup_offload_login_phase(iscsi_conn_t *conn)
return;
}
+ if (iscsi_session_set_neg_params(conn)) {
+ iscsi_login_eh(conn, c->qtask, ISCSI_ERR_LOGIN);
+ return;
+ }
+
if (iscsi_host_set_params(session)) {
iscsi_login_eh(conn, c->qtask, ISCSI_ERR_LOGIN);
return;
@@ -1618,6 +1618,16 @@ static void session_conn_poll(void *data)
return;
}
+ if (iscsi_session_set_params(conn)) {
+ iscsi_login_eh(conn, qtask, ISCSI_ERR_LOGIN);
+ return;
+ }
+
+ if (iscsi_host_set_params(session)) {
+ iscsi_login_eh(conn, qtask, ISCSI_ERR_LOGIN);
+ return;
+ }
+
if (iscsi_login_begin(session, c)) {
iscsi_login_eh(conn, qtask, ISCSI_ERR_LOGIN);
return;
diff --git a/usr/initiator.h b/usr/initiator.h
index 680640c..c34625b 100644
--- a/usr/initiator.h
+++ b/usr/initiator.h
@@ -344,6 +344,7 @@ extern void free_initiator(void);
extern void iscsi_initiator_init(void);
/* initiator code common to discovery and normal sessions */
+extern int iscsi_session_set_neg_params(struct iscsi_conn *conn);
extern int iscsi_session_set_params(struct iscsi_conn *conn);
extern int iscsi_host_set_params(struct iscsi_session *session);
extern int iscsi_host_set_net_params(struct iface_rec *iface,
diff --git a/usr/initiator_common.c b/usr/initiator_common.c
index e2e87a1..109e8d7 100644
--- a/usr/initiator_common.c
+++ b/usr/initiator_common.c
@@ -345,9 +345,9 @@ void iscsi_session_init_params(struct iscsi_session
*session)
}
}
-#define MAX_SESSION_PARAMS 35
+#define MAX_SESSION_NEG_PARAMS 16
-int iscsi_session_set_params(struct iscsi_conn *conn)
+int iscsi_session_set_neg_params(struct iscsi_conn *conn)
{
struct iscsi_session *session = conn->session;
int i, rc;
@@ -357,7 +357,7 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
int type;
void *value;
int conn_only;
- } conntbl[MAX_SESSION_PARAMS] = {
+ } conntbl[MAX_SESSION_NEG_PARAMS] = {
{
.param = ISCSI_PARAM_MAX_RECV_DLENGTH,
.value = &conn->max_recv_dlength,
@@ -434,15 +434,58 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
.type = ISCSI_INT,
.conn_only = 1,
}, {
- .param = ISCSI_PARAM_TARGET_NAME,
- .conn_only = 0,
- .type = ISCSI_STRING,
- .value = session->target_name,
- }, {
.param = ISCSI_PARAM_TPGT,
.value = &session->portal_group_tag,
.type = ISCSI_INT,
.conn_only = 0,
+ },
+ };
+
+ iscsi_session_init_params(session);
+
+ /* Entered full-feature phase! */
+ for (i = 0; i < MAX_SESSION_NEG_PARAMS; i++) {
+ if (conn->id != 0 && !conntbl[i].conn_only)
+ continue;
+
+ if (!(session->param_mask & (1ULL << conntbl[i].param)))
+ continue;
+
+ rc = ipc->set_param(session->t->handle, session->id,
+ conn->id, conntbl[i].param, conntbl[i].value,
+ conntbl[i].type);
+ if (rc && rc != -ENOSYS) {
+ log_error("can't set operational parameter %d for "
+ "connection %d:%d, retcode %d (%d)",
+ conntbl[i].param, session->id, conn->id,
+ rc, errno);
+ return EPERM;
+ }
+
+ print_param_value(conntbl[i].param, conntbl[i].value,
+ conntbl[i].type);
+ }
+
+ return 0;
+}
+
+#define MAX_SESSION_PARAMS 20
+
+int iscsi_session_set_params(struct iscsi_conn *conn)
+{
+ struct iscsi_session *session = conn->session;
+ int i, rc;
+ struct connparam {
+ int param;
+ int type;
+ void *value;
+ int conn_only;
+ } conntbl[MAX_SESSION_PARAMS] = {
+ {
+ .param = ISCSI_PARAM_TARGET_NAME,
+ .conn_only = 0,
+ .type = ISCSI_STRING,
+ .value = session->target_name,
}, {
.param = ISCSI_PARAM_PERSISTENT_ADDRESS,
.value = session->nrec.conn[conn->id].address,
@@ -512,22 +555,32 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
.param = ISCSI_PARAM_IFACE_NAME,
.value = session->nrec.iface.name,
.type = ISCSI_STRING,
+ .conn_only = 0,
}, {
.param = ISCSI_PARAM_INITIATOR_NAME,
.value = session->initiator_name,
.type = ISCSI_STRING,
+ .conn_only = 0,
}, {
.param = ISCSI_PARAM_BOOT_ROOT,
.value = session->nrec.session.boot_root,
.type = ISCSI_STRING,
+ .conn_only = 0,
}, {
.param = ISCSI_PARAM_BOOT_NIC,
.value = session->nrec.session.boot_nic,
.type = ISCSI_STRING,
+ .conn_only = 0,
}, {
.param = ISCSI_PARAM_BOOT_TARGET,
.value = session->nrec.session.boot_target,
.type = ISCSI_STRING,
+ .conn_only = 0,
+ }, {
+ .param = ISCSI_PARAM_DISCOVERY_SESS,
+ .value = &session->type,
+ .type = ISCSI_INT,
+ .conn_only = 0,
},
};