aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/leases.c
diff options
context:
space:
mode:
authorChristian Lindeberg <christian.lindeberg@axis.com>2016-03-01 19:23:22 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2016-03-01 19:23:22 +0100
commitea2b71be66b7500cc3ddaa0f617491610ff07dc4 (patch)
tree14d5c499eda33b727a265f996e5f8c0d78e0295c /networking/udhcp/leases.c
parente5aba8871254d411766b9d04d89dcff4ded21e76 (diff)
downloadbusybox-w32-ea2b71be66b7500cc3ddaa0f617491610ff07dc4.tar.gz
busybox-w32-ea2b71be66b7500cc3ddaa0f617491610ff07dc4.tar.bz2
busybox-w32-ea2b71be66b7500cc3ddaa0f617491610ff07dc4.zip
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 <christian.lindeberg@axis.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/leases.c')
-rw-r--r--networking/udhcp/leases.c4
1 files changed, 3 insertions, 1 deletions
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)
17 /* Unexpired leases have g_leases[i].expires >= current time 17 /* Unexpired leases have g_leases[i].expires >= current time
18 * and therefore can't ever match */ 18 * and therefore can't ever match */
19 for (i = 0; i < server_config.max_leases; i++) { 19 for (i = 0; i < server_config.max_leases; i++) {
20 if (g_leases[i].expires < oldest_time) { 20 if (g_leases[i].expires == 0 /* empty entry */
21 || g_leases[i].expires < oldest_time
22 ) {
21 oldest_time = g_leases[i].expires; 23 oldest_time = g_leases[i].expires;
22 oldest_lease = &g_leases[i]; 24 oldest_lease = &g_leases[i];
23 } 25 }