]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
NetworkPkg: reset DHCP child when leaving PXE LoadFile.
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / PxeBcImpl.c
index 19c83d3234fde237f4c82b0168462e6bb19e353b..12e5566a7913b1804551f69b23c970935758c0c0 100644 (file)
@@ -204,6 +204,18 @@ EfiPxeBcStart (
     if (EFI_ERROR (Status)) {\r
       goto ON_ERROR;\r
     }\r
+\r
+    //\r
+    //DHCP4 service allows only one of its children to be configured in  \r
+    //the active state, If the DHCP4 D.O.R.A started by IP4 auto  \r
+    //configuration and has not been completed, the Dhcp4 state machine \r
+    //will not be in the right state for the PXE to start a new round D.O.R.A. \r
+    //so we need to switch it's policy to static.\r
+    //\r
+    Status = PxeBcSetIp4Policy (Private);\r
+    if (EFI_ERROR (Status)) {\r
+      goto ON_ERROR;\r
+    }\r
   }\r
 \r
   //\r
@@ -1265,7 +1277,7 @@ EfiPxeBcUdpRead (
   UINTN                       FragmentIndex;\r
   UINT8                       *FragmentBuffer;\r
 \r
-  if (This == NULL || DestIp == NULL || DestPort == NULL) {\r
+  if (This == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -1276,9 +1288,9 @@ EfiPxeBcUdpRead (
   Udp4Rx    = NULL;\r
   Udp6Rx    = NULL;\r
 \r
-  if (((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) != 0 && DestPort == NULL) ||\r
-      ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) != 0 && SrcIp == NULL) ||\r
-      ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) != 0 && SrcPort == NULL)) {\r
+  if (((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) == 0 && DestPort == NULL) ||\r
+      ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) == 0 && SrcIp == NULL) ||\r
+      ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) == 0 && SrcPort == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -2316,6 +2328,10 @@ EfiPxeLoadFile (
   EFI_STATUS                  Status;\r
   BOOLEAN                     MediaPresent;\r
 \r
+  if (FilePath == NULL || !IsDevicePathEnd (FilePath)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
   VirtualNic = PXEBC_VIRTUAL_NIC_FROM_LOADFILE (This);\r
   Private    = VirtualNic->Private;\r
   PxeBc      = &Private->PxeBc;\r
@@ -2376,6 +2392,16 @@ EfiPxeLoadFile (
     //   3. unsupported.\r
     //\r
     PxeBc->Stop (PxeBc);\r
+  } else {\r
+    //\r
+    // The DHCP4 can have only one configured child instance so we need to stop\r
+    // reset the DHCP4 child before we return. Otherwise these programs which \r
+    // also need to use DHCP4 will be impacted.\r
+    //\r
+    if (!PxeBc->Mode->UsingIpv6) {\r
+      Private->Dhcp4->Stop (Private->Dhcp4);\r
+      Private->Dhcp4->Configure (Private->Dhcp4, NULL);\r
+    }\r
   }\r
 \r
   return Status;\r