[PATCH 5/6] net: lwip: wget: initialize dns if a hostname is used in a URL

Jerome Forissier jerome.forissier at linaro.org
Fri May 30 10:06:56 CEST 2025


On 5/29/25 23:49, Tim Harvey wrote:
> Initialize dns servers if a hostname (vs ipaddr) is used in a URL.
> Otherwise the wget will fail without displaying an error due to
> dns_gethostbyname failing silently when no DNS servers are set unless
> you have previously performed a 'dns <arg>' command.

Ha! I think I did not notice this issue because I always used DHCP,
which populates the DNS servers internally in the lwIP stack.
That sounds reasonable.

> 
> Signed-off-by: Tim Harvey <tharvey at gateworks.com>
> ---
>  net/lwip/wget.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/net/lwip/wget.c b/net/lwip/wget.c
> index ea1113e18b11..76401991bde6 100644
> --- a/net/lwip/wget.c
> +++ b/net/lwip/wget.c
> @@ -460,6 +460,10 @@ int wget_do_request(ulong dst_addr, char *uri)
>  	if (!netif)
>  		return -1;
>  
> +	/* if URL with hostname init dns */
> +	if (!ipaddr_aton(ctx.server_name, NULL) && net_lwip_dns_init())
> +		return CMD_RET_FAILURE;
> +
>  	memset(&conn, 0, sizeof(conn));
>  #if CONFIG_IS_ENABLED(WGET_HTTPS)
>  	if (is_https) {

Acked-by: Jerome Forissier <jerome.forissier at linaro.org>

Thanks,
-- 
Jerome


More information about the U-Boot mailing list