]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg/Ip6Dxe: fix a bug in IP6 driver for IpSec protocol notify.
authorFu Siyuan <siyuan.fu@intel.com>
Mon, 4 Sep 2017 08:04:53 +0000 (16:04 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Wed, 6 Sep 2017 06:57:45 +0000 (14:57 +0800)
The IP driver uses EfiCreateProtocolNotifyEvent() to register notify callback
function for IpSec protocol, but it didn't notice that the callback will always
be executed at least once, even the protocol wasn't in handle database.
As a result, the Ip6IpSecProcessPacket() will still always call LocateProtocol()
even the IpSec protocol is not installed, which will impact the network
performance.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
NetworkPkg/Ip6Dxe/Ip6Driver.c
NetworkPkg/Ip6Dxe/Ip6Input.c

index 8a8cc8916afeb965adb5ef51168f507e66e811a7..43af838ccd661ffaf6d0bb547e0b75117943d6d0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The driver binding and service binding protocol for IP6 driver.\r
 \r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
 \r
   This program and the accompanying materials\r
@@ -41,14 +41,20 @@ IpSec2InstalledCallback (
   IN VOID       *Context\r
   )\r
 {\r
+  EFI_STATUS    Status;\r
   //\r
-  // Close the event so it does not get called again.\r
+  // Test if protocol was even found.\r
+  // Notification function will be called at least once.\r
   //\r
-  gBS->CloseEvent (Event);\r
-\r
-  mIpSec2Installed = TRUE;\r
+  Status = gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, &mIpSec);\r
+  if (Status == EFI_SUCCESS && mIpSec != NULL) {\r
+    //\r
+    // Close the event so it does not get called again.\r
+    //\r
+    gBS->CloseEvent (Event);\r
 \r
-  return;\r
+    mIpSec2Installed = TRUE;\r
+  }\r
 }\r
 \r
 /**\r
index e53e0874b9b52fa9affbb3eb95fbdf913e6f73b3..6aa55555b81beff046f58cd117282e5a2a701ff8 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   IP6 internal functions to process the incoming packets.\r
 \r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
 \r
   This program and the accompanying materials\r
@@ -530,6 +530,7 @@ Ip6IpSecProcessPacket (
   if (!mIpSec2Installed) {\r
     goto ON_EXIT;\r
   }\r
+  ASSERT (mIpSec != NULL);\r
   \r
   Packet        = *Netbuf;\r
   RecycleEvent  = NULL;\r
@@ -541,17 +542,6 @@ Ip6IpSecProcessPacket (
   FragmentCount = Packet->BlockOpNum;\r
   ZeroMem (&ZeroHead, sizeof (EFI_IP6_HEADER));\r
 \r
-  if (mIpSec == NULL) {\r
-    gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **) &mIpSec);\r
-\r
-    //\r
-    // Check whether the ipsec protocol is available.\r
-    //\r
-    if (mIpSec == NULL) {\r
-      goto ON_EXIT;\r
-    }\r
-  }\r
-\r
   //\r
   // Check whether the ipsec enable variable is set.\r
   //\r