From nobody Thu Dec 26 13:25:34 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1504512433644411.78625840508755; Mon, 4 Sep 2017 01:07:13 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C807921E3EA98; Mon, 4 Sep 2017 01:04:22 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 06B4B21E3EA88 for ; Mon, 4 Sep 2017 01:04:21 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2017 01:07:08 -0700 Received: from sfu5-mobl.ccr.corp.intel.com ([10.239.193.124]) by fmsmga004.fm.intel.com with ESMTP; 04 Sep 2017 01:07:07 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,473,1498546800"; d="scan'208";a="307676236" From: Fu Siyuan To: edk2-devel@lists.01.org Date: Mon, 4 Sep 2017 16:07:01 +0800 Message-Id: <20170904080702.14488-2-siyuan.fu@intel.com> X-Mailer: git-send-email 2.13.0.windows.1 In-Reply-To: <20170904080702.14488-1-siyuan.fu@intel.com> References: <20170904080702.14488-1-siyuan.fu@intel.com> Subject: [edk2] [Patch 1/2] MdeModulePkg/Ip4Dxe: fix a bug in IP4 driver for IpSec protocol notify. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The IP driver uses EfiCreateProtocolNotifyEvent() to register notify callba= ck function for IpSec protocol, but it didn't notice that the callback will al= ways be executed at least once, even the protocol wasn't in handle database. As a result, the Ip4IpSecProcessPacket() will still always call LocateProto= col() even the IpSec protocol is not installed, which will impact the network performance. Cc: Ye Ting Cc: Wu Jiaxin Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan --- 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/MdeModuleP= kg/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 =3D gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, &mIpSec); + if (Status =3D=3D EFI_SUCCESS && mIpSec !=3D NULL) { + // + // Close the event so it does not get called again. + // + gBS->CloseEvent (Event); =20 - mIpSec2Installed =3D TRUE; + mIpSec2Installed =3D TRUE; + } } =20 /** diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c b/MdeModulePk= g/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. =20 -Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
=20 This program and the accompanying materials @@ -518,6 +518,7 @@ Ip4IpSecProcessPacket ( if (!mIpSec2Installed) { goto ON_EXIT; } + ASSERT (mIpSec !=3D NULL); =20 Packet =3D *Netbuf; RecycleEvent =3D NULL; @@ -527,13 +528,6 @@ Ip4IpSecProcessPacket ( FragmentCount =3D Packet->BlockOpNum; =20 ZeroMem (&ZeroHead, sizeof (IP4_HEAD)); - =20 - if (mIpSec =3D=3D NULL) { - gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **) &mIpSec); - if (mIpSec =3D=3D NULL) { - goto ON_EXIT; - } - } =20 // // Check whether the IPsec enable variable is set. --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:25:34 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1504512435815443.4075861172656; Mon, 4 Sep 2017 01:07:15 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 13F1B21E3EA9B; Mon, 4 Sep 2017 01:04:23 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5E3AC21E3EA88 for ; Mon, 4 Sep 2017 01:04:21 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2017 01:07:08 -0700 Received: from sfu5-mobl.ccr.corp.intel.com ([10.239.193.124]) by fmsmga004.fm.intel.com with ESMTP; 04 Sep 2017 01:07:08 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,473,1498546800"; d="scan'208";a="307676241" From: Fu Siyuan To: edk2-devel@lists.01.org Date: Mon, 4 Sep 2017 16:07:02 +0800 Message-Id: <20170904080702.14488-3-siyuan.fu@intel.com> X-Mailer: git-send-email 2.13.0.windows.1 In-Reply-To: <20170904080702.14488-1-siyuan.fu@intel.com> References: <20170904080702.14488-1-siyuan.fu@intel.com> Subject: [edk2] [Patch 2/2] NetworkPkg/Ip6Dxe: fix a bug in IP6 driver for IpSec protocol notify. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The IP driver uses EfiCreateProtocolNotifyEvent() to register notify callba= ck function for IpSec protocol, but it didn't notice that the callback will al= ways be executed at least once, even the protocol wasn't in handle database. As a result, the Ip6IpSecProcessPacket() will still always call LocateProto= col() even the IpSec protocol is not installed, which will impact the network performance. Cc: Ye Ting Cc: Wu Jiaxin Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan --- NetworkPkg/Ip6Dxe/Ip6Driver.c | 18 ++++++++++++------ 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 8a8cc89..43af838 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. =20 - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
=20 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 =3D TRUE; + Status =3D gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, &mIpSec); + if (Status =3D=3D EFI_SUCCESS && mIpSec !=3D NULL) { + // + // Close the event so it does not get called again. + // + gBS->CloseEvent (Event); =20 - return; + mIpSec2Installed =3D TRUE; + } } =20 /** diff --git a/NetworkPkg/Ip6Dxe/Ip6Input.c b/NetworkPkg/Ip6Dxe/Ip6Input.c index e53e087..6aa5555 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Input.c +++ b/NetworkPkg/Ip6Dxe/Ip6Input.c @@ -1,7 +1,7 @@ /** @file IP6 internal functions to process the incoming packets. =20 - Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
=20 This program and the accompanying materials @@ -530,6 +530,7 @@ Ip6IpSecProcessPacket ( if (!mIpSec2Installed) { goto ON_EXIT; } + ASSERT (mIpSec !=3D NULL); =20 Packet =3D *Netbuf; RecycleEvent =3D NULL; @@ -541,17 +542,6 @@ Ip6IpSecProcessPacket ( FragmentCount =3D Packet->BlockOpNum; ZeroMem (&ZeroHead, sizeof (EFI_IP6_HEADER)); =20 - if (mIpSec =3D=3D NULL) { - gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **) &mIpSec); - - // - // Check whether the ipsec protocol is available. - // - if (mIpSec =3D=3D NULL) { - goto ON_EXIT; - } - } - // // Check whether the ipsec enable variable is set. // --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel