]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Sync Bug:PXE Boot issue- UefiPxeBc driver currently does not follow PXE Spec
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 19 Sep 2008 07:12:23 +0000 (07:12 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 19 Sep 2008 07:12:23 +0000 (07:12 +0000)
[Root Cause Analysis]
The PXE offer selection in the PXE driver is splitted into two passes and the two passes are required to follow the same flow. However, in current code, there is some difference between the two.
[Solution]
make the second offer selection pass exactly match the first one.

2. Fixed one bug when allocating pool for UDP transmit packet.

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

MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h

index c70390ab2e72c9375c78c5b829e84df0e7c7bbd4..eb91307944c7e6f9d7cb041db9368e7585325943 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2007, Intel Corporation\r
+Copyright (c) 2007 - 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
@@ -401,72 +401,84 @@ PxeBcCheckSelectedOffer (
     if (!PxeBcTryBinl (Private, Private->SelectedOffer - 1)) {\r
       Status = EFI_NO_RESPONSE;\r
     }\r
-  } else if ((SelectedOffer->OfferType == DHCP4_PACKET_TYPE_DHCP_ONLY) &&\r
-           (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL)) {\r
+  } else if (SelectedOffer->OfferType == DHCP4_PACKET_TYPE_DHCP_ONLY) {\r
     //\r
-    // The selected offer to finish the D.O.R.A. is a DHCP only offer and\r
-    // bootfile name is not provided in this offer, we need try proxy offers\r
-    // to get the bootfile name or the discovery info\r
+    // The selected offer to finish the D.O.R.A. is a DHCP only offer, we need \r
+    // try proxy offers if there are some, othewise the bootfile name must be \r
+    // set in this DHCP only offer.\r
     //\r
-    ProxyOfferIndex = Private->NumOffers;\r
-\r
-    if (Private->SortOffers) {\r
+    if (Private->GotProxyOffer) {\r
       //\r
-      // Choose proxy offer from the type we stored during DHCP offer selection\r
+      // Get rid of the compiler warning.\r
       //\r
-      ASSERT (Private->ProxyIndex[Private->ProxyOfferType] > 0);\r
-\r
-      if (Private->ProxyOfferType == DHCP4_PACKET_TYPE_BINL) {\r
+      ProxyOfferIndex = 0;\r
+      if (Private->SortOffers) {\r
         //\r
-        // We buffer all received BINL proxy offers, try them all one by one\r
+        // The offers are sorted before selecting, the proxy offer type must be\r
+        // already determined.\r
         //\r
-        if (!PxeBcTryBinlProxy (Private, &ProxyOfferIndex)) {\r
-          Status = EFI_NO_RESPONSE;\r
+        ASSERT (Private->ProxyIndex[Private->ProxyOfferType] > 0);\r
+\r
+        if (Private->ProxyOfferType == DHCP4_PACKET_TYPE_BINL) {\r
+          //\r
+          // We buffer all received BINL proxy offers, try them all one by one\r
+          //\r
+          if (!PxeBcTryBinlProxy (Private, &ProxyOfferIndex)) {\r
+            Status = EFI_NO_RESPONSE;\r
+          }\r
+        } else {\r
+          //\r
+          // For other types, only one proxy offer is buffered.\r
+          //\r
+          ProxyOfferIndex = Private->ProxyIndex[Private->ProxyOfferType] - 1;\r
         }\r
       } else {\r
         //\r
-        // For other types, only one proxy offer is buffered.\r
+        // The proxy offer type is not determined, choose proxy offer in the \r
+        // received order.\r
         //\r
-        ProxyOfferIndex = Private->ProxyIndex[Private->ProxyOfferType] - 1;\r
-      }\r
-    } else {\r
-      //\r
-      // Choose proxy offer in the received order.\r
-      //\r
-      Status = EFI_NO_RESPONSE;\r
+        Status = EFI_NO_RESPONSE;\r
 \r
-      for (Index = 0; Index < Private->NumOffers; Index++) {\r
+        for (Index = 0; Index < Private->NumOffers; Index++) {\r
 \r
-        Offer = &Private->Dhcp4Offers[Index].Packet.Offer;\r
-        if (!IS_PROXY_DHCP_OFFER (Offer)) {\r
-          //\r
-          // Skip non proxy dhcp offers.\r
-          //\r
-          continue;\r
-        }\r
-\r
-        if (Private->Dhcp4Offers[Index].OfferType == DHCP4_PACKET_TYPE_BINL) {\r
-          //\r
-          // Try BINL\r
-          //\r
-          if (!PxeBcTryBinl (Private, Index)) {\r
+          Offer = &Private->Dhcp4Offers[Index].Packet.Offer;\r
+          if (!IS_PROXY_DHCP_OFFER (Offer)) {\r
             //\r
-            // Failed, skip to the next offer\r
+            // Skip non proxy dhcp offers.\r
             //\r
             continue;\r
           }\r
-        }\r
 \r
-        Status = EFI_SUCCESS;\r
-        break;\r
+          if (Private->Dhcp4Offers[Index].OfferType == DHCP4_PACKET_TYPE_BINL) {\r
+            //\r
+            // Try BINL\r
+            //\r
+            if (!PxeBcTryBinl (Private, Index)) {\r
+              //\r
+              // Failed, skip to the next offer\r
+              //\r
+              continue;\r
+            }\r
+          }\r
+\r
+          Private->ProxyOfferType = Private->Dhcp4Offers[Index].OfferType;\r
+          ProxyOfferIndex         = Index;\r
+          Status                  = EFI_SUCCESS;\r
+          break;\r
+        }\r
       }\r
-    }\r
 \r
-    if (!EFI_ERROR (Status) && (Private->ProxyOfferType != DHCP4_PACKET_TYPE_BINL)) {\r
+      if (!EFI_ERROR (Status) && (Private->ProxyOfferType != DHCP4_PACKET_TYPE_BINL)) {\r
+        //\r
+        // Copy the proxy offer to Mode and set the flag\r
+        //\r
+        PxeBcCopyProxyOffer (Private, ProxyOfferIndex);\r
+      }\r
+    } else {\r
       //\r
-      // Copy the proxy offer to Mode and set the flag\r
+      // No proxy offer is received, the bootfile name MUST be set.\r
       //\r
-      PxeBcCopyProxyOffer (Private, ProxyOfferIndex);\r
+      ASSERT (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL);\r
     }\r
   }\r
 \r
@@ -560,6 +572,8 @@ PxeBcCacheDhcpOffer (
       //\r
       // It's a proxy dhcp offer with no your address, including pxe10, wfm11a or binl offer.\r
       //\r
+      Private->GotProxyOffer = TRUE;\r
+\r
       if (OfferType == DHCP4_PACKET_TYPE_BINL) {\r
         //\r
         // Cache all binl offers.\r
@@ -609,7 +623,6 @@ PxeBcSelectOffer (
   UINT32            Index;\r
   UINT32            OfferIndex;\r
   EFI_DHCP4_PACKET  *Offer;\r
-  BOOLEAN           GotProxyOffer;\r
 \r
   Private->SelectedOffer = 0;\r
 \r
@@ -688,15 +701,6 @@ PxeBcSelectOffer (
     //\r
     // Try the offers in the received order.\r
     //\r
-    GotProxyOffer = FALSE;\r
-    for (Index = 0; Index < DHCP4_PACKET_TYPE_MAX; Index++) {\r
-\r
-      GotProxyOffer = (BOOLEAN) (Private->ProxyIndex[Index] > 0);\r
-      if (GotProxyOffer) {\r
-        break;\r
-      }\r
-    }\r
-\r
     for (Index = 0; Index < Private->NumOffers; Index++) {\r
 \r
       Offer = &Private->Dhcp4Offers[Index].Packet.Offer;\r
@@ -709,7 +713,7 @@ PxeBcSelectOffer (
       }\r
 \r
       if ((Private->Dhcp4Offers[Index].OfferType == DHCP4_PACKET_TYPE_DHCP_ONLY) &&\r
-          ((!GotProxyOffer) && (Private->Dhcp4Offers[Index].Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL))) {\r
+          ((!Private->GotProxyOffer) && (Private->Dhcp4Offers[Index].Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL))) {\r
         //\r
         // DHCP only offer but no proxy offer received and no bootfile option in this offer\r
         //\r
index f8bdf5c9453e74321a5f930d87d5dda2165b669d..87bedcb006a3c11286b28be8870a3e8af267f75f 100644 (file)
@@ -513,8 +513,9 @@ EfiPxeBcDhcp (
     //\r
     // Zero those arrays to record the varies numbers of DHCP OFFERS.\r
     //\r
-    Private->NumOffers   = 0;\r
-    Private->BootpIndex  = 0;\r
+    Private->GotProxyOffer = FALSE;\r
+    Private->NumOffers     = 0;\r
+    Private->BootpIndex    = 0;\r
     ZeroMem (Private->ServerCount, sizeof (Private->ServerCount));\r
     ZeroMem (Private->ProxyIndex, sizeof (Private->ProxyIndex));\r
 \r
@@ -1158,7 +1159,7 @@ EfiPxeBcUdpWrite (
   }\r
 \r
   FragCount = (HeaderSize != NULL) ? 2 : 1;\r
-  Udp4TxData = (EFI_UDP4_TRANSMIT_DATA *) AllocatePool (sizeof (EFI_UDP4_TRANSMIT_DATA) + (FragCount - 1) * sizeof (EFI_UDP4_FRAGMENT_DATA));\r
+  Udp4TxData = (EFI_UDP4_TRANSMIT_DATA *) AllocateZeroPool (sizeof (EFI_UDP4_TRANSMIT_DATA) + (FragCount - 1) * sizeof (EFI_UDP4_FRAGMENT_DATA));\r
   if (Udp4TxData == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
index df77c5da49c13ceb83597b59686b45b1ae0a0480..028adcd7530d8bc131762ecb961a3134fdd01e4e 100644 (file)
@@ -103,6 +103,7 @@ struct _PXEBC_PRIVATE_DATA {
   UINT8                                     MacLen;
 
   BOOLEAN                                   SortOffers;
+  BOOLEAN                                   GotProxyOffer;
   UINT32                                    NumOffers;
   UINT32                                    SelectedOffer;
   UINT32                                    ProxyOfferType;
@@ -127,9 +128,9 @@ struct _PXEBC_PRIVATE_DATA {
   UINT32                                    BinlIndex[PXEBC_MAX_OFFER_NUM];
 
   EFI_EVENT                                 GetArpCacheEvent;
-  //\r
-  // token and event used to get ICMP error data from IP\r
-  //\r
+  //
+  // token and event used to get ICMP error data from IP
+  //
   EFI_IP4_COMPLETION_TOKEN                  IcmpErrorRcvToken;
 };