]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Enforce a minimum lease of 20 seconds so we can do things
authorRoy Marples <roy@marples.name>
Wed, 13 May 2009 18:14:50 +0000 (18:14 +0000)
committerRoy Marples <roy@marples.name>
Wed, 13 May 2009 18:14:50 +0000 (18:14 +0000)
like ARP check and restart services.

bind.c

diff --git a/bind.c b/bind.c
index 9e97a4310fd8def722eae7d72d95ed4f7af56c3c..b428b881a31d439b5605627f5755072ee44a8955 100644 (file)
--- a/bind.c
+++ b/bind.c
@@ -49,6 +49,9 @@
 #  define _PATH_DEVNULL "/dev/null"
 #endif
 
+/* We do things after aquiring the lease, so ensure we have enough time for them */
+#define DHCP_MIN_LEASE 20
+
 #ifndef THERE_IS_NO_FORK
 pid_t
 daemonise(void)
@@ -164,6 +167,12 @@ bind_interface(void *arg)
                        syslog(LOG_INFO, "%s: leased %s for infinity",
                            iface->name, inet_ntoa(lease->addr));
                } else {
+                       if (lease->leasetime < DHCP_MIN_LEASE) {
+                               syslog(LOG_WARNING,
+                                   "%s: minimum lease is %d seconds",
+                                   iface->name, DHCP_MIN_LEASE);
+                               lease->leasetime = DHCP_MIN_LEASE;
+                       }
                        if (lease->rebindtime == 0)
                                lease->rebindtime = lease->leasetime * T2;
                        else if (lease->rebindtime >= lease->leasetime) {