Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/RMerl/asuswrt-merlin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Grishenko <themiron@mail.ru>2016-12-09 22:42:03 +0300
committerVladislav Grishenko <themiron@mail.ru>2016-12-10 03:31:43 +0300
commit6064ce77e70e8e6d1041db98e3d2decd3158a87e (patch)
tree59acc77a0604e477fa214e68d4335cca700e06ef
parent4f2900abd9a1b7297753be2a78670f7d7601a12b (diff)
busybox: udhcpc: fix T2 time to be 0,875 of duration lease per RFC2132, not just fixed 60 seconds
-rw-r--r--release/src/router/busybox/networking/udhcp/dhcpc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/release/src/router/busybox/networking/udhcp/dhcpc.c b/release/src/router/busybox/networking/udhcp/dhcpc.c
index b578ae5401..7ce1feeb8b 100644
--- a/release/src/router/busybox/networking/udhcp/dhcpc.c
+++ b/release/src/router/busybox/networking/udhcp/dhcpc.c
@@ -1264,6 +1264,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
uint32_t xid = xid; /* for compiler */
int packet_num;
int timeout; /* must be signed */
+ int rebind_timeout;
unsigned already_waited_sec;
unsigned opt;
IF_FEATURE_UDHCPC_ARPING(unsigned arpping_ms;)
@@ -1412,6 +1413,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
change_listen_mode(LISTEN_RAW);
packet_num = 0;
timeout = 0;
+ rebind_timeout = 0;
already_waited_sec = 0;
/* Main event loop. select() waits on signal pipe and possibly
@@ -1532,7 +1534,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
case RENEW_REQUESTED: /* manual (SIGUSR1) renew */
case_RENEW_REQUESTED:
case RENEWING:
- if (timeout > 60) {
+ if (timeout > rebind_timeout) {
/* send an unicast renew request */
/* Sometimes observed to fail (EADDRNOTAVAIL) to bind
* a new UDP socket for sending inside send_renew.
@@ -1596,8 +1598,13 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
* (Ab)use -A TIMEOUT value (usually 20 sec)
* as a cap on the timeout.
*/
+ if (timeout > rebind_timeout)
+ rebind_timeout = 0;
if (timeout > tryagain_timeout)
timeout = tryagain_timeout;
+ /* Keep unicasting the first renew only */
+ if (rebind_timeout == 0)
+ rebind_timeout = timeout / 2;
goto case_RENEW_REQUESTED;
}
/* Start things over */
@@ -1778,6 +1785,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
udhcp_run_script(&packet, state == REQUESTING ? "bound" : "renew");
already_waited_sec = (unsigned)monotonic_sec() - start;
timeout = lease_seconds / 2;
+ rebind_timeout = timeout / 8;
if ((unsigned)timeout < already_waited_sec) {
/* Something went wrong. Back to discover state */
timeout = already_waited_sec = 0;