From: tye Date: Wed, 21 Oct 2009 09:37:10 +0000 (+0000) Subject: 1. Fix a bug in Dhcp4 to prevent unexpected broadcast DHCP packets be queued up in... X-Git-Tag: edk2-stable201903~16965 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=c5bcc2e2abf1190632aad8b1979c84ffc1c17d98 1. Fix a bug in Dhcp4 to prevent unexpected broadcast DHCP packets be queued up in the system: these packets will never be freed and will cumulate as time goes on, and then it will cause the system becomes very slow. This issue is reported by HP. 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 --- diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c index 5ccbefd432..1ca0589b90 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2006 - 2008, Intel Corporation.
+Copyright (c) 2006 - 2009, Intel Corporation.
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -310,6 +310,14 @@ Dhcp4DriverBindingStart ( return Status; } + // + // Start the receiving + // + Status = UdpIoRecvDatagram (DhcpSb->UdpIo, DhcpInput, DhcpSb, 0); + + if (EFI_ERROR (Status)) { + goto ON_ERROR; + } Status = gBS->SetTimer (DhcpSb->Timer, TimerPeriodic, TICKS_PER_SECOND); if (EFI_ERROR (Status)) { diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c index 90031903a4..a4b8fa8137 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c @@ -816,14 +816,6 @@ EfiDhcp4Start ( goto ON_ERROR; } - // - // Start/Restart the receiving. - // - Status = UdpIoRecvDatagram (DhcpSb->UdpIo, DhcpInput, DhcpSb, 0); - - if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) { - goto ON_ERROR; - } Instance->CompletionEvent = CompletionEvent; @@ -1584,8 +1576,19 @@ ON_ERROR: // Keep polling until timeout if no error happens and the CompletionEvent // is NULL. // - while (Instance->Timeout != 0) { - Instance->UdpIo->Udp->Poll (Instance->UdpIo->Udp); + while (TRUE) { + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + // + // Raise TPL to protect the UDPIO in instance, in case that DhcpOnTimerTick + // free it when timeout. + // + if (Instance->Timeout > 0) { + Instance->UdpIo->Udp->Poll (Instance->UdpIo->Udp); + gBS->RestoreTPL (OldTpl); + } else { + gBS->RestoreTPL (OldTpl); + break; + } } } diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c index 1b3afa3dd8..be8ceb0450 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c @@ -443,6 +443,7 @@ DhcpCleanLease ( DhcpSb->DhcpState = Dhcp4Init; DhcpSb->Xid = DhcpSb->Xid + 1; DhcpSb->ClientAddr = 0; + DhcpSb->Netmask = 0; DhcpSb->ServerAddr = 0; if (DhcpSb->LastOffer != NULL) { @@ -1066,6 +1067,7 @@ DhcpInput ( if (EFI_ERROR (Status)) { NetbufFree (UdpPacket); + UdpIoRecvDatagram (DhcpSb->UdpIo, DhcpInput, DhcpSb, 0); DhcpEndSession (DhcpSb, Status); return ; }