v3: * Update the macro of Ip4 device path node length. GatewayIpAddress and SubnetMask do not exist in old IPv4_DEVICE_PATH, this will lead new IScsiDxe to error if IPv4_DEVICE_PATH in system is not updated. Following UEFI2.5 spec of IPv4_DEVICE_PATH do a check before accessing fields only defined in new version, add a judgement here to make old IPv4_DEVICE_PATH and new IScsiDxe can cowork.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: fanwang2 <fan.w...@intel.com> --- .../Universal/Network/IScsiDxe/IScsiMisc.c | 27 ++++++++++++++-------- .../Universal/Network/IScsiDxe/IScsiMisc.h | 7 +++++- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c index 61c407e..621fbc0 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c @@ -1,9 +1,9 @@ /** @file Miscellaneous routines for iSCSI driver. -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 http://opensource.org/licenses/bsd-license.php @@ -812,19 +812,28 @@ IScsiGetTcpConnDevicePath ( DPathNode->Ipv4.LocalPort = 0; DPathNode->Ipv4.StaticIpAddress = (BOOLEAN) (!Session->ConfigData.NvData.InitiatorInfoFromDhcp); - IP4_COPY_ADDRESS ( - &DPathNode->Ipv4.GatewayIpAddress, - &Session->ConfigData.NvData.Gateway - ); - - IP4_COPY_ADDRESS ( - &DPathNode->Ipv4.SubnetMask, - &Session->ConfigData.NvData.SubnetMask - ); + // + // Add a judgement here to support previous versions of IPv4_DEVICE_PATH. + // In previous versions of IPv4_DEVICE_PATH, GatewayIpAddress and SubnetMask + // do not exist. + // In new version of IPv4_DEVICE_PATH, structcure length is 27. + // + if (DevicePathNodeLength (&DPathNode->Ipv4) == IPv4_NODE_LEN_NEW_VERSIONS) { + + IP4_COPY_ADDRESS ( + &DPathNode->Ipv4.GatewayIpAddress, + &Session->ConfigData.NvData.Gateway + ); + + IP4_COPY_ADDRESS ( + &DPathNode->Ipv4.SubnetMask, + &Session->ConfigData.NvData.SubnetMask + ); + } break; } DPathNode = (EFI_DEV_PATH *) NextDevicePathNode (&DPathNode->DevPath); diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h index 052a90f..0bb7da0 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h @@ -1,9 +1,9 @@ /** @file Miscellaneous definitions for iSCSI driver. -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 http://opensource.org/licenses/bsd-license.php @@ -17,10 +17,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Library/BaseLib.h> typedef struct _ISCSI_SESSION_CONFIG_DATA ISCSI_SESSION_CONFIG_DATA; +/// +/// IPv4 Device Path Node Length +/// +#define IPv4_NODE_LEN_NEW_VERSIONS 27 + #pragma pack(1) typedef struct { BOOLEAN Enabled; BOOLEAN InitiatorInfoFromDhcp; -- 1.9.5.msysgit.1 ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel