[PATCH 5/6] net: lwip: dhcp: Save DHCP siaddr field to tftpserverip env var

Jerome Forissier jerome.forissier at arm.com
Mon Jan 19 10:14:24 CET 2026


On 17/01/2026 01:24, Jonas Karlman wrote:
> The DHCP siaddr field contains the IP address of next server to use in
> bootstrap. Typically this will be the IP address of a TFTP server or the
> IP address of the DHCP server itself.
> 
> RFC 2131, 2. Protocol Summary, Page 10:
> 
>    DHCP clarifies the interpretation of the 'siaddr' field as the
>    address of the server to use in the next step of the client's
>    bootstrap process.  A DHCP server may return its own address in the
>    'siaddr' field, if the server is prepared to supply the next
>    bootstrap service (e.g., delivery of an operating system executable
>    image).  A DHCP server always returns its own address in the 'server
>    identifier' option.
> 
> Set the 'tftpserverip' env variable when the siaddr field contains an
> IP address that is different compared to the DHCP server IP address.
> 
> Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
> ---
>  net/lwip/dhcp.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/lwip/dhcp.c b/net/lwip/dhcp.c
> index 4cd4184c42bb..acdf601d7eb5 100644
> --- a/net/lwip/dhcp.c
> +++ b/net/lwip/dhcp.c
> @@ -101,6 +101,9 @@ static int dhcp_loop(struct udevice *udev)
>  	env_set("serverip", ip4addr_ntoa(&dhcp->server_ip_addr));
>  	if (!ip4_addr_isany(&dhcp->offered_gw_addr))
>  		env_set(gwstr, ip4addr_ntoa(&dhcp->offered_gw_addr));
> +	if (!ip4_addr_isany(&dhcp->offered_si_addr) &&
> +	    !ip4_addr_eq(&dhcp->offered_si_addr, &dhcp->server_ip_addr))
> +		env_set("tftpserverip", ip4addr_ntoa(&dhcp->offered_si_addr));
>  
>  #ifdef CONFIG_PROT_DNS_LWIP
>  	env_set("dnsip", ip4addr_ntoa(dns_getserver(0)));

Reviewed-by: Jerome Forissier <jerome.forissier at arm.com>

Thanks,
-- 
Jerome


More information about the U-Boot mailing list