From: Fu Siyuan <siyuan.fu@intel.com>
To: edk2-devel@lists.01.org
Cc: Ye Ting <ting.ye@intel.com>, Wu Jiaxin <jiaxin.wu@intel.com>
Subject: [Patch 1/2] MdeModulePkg/Ip4Dxe: fix a bug in IP4 driver for IpSec protocol notify.
Date: Mon, 4 Sep 2017 16:07:01 +0800 [thread overview]
Message-ID: <20170904080702.14488-2-siyuan.fu@intel.com> (raw)
In-Reply-To: <20170904080702.14488-1-siyuan.fu@intel.com>
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 Ip4IpSecProcessPacket() will still always call LocateProtocol()
even the IpSec protocol is not installed, which will impact the network
performance.
Cc: Ye Ting <ting.ye@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
---
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c | 14 +++++++++++---
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c | 10 ++--------
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
index 792db5c..03ba458 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
@@ -41,12 +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);
+ 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);
- mIpSec2Installed = TRUE;
+ mIpSec2Installed = TRUE;
+ }
}
/**
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
index 09b8f2b..e694323 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
@@ -1,7 +1,7 @@
/** @file
IP4 input process.
-Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
This program and the accompanying materials
@@ -518,6 +518,7 @@ Ip4IpSecProcessPacket (
if (!mIpSec2Installed) {
goto ON_EXIT;
}
+ ASSERT (mIpSec != NULL);
Packet = *Netbuf;
RecycleEvent = NULL;
@@ -527,13 +528,6 @@ Ip4IpSecProcessPacket (
FragmentCount = Packet->BlockOpNum;
ZeroMem (&ZeroHead, sizeof (IP4_HEAD));
-
- if (mIpSec == NULL) {
- gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **) &mIpSec);
- if (mIpSec == NULL) {
- goto ON_EXIT;
- }
- }
//
// Check whether the IPsec enable variable is set.
--
1.9.5.msysgit.1
next prev parent reply other threads:[~2017-09-04 8:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-04 8:07 [Patch 0/2] Fix bug in IP driver for IpSec protocol notify Fu Siyuan
2017-09-04 8:07 ` Fu Siyuan [this message]
2017-09-06 8:03 ` [Patch 1/2] MdeModulePkg/Ip4Dxe: fix a bug in IP4 " Ard Biesheuvel
2017-09-04 8:07 ` [Patch 2/2] NetworkPkg/Ip6Dxe: fix a bug in IP6 " Fu Siyuan
2017-09-06 6:51 ` [Patch 0/2] Fix bug in IP " Ye, Ting
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170904080702.14488-2-siyuan.fu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox