diff options
author | Fu Siyuan <siyuan.fu@intel.com> | 2017-09-04 16:04:53 +0800 |
---|---|---|
committer | Fu Siyuan <siyuan.fu@intel.com> | 2017-09-06 14:57:45 +0800 |
commit | 9a04dcffbb1e59333e500a8ce66e01a562be8b4f (patch) | |
tree | bcbd97d26dadaeaa8cec12d3f67881cfc8aff7b2 | |
parent | 5aae2d35de031a38e7812c615ff6bce36b31466a (diff) | |
download | edk2-9a04dcffbb1e59333e500a8ce66e01a562be8b4f.tar.gz edk2-9a04dcffbb1e59333e500a8ce66e01a562be8b4f.tar.bz2 edk2-9a04dcffbb1e59333e500a8ce66e01a562be8b4f.zip |
NetworkPkg/Ip6Dxe: fix a bug in IP6 driver for IpSec protocol notify.
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>
-rw-r--r-- | NetworkPkg/Ip6Dxe/Ip6Driver.c | 18 | ||||
-rw-r--r-- | NetworkPkg/Ip6Dxe/Ip6Input.c | 14 |
2 files changed, 14 insertions, 18 deletions
diff --git a/NetworkPkg/Ip6Dxe/Ip6Driver.c b/NetworkPkg/Ip6Dxe/Ip6Driver.c index 8a8cc8916a..43af838ccd 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Driver.c +++ b/NetworkPkg/Ip6Dxe/Ip6Driver.c @@ -1,7 +1,7 @@ /** @file
The driver binding and service binding protocol for IP6 driver.
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
This program and the accompanying materials
@@ -41,14 +41,20 @@ IpSec2InstalledCallback ( IN VOID *Context
)
{
+ EFI_STATUS Status;
//
- // Close the event so it does not get called again.
+ // Test if protocol was even found.
+ // Notification function will be called at least once.
//
- gBS->CloseEvent (Event);
-
- mIpSec2Installed = TRUE;
+ Status = gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, &mIpSec);
+ if (Status == EFI_SUCCESS && mIpSec != NULL) {
+ //
+ // Close the event so it does not get called again.
+ //
+ gBS->CloseEvent (Event);
- return;
+ mIpSec2Installed = TRUE;
+ }
}
/**
diff --git a/NetworkPkg/Ip6Dxe/Ip6Input.c b/NetworkPkg/Ip6Dxe/Ip6Input.c index e53e0874b9..6aa55555b8 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Input.c +++ b/NetworkPkg/Ip6Dxe/Ip6Input.c @@ -1,7 +1,7 @@ /** @file
IP6 internal functions to process the incoming packets.
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
This program and the accompanying materials
@@ -530,6 +530,7 @@ Ip6IpSecProcessPacket ( if (!mIpSec2Installed) {
goto ON_EXIT;
}
+ ASSERT (mIpSec != NULL);
Packet = *Netbuf;
RecycleEvent = NULL;
@@ -541,17 +542,6 @@ Ip6IpSecProcessPacket ( FragmentCount = Packet->BlockOpNum;
ZeroMem (&ZeroHead, sizeof (EFI_IP6_HEADER));
- if (mIpSec == NULL) {
- gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **) &mIpSec);
-
- //
- // Check whether the ipsec protocol is available.
- //
- if (mIpSec == NULL) {
- goto ON_EXIT;
- }
- }
-
//
// Check whether the ipsec enable variable is set.
//
|