udhcpc: ensure at least one unicast renew attempt
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 30 Oct 2018 10:56:18 +0000 (11:56 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 30 Oct 2018 10:56:18 +0000 (11:56 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/udhcp/d6_dhcpc.c
networking/udhcp/dhcpc.c

index 66e4b6c6ac4b9eea90ab0687f806c42644e9b6f2..e2f8a6a9cc73dcc60f96197af6763404ac024a8f 100644 (file)
@@ -1738,8 +1738,9 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
                                /* note: "int timeout" will not overflow even with 0xffffffff inputs here: */
                                timeout = (prefix_timeout < address_timeout ? prefix_timeout : address_timeout) / 2;
                                /* paranoia: must not be too small */
-                               if (timeout < 0x10)
-                                       timeout = 0x10;
+                               /* timeout > 60 - ensures at least one unicast renew attempt */
+                               if (timeout < 61)
+                                       timeout = 61;
                                /* enter bound state */
                                d6_run_script(packet.d6_options, packet_end,
                                        (state == REQUESTING ? "bound" : "renew"));
index ab3e5a4637d5163803cc2cb500499d8d6e798924..d2f1659047972e20c1a58ddf457daeec7f08ce8d 100644 (file)
@@ -1725,8 +1725,9 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                                        move_from_unaligned32(lease_seconds, temp);
                                        lease_seconds = ntohl(lease_seconds);
                                        /* paranoia: must not be too small and not prone to overflows */
-                                       if (lease_seconds < 0x10)
-                                               lease_seconds = 0x10;
+                                       /* timeout > 60 - ensures at least one unicast renew attempt */
+                                       if (lease_seconds < 2 * 61)
+                                               lease_seconds = 2 * 61;
                                        //if (lease_seconds > 0x7fffffff)
                                        //      lease_seconds = 0x7fffffff;
                                        //^^^not necessary since "timeout = lease_seconds / 2"