From ea2b71be66b7500cc3ddaa0f617491610ff07dc4 Mon Sep 17 00:00:00 2001 From: Christian Lindeberg Date: Tue, 1 Mar 2016 19:23:22 +0100 Subject: udhcpd: keep expired leases at startup 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 Signed-off-by: Denys Vlasenko --- networking/udhcp/leases.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'networking/udhcp/leases.c') diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c index 844bb60b1..411b74962 100644 --- a/networking/udhcp/leases.c +++ b/networking/udhcp/leases.c @@ -17,7 +17,9 @@ static struct dyn_lease *oldest_expired_lease(void) /* Unexpired leases have g_leases[i].expires >= current time * and therefore can't ever match */ for (i = 0; i < server_config.max_leases; i++) { - if (g_leases[i].expires < oldest_time) { + if (g_leases[i].expires == 0 /* empty entry */ + || g_leases[i].expires < oldest_time + ) { oldest_time = g_leases[i].expires; oldest_lease = &g_leases[i]; } -- cgit v1.2.3