]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Add old IPv4_DEVICE_PATH support for new IScsiDxe
authorfanwang2 <fan.wang@intel.com>
Sun, 26 Jul 2015 08:04:04 +0000 (08:04 +0000)
committerjljusten <jljusten@Edk2>
Sun, 26 Jul 2015 08:04:04 +0000 (08:04 +0000)
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

MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h

index 61c407e6fff780d21dc2b23791635a6e20f3892e..621fbc00e4a09cbe172d3fadec2714fe0e646d48 100644 (file)
@@ -814,15 +814,24 @@ IScsiGetTcpConnDevicePath (
       DPathNode->Ipv4.StaticIpAddress = \r
         (BOOLEAN) (!Session->ConfigData.NvData.InitiatorInfoFromDhcp);\r
 \r
-      IP4_COPY_ADDRESS (\r
-        &DPathNode->Ipv4.GatewayIpAddress,\r
-        &Session->ConfigData.NvData.Gateway\r
-        );\r
-\r
-      IP4_COPY_ADDRESS (\r
-        &DPathNode->Ipv4.SubnetMask,\r
-        &Session->ConfigData.NvData.SubnetMask\r
-        );\r
+      //\r
+      //  Add a judgement here to support previous versions of IPv4_DEVICE_PATH.\r
+      //  In previous versions of IPv4_DEVICE_PATH, GatewayIpAddress and SubnetMask\r
+      //  do not exist.\r
+      //  In new version of IPv4_DEVICE_PATH, structcure length is 27.\r
+      //\r
+      if (DevicePathNodeLength (&DPathNode->Ipv4) == IPv4_NODE_LEN_NEW_VERSIONS) {  \r
+\r
+        IP4_COPY_ADDRESS (\r
+          &DPathNode->Ipv4.GatewayIpAddress,\r
+          &Session->ConfigData.NvData.Gateway\r
+          );\r
+\r
+        IP4_COPY_ADDRESS (\r
+          &DPathNode->Ipv4.SubnetMask,\r
+          &Session->ConfigData.NvData.SubnetMask\r
+          );\r
+      }\r
 \r
       break;\r
     }\r
index 052a90f8d493d125b188b5a7ae47b55474e2bc48..0bb7da070dd2ae71a7eff9b502ed2fa86f61cb3d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Miscellaneous definitions for iSCSI driver.\r
 \r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -19,6 +19,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 typedef struct _ISCSI_SESSION_CONFIG_DATA ISCSI_SESSION_CONFIG_DATA;\r
 \r
+///\r
+/// IPv4 Device Path Node Length\r
+///\r
+#define IPv4_NODE_LEN_NEW_VERSIONS    27\r
+\r
 #pragma pack(1)\r
 typedef struct {\r
   BOOLEAN           Enabled;\r