On 08/25/2014 12:27 PM, Wyllys Ingersoll wrote: > in iscsi_copy_operational_params, the conn->max_recv_dlength is set to > _padding (conn_conf->MaxRecvDataSegmentLength); > > initiator_common.c:153 :: conn->max_recv_dlength = > __padding(conn_conf->MaxRecvDataSegmentLength); > > This (_padding) rounds up the value. If the configured > MaxRecvDataSegmentLength is set to the actual maximum (2^24 -1 : > 16777215), the _padding function changes it to 16777216, causing the > comparison to fail since it is above the maximum and it resets the > value to the default minimum (262144). This is probably not the > intended result. > > The actual maximum is really 16777212 since 16777212 & 0x03 == 0, > which will cause it to pass thru the _padding function with no change. > > The _padding issue probably affects other parameters as well, thats > the one where I first noticed the problem. >
The attached patch should fix this. It just rounds down instead of rounding up. -- 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 open-iscsi+unsubscr...@googlegroups.com. To post to this group, send email to open-iscsi@googlegroups.com. Visit this group at http://groups.google.com/group/open-iscsi. For more options, visit https://groups.google.com/d/optout.
diff --git a/usr/initiator_common.c b/usr/initiator_common.c index 8ff993d..6562698 100644 --- a/usr/initiator_common.c +++ b/usr/initiator_common.c @@ -51,21 +51,10 @@ struct iscsi_session *session_find_by_sid(uint32_t sid) return NULL; } -/* - * calculate parameter's padding - */ static unsigned int -__padding(unsigned int param) +round_down_on_pad_bound(unsigned int param) { - int pad; - - pad = param & 3; - if (pad) { - pad = 4 - pad; - log_debug(1, "parameter's value %d padded to %d bytes\n", - param, param + pad); - } - return param + pad; + return param & ~(ISCSI_PAD_LEN - 1); } int iscsi_setup_authentication(struct iscsi_session *session, @@ -151,7 +140,7 @@ iscsi_copy_operational_params(struct iscsi_conn *conn, conn->datadgst_en = conn_conf->DataDigest; conn->max_recv_dlength = - __padding(conn_conf->MaxRecvDataSegmentLength); + round_down_on_pad_bound(conn_conf->MaxRecvDataSegmentLength); if (conn->max_recv_dlength < ISCSI_MIN_MAX_RECV_SEG_LEN || conn->max_recv_dlength > ISCSI_MAX_MAX_RECV_SEG_LEN) { log_error("Invalid iscsi.MaxRecvDataSegmentLength. Must be " @@ -166,7 +155,7 @@ iscsi_copy_operational_params(struct iscsi_conn *conn, /* zero indicates to use the target's value */ conn->max_xmit_dlength = - __padding(conn_conf->MaxXmitDataSegmentLength); + round_down_on_pad_bound(conn_conf->MaxXmitDataSegmentLength); if (conn->max_xmit_dlength == 0) conn->max_xmit_dlength = ISCSI_DEF_MAX_RECV_SEG_LEN; if (conn->max_xmit_dlength < ISCSI_MIN_MAX_RECV_SEG_LEN || @@ -184,7 +173,8 @@ iscsi_copy_operational_params(struct iscsi_conn *conn, /* session's operational parameters */ session->initial_r2t_en = session_conf->InitialR2T; session->imm_data_en = session_conf->ImmediateData; - session->first_burst = __padding(session_conf->FirstBurstLength); + session->first_burst = + round_down_on_pad_bound(session_conf->FirstBurstLength); /* * some targets like netapp fail the login if sent bad first_burst * and max_burst lens, even when immediate data=no and @@ -202,7 +192,8 @@ iscsi_copy_operational_params(struct iscsi_conn *conn, session->first_burst = DEF_INI_FIRST_BURST_LEN; } - session->max_burst = __padding(session_conf->MaxBurstLength); + session->max_burst = + round_down_on_pad_bound(session_conf->MaxBurstLength); if (session->max_burst < ISCSI_MIN_MAX_BURST_LEN || session->max_burst > ISCSI_MAX_MAX_BURST_LEN) { log_error("Invalid iscsi.MaxBurstLength of %u. Must be "