* Re: [patch] NetworkPkg: Fix protocol handler service in HttpDxe.
2017-01-22 1:40 [patch] NetworkPkg: Fix protocol handler service in HttpDxe Zhang Lubo
@ 2017-01-22 2:41 ` Wu, Jiaxin
2017-01-22 4:49 ` Fu, Siyuan
2017-01-22 6:28 ` Subramanian, Sriram
2 siblings, 0 replies; 4+ messages in thread
From: Wu, Jiaxin @ 2017-01-22 2:41 UTC (permalink / raw)
To: Zhang, Lubo, edk2-devel@lists.01.org
Cc: Sriram Subramanian, Ye, Ting, Fu, Siyuan
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Thanks,
Jiaxin
> -----Original Message-----
> From: Zhang, Lubo
> Sent: Sunday, January 22, 2017 9:41 AM
> To: edk2-devel@lists.01.org
> Cc: Sriram Subramanian <sriram-s@hpe.com>; Ye, Ting <ting.ye@intel.com>;
> Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [patch] NetworkPkg: Fix protocol handler service in HttpDxe.
>
> When we create a HTTP driver service binding private
> instance, there may be different DriverBindingHandle
> for Ipv4 or Ipv6, so it is essential to distinguish
> the HttpService image which will be used in open
> protocol or close protocol.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
> Cc: Sriram Subramanian <sriram-s@hpe.com>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
> NetworkPkg/HttpDxe/HttpDns.c | 18 ++++++++--------
> NetworkPkg/HttpDxe/HttpDriver.c | 21 +++++++++---------
> NetworkPkg/HttpDxe/HttpImpl.c | 11 ++++++++--
> NetworkPkg/HttpDxe/HttpProto.c | 48 ++++++++++++++++++++-------------------
> --
> NetworkPkg/HttpDxe/HttpProto.h | 5 +++--
> 5 files changed, 55 insertions(+), 48 deletions(-)
>
> diff --git a/NetworkPkg/HttpDxe/HttpDns.c b/NetworkPkg/HttpDxe/HttpDns.c
> index 0f5fe18..59cd7b3 100644
> --- a/NetworkPkg/HttpDxe/HttpDns.c
> +++ b/NetworkPkg/HttpDxe/HttpDns.c
> @@ -1,9 +1,9 @@
> /** @file
> Routines for HttpDxe driver to perform DNS resolution based on UEFI DNS
> protocols.
>
> -Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2017, Intel Corporation. All rights reserved.<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
> http://opensource.org/licenses/bsd-license.php
>
> @@ -86,11 +86,11 @@ HttpDns4 (
> //
> // Create a DNS child instance and get the protocol.
> //
> Status = NetLibCreateServiceChild (
> Service->ControllerHandle,
> - Service->ImageHandle,
> + Service->Ip4DriverBindingHandle,
> &gEfiDns4ServiceBindingProtocolGuid,
> &Dns4Handle
> );
> if (EFI_ERROR (Status)) {
> goto Exit;
> @@ -98,11 +98,11 @@ HttpDns4 (
>
> Status = gBS->OpenProtocol (
> Dns4Handle,
> &gEfiDns4ProtocolGuid,
> (VOID **) &Dns4,
> - Service->ImageHandle,
> + Service->Ip4DriverBindingHandle,
> Service->ControllerHandle,
> EFI_OPEN_PROTOCOL_BY_DRIVER
> );
> if (EFI_ERROR (Status)) {
> goto Exit;
> @@ -194,19 +194,19 @@ Exit:
> Dns4->Configure (Dns4, NULL);
>
> gBS->CloseProtocol (
> Dns4Handle,
> &gEfiDns4ProtocolGuid,
> - Service->ImageHandle,
> + Service->Ip4DriverBindingHandle,
> Service->ControllerHandle
> );
> }
>
> if (Dns4Handle != NULL) {
> NetLibDestroyServiceChild (
> Service->ControllerHandle,
> - Service->ImageHandle,
> + Service->Ip4DriverBindingHandle,
> &gEfiDns4ServiceBindingProtocolGuid,
> Dns4Handle
> );
> }
>
> @@ -288,11 +288,11 @@ HttpDns6 (
> //
> // Create a DNSv6 child instance and get the protocol.
> //
> Status = NetLibCreateServiceChild (
> Service->ControllerHandle,
> - Service->ImageHandle,
> + Service->Ip6DriverBindingHandle,
> &gEfiDns6ServiceBindingProtocolGuid,
> &Dns6Handle
> );
> if (EFI_ERROR (Status)) {
> goto Exit;
> @@ -300,11 +300,11 @@ HttpDns6 (
>
> Status = gBS->OpenProtocol (
> Dns6Handle,
> &gEfiDns6ProtocolGuid,
> (VOID **) &Dns6,
> - Service->ImageHandle,
> + Service->Ip6DriverBindingHandle,
> Service->ControllerHandle,
> EFI_OPEN_PROTOCOL_BY_DRIVER
> );
> if (EFI_ERROR (Status)) {
> goto Exit;
> @@ -391,19 +391,19 @@ Exit:
> Dns6->Configure (Dns6, NULL);
>
> gBS->CloseProtocol (
> Dns6Handle,
> &gEfiDns6ProtocolGuid,
> - Service->ImageHandle,
> + Service->Ip6DriverBindingHandle,
> Service->ControllerHandle
> );
> }
>
> if (Dns6Handle != NULL) {
> NetLibDestroyServiceChild (
> Service->ControllerHandle,
> - Service->ImageHandle,
> + Service->Ip6DriverBindingHandle,
> &gEfiDns6ServiceBindingProtocolGuid,
> Dns6Handle
> );
> }
>
> diff --git a/NetworkPkg/HttpDxe/HttpDriver.c
> b/NetworkPkg/HttpDxe/HttpDriver.c
> index de27635..5727526 100644
> --- a/NetworkPkg/HttpDxe/HttpDriver.c
> +++ b/NetworkPkg/HttpDxe/HttpDriver.c
> @@ -1,9 +1,9 @@
> /** @file
> The driver binding and service binding protocol for HttpDxe driver.
>
> - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
> (C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
> @@ -43,21 +43,19 @@ EFI_DRIVER_BINDING_PROTOCOL
> gHttpDxeIp6DriverBinding = {
> /**
> Create a HTTP driver service binding private instance.
>
> @param[in] Controller The controller that has TCP4 service binding
> installed.
> - @param[in] ImageHandle The HTTP driver's image handle.
> @param[out] ServiceData Point to HTTP driver private instance.
>
> @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
> @retval EFI_SUCCESS A new HTTP driver private instance is created.
>
> **/
> EFI_STATUS
> HttpCreateService (
> IN EFI_HANDLE Controller,
> - IN EFI_HANDLE ImageHandle,
> OUT HTTP_SERVICE **ServiceData
> )
> {
> HTTP_SERVICE *HttpService;
>
> @@ -70,11 +68,10 @@ HttpCreateService (
> }
>
> HttpService->Signature = HTTP_SERVICE_SIGNATURE;
> HttpService->ServiceBinding.CreateChild = HttpServiceBindingCreateChild;
> HttpService->ServiceBinding.DestroyChild = HttpServiceBindingDestroyChild;
> - HttpService->ImageHandle = ImageHandle;
> HttpService->ControllerHandle = Controller;
> HttpService->ChildrenNumber = 0;
> InitializeListHead (&HttpService->ChildrenList);
>
> *ServiceData = HttpService;
> @@ -102,17 +99,17 @@ HttpCleanService (
> if (!UsingIpv6) {
> if (HttpService->Tcp4ChildHandle != NULL) {
> gBS->CloseProtocol (
> HttpService->Tcp4ChildHandle,
> &gEfiTcp4ProtocolGuid,
> - HttpService->ImageHandle,
> + HttpService->Ip4DriverBindingHandle,
> HttpService->ControllerHandle
> );
>
> NetLibDestroyServiceChild (
> HttpService->ControllerHandle,
> - HttpService->ImageHandle,
> + HttpService->Ip4DriverBindingHandle,
> &gEfiTcp4ServiceBindingProtocolGuid,
> HttpService->Tcp4ChildHandle
> );
>
> HttpService->Tcp4ChildHandle = NULL;
> @@ -120,17 +117,17 @@ HttpCleanService (
> } else {
> if (HttpService->Tcp6ChildHandle != NULL) {
> gBS->CloseProtocol (
> HttpService->Tcp6ChildHandle,
> &gEfiTcp6ProtocolGuid,
> - HttpService->ImageHandle,
> + HttpService->Ip6DriverBindingHandle,
> HttpService->ControllerHandle
> );
>
> NetLibDestroyServiceChild (
> HttpService->ControllerHandle,
> - HttpService->ImageHandle,
> + HttpService->Ip6DriverBindingHandle,
> &gEfiTcp6ServiceBindingProtocolGuid,
> HttpService->Tcp6ChildHandle
> );
>
> HttpService->Tcp6ChildHandle = NULL;
> @@ -380,11 +377,11 @@ HttpDxeStart (
> );
>
> if (!EFI_ERROR (Status)) {
> HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);
> } else {
> - Status = HttpCreateService (ControllerHandle, This->DriverBindingHandle,
> &HttpService);
> + Status = HttpCreateService (ControllerHandle, &HttpService);
> if (EFI_ERROR (Status)) {
> return Status;
> }
>
> ASSERT (HttpService != NULL);
> @@ -403,11 +400,12 @@ HttpDxeStart (
> goto ON_ERROR;
> }
> }
>
> if (IpVersion == IP_VERSION_4) {
> -
> + HttpService->Ip4DriverBindingHandle = This->DriverBindingHandle;
> +
> if (HttpService->Tcp4ChildHandle == NULL) {
> //
> // Create a TCP4 child instance, but do not configure it. This will establish
> the parent-child relationship.
> //
> Status = NetLibCreateServiceChild (
> @@ -438,11 +436,12 @@ HttpDxeStart (
> return EFI_ALREADY_STARTED;
> }
>
> } else {
> UsingIpv6 = TRUE;
> -
> + HttpService->Ip6DriverBindingHandle = This->DriverBindingHandle;
> +
> if (HttpService->Tcp6ChildHandle == NULL) {
> //
> // Create a TCP6 child instance, but do not configure it. This will establish
> the parent-child relationship.
> //
> Status = NetLibCreateServiceChild (
> diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
> index d19f733..bd8e0c0 100644
> --- a/NetworkPkg/HttpDxe/HttpImpl.c
> +++ b/NetworkPkg/HttpDxe/HttpImpl.c
> @@ -1,9 +1,9 @@
> /** @file
> Implementation of EFI_HTTP_PROTOCOL protocol interfaces.
>
> - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
> (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<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
> @@ -247,10 +247,11 @@ EfiHttpRequest (
> UINTN UrlLen;
> CHAR16 *HostNameStr;
> HTTP_TOKEN_WRAP *Wrap;
> CHAR8 *FileUrl;
> UINTN RequestMsgSize;
> + EFI_HANDLE ImageHandle;
>
> //
> // Initializations
> //
> Url = NULL;
> @@ -359,12 +360,18 @@ EfiHttpRequest (
> //
> if (HttpInstance->UseHttps && HttpInstance->TlsChildHandle == NULL) {
> //
> // Use TlsSb to create Tls child and open the TLS protocol.
> //
> + if (HttpInstance->LocalAddressIsIPv6) {
> + ImageHandle = HttpInstance->Service->Ip6DriverBindingHandle;
> + } else {
> + ImageHandle = HttpInstance->Service->Ip4DriverBindingHandle;
> + }
> +
> HttpInstance->TlsChildHandle = TlsCreateChild (
> - HttpInstance->Service->ImageHandle,
> + ImageHandle,
> &(HttpInstance->Tls),
> &(HttpInstance->TlsConfiguration)
> );
> if (HttpInstance->TlsChildHandle == NULL) {
> return EFI_DEVICE_ERROR;
> diff --git a/NetworkPkg/HttpDxe/HttpProto.c
> b/NetworkPkg/HttpDxe/HttpProto.c
> index 2e8c42e..3d61ba2 100644
> --- a/NetworkPkg/HttpDxe/HttpProto.c
> +++ b/NetworkPkg/HttpDxe/HttpProto.c
> @@ -640,11 +640,11 @@ HttpInitProtocol (
> //
> // Create TCP4 child.
> //
> Status = NetLibCreateServiceChild (
> HttpInstance->Service->ControllerHandle,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip4DriverBindingHandle,
> &gEfiTcp4ServiceBindingProtocolGuid,
> &HttpInstance->Tcp4ChildHandle
> );
>
> if (EFI_ERROR (Status)) {
> @@ -653,11 +653,11 @@ HttpInitProtocol (
>
> Status = gBS->OpenProtocol (
> HttpInstance->Tcp4ChildHandle,
> &gEfiTcp4ProtocolGuid,
> (VOID **) &Interface,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip4DriverBindingHandle,
> HttpInstance->Service->ControllerHandle,
> EFI_OPEN_PROTOCOL_BY_DRIVER
> );
>
> if (EFI_ERROR (Status)) {
> @@ -666,11 +666,11 @@ HttpInitProtocol (
>
> Status = gBS->OpenProtocol (
> HttpInstance->Tcp4ChildHandle,
> &gEfiTcp4ProtocolGuid,
> (VOID **) &HttpInstance->Tcp4,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip4DriverBindingHandle,
> HttpInstance->Handle,
> EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
> );
> if (EFI_ERROR(Status)) {
> goto ON_ERROR;
> @@ -678,11 +678,11 @@ HttpInitProtocol (
>
> Status = gBS->OpenProtocol (
> HttpInstance->Service->Tcp4ChildHandle,
> &gEfiTcp4ProtocolGuid,
> (VOID **) &Interface,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip4DriverBindingHandle,
> HttpInstance->Handle,
> EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
> );
> if (EFI_ERROR(Status)) {
> goto ON_ERROR;
> @@ -691,11 +691,11 @@ HttpInitProtocol (
> //
> // Create TCP6 Child.
> //
> Status = NetLibCreateServiceChild (
> HttpInstance->Service->ControllerHandle,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip6DriverBindingHandle,
> &gEfiTcp6ServiceBindingProtocolGuid,
> &HttpInstance->Tcp6ChildHandle
> );
>
> if (EFI_ERROR (Status)) {
> @@ -704,11 +704,11 @@ HttpInitProtocol (
>
> Status = gBS->OpenProtocol (
> HttpInstance->Tcp6ChildHandle,
> &gEfiTcp6ProtocolGuid,
> (VOID **) &Interface,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip6DriverBindingHandle,
> HttpInstance->Service->ControllerHandle,
> EFI_OPEN_PROTOCOL_BY_DRIVER
> );
>
> if (EFI_ERROR (Status)) {
> @@ -717,11 +717,11 @@ HttpInitProtocol (
>
> Status = gBS->OpenProtocol (
> HttpInstance->Tcp6ChildHandle,
> &gEfiTcp6ProtocolGuid,
> (VOID **) &HttpInstance->Tcp6,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip6DriverBindingHandle,
> HttpInstance->Handle,
> EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
> );
>
> if (EFI_ERROR(Status)) {
> @@ -730,11 +730,11 @@ HttpInitProtocol (
>
> Status = gBS->OpenProtocol (
> HttpInstance->Service->Tcp6ChildHandle,
> &gEfiTcp6ProtocolGuid,
> (VOID **) &Interface,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip6DriverBindingHandle,
> HttpInstance->Handle,
> EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
> );
>
> if (EFI_ERROR(Status)) {
> @@ -754,66 +754,66 @@ ON_ERROR:
>
> if (HttpInstance->Tcp4ChildHandle != NULL) {
> gBS->CloseProtocol (
> HttpInstance->Tcp4ChildHandle,
> &gEfiTcp4ProtocolGuid,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip4DriverBindingHandle,
> HttpInstance->Service->ControllerHandle
> );
>
> gBS->CloseProtocol (
> HttpInstance->Tcp4ChildHandle,
> &gEfiTcp4ProtocolGuid,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip4DriverBindingHandle,
> HttpInstance->Handle
> );
>
> NetLibDestroyServiceChild (
> HttpInstance->Service->ControllerHandle,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip4DriverBindingHandle,
> &gEfiTcp4ServiceBindingProtocolGuid,
> HttpInstance->Tcp4ChildHandle
> );
> }
>
> if (HttpInstance->Service->Tcp4ChildHandle != NULL) {
> gBS->CloseProtocol (
> HttpInstance->Service->Tcp4ChildHandle,
> &gEfiTcp4ProtocolGuid,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip4DriverBindingHandle,
> HttpInstance->Handle
> );
> }
>
> if (HttpInstance->Tcp6ChildHandle != NULL) {
> gBS->CloseProtocol (
> HttpInstance->Tcp6ChildHandle,
> &gEfiTcp6ProtocolGuid,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip6DriverBindingHandle,
> HttpInstance->Service->ControllerHandle
> );
>
> gBS->CloseProtocol (
> HttpInstance->Tcp6ChildHandle,
> &gEfiTcp6ProtocolGuid,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip6DriverBindingHandle,
> HttpInstance->Handle
> );
>
> NetLibDestroyServiceChild (
> HttpInstance->Service->ControllerHandle,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip6DriverBindingHandle,
> &gEfiTcp6ServiceBindingProtocolGuid,
> HttpInstance->Tcp6ChildHandle
> );
> }
>
> if (HttpInstance->Service->Tcp6ChildHandle != NULL) {
> gBS->CloseProtocol (
> HttpInstance->Service->Tcp6ChildHandle,
> &gEfiTcp6ProtocolGuid,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip6DriverBindingHandle,
> HttpInstance->Handle
> );
> }
>
> return EFI_UNSUPPORTED;
> @@ -866,66 +866,66 @@ HttpCleanProtocol (
>
> if (HttpInstance->Tcp4ChildHandle != NULL) {
> gBS->CloseProtocol (
> HttpInstance->Tcp4ChildHandle,
> &gEfiTcp4ProtocolGuid,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip4DriverBindingHandle,
> HttpInstance->Service->ControllerHandle
> );
>
> gBS->CloseProtocol (
> HttpInstance->Tcp4ChildHandle,
> &gEfiTcp4ProtocolGuid,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip4DriverBindingHandle,
> HttpInstance->Handle
> );
>
> NetLibDestroyServiceChild (
> HttpInstance->Service->ControllerHandle,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip4DriverBindingHandle,
> &gEfiTcp4ServiceBindingProtocolGuid,
> HttpInstance->Tcp4ChildHandle
> );
> }
>
> if (HttpInstance->Service->Tcp4ChildHandle != NULL) {
> gBS->CloseProtocol (
> HttpInstance->Service->Tcp4ChildHandle,
> &gEfiTcp4ProtocolGuid,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip4DriverBindingHandle,
> HttpInstance->Handle
> );
> }
>
> if (HttpInstance->Tcp6ChildHandle != NULL) {
> gBS->CloseProtocol (
> HttpInstance->Tcp6ChildHandle,
> &gEfiTcp6ProtocolGuid,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip6DriverBindingHandle,
> HttpInstance->Service->ControllerHandle
> );
>
> gBS->CloseProtocol (
> HttpInstance->Tcp6ChildHandle,
> &gEfiTcp6ProtocolGuid,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip6DriverBindingHandle,
> HttpInstance->Handle
> );
>
> NetLibDestroyServiceChild (
> HttpInstance->Service->ControllerHandle,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip6DriverBindingHandle,
> &gEfiTcp6ServiceBindingProtocolGuid,
> HttpInstance->Tcp6ChildHandle
> );
> }
>
> if (HttpInstance->Service->Tcp6ChildHandle != NULL) {
> gBS->CloseProtocol (
> HttpInstance->Service->Tcp6ChildHandle,
> &gEfiTcp6ProtocolGuid,
> - HttpInstance->Service->ImageHandle,
> + HttpInstance->Service->Ip6DriverBindingHandle,
> HttpInstance->Handle
> );
> }
>
> TlsCloseTxRxEvent (HttpInstance);
> diff --git a/NetworkPkg/HttpDxe/HttpProto.h
> b/NetworkPkg/HttpDxe/HttpProto.h
> index ced8aca..95fb484 100644
> --- a/NetworkPkg/HttpDxe/HttpProto.h
> +++ b/NetworkPkg/HttpDxe/HttpProto.h
> @@ -1,9 +1,9 @@
> /** @file
> The header files of miscellaneous routines for HttpDxe driver.
>
> -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
> (C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
> http://opensource.org/licenses/bsd-license.php
> @@ -57,11 +57,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
> #define HTTP_URL_BUFFER_LEN 4096
>
> typedef struct _HTTP_SERVICE {
> UINT32 Signature;
> EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
> - EFI_HANDLE ImageHandle;
> + EFI_HANDLE Ip4DriverBindingHandle;
> + EFI_HANDLE Ip6DriverBindingHandle;
> EFI_HANDLE ControllerHandle;
> EFI_HANDLE Tcp4ChildHandle;
> EFI_HANDLE Tcp6ChildHandle;
> LIST_ENTRY ChildrenList;
> UINTN ChildrenNumber;
> --
> 1.9.5.msysgit.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] NetworkPkg: Fix protocol handler service in HttpDxe.
2017-01-22 1:40 [patch] NetworkPkg: Fix protocol handler service in HttpDxe Zhang Lubo
2017-01-22 2:41 ` Wu, Jiaxin
@ 2017-01-22 4:49 ` Fu, Siyuan
2017-01-22 6:28 ` Subramanian, Sriram
2 siblings, 0 replies; 4+ messages in thread
From: Fu, Siyuan @ 2017-01-22 4:49 UTC (permalink / raw)
To: Zhang, Lubo, edk2-devel@lists.01.org
Cc: Sriram Subramanian, Ye, Ting, Wu, Jiaxin
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
-----Original Message-----
From: Zhang, Lubo
Sent: 2017年1月22日 9:41
To: edk2-devel@lists.01.org
Cc: Sriram Subramanian <sriram-s@hpe.com>; Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
Subject: [patch] NetworkPkg: Fix protocol handler service in HttpDxe.
When we create a HTTP driver service binding private instance, there may be different DriverBindingHandle for Ipv4 or Ipv6, so it is essential to distinguish the HttpService image which will be used in open protocol or close protocol.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Sriram Subramanian <sriram-s@hpe.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
---
NetworkPkg/HttpDxe/HttpDns.c | 18 ++++++++--------
NetworkPkg/HttpDxe/HttpDriver.c | 21 +++++++++---------
NetworkPkg/HttpDxe/HttpImpl.c | 11 ++++++++--
NetworkPkg/HttpDxe/HttpProto.c | 48 ++++++++++++++++++++---------------------
NetworkPkg/HttpDxe/HttpProto.h | 5 +++--
5 files changed, 55 insertions(+), 48 deletions(-)
diff --git a/NetworkPkg/HttpDxe/HttpDns.c b/NetworkPkg/HttpDxe/HttpDns.c index 0f5fe18..59cd7b3 100644
--- a/NetworkPkg/HttpDxe/HttpDns.c
+++ b/NetworkPkg/HttpDxe/HttpDns.c
@@ -1,9 +1,9 @@
/** @file
Routines for HttpDxe driver to perform DNS resolution based on UEFI DNS protocols.
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017, Intel Corporation. All rights reserved.<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 http://opensource.org/licenses/bsd-license.php
@@ -86,11 +86,11 @@ HttpDns4 (
//
// Create a DNS child instance and get the protocol.
//
Status = NetLibCreateServiceChild (
Service->ControllerHandle,
- Service->ImageHandle,
+ Service->Ip4DriverBindingHandle,
&gEfiDns4ServiceBindingProtocolGuid,
&Dns4Handle
);
if (EFI_ERROR (Status)) {
goto Exit;
@@ -98,11 +98,11 @@ HttpDns4 (
Status = gBS->OpenProtocol (
Dns4Handle,
&gEfiDns4ProtocolGuid,
(VOID **) &Dns4,
- Service->ImageHandle,
+ Service->Ip4DriverBindingHandle,
Service->ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
goto Exit;
@@ -194,19 +194,19 @@ Exit:
Dns4->Configure (Dns4, NULL);
gBS->CloseProtocol (
Dns4Handle,
&gEfiDns4ProtocolGuid,
- Service->ImageHandle,
+ Service->Ip4DriverBindingHandle,
Service->ControllerHandle
);
}
if (Dns4Handle != NULL) {
NetLibDestroyServiceChild (
Service->ControllerHandle,
- Service->ImageHandle,
+ Service->Ip4DriverBindingHandle,
&gEfiDns4ServiceBindingProtocolGuid,
Dns4Handle
);
}
@@ -288,11 +288,11 @@ HttpDns6 (
//
// Create a DNSv6 child instance and get the protocol.
//
Status = NetLibCreateServiceChild (
Service->ControllerHandle,
- Service->ImageHandle,
+ Service->Ip6DriverBindingHandle,
&gEfiDns6ServiceBindingProtocolGuid,
&Dns6Handle
);
if (EFI_ERROR (Status)) {
goto Exit;
@@ -300,11 +300,11 @@ HttpDns6 (
Status = gBS->OpenProtocol (
Dns6Handle,
&gEfiDns6ProtocolGuid,
(VOID **) &Dns6,
- Service->ImageHandle,
+ Service->Ip6DriverBindingHandle,
Service->ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
goto Exit;
@@ -391,19 +391,19 @@ Exit:
Dns6->Configure (Dns6, NULL);
gBS->CloseProtocol (
Dns6Handle,
&gEfiDns6ProtocolGuid,
- Service->ImageHandle,
+ Service->Ip6DriverBindingHandle,
Service->ControllerHandle
);
}
if (Dns6Handle != NULL) {
NetLibDestroyServiceChild (
Service->ControllerHandle,
- Service->ImageHandle,
+ Service->Ip6DriverBindingHandle,
&gEfiDns6ServiceBindingProtocolGuid,
Dns6Handle
);
}
diff --git a/NetworkPkg/HttpDxe/HttpDriver.c b/NetworkPkg/HttpDxe/HttpDriver.c index de27635..5727526 100644
--- a/NetworkPkg/HttpDxe/HttpDriver.c
+++ b/NetworkPkg/HttpDxe/HttpDriver.c
@@ -1,9 +1,9 @@
/** @file
The driver binding and service binding protocol for HttpDxe driver.
- Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2017, Intel Corporation. All rights
+ reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<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 @@ -43,21 +43,19 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp6DriverBinding = {
/**
Create a HTTP driver service binding private instance.
@param[in] Controller The controller that has TCP4 service binding
installed.
- @param[in] ImageHandle The HTTP driver's image handle.
@param[out] ServiceData Point to HTTP driver private instance.
@retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
@retval EFI_SUCCESS A new HTTP driver private instance is created.
**/
EFI_STATUS
HttpCreateService (
IN EFI_HANDLE Controller,
- IN EFI_HANDLE ImageHandle,
OUT HTTP_SERVICE **ServiceData
)
{
HTTP_SERVICE *HttpService;
@@ -70,11 +68,10 @@ HttpCreateService (
}
HttpService->Signature = HTTP_SERVICE_SIGNATURE;
HttpService->ServiceBinding.CreateChild = HttpServiceBindingCreateChild;
HttpService->ServiceBinding.DestroyChild = HttpServiceBindingDestroyChild;
- HttpService->ImageHandle = ImageHandle;
HttpService->ControllerHandle = Controller;
HttpService->ChildrenNumber = 0;
InitializeListHead (&HttpService->ChildrenList);
*ServiceData = HttpService;
@@ -102,17 +99,17 @@ HttpCleanService (
if (!UsingIpv6) {
if (HttpService->Tcp4ChildHandle != NULL) {
gBS->CloseProtocol (
HttpService->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpService->ImageHandle,
+ HttpService->Ip4DriverBindingHandle,
HttpService->ControllerHandle
);
NetLibDestroyServiceChild (
HttpService->ControllerHandle,
- HttpService->ImageHandle,
+ HttpService->Ip4DriverBindingHandle,
&gEfiTcp4ServiceBindingProtocolGuid,
HttpService->Tcp4ChildHandle
);
HttpService->Tcp4ChildHandle = NULL; @@ -120,17 +117,17 @@ HttpCleanService (
} else {
if (HttpService->Tcp6ChildHandle != NULL) {
gBS->CloseProtocol (
HttpService->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpService->ImageHandle,
+ HttpService->Ip6DriverBindingHandle,
HttpService->ControllerHandle
);
NetLibDestroyServiceChild (
HttpService->ControllerHandle,
- HttpService->ImageHandle,
+ HttpService->Ip6DriverBindingHandle,
&gEfiTcp6ServiceBindingProtocolGuid,
HttpService->Tcp6ChildHandle
);
HttpService->Tcp6ChildHandle = NULL; @@ -380,11 +377,11 @@ HttpDxeStart (
);
if (!EFI_ERROR (Status)) {
HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);
} else {
- Status = HttpCreateService (ControllerHandle, This->DriverBindingHandle, &HttpService);
+ Status = HttpCreateService (ControllerHandle, &HttpService);
if (EFI_ERROR (Status)) {
return Status;
}
ASSERT (HttpService != NULL);
@@ -403,11 +400,12 @@ HttpDxeStart (
goto ON_ERROR;
}
}
if (IpVersion == IP_VERSION_4) {
-
+ HttpService->Ip4DriverBindingHandle = This->DriverBindingHandle;
+
if (HttpService->Tcp4ChildHandle == NULL) {
//
// Create a TCP4 child instance, but do not configure it. This will establish the parent-child relationship.
//
Status = NetLibCreateServiceChild ( @@ -438,11 +436,12 @@ HttpDxeStart (
return EFI_ALREADY_STARTED;
}
} else {
UsingIpv6 = TRUE;
-
+ HttpService->Ip6DriverBindingHandle = This->DriverBindingHandle;
+
if (HttpService->Tcp6ChildHandle == NULL) {
//
// Create a TCP6 child instance, but do not configure it. This will establish the parent-child relationship.
//
Status = NetLibCreateServiceChild ( diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index d19f733..bd8e0c0 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -1,9 +1,9 @@
/** @file
Implementation of EFI_HTTP_PROTOCOL protocol interfaces.
- Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2017, Intel Corporation. All rights
+ reserved.<BR>
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<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 @@ -247,10 +247,11 @@ EfiHttpRequest (
UINTN UrlLen;
CHAR16 *HostNameStr;
HTTP_TOKEN_WRAP *Wrap;
CHAR8 *FileUrl;
UINTN RequestMsgSize;
+ EFI_HANDLE ImageHandle;
//
// Initializations
//
Url = NULL;
@@ -359,12 +360,18 @@ EfiHttpRequest (
//
if (HttpInstance->UseHttps && HttpInstance->TlsChildHandle == NULL) {
//
// Use TlsSb to create Tls child and open the TLS protocol.
//
+ if (HttpInstance->LocalAddressIsIPv6) {
+ ImageHandle = HttpInstance->Service->Ip6DriverBindingHandle;
+ } else {
+ ImageHandle = HttpInstance->Service->Ip4DriverBindingHandle;
+ }
+
HttpInstance->TlsChildHandle = TlsCreateChild (
- HttpInstance->Service->ImageHandle,
+ ImageHandle,
&(HttpInstance->Tls),
&(HttpInstance->TlsConfiguration)
);
if (HttpInstance->TlsChildHandle == NULL) {
return EFI_DEVICE_ERROR;
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c index 2e8c42e..3d61ba2 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -640,11 +640,11 @@ HttpInitProtocol (
//
// Create TCP4 child.
//
Status = NetLibCreateServiceChild (
HttpInstance->Service->ControllerHandle,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
&gEfiTcp4ServiceBindingProtocolGuid,
&HttpInstance->Tcp4ChildHandle
);
if (EFI_ERROR (Status)) {
@@ -653,11 +653,11 @@ HttpInitProtocol (
Status = gBS->OpenProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
(VOID **) &Interface,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Service->ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
@@ -666,11 +666,11 @@ HttpInitProtocol (
Status = gBS->OpenProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
(VOID **) &HttpInstance->Tcp4,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
if (EFI_ERROR(Status)) {
goto ON_ERROR;
@@ -678,11 +678,11 @@ HttpInitProtocol (
Status = gBS->OpenProtocol (
HttpInstance->Service->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
(VOID **) &Interface,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
if (EFI_ERROR(Status)) {
goto ON_ERROR;
@@ -691,11 +691,11 @@ HttpInitProtocol (
//
// Create TCP6 Child.
//
Status = NetLibCreateServiceChild (
HttpInstance->Service->ControllerHandle,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
&gEfiTcp6ServiceBindingProtocolGuid,
&HttpInstance->Tcp6ChildHandle
);
if (EFI_ERROR (Status)) {
@@ -704,11 +704,11 @@ HttpInitProtocol (
Status = gBS->OpenProtocol (
HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
(VOID **) &Interface,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Service->ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
@@ -717,11 +717,11 @@ HttpInitProtocol (
Status = gBS->OpenProtocol (
HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
(VOID **) &HttpInstance->Tcp6,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
if (EFI_ERROR(Status)) {
@@ -730,11 +730,11 @@ HttpInitProtocol (
Status = gBS->OpenProtocol (
HttpInstance->Service->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
(VOID **) &Interface,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
if (EFI_ERROR(Status)) {
@@ -754,66 +754,66 @@ ON_ERROR:
if (HttpInstance->Tcp4ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Service->ControllerHandle
);
gBS->CloseProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle
);
NetLibDestroyServiceChild (
HttpInstance->Service->ControllerHandle,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
&gEfiTcp4ServiceBindingProtocolGuid,
HttpInstance->Tcp4ChildHandle
);
}
if (HttpInstance->Service->Tcp4ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Service->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle
);
}
if (HttpInstance->Tcp6ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Service->ControllerHandle
);
gBS->CloseProtocol (
HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle
);
NetLibDestroyServiceChild (
HttpInstance->Service->ControllerHandle,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
&gEfiTcp6ServiceBindingProtocolGuid,
HttpInstance->Tcp6ChildHandle
);
}
if (HttpInstance->Service->Tcp6ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Service->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle
);
}
return EFI_UNSUPPORTED;
@@ -866,66 +866,66 @@ HttpCleanProtocol (
if (HttpInstance->Tcp4ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Service->ControllerHandle
);
gBS->CloseProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle
);
NetLibDestroyServiceChild (
HttpInstance->Service->ControllerHandle,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
&gEfiTcp4ServiceBindingProtocolGuid,
HttpInstance->Tcp4ChildHandle
);
}
if (HttpInstance->Service->Tcp4ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Service->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle
);
}
if (HttpInstance->Tcp6ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Service->ControllerHandle
);
gBS->CloseProtocol (
HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle
);
NetLibDestroyServiceChild (
HttpInstance->Service->ControllerHandle,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
&gEfiTcp6ServiceBindingProtocolGuid,
HttpInstance->Tcp6ChildHandle
);
}
if (HttpInstance->Service->Tcp6ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Service->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle
);
}
TlsCloseTxRxEvent (HttpInstance);
diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h index ced8aca..95fb484 100644
--- a/NetworkPkg/HttpDxe/HttpProto.h
+++ b/NetworkPkg/HttpDxe/HttpProto.h
@@ -1,9 +1,9 @@
/** @file
The header files of miscellaneous routines for HttpDxe driver.
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<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 http://opensource.org/licenses/bsd-license.php
@@ -57,11 +57,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define HTTP_URL_BUFFER_LEN 4096
typedef struct _HTTP_SERVICE {
UINT32 Signature;
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
- EFI_HANDLE ImageHandle;
+ EFI_HANDLE Ip4DriverBindingHandle;
+ EFI_HANDLE Ip6DriverBindingHandle;
EFI_HANDLE ControllerHandle;
EFI_HANDLE Tcp4ChildHandle;
EFI_HANDLE Tcp6ChildHandle;
LIST_ENTRY ChildrenList;
UINTN ChildrenNumber;
--
1.9.5.msysgit.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] NetworkPkg: Fix protocol handler service in HttpDxe.
2017-01-22 1:40 [patch] NetworkPkg: Fix protocol handler service in HttpDxe Zhang Lubo
2017-01-22 2:41 ` Wu, Jiaxin
2017-01-22 4:49 ` Fu, Siyuan
@ 2017-01-22 6:28 ` Subramanian, Sriram
2 siblings, 0 replies; 4+ messages in thread
From: Subramanian, Sriram @ 2017-01-22 6:28 UTC (permalink / raw)
To: Zhang Lubo, edk2-devel@lists.01.org; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Tested-by: Sriram Subramanian <sriram-s@hpe.com>
-----Original Message-----
From: Zhang Lubo [mailto:lubo.zhang@intel.com]
Sent: Sunday, January 22, 2017 7:11 AM
To: edk2-devel@lists.01.org
Cc: Subramanian, Sriram <sriram-s@hpe.com>; Ye Ting <ting.ye@intel.com>; Fu Siyuan <siyuan.fu@intel.com>; Wu Jiaxin <jiaxin.wu@intel.com>
Subject: [patch] NetworkPkg: Fix protocol handler service in HttpDxe.
When we create a HTTP driver service binding private
instance, there may be different DriverBindingHandle
for Ipv4 or Ipv6, so it is essential to distinguish
the HttpService image which will be used in open
protocol or close protocol.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Sriram Subramanian <sriram-s@hpe.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
---
NetworkPkg/HttpDxe/HttpDns.c | 18 ++++++++--------
NetworkPkg/HttpDxe/HttpDriver.c | 21 +++++++++---------
NetworkPkg/HttpDxe/HttpImpl.c | 11 ++++++++--
NetworkPkg/HttpDxe/HttpProto.c | 48 ++++++++++++++++++++---------------------
NetworkPkg/HttpDxe/HttpProto.h | 5 +++--
5 files changed, 55 insertions(+), 48 deletions(-)
diff --git a/NetworkPkg/HttpDxe/HttpDns.c b/NetworkPkg/HttpDxe/HttpDns.c
index 0f5fe18..59cd7b3 100644
--- a/NetworkPkg/HttpDxe/HttpDns.c
+++ b/NetworkPkg/HttpDxe/HttpDns.c
@@ -1,9 +1,9 @@
/** @file
Routines for HttpDxe driver to perform DNS resolution based on UEFI DNS protocols.
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017, Intel Corporation. All rights reserved.<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
http://opensource.org/licenses/bsd-license.php
@@ -86,11 +86,11 @@ HttpDns4 (
//
// Create a DNS child instance and get the protocol.
//
Status = NetLibCreateServiceChild (
Service->ControllerHandle,
- Service->ImageHandle,
+ Service->Ip4DriverBindingHandle,
&gEfiDns4ServiceBindingProtocolGuid,
&Dns4Handle
);
if (EFI_ERROR (Status)) {
goto Exit;
@@ -98,11 +98,11 @@ HttpDns4 (
Status = gBS->OpenProtocol (
Dns4Handle,
&gEfiDns4ProtocolGuid,
(VOID **) &Dns4,
- Service->ImageHandle,
+ Service->Ip4DriverBindingHandle,
Service->ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
goto Exit;
@@ -194,19 +194,19 @@ Exit:
Dns4->Configure (Dns4, NULL);
gBS->CloseProtocol (
Dns4Handle,
&gEfiDns4ProtocolGuid,
- Service->ImageHandle,
+ Service->Ip4DriverBindingHandle,
Service->ControllerHandle
);
}
if (Dns4Handle != NULL) {
NetLibDestroyServiceChild (
Service->ControllerHandle,
- Service->ImageHandle,
+ Service->Ip4DriverBindingHandle,
&gEfiDns4ServiceBindingProtocolGuid,
Dns4Handle
);
}
@@ -288,11 +288,11 @@ HttpDns6 (
//
// Create a DNSv6 child instance and get the protocol.
//
Status = NetLibCreateServiceChild (
Service->ControllerHandle,
- Service->ImageHandle,
+ Service->Ip6DriverBindingHandle,
&gEfiDns6ServiceBindingProtocolGuid,
&Dns6Handle
);
if (EFI_ERROR (Status)) {
goto Exit;
@@ -300,11 +300,11 @@ HttpDns6 (
Status = gBS->OpenProtocol (
Dns6Handle,
&gEfiDns6ProtocolGuid,
(VOID **) &Dns6,
- Service->ImageHandle,
+ Service->Ip6DriverBindingHandle,
Service->ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
goto Exit;
@@ -391,19 +391,19 @@ Exit:
Dns6->Configure (Dns6, NULL);
gBS->CloseProtocol (
Dns6Handle,
&gEfiDns6ProtocolGuid,
- Service->ImageHandle,
+ Service->Ip6DriverBindingHandle,
Service->ControllerHandle
);
}
if (Dns6Handle != NULL) {
NetLibDestroyServiceChild (
Service->ControllerHandle,
- Service->ImageHandle,
+ Service->Ip6DriverBindingHandle,
&gEfiDns6ServiceBindingProtocolGuid,
Dns6Handle
);
}
diff --git a/NetworkPkg/HttpDxe/HttpDriver.c b/NetworkPkg/HttpDxe/HttpDriver.c
index de27635..5727526 100644
--- a/NetworkPkg/HttpDxe/HttpDriver.c
+++ b/NetworkPkg/HttpDxe/HttpDriver.c
@@ -1,9 +1,9 @@
/** @file
The driver binding and service binding protocol for HttpDxe driver.
- Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
@@ -43,21 +43,19 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp6DriverBinding = {
/**
Create a HTTP driver service binding private instance.
@param[in] Controller The controller that has TCP4 service binding
installed.
- @param[in] ImageHandle The HTTP driver's image handle.
@param[out] ServiceData Point to HTTP driver private instance.
@retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
@retval EFI_SUCCESS A new HTTP driver private instance is created.
**/
EFI_STATUS
HttpCreateService (
IN EFI_HANDLE Controller,
- IN EFI_HANDLE ImageHandle,
OUT HTTP_SERVICE **ServiceData
)
{
HTTP_SERVICE *HttpService;
@@ -70,11 +68,10 @@ HttpCreateService (
}
HttpService->Signature = HTTP_SERVICE_SIGNATURE;
HttpService->ServiceBinding.CreateChild = HttpServiceBindingCreateChild;
HttpService->ServiceBinding.DestroyChild = HttpServiceBindingDestroyChild;
- HttpService->ImageHandle = ImageHandle;
HttpService->ControllerHandle = Controller;
HttpService->ChildrenNumber = 0;
InitializeListHead (&HttpService->ChildrenList);
*ServiceData = HttpService;
@@ -102,17 +99,17 @@ HttpCleanService (
if (!UsingIpv6) {
if (HttpService->Tcp4ChildHandle != NULL) {
gBS->CloseProtocol (
HttpService->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpService->ImageHandle,
+ HttpService->Ip4DriverBindingHandle,
HttpService->ControllerHandle
);
NetLibDestroyServiceChild (
HttpService->ControllerHandle,
- HttpService->ImageHandle,
+ HttpService->Ip4DriverBindingHandle,
&gEfiTcp4ServiceBindingProtocolGuid,
HttpService->Tcp4ChildHandle
);
HttpService->Tcp4ChildHandle = NULL;
@@ -120,17 +117,17 @@ HttpCleanService (
} else {
if (HttpService->Tcp6ChildHandle != NULL) {
gBS->CloseProtocol (
HttpService->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpService->ImageHandle,
+ HttpService->Ip6DriverBindingHandle,
HttpService->ControllerHandle
);
NetLibDestroyServiceChild (
HttpService->ControllerHandle,
- HttpService->ImageHandle,
+ HttpService->Ip6DriverBindingHandle,
&gEfiTcp6ServiceBindingProtocolGuid,
HttpService->Tcp6ChildHandle
);
HttpService->Tcp6ChildHandle = NULL;
@@ -380,11 +377,11 @@ HttpDxeStart (
);
if (!EFI_ERROR (Status)) {
HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);
} else {
- Status = HttpCreateService (ControllerHandle, This->DriverBindingHandle, &HttpService);
+ Status = HttpCreateService (ControllerHandle, &HttpService);
if (EFI_ERROR (Status)) {
return Status;
}
ASSERT (HttpService != NULL);
@@ -403,11 +400,12 @@ HttpDxeStart (
goto ON_ERROR;
}
}
if (IpVersion == IP_VERSION_4) {
-
+ HttpService->Ip4DriverBindingHandle = This->DriverBindingHandle;
+
if (HttpService->Tcp4ChildHandle == NULL) {
//
// Create a TCP4 child instance, but do not configure it. This will establish the parent-child relationship.
//
Status = NetLibCreateServiceChild (
@@ -438,11 +436,12 @@ HttpDxeStart (
return EFI_ALREADY_STARTED;
}
} else {
UsingIpv6 = TRUE;
-
+ HttpService->Ip6DriverBindingHandle = This->DriverBindingHandle;
+
if (HttpService->Tcp6ChildHandle == NULL) {
//
// Create a TCP6 child instance, but do not configure it. This will establish the parent-child relationship.
//
Status = NetLibCreateServiceChild (
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index d19f733..bd8e0c0 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -1,9 +1,9 @@
/** @file
Implementation of EFI_HTTP_PROTOCOL protocol interfaces.
- Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<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
@@ -247,10 +247,11 @@ EfiHttpRequest (
UINTN UrlLen;
CHAR16 *HostNameStr;
HTTP_TOKEN_WRAP *Wrap;
CHAR8 *FileUrl;
UINTN RequestMsgSize;
+ EFI_HANDLE ImageHandle;
//
// Initializations
//
Url = NULL;
@@ -359,12 +360,18 @@ EfiHttpRequest (
//
if (HttpInstance->UseHttps && HttpInstance->TlsChildHandle == NULL) {
//
// Use TlsSb to create Tls child and open the TLS protocol.
//
+ if (HttpInstance->LocalAddressIsIPv6) {
+ ImageHandle = HttpInstance->Service->Ip6DriverBindingHandle;
+ } else {
+ ImageHandle = HttpInstance->Service->Ip4DriverBindingHandle;
+ }
+
HttpInstance->TlsChildHandle = TlsCreateChild (
- HttpInstance->Service->ImageHandle,
+ ImageHandle,
&(HttpInstance->Tls),
&(HttpInstance->TlsConfiguration)
);
if (HttpInstance->TlsChildHandle == NULL) {
return EFI_DEVICE_ERROR;
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c
index 2e8c42e..3d61ba2 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -640,11 +640,11 @@ HttpInitProtocol (
//
// Create TCP4 child.
//
Status = NetLibCreateServiceChild (
HttpInstance->Service->ControllerHandle,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
&gEfiTcp4ServiceBindingProtocolGuid,
&HttpInstance->Tcp4ChildHandle
);
if (EFI_ERROR (Status)) {
@@ -653,11 +653,11 @@ HttpInitProtocol (
Status = gBS->OpenProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
(VOID **) &Interface,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Service->ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
@@ -666,11 +666,11 @@ HttpInitProtocol (
Status = gBS->OpenProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
(VOID **) &HttpInstance->Tcp4,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
if (EFI_ERROR(Status)) {
goto ON_ERROR;
@@ -678,11 +678,11 @@ HttpInitProtocol (
Status = gBS->OpenProtocol (
HttpInstance->Service->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
(VOID **) &Interface,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
if (EFI_ERROR(Status)) {
goto ON_ERROR;
@@ -691,11 +691,11 @@ HttpInitProtocol (
//
// Create TCP6 Child.
//
Status = NetLibCreateServiceChild (
HttpInstance->Service->ControllerHandle,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
&gEfiTcp6ServiceBindingProtocolGuid,
&HttpInstance->Tcp6ChildHandle
);
if (EFI_ERROR (Status)) {
@@ -704,11 +704,11 @@ HttpInitProtocol (
Status = gBS->OpenProtocol (
HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
(VOID **) &Interface,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Service->ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
@@ -717,11 +717,11 @@ HttpInitProtocol (
Status = gBS->OpenProtocol (
HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
(VOID **) &HttpInstance->Tcp6,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
if (EFI_ERROR(Status)) {
@@ -730,11 +730,11 @@ HttpInitProtocol (
Status = gBS->OpenProtocol (
HttpInstance->Service->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
(VOID **) &Interface,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
if (EFI_ERROR(Status)) {
@@ -754,66 +754,66 @@ ON_ERROR:
if (HttpInstance->Tcp4ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Service->ControllerHandle
);
gBS->CloseProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle
);
NetLibDestroyServiceChild (
HttpInstance->Service->ControllerHandle,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
&gEfiTcp4ServiceBindingProtocolGuid,
HttpInstance->Tcp4ChildHandle
);
}
if (HttpInstance->Service->Tcp4ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Service->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle
);
}
if (HttpInstance->Tcp6ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Service->ControllerHandle
);
gBS->CloseProtocol (
HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle
);
NetLibDestroyServiceChild (
HttpInstance->Service->ControllerHandle,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
&gEfiTcp6ServiceBindingProtocolGuid,
HttpInstance->Tcp6ChildHandle
);
}
if (HttpInstance->Service->Tcp6ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Service->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle
);
}
return EFI_UNSUPPORTED;
@@ -866,66 +866,66 @@ HttpCleanProtocol (
if (HttpInstance->Tcp4ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Service->ControllerHandle
);
gBS->CloseProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle
);
NetLibDestroyServiceChild (
HttpInstance->Service->ControllerHandle,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
&gEfiTcp4ServiceBindingProtocolGuid,
HttpInstance->Tcp4ChildHandle
);
}
if (HttpInstance->Service->Tcp4ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Service->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle
);
}
if (HttpInstance->Tcp6ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Service->ControllerHandle
);
gBS->CloseProtocol (
HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle
);
NetLibDestroyServiceChild (
HttpInstance->Service->ControllerHandle,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
&gEfiTcp6ServiceBindingProtocolGuid,
HttpInstance->Tcp6ChildHandle
);
}
if (HttpInstance->Service->Tcp6ChildHandle != NULL) {
gBS->CloseProtocol (
HttpInstance->Service->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid,
- HttpInstance->Service->ImageHandle,
+ HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle
);
}
TlsCloseTxRxEvent (HttpInstance);
diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h
index ced8aca..95fb484 100644
--- a/NetworkPkg/HttpDxe/HttpProto.h
+++ b/NetworkPkg/HttpDxe/HttpProto.h
@@ -1,9 +1,9 @@
/** @file
The header files of miscellaneous routines for HttpDxe driver.
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
http://opensource.org/licenses/bsd-license.php
@@ -57,11 +57,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define HTTP_URL_BUFFER_LEN 4096
typedef struct _HTTP_SERVICE {
UINT32 Signature;
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
- EFI_HANDLE ImageHandle;
+ EFI_HANDLE Ip4DriverBindingHandle;
+ EFI_HANDLE Ip6DriverBindingHandle;
EFI_HANDLE ControllerHandle;
EFI_HANDLE Tcp4ChildHandle;
EFI_HANDLE Tcp6ChildHandle;
LIST_ENTRY ChildrenList;
UINTN ChildrenNumber;
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 4+ messages in thread