[PATCH] udhcpd: keep expired leases at startup

Denys Vlasenko vda.linux at googlemail.com
Tue Mar 1 18:24:20 UTC 2016


Applied in a simplified form, without config option. Thanks.

On Thu, Feb 18, 2016 at 12:10 PM, Christian Lindeberg
<christian.lindeberg at axis.com> wrote:
> Let udhcpd retain the information about expired leases when restarting
> so that the leases are reserved until they possibly become the oldest
> expired lease.
>
> This reduces the frequency of IP address changes for example when the
> DHCP server and a group of clients, who do not store and request their
> previously offered IP address across restarts, are collectively restarted
> and the startup order of the clients are not guaranteed.
>
> Signed-off-by: Christian Lindeberg <christian.lindeberg at axis.com>
> ---
>  networking/udhcp/Config.src |   12 ++++++++++++
>  networking/udhcp/files.c    |    4 ++++
>  2 files changed, 16 insertions(+)
>
> diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src
> index c34c8d6f08ce63e51b13a035e30f5985009ddd57..5111c207c6f7adf2b449975f4b2119fe1d459cfc 100644
> --- a/networking/udhcp/Config.src
> +++ b/networking/udhcp/Config.src
> @@ -55,6 +55,18 @@ config FEATURE_UDHCPD_BASE_IP_ON_MAC
>           for the same client to (almost always) contain the same
>           IP address.
>
> +config FEATURE_UDHCPD_KEEP_EXPIRED_LEASES
> +       bool "Keep expired leases at startup"
> +       default n
> +       depends on UDHCPD
> +       help
> +         If selected, udhcpd will retain the information about expired
> +         leases when restarting.
> +
> +         This reduces the frequency of IP address changes and makes
> +         consecutive DHCPOFFERS for the same client to (almost always)
> +         contain the same IP address.
> +
>  config DHCPD_LEASES_FILE
>         string "Absolute path to lease file"
>         default "/var/lib/misc/udhcpd.leases"
> diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
> index 1c8808c0f1fcc911c54ec093421eb535a820c48d..18d4613df4d29ded6acd83f2188fb806057315af 100644
> --- a/networking/udhcp/files.c
> +++ b/networking/udhcp/files.c
> @@ -195,7 +195,11 @@ void FAST_FUNC read_leases(const char *file)
>                         uint32_t static_nip;
>
>                         if (expires <= 0)
> +#if ENABLE_FEATURE_UDHCPD_KEEP_EXPIRED_LEASES
> +                               expires = 0;
> +#else
>                                 continue;
> +#endif
>
>                         /* Check if there is a different static lease for this IP or MAC */
>                         static_nip = get_static_nip_by_mac(server_config.static_leases, lease.lease_mac);
> --
> 1.7.10.4
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list