]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix ping command issue in IP4 driver.
authorsfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 25 Apr 2013 01:25:49 +0000 (01:25 +0000)
committersfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 25 Apr 2013 01:25:49 +0000 (01:25 +0000)
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Ouyang Qian <qian.ouyang@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14314 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c

index 4a3d342711ca7d257f3cbc91be191a1f6a16e988..73b4e246e0dc66b50f4bdb4502d6b786d525b87d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The driver binding and service binding protocol for IP4 driver.\r
 \r
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>\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
@@ -572,6 +572,8 @@ Ip4DriverBindingStop (
   INTN                                     State;\r
   LIST_ENTRY                               *List;\r
   IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT  Context;\r
+  IP4_INTERFACE                            *IpIf;\r
+  IP4_ROUTE_TABLE                          *RouteTable;\r
 \r
   //\r
   // IP4 driver opens the MNP child, ARP children or the IP4_CONFIG protocol\r
@@ -681,6 +683,35 @@ Ip4DriverBindingStop (
                &Context,\r
                NULL\r
                );\r
+  } else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) {\r
+    //\r
+    // The ARP protocol for the default interface is being uninstalled and all\r
+    // its IP child handles should have been destroyed before. So, release the\r
+    // default interface and route table, create a new one and mark it as not started.\r
+    //\r
+    Ip4CancelReceive (IpSb->DefaultInterface);\r
+    Ip4FreeInterface (IpSb->DefaultInterface, NULL);\r
+    Ip4FreeRouteTable (IpSb->DefaultRouteTable);\r
+    \r
+    IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);\r
+    if (IpIf == NULL) {\r
+      goto ON_ERROR;\r
+    }\r
+    RouteTable = Ip4CreateRouteTable ();\r
+    if (RouteTable == NULL) {\r
+      Ip4FreeInterface (IpIf, NULL);\r
+      goto ON_ERROR;;\r
+    }\r
+    \r
+    IpSb->DefaultInterface  = IpIf;\r
+    InsertHeadList (&IpSb->Interfaces, &IpIf->Link);\r
+    IpSb->DefaultRouteTable = RouteTable;\r
+    Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);\r
+\r
+    if (IpSb->Ip4Config != NULL && IpSb->State != IP4_SERVICE_DESTROY) {\r
+      IpSb->Ip4Config->Stop (IpSb->Ip4Config);\r
+    }\r
+    IpSb->State = IP4_SERVICE_UNSTARTED;\r
   } else if (IsListEmpty (&IpSb->Children)) {\r
     State           = IpSb->State;\r
     IpSb->State     = IP4_SERVICE_DESTROY;\r
index 67116363331c0a272e09d47382dc6c203c0f61d4..e4ab17a37ea555a9c10206f8e474d0c47fc41bed 100644 (file)
@@ -740,11 +740,24 @@ Ip4FreeInterface (
   //\r
   Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, IpInstance);\r
 \r
+  if (--Interface->RefCnt > 0) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
   //\r
-  // Destroy the ARP instance if this is the last IP instance that\r
-  // has the address.\r
+  // Destroy the interface if this is the last IP instance that\r
+  // has the address. Remove all the system transmitted packets\r
+  // from this interface, cancel the receive request if there is\r
+  // one, and destroy the ARP requests.\r
   //\r
-  if (Interface->Arp != NULL && IsListEmpty (&Interface->IpInstances)) {\r
+  Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, NULL);\r
+  Ip4CancelReceive (Interface);\r
+\r
+  ASSERT (IsListEmpty (&Interface->IpInstances));\r
+  ASSERT (IsListEmpty (&Interface->ArpQues));\r
+  ASSERT (IsListEmpty (&Interface->SentFrames));\r
+\r
+  if (Interface->Arp != NULL) {\r
     gBS->CloseProtocol (\r
           Interface->ArpHandle,\r
           &gEfiArpProtocolGuid,\r
@@ -758,25 +771,8 @@ Ip4FreeInterface (
       &gEfiArpServiceBindingProtocolGuid,\r
       Interface->ArpHandle\r
       );\r
-    Interface->Arp = NULL;\r
-  }\r
-  \r
-  if (--Interface->RefCnt > 0) {\r
-    return EFI_SUCCESS;\r
   }\r
 \r
-  //\r
-  // Destroy the interface if it is not referenced by any IP instance (for common Interface)\r
-  // or the IP service (for the DefaultInterface). Remove all the system transmitted packets\r
-  // from this interface, cancel the receive request if there is one.\r
-  //\r
-  Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, NULL);\r
-  Ip4CancelReceive (Interface);\r
-\r
-  ASSERT (IsListEmpty (&Interface->IpInstances));\r
-  ASSERT (IsListEmpty (&Interface->ArpQues));\r
-  ASSERT (IsListEmpty (&Interface->SentFrames));\r
-\r
   RemoveEntryList (&Interface->Link);\r
   FreePool (Interface);\r
 \r