diff options
author | Ye Ting <ting.ye@intel.com> | 2015-02-04 08:53:56 +0000 |
---|---|---|
committer | tye1 <tye1@Edk2> | 2015-02-04 08:53:56 +0000 |
commit | 57f2e114787a640cf3dead0117bf06584ec2b439 (patch) | |
tree | f2a4a2fe71e27f1906ad12a66472eb28fcad5e36 | |
parent | 27c93c06c0a81d7b48cac70f9eeff133858b696c (diff) | |
download | edk2-platforms-57f2e114787a640cf3dead0117bf06584ec2b439.tar.xz |
Enhance the parameter check to avoid potential issue in negotiation.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Tian Feng <feng.tian@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16750 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c index b2bf9466c1..1ac79e7ca1 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c @@ -1,7 +1,7 @@ /** @file
The implementation of iSCSI protocol based on RFC3720.
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1225,12 +1225,14 @@ IScsiCheckOpParams ( //
// InitialR2T, result function is OR.
//
- Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);
- if (Value == NULL) {
- goto ON_ERROR;
- }
+ if (!Session->InitialR2T) {
+ Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);
+ if (Value == NULL) {
+ goto ON_ERROR;
+ }
- Session->InitialR2T = (BOOLEAN) (Session->InitialR2T || (AsciiStrCmp (Value, "Yes") == 0));
+ Session->InitialR2T = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);
+ }
//
// ImmediateData, result function is AND.
@@ -1240,7 +1242,7 @@ IScsiCheckOpParams ( goto ON_ERROR;
}
- Session->ImmediateData = (BOOLEAN) (Session->ImmediateData && (AsciiStrCmp (Value, "Yes") == 0));
+ Session->ImmediateData = (BOOLEAN) (Session->ImmediateData && (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0));
//
// MaxRecvDataSegmentLength is declarative.
@@ -1265,13 +1267,15 @@ IScsiCheckOpParams ( // ImmediateData=No.
// This Key/Value is negotiation type.
//
- Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_FIRST_BURST_LENGTH);
- if (Value == NULL) {
- goto ON_ERROR;
- }
+ if (!(Session->InitialR2T && !Session->ImmediateData)) {
+ Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_FIRST_BURST_LENGTH);
+ if (Value == NULL) {
+ goto ON_ERROR;
+ }
- NumericValue = AsciiStrDecimalToUintn (Value);
- Session->FirstBurstLength = (UINT32) MIN (Session->FirstBurstLength, NumericValue);
+ NumericValue = AsciiStrDecimalToUintn (Value);
+ Session->FirstBurstLength = (UINT32) MIN (Session->FirstBurstLength, NumericValue);
+ }
//
// MaxConnections, result function is Minimum.
@@ -1360,7 +1364,7 @@ IScsiCheckOpParams ( Session->MaxOutstandingR2T = (UINT16) MIN (Session->MaxOutstandingR2T, NumericValue);
//
- // Remove declarative key-value paris if any.
+ // Remove declarative key-value pairs, if any.
//
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_SESSION_TYPE);
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ALIAS);
@@ -1368,9 +1372,17 @@ IScsiCheckOpParams ( //
// Remove the key-value that may not needed for result function is OR.
//
+ IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_PDU_IN_ORDER);
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_SEQUENCE_IN_ORDER);
+ //
+ // Remove irrelevant parameter, if any.
+ //
+ if (Session->InitialR2T && !Session->ImmediateData) {
+ IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_FIRST_BURST_LENGTH);
+ }
+
if (IsListEmpty (KeyValueList)) {
//
// Succeed if no more keys in the list.
|