On Tue, Nov 03, 2015 at 04:13:27PM +0800, Zhang Lubo wrote:
> v2:
> *Rewrite the logic of setting ipv6 gateway in httpboot driver and update some 
> comment.
> 
> Fix a potential bug which can cause assert when setting ipv6 Gateway. If 
> there is no
> router in network environment, it will fail to find out the gateway address 
> which can
> route the message to Http Server Ip . When it check the IP6 route table again 
> 1 seconds
> later, it will assert while the router table structure had been freed last 
> time without
> retrieve new relevant data form ip6 driver.
> 
> Cc: Fu Siyuan <siyuan...@intel.com>
> Cc: Ye Ting <ting...@intel.com>
> CC: Wu Jiaxin <jiaxin...@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo <lubo.zh...@intel.com>
> ---
>  NetworkPkg/HttpBootDxe/HttpBootClient.c        |  234 ++++-
>  NetworkPkg/HttpBootDxe/HttpBootComponentName.c |    5 +-
>  NetworkPkg/HttpBootDxe/HttpBootDhcp4.c         |   12 +-
>  NetworkPkg/HttpBootDxe/HttpBootDhcp4.h         |   11 +
>  NetworkPkg/HttpBootDxe/HttpBootDhcp6.c         |  984 +++++++++++++++++++
>  NetworkPkg/HttpBootDxe/HttpBootDhcp6.h         |  198 ++++
>  NetworkPkg/HttpBootDxe/HttpBootDxe.c           |  903 +++++++++++++++---
>  NetworkPkg/HttpBootDxe/HttpBootDxe.h           |  159 +++-
>  NetworkPkg/HttpBootDxe/HttpBootDxe.inf         |    9 +
>  NetworkPkg/HttpBootDxe/HttpBootImpl.c          |  109 ++-
>  NetworkPkg/HttpBootDxe/HttpBootImpl.h          |    2 +-
>  NetworkPkg/HttpBootDxe/HttpBootSupport.c       |  292 +++++-
>  NetworkPkg/HttpBootDxe/HttpBootSupport.h       |   70 ++
>  NetworkPkg/HttpDxe/HttpDns.c                   |  207 +++-
>  NetworkPkg/HttpDxe/HttpDns.h                   |   20 +
>  NetworkPkg/HttpDxe/HttpDriver.c                |  806 +++++++++++-----
>  NetworkPkg/HttpDxe/HttpDriver.h                |  143 ++-
>  NetworkPkg/HttpDxe/HttpDxe.inf                 |    5 +
>  NetworkPkg/HttpDxe/HttpImpl.c                  |  358 +++----
>  NetworkPkg/HttpDxe/HttpImpl.h                  |    1 -
>  NetworkPkg/HttpDxe/HttpProto.c                 | 1210 
> ++++++++++++++++++++----
>  NetworkPkg/HttpDxe/HttpProto.h                 |  182 +++-
>  22 files changed, 5017 insertions(+), 903 deletions(-)
>  create mode 100644 NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
>  create mode 100644 NetworkPkg/HttpBootDxe/HttpBootDhcp6.h
> 
--8<--
> diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
> index 588e1bb..f5df660 100644
> --- a/NetworkPkg/HttpDxe/HttpImpl.c
> +++ b/NetworkPkg/HttpDxe/HttpImpl.c
--8<--
> @@ -377,28 +383,39 @@ EfiHttpRequest (
>      }
>    } 
>  
>    if (Configure) {
>      //
> -    // Parse Url for IPv4 address, if failed, perform DNS resolution.
> +    // Parse Url for IPv4 or IPv6 address, if failed, perform DNS resolution.
>      //
> -    Status = NetLibAsciiStrToIp4 (HostName, &HttpInstance->RemoteAddr);
> +    if (!HttpInstance->LocalAddressIsIPv6) {
> +      Status = NetLibAsciiStrToIp4 (HostName, &HttpInstance->RemoteAddr);
> +    } else {
> +      Status = NetLibAsciiStrToIp6 (HostName, &HttpInstance->RemoteIpv6Addr);
The 'HostName' shouldn't be passed to NetLibAsciiStrToIp6 directly since it
contains '[' and ']' and NetLibAsciiStrToIp6 doesn't expect that, and
HttpInitTcp() would complain that the IP address cannot be found.

Gary Lin

> +    }
> +
>      if (EFI_ERROR (Status)) {
> -      HostNameStr = AllocateZeroPool ((AsciiStrLen (HostName) + 1) * sizeof 
> (UINT16));
> +      HostNameStr = AllocateZeroPool ((AsciiStrLen (HostName) + 1) * sizeof 
> (CHAR16));
>        if (HostNameStr == NULL) {
>          Status = EFI_OUT_OF_RESOURCES;
>          goto Error1;
>        }
> -
> +      
>        AsciiStrToUnicodeStr (HostName, HostNameStr);
> -      Status = HttpDns4 (HttpInstance, HostNameStr, 
> &HttpInstance->RemoteAddr);
> +      if (!HttpInstance->LocalAddressIsIPv6) {
> +        Status = HttpDns4 (HttpInstance, HostNameStr, 
> &HttpInstance->RemoteAddr);
> +      } else {
> +        Status = HttpDns6 (HttpInstance, HostNameStr, 
> &HttpInstance->RemoteIpv6Addr);
> +      }
> +      
>        FreePool (HostNameStr);
>        if (EFI_ERROR (Status)) {
>          goto Error1;
>        }
>      }
>  
> +
>      //
>      // Save the RemotePort and RemoteHost.
>      //
>      ASSERT (HttpInstance->RemoteHost == NULL);
>      HttpInstance->RemotePort = RemotePort;

--8<--

 
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to