Negotiate InitialR2T during login. Default to offer No, but update

and accept what Target responds.

Store the result of the negotiated setting in the iscsi context
so we can use it later to determine how to send solicited/unsolicited
data.
This commit is contained in:
Ronnie Sahlberg
2011-01-02 12:50:00 +11:00
parent 190ea92810
commit 32228a4509
3 changed files with 23 additions and 3 deletions

View File

@@ -40,6 +40,11 @@ struct iscsi_in_pdu {
void iscsi_free_iscsi_in_pdu(struct iscsi_in_pdu *in);
void iscsi_free_iscsi_inqueue(struct iscsi_in_pdu *inqueue);
enum iscsi_initial_r2t {
ISCSI_INITIAL_R2T_NO = 0,
ISCSI_INITIAL_R2T_YES = 1
};
struct iscsi_context {
const char *initiator_name;
const char *target_name;
@@ -86,6 +91,8 @@ struct iscsi_context {
uint32_t max_burst_length;
uint32_t first_burst_length;
uint32_t max_recv_data_segment_length;
enum iscsi_initial_r2t want_initial_r2t;
enum iscsi_initial_r2t use_initial_r2t;
};
#define ISCSI_PDU_IMMEDIATE 0x40

View File

@@ -60,9 +60,11 @@ iscsi_create_context(const char *initiator_name)
iscsi->next_phase = ISCSI_PDU_LOGIN_NSG_OPNEG;
iscsi->secneg_phase = ISCSI_LOGIN_SECNEG_PHASE_OFFER_CHAP;
iscsi->max_burst_length = 262144;
iscsi->first_burst_length = 262144;
iscsi->max_burst_length = 262144;
iscsi->first_burst_length = 262144;
iscsi->max_recv_data_segment_length = 262144;
iscsi->want_initial_r2t = ISCSI_INITIAL_R2T_NO;
iscsi->use_initial_r2t = ISCSI_INITIAL_R2T_NO;
return iscsi;
}

View File

@@ -195,12 +195,15 @@ iscsi_login_add_initialr2t(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
return 0;
}
str = (char *)"InitialR2T=Yes";
asprintf(&str, "InitialR2T=%s", iscsi->want_initial_r2t == ISCSI_INITIAL_R2T_NO ?
"No" : "Yes");
if (iscsi_pdu_add_data(iscsi, pdu, (unsigned char *)str, strlen(str)+1)
!= 0) {
iscsi_set_error(iscsi, "Out-of-memory: pdu add data failed.");
free(str);
return -1;
}
free(str);
return 0;
}
@@ -931,6 +934,14 @@ iscsi_process_login_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
iscsi->first_burst_length = strtol((char *)ptr + 17, NULL, 10);
}
if (!strncmp((char *)ptr, "InitialR2T=", 11)) {
if (!strcmp((char *)ptr + 11, "No")) {
iscsi->use_initial_r2t = ISCSI_INITIAL_R2T_NO;
} else {
iscsi->use_initial_r2t = ISCSI_INITIAL_R2T_YES;
}
}
if (!strncmp((char *)ptr, "MaxBurstLength=", 15)) {
iscsi->max_burst_length = strtol((char *)ptr + 15, NULL, 10);
}