Fix a bug about the iSCSI DHCP dependency issue.
[mirror_edk2.git] / NetworkPkg / IScsiDxe / IScsiDriver.c
index cc452e7..6d6f9a1 100644 (file)
@@ -112,13 +112,16 @@ IScsiSupported (
   EFI_STATUS                Status;\r
   EFI_GUID                  *IScsiServiceBindingGuid;\r
   EFI_GUID                  *TcpServiceBindingGuid;\r
+  EFI_GUID                  *DhcpServiceBindingGuid;\r
 \r
   if (IpVersion == IP_VERSION_4) {\r
     IScsiServiceBindingGuid  = &gIScsiV4PrivateGuid;\r
     TcpServiceBindingGuid    = &gEfiTcp4ServiceBindingProtocolGuid;\r
+    DhcpServiceBindingGuid   = &gEfiDhcp4ServiceBindingProtocolGuid;\r
   } else {\r
     IScsiServiceBindingGuid  = &gIScsiV6PrivateGuid;\r
     TcpServiceBindingGuid    = &gEfiTcp6ServiceBindingProtocolGuid;\r
+    DhcpServiceBindingGuid   = &gEfiDhcp6ServiceBindingProtocolGuid;\r
   }\r
 \r
   Status = gBS->OpenProtocol (\r
@@ -131,24 +134,40 @@ IScsiSupported (
                   );\r
   if (!EFI_ERROR (Status)) {\r
     return EFI_ALREADY_STARTED;\r
-  } else {\r
+  }\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  TcpServiceBindingGuid,\r
+                  NULL,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Status = IScsiIsDevicePathSupported (RemainingDevicePath);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (IScsiDhcpIsConfigured (ControllerHandle, IpVersion)) {\r
     Status = gBS->OpenProtocol (\r
                     ControllerHandle,\r
-                    TcpServiceBindingGuid,\r
+                    DhcpServiceBindingGuid,\r
                     NULL,\r
                     This->DriverBindingHandle,\r
                     ControllerHandle,\r
                     EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
                     );\r
-    if (!EFI_ERROR (Status)) {\r
-      Status = IScsiIsDevicePathSupported (RemainingDevicePath);\r
-      if (!EFI_ERROR (Status)) {\r
-        return EFI_SUCCESS;\r
-      }\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_UNSUPPORTED;\r
     }\r
   }\r
-\r
-  return EFI_UNSUPPORTED;\r
+  \r
+  return EFI_SUCCESS;\r
 }\r
 \r
 \r