]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/IpSecDxe/IpSecDriver.c
StandaloneMmPkg/Core/Dispatcher: don't copy dispatched image twice
[mirror_edk2.git] / NetworkPkg / IpSecDxe / IpSecDriver.c
index 454d218c75456282bfc6651e8062fef5fa406621..3082d997b7cb44da8d0616bd58ed4816c273a74c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Driver Binding Protocol for IPsec Driver.\r
 \r
-  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<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
@@ -28,7 +28,7 @@
   @param[in]  RemainingDevicePath  Optional parameter used to pick a specific child\r
                                    device to start.\r
   @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.\r
-  \r
+\r
   @retval EFI_SUCCES           This driver supports this device.\r
   @retval EFI_ALREADY_STARTED  This driver is already running on this device.\r
   @retval other                This driver does not support this device.\r
@@ -45,7 +45,7 @@ IpSecSupported (
 {\r
   EFI_STATUS  Status;\r
   EFI_GUID    *UdpServiceBindingGuid;\r
-  \r
+\r
   if (IpVersion == IP_VERSION_4) {\r
     UdpServiceBindingGuid  = &gEfiUdp4ServiceBindingProtocolGuid;\r
   } else {\r
@@ -178,6 +178,7 @@ IpSecStop (
   IKE_UDP_SERVICE     *UdpSrv;\r
   LIST_ENTRY          *Entry;\r
   LIST_ENTRY          *Next;\r
+  IKEV2_SA_SESSION    *Ikev2SaSession;\r
 \r
   //\r
   // Locate ipsec protocol to get private data.\r
@@ -196,7 +197,27 @@ IpSecStop (
   //\r
   if ((IpVersion == IP_VERSION_4 && Private->Udp6Num ==0) ||\r
       (IpVersion == IP_VERSION_6 && Private->Udp4Num ==0)) {\r
-    IkeDeleteAllSas (Private, FALSE);\r
+    //\r
+    // If IKEv2 SAs are under establishing, delete it directly.\r
+    //\r
+    if (!IsListEmpty (&Private->Ikev2SessionList)) {\r
+      NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Ikev2SessionList) {\r
+        Ikev2SaSession = IKEV2_SA_SESSION_BY_SESSION (Entry);\r
+        RemoveEntryList (&Ikev2SaSession->BySessionTable);\r
+        Ikev2SaSessionFree (Ikev2SaSession);\r
+      }\r
+    }\r
+\r
+    //\r
+    // Delete established IKEv2 SAs.\r
+    //\r
+    if (!IsListEmpty (&Private->Ikev2EstablishedList)) {\r
+      NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Ikev2EstablishedList) {\r
+        Ikev2SaSession = IKEV2_SA_SESSION_BY_SESSION (Entry);\r
+        RemoveEntryList (&Ikev2SaSession->BySessionTable);\r
+        Ikev2SaSessionFree (Ikev2SaSession);\r
+      }\r
+    }\r
   }\r
 \r
   if (IpVersion == IP_VERSION_4) {\r
@@ -610,16 +631,11 @@ IpSecDriverEntryPoint (
   return Status;\r
 \r
 ON_UNINSTALL_IPSEC4_DB:\r
-  gBS->UninstallMultipleProtocolInterfaces (\r
-         ImageHandle,\r
-         &gEfiDriverBindingProtocolGuid,\r
-         &gIpSec4DriverBinding,\r
-         &gEfiComponentName2ProtocolGuid,\r
-         &gIpSecComponentName2,\r
-         &gEfiComponentNameProtocolGuid,\r
-         &gIpSecComponentName,\r
-         NULL\r
-         );\r
+  EfiLibUninstallDriverBindingComponentName2 (\r
+    &gIpSec4DriverBinding,\r
+    &gIpSecComponentName,\r
+    &gIpSecComponentName2\r
+    );\r
 \r
 ON_UNINSTALL_IPSEC:\r
   gBS->UninstallProtocolInterface (\r