]> git.proxmox.com Git - mirror_edk2.git/commitdiff
[Description]:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 24 Jun 2008 08:36:11 +0000 (08:36 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 24 Jun 2008 08:36:11 +0000 (08:36 +0000)
 Misuse of retransmisson of DHCPDISCOVER in Dhcp4 drive, the root cause is that DHCP doesn't retransmit discover message when timeout.
[Solution]:
 Correct the mechanism for discover message.
[Impaction]:
 Dhcp4Dxe.
[Reference Info]:
 EDK tracker 1150 - Misuse of retransmisson of DHCPDISCOVER in Dhcp4 drive.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5366 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c

index d7e41134af4b959c22bbf5c2f306569c163b6cf1..bf401bda0d0cfe66a91a6cff16fc037adfea4f78 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006, Intel Corporation\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
 All rights reserved. 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
@@ -136,8 +136,6 @@ struct _DHCP_SERVICE {
   UINT32                        PacketToLive; // Retransmission timer for our packets\r
   INTN                          CurRetry;\r
   INTN                          MaxRetries;\r
-\r
-  UINT32                        WaitOffer;    // Time to collect the offers\r
   UINT32                        LeaseLife;\r
 };\r
 \r
index 9cead840bd1824da9a87039a0696bd28506c0108..415ffa8ab7838e9d6dd9270878060e7c38f68fca 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
 All rights reserved. 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
@@ -272,9 +272,7 @@ DhcpSetTransmitTimer (
 \r
   DhcpSb->PacketToLive = Times[DhcpSb->CurRetry];\r
 \r
-  if (DhcpSb->DhcpState == Dhcp4Selecting) {\r
-    DhcpSb->WaitOffer = DhcpSb->PacketToLive;\r
-  }\r
+  return;\r
 }\r
 \r
 /**\r
@@ -497,7 +495,6 @@ DhcpCleanLease (
   DhcpSb->PacketToLive  = 0;\r
   DhcpSb->CurRetry      = 0;\r
   DhcpSb->MaxRetries    = 0;\r
-  DhcpSb->WaitOffer     = 0;\r
   DhcpSb->LeaseLife     = 0;\r
 }\r
 \r
@@ -525,11 +522,6 @@ DhcpChooseOffer (
 \r
   ASSERT (DhcpSb->LastOffer != NULL);\r
 \r
-  //\r
-  // Stop waiting more offers\r
-  //\r
-  DhcpSb->WaitOffer = 0;\r
-\r
   //\r
   // User will cache previous offers if he wants to select\r
   // from multiple offers. If user provides an invalid packet,\r
@@ -1501,30 +1493,27 @@ DhcpOnTimerTick (
 \r
   DhcpSb   = (DHCP_SERVICE *) Context;\r
   Instance = DhcpSb->ActiveChild;\r
-\r
+  \r
   //\r
-  // Check the time to wait offer\r
+  // Check the retransmit timer\r
   //\r
-  if ((DhcpSb->WaitOffer > 0) && (--DhcpSb->WaitOffer == 0)) {\r
+  if ((DhcpSb->PacketToLive > 0) && (--DhcpSb->PacketToLive == 0)) {\r
+\r
     //\r
-    // OK, offer collection finished, select a offer\r
+    // Select offer at each timeout if any offer received.\r
     //\r
-    ASSERT (DhcpSb->DhcpState == Dhcp4Selecting);\r
+    if (DhcpSb->DhcpState == Dhcp4Selecting && DhcpSb->LastOffer != NULL) {\r
 \r
-    if (DhcpSb->LastOffer == NULL) {\r
-      goto END_SESSION;\r
-    }\r
+      Status = DhcpChooseOffer (DhcpSb);\r
 \r
-    if (EFI_ERROR (DhcpChooseOffer (DhcpSb))) {\r
-      goto END_SESSION;\r
+      if (EFI_ERROR(Status)) {\r
+        FreePool (DhcpSb->LastOffer);\r
+        DhcpSb->LastOffer = NULL;\r
+      } else {\r
+        goto ON_EXIT;\r
+      }\r
     }\r
-  }\r
-\r
-  //\r
-  // Check the retransmit timer\r
-  //\r
-  if ((DhcpSb->PacketToLive > 0) && (--DhcpSb->PacketToLive == 0)) {\r
-\r
+    \r
     if (++DhcpSb->CurRetry < DhcpSb->MaxRetries) {\r
       //\r
       // Still has another try\r
@@ -1532,10 +1521,7 @@ DhcpOnTimerTick (
       DhcpRetransmit (DhcpSb);\r
       DhcpSetTransmitTimer (DhcpSb);\r
 \r
-    } else {\r
-      if (!DHCP_CONNECTED (DhcpSb->DhcpState)) {\r
-        goto END_SESSION;\r
-      }\r
+    } else if (DHCP_CONNECTED (DhcpSb->DhcpState)) {\r
 \r
       //\r
       // Retransmission failed, if the DHCP request is initiated by\r
@@ -1562,9 +1548,11 @@ DhcpOnTimerTick (
         DhcpSb->IoStatus = EFI_TIMEOUT;\r
         DhcpNotifyUser (DhcpSb, DHCP_NOTIFY_RENEWREBIND);\r
       }\r
+    } else {\r
+      goto END_SESSION;\r
     }\r
   }\r
-\r
+  \r
   //\r
   // If an address has been acquired, check whether need to\r
   // refresh or whether it has expired.\r
@@ -1628,9 +1616,7 @@ DhcpOnTimerTick (
     }\r
   }\r
 \r
-  //\r
-  //\r
-  //\r
+ON_EXIT:\r
   if ((Instance != NULL) && (Instance->Token != NULL)) {\r
     Instance->Timeout--;\r
     if (Instance->Timeout == 0) {\r