diff options
author | John Schroeder | 2014-12-25 21:12:51 +0100 |
---|---|---|
committer | Denys Vlasenko | 2014-12-25 21:12:51 +0100 |
commit | 8074a6ca4dc4e30e38570b52529b87c547c41b1b (patch) | |
tree | 3982ed26089d3aabcf7f68a1260ff133cb85988b | |
parent | b9965077e51bb9952c4fd161164e796e5fc66fbf (diff) | |
download | busybox-8074a6ca4dc4e30e38570b52529b87c547c41b1b.zip busybox-8074a6ca4dc4e30e38570b52529b87c547c41b1b.tar.gz |
udhcpd: account for script delay in lease
Prevent nasty surprises if script runs longer than lease time / 2.
Signed-off-by: John Schroeder <jschroed@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/udhcp/dhcpc.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index a34829c..9d3d1a3 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -1752,7 +1752,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) } #endif /* enter bound state */ - timeout = lease_seconds / 2; temp_addr.s_addr = packet.yiaddr; bb_info_msg("Lease of %s obtained, lease time %u", inet_ntoa(temp_addr), (unsigned)lease_seconds); @@ -1761,6 +1760,11 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) start = monotonic_sec(); udhcp_run_script(&packet, state == REQUESTING ? "bound" : "renew"); already_waited_sec = (unsigned)monotonic_sec() - start; + timeout = lease_seconds / 2; + if ((unsigned)timeout < already_waited_sec) { + /* Something went wrong. Back to discover state */ + timeout = already_waited_sec = 0; + } state = BOUND; change_listen_mode(LISTEN_NONE); |