Negotiate ImmediateData during login and store the result in iscsi->
We will use this later to decide when we should send unsolicited imemdiate data to the target. Currently we always send unsolicited immediate data but targets configured to not allow immediate data may refuce this and turn an error.
This commit is contained in:
@@ -65,6 +65,8 @@ iscsi_create_context(const char *initiator_name)
|
||||
iscsi->max_recv_data_segment_length = 262144;
|
||||
iscsi->want_initial_r2t = ISCSI_INITIAL_R2T_NO;
|
||||
iscsi->use_initial_r2t = ISCSI_INITIAL_R2T_NO;
|
||||
iscsi->want_immediate_data = ISCSI_IMMEDIATE_DATA_YES;
|
||||
iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_YES;
|
||||
|
||||
return iscsi;
|
||||
}
|
||||
|
||||
13
lib/login.c
13
lib/login.c
@@ -218,12 +218,15 @@ iscsi_login_add_immediatedata(struct iscsi_context *iscsi, struct iscsi_pdu *pdu
|
||||
return 0;
|
||||
}
|
||||
|
||||
str = (char *)"ImmediateData=Yes";
|
||||
asprintf(&str, "ImmediateData=%s", iscsi->want_immediate_data == ISCSI_IMMEDIATE_DATA_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;
|
||||
}
|
||||
@@ -942,6 +945,14 @@ iscsi_process_login_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
||||
}
|
||||
}
|
||||
|
||||
if (!strncmp((char *)ptr, "ImmediateData=", 14)) {
|
||||
if (!strcmp((char *)ptr + 14, "No")) {
|
||||
iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
|
||||
} else {
|
||||
iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (!strncmp((char *)ptr, "MaxBurstLength=", 15)) {
|
||||
iscsi->max_burst_length = strtol((char *)ptr + 15, NULL, 10);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user