There is an issue in this implementation

1. This patch addresses the problem of DHCP being triggered during boot up.
2. But the below piece of code will not let the DHCP DORA get triggered when, 
for instance, running "ifconfig -s eth0 dhcp" in the UEFI Shell:

   if (NewPolicy == Instance->Policy) {
-    if (NewPolicy != Ip4Config2PolicyDhcp || Instance->DhcpSuccess) {
-      return EFI_ABORTED;
-    }
-    
+     return EFI_ABORTED;

The NewPolicy and Instance->Policy are likely the same, so it is likely that 
nothing will get triggered, and the NIC will not have an IP address.

Only if you set a static policy, and later on change to DHCP, things work and 
the NIC can then get a DHCP IP.



Thanks,
--Samer


-----Original Message-----
From: Wu, Jiaxin
Sent: Friday, August 07, 2015 2:28 PM
To: edk2-devel@lists.01.org
Cc: Fu, Siyuan; Ye, Ting
Subject: [Patch] MdeModulePkg: Fix issue about Ip4Dxe implementation for DHCP 
DORA process

DHCP policy is applied as default at boot time on all NICs in the system, which 
results in all NIC ports attempting DHCP and trying to acquire IP addresses 
during boot.
Ip4 driver should only set dhcp as default policy, and not trigger DORA at 
driver binding start(). We should start DORA until one IP child is configured 
to use default address.

Cc: Fu Siyuan <siyuan...@intel.com>
Cc: Ye Ting <ting...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin...@intel.com>
---
 .../Universal/Network/Ip4Dxe/Ip4Config2Impl.c       | 21 +--------------------
 .../Universal/Network/Ip4Dxe/Ip4Config2Impl.h       | 16 ++++++++++++++++
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c     |  7 +++++--
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
index 2da4a51..fcb2bdd 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
@@ -83,26 +83,10 @@ Ip4Config2DestroyDhcp4 (
 
   return Status;
 }
 
 /**
-  Start the DHCP configuration for this IP service instance.
-  It will locates the EFI_IP4_CONFIG2_PROTOCOL, then start the
-  DHCP configuration.
-
-  @param[in]  Instance           The IP4 config2 instance to configure.
-
-  @retval EFI_SUCCESS            The auto configuration is successfull started.
-  @retval Others                 Failed to start auto configuration.
-
-**/
-EFI_STATUS
-Ip4StartAutoConfig (
-  IN IP4_CONFIG2_INSTANCE   *Instance
-  );
-
-/**
   Update the current policy to NewPolicy. During the transition
   period, the default router list
   and address list in all interfaces will be released.
 
   @param[in]  IpSb               The IP4 service binding instance.
@@ -990,14 +974,11 @@ Ip4Config2SetPolicy (
   if (NewPolicy >= Ip4Config2PolicyMax) {
     return EFI_INVALID_PARAMETER;
   }
 
   if (NewPolicy == Instance->Policy) {
-    if (NewPolicy != Ip4Config2PolicyDhcp || Instance->DhcpSuccess) {
-      return EFI_ABORTED;
-    }
-    
+     return EFI_ABORTED;
   } else {
     if (NewPolicy == Ip4Config2PolicyDhcp) {
       //
       // The policy is changed from static to dhcp:
       // Clean the ManualAddress, Gateway and DnsServers, shrink the variable 
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h
index 26e16a2..e74b9ae 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h
@@ -209,10 +209,26 @@ typedef struct {
   UINT8                   Route;
 } IP4_CONFIG2_DHCP4_OPTION;
 #pragma pack()
 
 /**
+  Start the DHCP configuration for this IP service instance.
+  It will locates the EFI_IP4_CONFIG2_PROTOCOL, then start the  DHCP 
+ configuration.
+
+  @param[in]  Instance           The IP4 config2 instance to configure.
+
+  @retval EFI_SUCCESS            The auto configuration is successfull started.
+  @retval Others                 Failed to start auto configuration.
+
+**/
+EFI_STATUS
+Ip4StartAutoConfig (
+  IN IP4_CONFIG2_INSTANCE   *Instance
+  );
+
+/**
   Initialize an IP4_CONFIG2_INSTANCE.
 
   @param[out]    Instance       The buffer of IP4_CONFIG2_INSTANCE to be 
initialized.
 
   @retval EFI_OUT_OF_RESOURCES  Failed to allocate resources to complete the 
operation.
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
index b0f597f..2fb4f4c 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
@@ -676,12 +676,15 @@ Ip4ConfigProtocol (
     //
     // Use the default address. If the default configuration hasn't
     // been started, start it.
     //
     if (IpSb->State == IP4_SERVICE_UNSTARTED) {
-      Status = EFI_NO_MAPPING;
-      goto ON_ERROR;
+      Status = Ip4StartAutoConfig (&IpSb->Ip4Config2Instance);
+
+      if (EFI_ERROR (Status)) {
+        goto ON_ERROR;
+      }
     }
 
     IpIf = IpSb->DefaultInterface;
     NET_GET_REF (IpSb->DefaultInterface);
 
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to