]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c
NetworkPkg/UefiPxeBcDxe: handle competing DHCP servers (more) gracefully
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / PxeBcBoot.c
index 46a13c5b1fd7396b1d7c28b6af3821bcbbd961db..d062a526077b270d35867d22012578e58445bd29 100644 (file)
@@ -4,13 +4,7 @@
   Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 \r
-  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
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -263,7 +257,7 @@ ON_EXIT:
 \r
   @retval EFI_ABORTED     User cancel operation.\r
   @retval EFI_SUCCESS     Select the boot menu success.\r
-  @retval EFI_NOT_READY   Read the input key from the keybroad has not finish.\r
+  @retval EFI_NOT_READY   Read the input key from the keyboard has not finish.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -488,7 +482,20 @@ PxeBcDhcp4BootInfo (
     Cache4 = &Private->DhcpAck.Dhcp4;\r
   }\r
 \r
-  ASSERT (Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL);\r
+  if (Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL) {\r
+    //\r
+    // This should never happen in a correctly configured DHCP / PXE\r
+    // environment. One misconfiguration that can cause it is two DHCP servers\r
+    // mistakenly running on the same network segment at the same time, and\r
+    // racing each other in answering DHCP requests. Thus, the DHCP packets\r
+    // that the edk2 PXE client considers "belonging together" may actually be\r
+    // entirely independent, coming from two (competing) DHCP servers.\r
+    //\r
+    // Try to deal with this gracefully. Note that this check is not\r
+    // comprehensive, as we don't try to identify all such errors.\r
+    //\r
+    return EFI_PROTOCOL_ERROR;\r
+  }\r
 \r
   //\r
   // Parse the boot server address.\r
@@ -618,7 +625,20 @@ PxeBcDhcp6BootInfo (
     Cache6 = &Private->DhcpAck.Dhcp6;\r
   }\r
 \r
-  ASSERT (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] != NULL);\r
+  if (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL) {\r
+    //\r
+    // This should never happen in a correctly configured DHCP / PXE\r
+    // environment. One misconfiguration that can cause it is two DHCP servers\r
+    // mistakenly running on the same network segment at the same time, and\r
+    // racing each other in answering DHCP requests. Thus, the DHCP packets\r
+    // that the edk2 PXE client considers "belonging together" may actually be\r
+    // entirely independent, coming from two (competing) DHCP servers.\r
+    //\r
+    // Try to deal with this gracefully. Note that this check is not\r
+    // comprehensive, as we don't try to identify all such errors.\r
+    //\r
+    return EFI_PROTOCOL_ERROR;\r
+  }\r
 \r
   //\r
   // Set the station address to IP layer.\r
@@ -976,7 +996,7 @@ PxeBcDiscoverBootFile (
   @param[in, out] Private           Pointer to PxeBc private data.\r
   @param[out]     NewMakeCallback   If TRUE, it is a new callback.\r
                                     Otherwise, it is not new callback.\r
-  @retval EFI_SUCCESS          PxeBaseCodeCallbackProtocol installed succesfully.\r
+  @retval EFI_SUCCESS          PxeBaseCodeCallbackProtocol installed successfully.\r
   @retval Others               Failed to install PxeBaseCodeCallbackProtocol.\r
 \r
 **/\r