Hi Jonas,

On 16/01/2026 10:28, Jonas Karlman wrote:
> I took a closer look at how the UniFi dnsmasq config was generated and
> noticed that I must configure the "Network Boot" option and not the
> "TFTP Server" option to have a generated config that make dnsmasq
> replace the DHCP siaddr field with the TFTP server ip :-S
> 
> And legacy stack seem to work as expected and correctly uses the
> expected siaddr field to configure the internal net_server_ip var.
> 
> Following diff seem to make lwIP also pick up the siaddr as the
> tftpserverip (in addition to serverip for the DHCP server):
> 
> diff --git a/net/lwip/dhcp.c b/net/lwip/dhcp.c
> index 731b57de3ba4..a3445a48b15d 100644
> --- a/net/lwip/dhcp.c
> +++ b/net/lwip/dhcp.c
> @@ -99,8 +99,11 @@ static int dhcp_loop(struct udevice *udev)
>         env_set(ipstr, ip4addr_ntoa(&dhcp->offered_ip_addr));
>         env_set(maskstr, ip4addr_ntoa(&dhcp->offered_sn_mask));
>         env_set("serverip", ip4addr_ntoa(&dhcp->server_ip_addr));
> -       if (dhcp->offered_gw_addr.addr != 0)
> +       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)));
> 
> With something like that I do not think I will have any further use of
> SERVERIP or TFTPSERVERIP Kconfig options for my labgrid farm, so can
> probably drop this series and will instead send above diff as a separate
> patch.

Sounds good to me.

Regards,
-- 
Jerome

Reply via email to