Discussion:
[edk2] [Patch v3] MdeModulePkg: Add old IPv4_DEVICE_PATH support for new IScsiDxe
Wang Fan
1970-01-01 00:00:00 UTC
Permalink
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 <***@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
Ye, Ting
2015-07-22 02:20:40 UTC
Permalink
Reviewed-by: Ye Ting <***@intel.com>


-----Original Message-----
From: Wang, Fan
Sent: Wednesday, July 22, 2015 8:58 AM
To: Ye, Ting; Fu, Siyuan; Wu, Jiaxin; edk2-***@lists.sourceforge.net; edk2-***@lists.01.org
Cc: Tian, Hot; Ni, Ruiyu
Subject: [Patch v3] MdeModulePkg: Add old IPv4_DEVICE_PATH support for new IScsiDxe

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 <***@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
Laszlo Ersek
2015-07-23 17:21:33 UTC
Permalink
Post by Wang Fan
* 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
---
.../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 @@
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 @@
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;
Until the SVN outage at sourceforge.net gets resolved, we plan to commit
patches that are ready for merging to the "master" branch of the git
repository at <https://github.com/tianocore/edk2-svn-offline.git>.
Please see the announcement:

http://thread.gmane.org/gmane.comp.bios.edk2.devel/227

This particular patch (or series) appears ready for merging, therefore
it is being picked up:

http://thread.gmane.org/gmane.comp.bios.edk2.devel/227/focus=251

Further development should be based on edk2-svn-offline/master, until
the SVN outage is fixed. At that point the accumulated patches will be
mass-committed from edk2-svn-offline/master to SVN.

Thanks
Laszlo


------------------------------------------------------------------------------
Loading...