public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Fu, Siyuan" <siyuan.fu@intel.com>
To: "Wu, Jiaxin" <jiaxin.wu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Ye, Ting" <ting.ye@intel.com>
Subject: Re: [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP
Date: Thu, 11 May 2017 00:50:36 +0000	[thread overview]
Message-ID: <B1FF2E9001CE9041BD10B825821D5BC58B313D3E@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <1494430381-8064-1-git-send-email-jiaxin.wu@intel.com>

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


  reply	other threads:[~2017-05-11  0:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2017-05-11  1:33 ` Ye, Ting

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B1FF2E9001CE9041BD10B825821D5BC58B313D3E@SHSMSX103.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox