Revision: 18367
http://sourceforge.net/p/edk2/code/18367
Author: hwu1225
Date: 2015-09-01 00:37:24 +0000 (Tue, 01 Sep 2015)
Log Message:
-----------
MdeModulePkg/NetworkPkg: Locate IpSec on IP packet processing only if it's
installed.
Modified the logic in Ip4Dxe and Ip6Dxe to not locate EFI_IPSEC2_PROTOCOL on
each
message transmit/receive. Instead, register a callback in the drivers entry
points
on the IpSec protocol installation, and process only if the protocol is
installed.
This speeds up the network stacks when IpSec is not installed since there is a
penalty associated with searching the entire handle database on each packet
processing.
(Sync patch r18365 from main trunk.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud <[email protected]>
Reviewed-by: Fu Siyuan <[email protected]>
Revision Links:
--------------
http://sourceforge.net/p/edk2/code/18365
Modified Paths:
--------------
branches/UDK2015/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
branches/UDK2015/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
branches/UDK2015/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
branches/UDK2015/NetworkPkg/Ip6Dxe/Ip6Driver.c
branches/UDK2015/NetworkPkg/Ip6Dxe/Ip6Impl.h
branches/UDK2015/NetworkPkg/Ip6Dxe/Ip6Input.c
Modified: branches/UDK2015/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
===================================================================
--- branches/UDK2015/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
2015-08-31 08:43:07 UTC (rev 18366)
+++ branches/UDK2015/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
2015-09-01 00:37:24 UTC (rev 18367)
@@ -2,6 +2,8 @@
The driver binding and service binding protocol for IP4 driver.
Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
+(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<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
@@ -23,7 +25,31 @@
NULL
};
+BOOLEAN mIpSec2Installed = FALSE;
+
/**
+ Callback function for IpSec2 Protocol install.
+
+ @param[in] Event Event whose notification function is being
invoked
+ @param[in] Context Pointer to the notification function's context
+
+**/
+VOID
+EFIAPI
+IpSec2InstalledCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ //
+ // Close the event so it does not get called again.
+ //
+ gBS->CloseEvent (Event);
+
+ mIpSec2Installed = TRUE;
+}
+
+/**
This is the declaration of an EFI image entry point. This entry point is
the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
both device drivers and bus drivers.
@@ -45,6 +71,16 @@
IN EFI_SYSTEM_TABLE *SystemTable
)
{
+ VOID *Registration;
+
+ EfiCreateProtocolNotifyEvent (
+ &gEfiIpSec2ProtocolGuid,
+ TPL_CALLBACK,
+ IpSec2InstalledCallback,
+ NULL,
+ &Registration
+ );
+
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
Modified: branches/UDK2015/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
===================================================================
--- branches/UDK2015/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
2015-08-31 08:43:07 UTC (rev 18366)
+++ branches/UDK2015/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
2015-09-01 00:37:24 UTC (rev 18367)
@@ -2,6 +2,8 @@
Ip4 internal functions and type defintions.
Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
+(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<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
@@ -396,5 +398,6 @@
);
extern EFI_IPSEC2_PROTOCOL *mIpSec;
+extern BOOLEAN mIpSec2Installed;
#endif
Modified: branches/UDK2015/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
===================================================================
--- branches/UDK2015/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
2015-08-31 08:43:07 UTC (rev 18366)
+++ branches/UDK2015/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
2015-09-01 00:37:24 UTC (rev 18367)
@@ -2,6 +2,8 @@
IP4 input process.
Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
+(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<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
@@ -512,6 +514,11 @@
IP4_HEAD ZeroHead;
Status = EFI_SUCCESS;
+
+ if (!mIpSec2Installed) {
+ goto ON_EXIT;
+ }
+
Packet = *Netbuf;
RecycleEvent = NULL;
IpSecWrap = NULL;
Modified: branches/UDK2015/NetworkPkg/Ip6Dxe/Ip6Driver.c
===================================================================
--- branches/UDK2015/NetworkPkg/Ip6Dxe/Ip6Driver.c 2015-08-31 08:43:07 UTC
(rev 18366)
+++ branches/UDK2015/NetworkPkg/Ip6Dxe/Ip6Driver.c 2015-09-01 00:37:24 UTC
(rev 18367)
@@ -2,6 +2,7 @@
The driver binding and service binding protocol for IP6 driver.
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD
License
@@ -24,7 +25,34 @@
NULL
};
+BOOLEAN mIpSec2Installed = FALSE;
+
/**
+ Callback function for IpSec2 Protocol install.
+
+ @param[in] Event Event whose notification function is being
invoked
+ @param[in] Context Pointer to the notification function's context
+
+ @retval EFI_SUCCESS Callback successful.
+**/
+VOID
+EFIAPI
+IpSec2InstalledCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ //
+ // Close the event so it does not get called again.
+ //
+ gBS->CloseEvent (Event);
+
+ mIpSec2Installed = TRUE;
+
+ return;
+}
+
+/**
This is the declaration of an EFI image entry point. This entry point is
the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
both device drivers and bus drivers.
@@ -46,6 +74,16 @@
IN EFI_SYSTEM_TABLE *SystemTable
)
{
+ VOID *Registration;
+
+ EfiCreateProtocolNotifyEvent (
+ &gEfiIpSec2ProtocolGuid,
+ TPL_CALLBACK,
+ IpSec2InstalledCallback,
+ NULL,
+ &Registration
+ );
+
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
Modified: branches/UDK2015/NetworkPkg/Ip6Dxe/Ip6Impl.h
===================================================================
--- branches/UDK2015/NetworkPkg/Ip6Dxe/Ip6Impl.h 2015-08-31 08:43:07 UTC
(rev 18366)
+++ branches/UDK2015/NetworkPkg/Ip6Dxe/Ip6Impl.h 2015-09-01 00:37:24 UTC
(rev 18367)
@@ -2,6 +2,7 @@
Implementation of EFI_IP6_PROTOCOL protocol interfaces and type definitions.
Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD
License
@@ -89,6 +90,7 @@
#define IP6_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)
extern EFI_IPSEC2_PROTOCOL *mIpSec;
+extern BOOLEAN mIpSec2Installed;
//
// IP6_TXTOKEN_WRAP wraps the upper layer's transmit token.
Modified: branches/UDK2015/NetworkPkg/Ip6Dxe/Ip6Input.c
===================================================================
--- branches/UDK2015/NetworkPkg/Ip6Dxe/Ip6Input.c 2015-08-31 08:43:07 UTC
(rev 18366)
+++ branches/UDK2015/NetworkPkg/Ip6Dxe/Ip6Input.c 2015-09-01 00:37:24 UTC
(rev 18367)
@@ -2,6 +2,7 @@
IP6 internal functions to process the incoming packets.
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD
License
@@ -525,6 +526,11 @@
EFI_IP6_HEADER ZeroHead;
Status = EFI_SUCCESS;
+
+ if (!mIpSec2Installed) {
+ goto ON_EXIT;
+ }
+
Packet = *Netbuf;
RecycleEvent = NULL;
IpSecWrap = NULL;
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits