public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP
@ 2017-05-10 15:33 Jiaxin Wu
  2017-05-11  0:50 ` Fu, Siyuan
  2017-05-11  1:33 ` Ye, Ting
  0 siblings, 2 replies; 3+ messages in thread
From: Jiaxin Wu @ 2017-05-10 15:33 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin

DHCP4 service allows only one of its children to be configured in the active
state. If the DHCP4 D.O.R.A started by IP4 auto configuration and has not
been completed, the Dhcp4 state machine will not be in the right state for
the iSCSI to start a new round D.O.R.A. So, we need to switch it's policy to
static.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
 NetworkPkg/IScsiDxe/IScsiDhcp.c | 61 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c b/NetworkPkg/IScsiDxe/IScsiDhcp.c
index 43ae50b..6587a05 100644
--- a/NetworkPkg/IScsiDxe/IScsiDhcp.c
+++ b/NetworkPkg/IScsiDxe/IScsiDhcp.c
@@ -369,10 +369,54 @@ IScsiParseDhcpAck (
   FreePool (OptionList);
 
   return Status;
 }
 
+/**
+  This function will switch the IP4 configuration policy to Static.
+
+  @param[in]  Ip4Config2          Pointer to the IP4 configuration protocol.
+
+  @retval     EFI_SUCCESS         The policy is already configured to static.
+  @retval     Others              Other error as indicated.
+
+**/
+EFI_STATUS
+IScsiSetIp4Policy (
+  IN EFI_IP4_CONFIG2_PROTOCOL        *Ip4Config2
+  )
+{
+  EFI_IP4_CONFIG2_POLICY          Policy;
+  EFI_STATUS                      Status;
+  UINTN                           DataSize;
+
+  DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);
+  Status = Ip4Config2->GetData (
+                         Ip4Config2,
+                         Ip4Config2DataTypePolicy,
+                         &DataSize,
+                         &Policy
+                         );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  if (Policy != Ip4Config2PolicyStatic) {
+    Policy = Ip4Config2PolicyStatic;
+    Status= Ip4Config2->SetData (
+                          Ip4Config2,
+                          Ip4Config2DataTypePolicy,
+                          sizeof (EFI_IP4_CONFIG2_POLICY),
+                          &Policy
+                          );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    } 
+  }
+
+  return EFI_SUCCESS;
+}
 
 /**
   Parse the DHCP ACK to get the address configuration and DNS information.
 
   @param[in]       Image            The handle of the driver image.
@@ -391,18 +435,20 @@ IScsiDoDhcp (
   IN     EFI_HANDLE                  Controller,
   IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
   )
 {
   EFI_HANDLE                    Dhcp4Handle;
+  EFI_IP4_CONFIG2_PROTOCOL      *Ip4Config2;
   EFI_DHCP4_PROTOCOL            *Dhcp4;
   EFI_STATUS                    Status;
   EFI_DHCP4_PACKET_OPTION       *ParaList;
   EFI_DHCP4_CONFIG_DATA         Dhcp4ConfigData;
   ISCSI_SESSION_CONFIG_NVDATA   *NvData;
   BOOLEAN                       MediaPresent;
 
   Dhcp4Handle = NULL;
+  Ip4Config2  = NULL;
   Dhcp4       = NULL;
   ParaList    = NULL;
 
   //
   // Check media status before doing DHCP.
@@ -412,10 +458,25 @@ IScsiDoDhcp (
   if (!MediaPresent) {
     return EFI_NO_MEDIA;
   }
 
   //
+  // DHCP4 service allows only one of its children to be configured in  
+  // the active state, If the DHCP4 D.O.R.A started by IP4 auto  
+  // configuration and has not been completed, the Dhcp4 state machine 
+  // will not be in the right state for the iSCSI to start a new round D.O.R.A. 
+  // So, we need to switch it's policy to static.
+  //
+  Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2);
+  if (!EFI_ERROR (Status)) {
+    Status = IScsiSetIp4Policy (Ip4Config2);
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+  }
+
+  //
   // Create a DHCP4 child instance and get the protocol.
   //
   Status = NetLibCreateServiceChild (
              Controller,
              Image,
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP
  2017-05-10 15:33 [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP Jiaxin Wu
@ 2017-05-11  0:50 ` Fu, Siyuan
  2017-05-11  1:33 ` Ye, Ting
  1 sibling, 0 replies; 3+ messages in thread
From: Fu, Siyuan @ 2017-05-11  0:50 UTC (permalink / raw)
  To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Ye, Ting

Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>


-----Original Message-----
From: Wu, Jiaxin 
Sent: 2017年5月10日 23:33
To: edk2-devel@lists.01.org
Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
Subject: [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP

DHCP4 service allows only one of its children to be configured in the active state. If the DHCP4 D.O.R.A started by IP4 auto configuration and has not been completed, the Dhcp4 state machine will not be in the right state for the iSCSI to start a new round D.O.R.A. So, we need to switch it's policy to static.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
 NetworkPkg/IScsiDxe/IScsiDhcp.c | 61 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c b/NetworkPkg/IScsiDxe/IScsiDhcp.c index 43ae50b..6587a05 100644
--- a/NetworkPkg/IScsiDxe/IScsiDhcp.c
+++ b/NetworkPkg/IScsiDxe/IScsiDhcp.c
@@ -369,10 +369,54 @@ IScsiParseDhcpAck (
   FreePool (OptionList);
 
   return Status;
 }
 
+/**
+  This function will switch the IP4 configuration policy to Static.
+
+  @param[in]  Ip4Config2          Pointer to the IP4 configuration protocol.
+
+  @retval     EFI_SUCCESS         The policy is already configured to static.
+  @retval     Others              Other error as indicated.
+
+**/
+EFI_STATUS
+IScsiSetIp4Policy (
+  IN EFI_IP4_CONFIG2_PROTOCOL        *Ip4Config2
+  )
+{
+  EFI_IP4_CONFIG2_POLICY          Policy;
+  EFI_STATUS                      Status;
+  UINTN                           DataSize;
+
+  DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);  Status = 
+ Ip4Config2->GetData (
+                         Ip4Config2,
+                         Ip4Config2DataTypePolicy,
+                         &DataSize,
+                         &Policy
+                         );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  if (Policy != Ip4Config2PolicyStatic) {
+    Policy = Ip4Config2PolicyStatic;
+    Status= Ip4Config2->SetData (
+                          Ip4Config2,
+                          Ip4Config2DataTypePolicy,
+                          sizeof (EFI_IP4_CONFIG2_POLICY),
+                          &Policy
+                          );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+  }
+
+  return EFI_SUCCESS;
+}
 
 /**
   Parse the DHCP ACK to get the address configuration and DNS information.
 
   @param[in]       Image            The handle of the driver image.
@@ -391,18 +435,20 @@ IScsiDoDhcp (
   IN     EFI_HANDLE                  Controller,
   IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
   )
 {
   EFI_HANDLE                    Dhcp4Handle;
+  EFI_IP4_CONFIG2_PROTOCOL      *Ip4Config2;
   EFI_DHCP4_PROTOCOL            *Dhcp4;
   EFI_STATUS                    Status;
   EFI_DHCP4_PACKET_OPTION       *ParaList;
   EFI_DHCP4_CONFIG_DATA         Dhcp4ConfigData;
   ISCSI_SESSION_CONFIG_NVDATA   *NvData;
   BOOLEAN                       MediaPresent;
 
   Dhcp4Handle = NULL;
+  Ip4Config2  = NULL;
   Dhcp4       = NULL;
   ParaList    = NULL;
 
   //
   // Check media status before doing DHCP.
@@ -412,10 +458,25 @@ IScsiDoDhcp (
   if (!MediaPresent) {
     return EFI_NO_MEDIA;
   }
 
   //
+  // DHCP4 service allows only one of its children to be configured in  
+ // the active state, If the DHCP4 D.O.R.A started by IP4 auto  // 
+ configuration and has not been completed, the Dhcp4 state machine  // 
+ will not be in the right state for the iSCSI to start a new round D.O.R.A.
+  // So, we need to switch it's policy to static.
+  //
+  Status = gBS->HandleProtocol (Controller, 
+ &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2);  if (!EFI_ERROR (Status)) {
+    Status = IScsiSetIp4Policy (Ip4Config2);
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+  }
+
+  //
   // Create a DHCP4 child instance and get the protocol.
   //
   Status = NetLibCreateServiceChild (
              Controller,
              Image,
--
1.9.5.msysgit.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP
  2017-05-10 15:33 [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP Jiaxin Wu
  2017-05-11  0:50 ` Fu, Siyuan
@ 2017-05-11  1:33 ` Ye, Ting
  1 sibling, 0 replies; 3+ messages in thread
From: Ye, Ting @ 2017-05-11  1:33 UTC (permalink / raw)
  To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Fu, Siyuan

Reviewed-by: Ye Ting <ting.ye@intel.com> 

-----Original Message-----
From: Wu, Jiaxin 
Sent: Wednesday, May 10, 2017 11:33 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
Subject: [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP

DHCP4 service allows only one of its children to be configured in the active state. If the DHCP4 D.O.R.A started by IP4 auto configuration and has not been completed, the Dhcp4 state machine will not be in the right state for the iSCSI to start a new round D.O.R.A. So, we need to switch it's policy to static.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
 NetworkPkg/IScsiDxe/IScsiDhcp.c | 61 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c b/NetworkPkg/IScsiDxe/IScsiDhcp.c index 43ae50b..6587a05 100644
--- a/NetworkPkg/IScsiDxe/IScsiDhcp.c
+++ b/NetworkPkg/IScsiDxe/IScsiDhcp.c
@@ -369,10 +369,54 @@ IScsiParseDhcpAck (
   FreePool (OptionList);
 
   return Status;
 }
 
+/**
+  This function will switch the IP4 configuration policy to Static.
+
+  @param[in]  Ip4Config2          Pointer to the IP4 configuration protocol.
+
+  @retval     EFI_SUCCESS         The policy is already configured to static.
+  @retval     Others              Other error as indicated.
+
+**/
+EFI_STATUS
+IScsiSetIp4Policy (
+  IN EFI_IP4_CONFIG2_PROTOCOL        *Ip4Config2
+  )
+{
+  EFI_IP4_CONFIG2_POLICY          Policy;
+  EFI_STATUS                      Status;
+  UINTN                           DataSize;
+
+  DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);  Status = 
+ Ip4Config2->GetData (
+                         Ip4Config2,
+                         Ip4Config2DataTypePolicy,
+                         &DataSize,
+                         &Policy
+                         );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  if (Policy != Ip4Config2PolicyStatic) {
+    Policy = Ip4Config2PolicyStatic;
+    Status= Ip4Config2->SetData (
+                          Ip4Config2,
+                          Ip4Config2DataTypePolicy,
+                          sizeof (EFI_IP4_CONFIG2_POLICY),
+                          &Policy
+                          );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+  }
+
+  return EFI_SUCCESS;
+}
 
 /**
   Parse the DHCP ACK to get the address configuration and DNS information.
 
   @param[in]       Image            The handle of the driver image.
@@ -391,18 +435,20 @@ IScsiDoDhcp (
   IN     EFI_HANDLE                  Controller,
   IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
   )
 {
   EFI_HANDLE                    Dhcp4Handle;
+  EFI_IP4_CONFIG2_PROTOCOL      *Ip4Config2;
   EFI_DHCP4_PROTOCOL            *Dhcp4;
   EFI_STATUS                    Status;
   EFI_DHCP4_PACKET_OPTION       *ParaList;
   EFI_DHCP4_CONFIG_DATA         Dhcp4ConfigData;
   ISCSI_SESSION_CONFIG_NVDATA   *NvData;
   BOOLEAN                       MediaPresent;
 
   Dhcp4Handle = NULL;
+  Ip4Config2  = NULL;
   Dhcp4       = NULL;
   ParaList    = NULL;
 
   //
   // Check media status before doing DHCP.
@@ -412,10 +458,25 @@ IScsiDoDhcp (
   if (!MediaPresent) {
     return EFI_NO_MEDIA;
   }
 
   //
+  // DHCP4 service allows only one of its children to be configured in  
+ // the active state, If the DHCP4 D.O.R.A started by IP4 auto  // 
+ configuration and has not been completed, the Dhcp4 state machine  // 
+ will not be in the right state for the iSCSI to start a new round D.O.R.A.
+  // So, we need to switch it's policy to static.
+  //
+  Status = gBS->HandleProtocol (Controller, 
+ &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2);  if (!EFI_ERROR (Status)) {
+    Status = IScsiSetIp4Policy (Ip4Config2);
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+  }
+
+  //
   // Create a DHCP4 child instance and get the protocol.
   //
   Status = NetLibCreateServiceChild (
              Controller,
              Image,
--
1.9.5.msysgit.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-11  1:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-10 15:33 [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP Jiaxin Wu
2017-05-11  0:50 ` Fu, Siyuan
2017-05-11  1:33 ` Ye, Ting

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox