Applied, thanks!

Joan Lledó, le mar. 29 juil. 2025 17:52:44 +0200, a ecrit:
> From: Joan Lledó <[email protected]>
> 
> After DHCPRELEASE, DHCP client sends a SIOCSIFADDR to set the
> interface address to 0.0.0.0. This is not accepted by our IP
> validator `ipv4config_is_valid()`. I think this use case is legit
> so this commit makes the translator accept 0.0.0.0 as a valid address.
> This assumes that a client trying to set IP to 0.0.0.0 is in fact trying
> to remove the IP from the interface. Then it sets all fields to NONE, in
> order to pass the validation.
> 
> * lwip/lwip-util.c: `configure_device`: Add the exception for 0.0.0.0
>   and 255.255.255.255.
> ---
>  lwip/lwip-util.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/lwip/lwip-util.c b/lwip/lwip-util.c
> index 77d2c233..eff15137 100644
> --- a/lwip/lwip-util.c
> +++ b/lwip/lwip-util.c
> @@ -333,6 +333,19 @@ configure_device (struct netif *netif, uint32_t addr, 
> uint32_t netmask,
>  {
>    error_t err = 0;
>  
> +  /*
> +   * The caller is trying to set an invalid address,
> +   * set all fields to empty so it passes the validation
> +   */
> +  if (addr == INADDR_ANY || addr == INADDR_NONE)
> +    {
> +      addr = INADDR_NONE;
> +      netmask = INADDR_NONE;
> +      peer = INADDR_NONE;
> +      broadcast = INADDR_NONE;
> +      gateway = INADDR_NONE;
> +    }
> +
>    if (netmask != INADDR_NONE)
>      /*
>       * If broadcasting is enabled and we have a netmask lesser than 31 bits
> -- 
> 2.47.2
> 
> 

Reply via email to