MdeModulePkg: Add old IPv4_DEVICE_PATH support for new IScsiDxe

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.wang@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
[lersek@redhat.com: rewrapped commit message]
Signed-off-by: Laszlo Ersek <lersek@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18057 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
fanwang2
2015-07-26 08:04:04 +00:00
committed by jljusten
parent 42f0586d61
commit 7b0b360633
2 changed files with 23 additions and 9 deletions

View File

@@ -814,15 +814,24 @@ IScsiGetTcpConnDevicePath (
DPathNode->Ipv4.StaticIpAddress =
(BOOLEAN) (!Session->ConfigData.NvData.InitiatorInfoFromDhcp);
IP4_COPY_ADDRESS (
&DPathNode->Ipv4.GatewayIpAddress,
&Session->ConfigData.NvData.Gateway
);
//
// 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.SubnetMask,
&Session->ConfigData.NvData.SubnetMask
);
IP4_COPY_ADDRESS (
&DPathNode->Ipv4.GatewayIpAddress,
&Session->ConfigData.NvData.Gateway
);
IP4_COPY_ADDRESS (
&DPathNode->Ipv4.SubnetMask,
&Session->ConfigData.NvData.SubnetMask
);
}
break;
}