]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Fix a bug in Dhcp4 to prevent unexpected broadcast DHCP packets be queued up in...
authortye <tye@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 21 Oct 2009 09:37:10 +0000 (09:37 +0000)
committertye <tye@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 21 Oct 2009 09:37:10 +0000 (09:37 +0000)
2. Sync HSD #210249 patch: Fix bug in handling certain network errors in EfiDhcp4TransmitReceive() for DHCP4 driver
3. Enhance DhcpCleanLease to clear Netmask as well, so that Dhcp4->GetModeData() could return clean data in Dhcp4Stopped state.

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

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

index 5ccbefd4321373257a73f0a68ee5f0338cbf34e2..1ca0589b900025f454447f80aace89682c353e92 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation.<BR>\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
@@ -310,6 +310,14 @@ Dhcp4DriverBindingStart (
     return Status;\r
   }\r
 \r
+  //\r
+  // Start the receiving\r
+  //\r
+  Status = UdpIoRecvDatagram (DhcpSb->UdpIo, DhcpInput, DhcpSb, 0);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_ERROR;\r
+  }\r
   Status = gBS->SetTimer (DhcpSb->Timer, TimerPeriodic, TICKS_PER_SECOND);\r
 \r
   if (EFI_ERROR (Status)) {\r
index 90031903a45ab60b11bceaf6336cd7f4dbf51775..a4b8fa8137d3860dc19d3abcae531c3cb9c1a84b 100644 (file)
@@ -816,14 +816,6 @@ EfiDhcp4Start (
     goto ON_ERROR;\r
   }\r
 \r
-  //\r
-  // Start/Restart the receiving.\r
-  //\r
-  Status = UdpIoRecvDatagram (DhcpSb->UdpIo, DhcpInput, DhcpSb, 0);\r
-\r
-  if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {\r
-    goto ON_ERROR;\r
-  }\r
 \r
   Instance->CompletionEvent = CompletionEvent;\r
 \r
@@ -1584,8 +1576,19 @@ ON_ERROR:
     // Keep polling until timeout if no error happens and the CompletionEvent\r
     // is NULL.\r
     //\r
-    while (Instance->Timeout != 0) {\r
-      Instance->UdpIo->Udp->Poll (Instance->UdpIo->Udp);\r
+    while (TRUE) {\r
+      OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+      //\r
+      // Raise TPL to protect the UDPIO in instance, in case that DhcpOnTimerTick\r
+      // free it when timeout.\r
+      //\r
+      if (Instance->Timeout > 0) {\r
+        Instance->UdpIo->Udp->Poll (Instance->UdpIo->Udp);\r
+        gBS->RestoreTPL (OldTpl);\r
+      } else {\r
+        gBS->RestoreTPL (OldTpl);\r
+        break;\r
+      }\r
     }\r
   }\r
 \r
index 1b3afa3dd89df7cac6feacdfeb950a41cdc160fc..be8ceb045086f737d47466fa154aad463ee2986c 100644 (file)
@@ -443,6 +443,7 @@ DhcpCleanLease (
   DhcpSb->DhcpState   = Dhcp4Init;\r
   DhcpSb->Xid         = DhcpSb->Xid + 1;\r
   DhcpSb->ClientAddr  = 0;\r
+  DhcpSb->Netmask     = 0;\r
   DhcpSb->ServerAddr  = 0;\r
 \r
   if (DhcpSb->LastOffer != NULL) {\r
@@ -1066,6 +1067,7 @@ DhcpInput (
 \r
   if (EFI_ERROR (Status)) {\r
     NetbufFree (UdpPacket);\r
+    UdpIoRecvDatagram (DhcpSb->UdpIo, DhcpInput, DhcpSb, 0);\r
     DhcpEndSession (DhcpSb, Status);\r
     return ;\r
   }\r