]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
Fix corner case with dhcp timeouts
authorHenrik Persson <henrik.persson@securitas-direct.com>
Wed, 5 Sep 2012 12:16:45 +0000 (14:16 +0200)
committergoldsimon <goldsimon@gmx.de>
Wed, 26 Sep 2012 19:25:04 +0000 (21:25 +0200)
If t1 >= t2 timeout then only t2 timer should be scheduled. This can happen
when a sub 1 minute lease is received.

src/core/dhcp.c

index 932165743b9fd5e8b594ef3dddffebfd82f3ddf1..dd55bbcb0f766326d851176e73f12f47d15ace91 100644 (file)
@@ -960,6 +960,11 @@ dhcp_bind(struct netif *netif)
     LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t2_rebind*1000));
   }
 
+  /* If we have sub 1 minute lease, t2 and t1 will kick in at the same time. */\r
+  if (dhcp->t1_timeout >= dhcp->t2_timeout && dhcp->t2_timeout > 0) {\r
+    dhcp->t1_timeout = 0;\r
+  }\r
+\r
   if (dhcp->subnet_mask_given) {
     /* copy offered network mask */
     ip_addr_copy(sn_mask, dhcp->offered_sn_mask);