[Stgt-devel] [PATCH] iscsi fix xmit param
Pete Wyckoff
pw
Tue Sep 4 22:03:06 CEST 2007
Repair one corner case in MaxRecvDataSegmentLength processing. Default
target has always kept data segments at 8k, even if the initiator asks
for more. Some target administrators may increase this by, e.g.:
tgtadm --lld iscsi --mode target --op update --tid 1 \
--name MaxXmitDataSegmentLength --value 262144
so that target will generate up to min(initiator-specified RDSL, 256k).
But if such a change is made, and the initiator does not specify RDSL,
which is odd but specification compliant, the target will incorrectly
use 256k instead of 8k.
Signed-off-by: Pete Wyckoff <pw at osc.edu>
---
usr/iscsi/iscsid.c | 10 +++++++---
usr/iscsi/iscsid.h | 1 +
usr/iscsi/target.c | 2 +-
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index ab3bf53..079c878 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -286,8 +286,10 @@ static void text_scan_login(struct iscsi_connection *conn)
unsigned int val;
char buf[32];
- if (idx == ISCSI_PARAM_MAX_RECV_DLENGTH)
+ if (idx == ISCSI_PARAM_MAX_RECV_DLENGTH) {
idx = ISCSI_PARAM_MAX_XMIT_DLENGTH;
+ conn->mxdsl_negotiated = 1;
+ }
if (param_str_to_val(session_keys, idx, value, &val) < 0) {
if (conn->session_param[idx].state
@@ -349,8 +351,6 @@ static int text_check_param(struct iscsi_connection *conn)
if (p[i].state == KEY_STATE_START && p[i].val != session_keys[i].def) {
if (conn->state == STATE_LOGIN) {
if (i == ISCSI_PARAM_MAX_XMIT_DLENGTH) {
- if (p[i].val > session_keys[i].def)
- p[i].val = session_keys[i].def;
p[i].state = KEY_STATE_DONE;
continue;
}
@@ -471,6 +471,10 @@ static void login_finish(struct iscsi_connection *conn)
{
switch (conn->session_type) {
case SESSION_NORMAL:
+ if (!conn->mxdsl_negotiated)
+ /* use spec default if he did not mention MRDSL */
+ conn->session_param[ISCSI_PARAM_MAX_XMIT_DLENGTH].val =
+ session_keys[ISCSI_PARAM_MAX_XMIT_DLENGTH].def;
if (!conn->session)
session_create(conn);
memcpy(conn->isid, conn->session->isid, sizeof(conn->isid));
diff --git a/usr/iscsi/iscsid.h b/usr/iscsi/iscsid.h
index a8c8cb1..2b08252 100644
--- a/usr/iscsi/iscsid.h
+++ b/usr/iscsi/iscsid.h
@@ -140,6 +140,7 @@ struct iscsi_connection {
int tid;
struct param session_param[ISCSI_PARAM_MAX];
+ int mxdsl_negotiated;
char *initiator;
uint8_t isid[6];
diff --git a/usr/iscsi/target.c b/usr/iscsi/target.c
index 2653839..53d8164 100644
--- a/usr/iscsi/target.c
+++ b/usr/iscsi/target.c
@@ -265,7 +265,7 @@ int iscsi_target_create(struct target *t)
struct iscsi_target *target;
struct param default_tgt_session_param[] = {
[ISCSI_PARAM_MAX_RECV_DLENGTH] = {0, 8192},
- [ISCSI_PARAM_MAX_XMIT_DLENGTH] = {0, 8192}, /* do not edit */
+ [ISCSI_PARAM_MAX_XMIT_DLENGTH] = {0, 8192},
[ISCSI_PARAM_HDRDGST_EN] = {0, DIGEST_NONE},
[ISCSI_PARAM_DATADGST_EN] = {0, DIGEST_NONE},
[ISCSI_PARAM_INITIAL_R2T_EN] = {0, 1},
--
1.5.2.5
More information about the stgt
mailing list