Revision: 14314
          http://edk2.svn.sourceforge.net/edk2/?rev=14314&view=rev
Author:   sfu5
Date:     2013-04-25 01:25:49 +0000 (Thu, 25 Apr 2013)
Log Message:
-----------
Fix ping command issue in IP4 driver.
Signed-off-by: Fu Siyuan <[email protected]>
Reviewed-by: Ye Ting <[email protected]>
Reviewed-by: Ouyang Qian <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
    trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c

Modified: trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c        
2013-04-25 01:18:58 UTC (rev 14313)
+++ trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c        
2013-04-25 01:25:49 UTC (rev 14314)
@@ -1,7 +1,7 @@
 /** @file
   The driver binding and service binding protocol for IP4 driver.
 
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -572,6 +572,8 @@
   INTN                                     State;
   LIST_ENTRY                               *List;
   IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT  Context;
+  IP4_INTERFACE                            *IpIf;
+  IP4_ROUTE_TABLE                          *RouteTable;
 
   //
   // IP4 driver opens the MNP child, ARP children or the IP4_CONFIG protocol
@@ -681,6 +683,35 @@
                &Context,
                NULL
                );
+  } else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) {
+    //
+    // The ARP protocol for the default interface is being uninstalled and all
+    // its IP child handles should have been destroyed before. So, release the
+    // default interface and route table, create a new one and mark it as not 
started.
+    //
+    Ip4CancelReceive (IpSb->DefaultInterface);
+    Ip4FreeInterface (IpSb->DefaultInterface, NULL);
+    Ip4FreeRouteTable (IpSb->DefaultRouteTable);
+    
+    IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);
+    if (IpIf == NULL) {
+      goto ON_ERROR;
+    }
+    RouteTable = Ip4CreateRouteTable ();
+    if (RouteTable == NULL) {
+      Ip4FreeInterface (IpIf, NULL);
+      goto ON_ERROR;;
+    }
+    
+    IpSb->DefaultInterface  = IpIf;
+    InsertHeadList (&IpSb->Interfaces, &IpIf->Link);
+    IpSb->DefaultRouteTable = RouteTable;
+    Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);
+
+    if (IpSb->Ip4Config != NULL && IpSb->State != IP4_SERVICE_DESTROY) {
+      IpSb->Ip4Config->Stop (IpSb->Ip4Config);
+    }
+    IpSb->State = IP4_SERVICE_UNSTARTED;
   } else if (IsListEmpty (&IpSb->Children)) {
     State           = IpSb->State;
     IpSb->State     = IP4_SERVICE_DESTROY;

Modified: trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c    2013-04-25 
01:18:58 UTC (rev 14313)
+++ trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c    2013-04-25 
01:25:49 UTC (rev 14314)
@@ -740,11 +740,24 @@
   //
   Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, IpInstance);
 
+  if (--Interface->RefCnt > 0) {
+    return EFI_SUCCESS;
+  }
+
   //
-  // Destroy the ARP instance if this is the last IP instance that
-  // has the address.
+  // Destroy the interface if this is the last IP instance that
+  // has the address. Remove all the system transmitted packets
+  // from this interface, cancel the receive request if there is
+  // one, and destroy the ARP requests.
   //
-  if (Interface->Arp != NULL && IsListEmpty (&Interface->IpInstances)) {
+  Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, NULL);
+  Ip4CancelReceive (Interface);
+
+  ASSERT (IsListEmpty (&Interface->IpInstances));
+  ASSERT (IsListEmpty (&Interface->ArpQues));
+  ASSERT (IsListEmpty (&Interface->SentFrames));
+
+  if (Interface->Arp != NULL) {
     gBS->CloseProtocol (
           Interface->ArpHandle,
           &gEfiArpProtocolGuid,
@@ -758,25 +771,8 @@
       &gEfiArpServiceBindingProtocolGuid,
       Interface->ArpHandle
       );
-    Interface->Arp = NULL;
   }
-  
-  if (--Interface->RefCnt > 0) {
-    return EFI_SUCCESS;
-  }
 
-  //
-  // Destroy the interface if it is not referenced by any IP instance (for 
common Interface)
-  // or the IP service (for the DefaultInterface). Remove all the system 
transmitted packets
-  // from this interface, cancel the receive request if there is one.
-  //
-  Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, NULL);
-  Ip4CancelReceive (Interface);
-
-  ASSERT (IsListEmpty (&Interface->IpInstances));
-  ASSERT (IsListEmpty (&Interface->ArpQues));
-  ASSERT (IsListEmpty (&Interface->SentFrames));
-
   RemoveEntryList (&Interface->Link);
   FreePool (Interface);
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to