diff options
author | John Schroeder <jschroed@gmail.com> | 2014-12-25 21:12:51 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-12-25 21:12:51 +0100 |
commit | 8074a6ca4dc4e30e38570b52529b87c547c41b1b (patch) | |
tree | 3982ed26089d3aabcf7f68a1260ff133cb85988b /networking/udhcp/dhcpc.c | |
parent | b9965077e51bb9952c4fd161164e796e5fc66fbf (diff) | |
download | busybox-w32-8074a6ca4dc4e30e38570b52529b87c547c41b1b.tar.gz busybox-w32-8074a6ca4dc4e30e38570b52529b87c547c41b1b.tar.bz2 busybox-w32-8074a6ca4dc4e30e38570b52529b87c547c41b1b.zip |
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>
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-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 a34829c3a..9d3d1a31c 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -1752,7 +1752,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1752 | } | 1752 | } |
1753 | #endif | 1753 | #endif |
1754 | /* enter bound state */ | 1754 | /* enter bound state */ |
1755 | timeout = lease_seconds / 2; | ||
1756 | temp_addr.s_addr = packet.yiaddr; | 1755 | temp_addr.s_addr = packet.yiaddr; |
1757 | bb_info_msg("Lease of %s obtained, lease time %u", | 1756 | bb_info_msg("Lease of %s obtained, lease time %u", |
1758 | inet_ntoa(temp_addr), (unsigned)lease_seconds); | 1757 | inet_ntoa(temp_addr), (unsigned)lease_seconds); |
@@ -1761,6 +1760,11 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1761 | start = monotonic_sec(); | 1760 | start = monotonic_sec(); |
1762 | udhcp_run_script(&packet, state == REQUESTING ? "bound" : "renew"); | 1761 | udhcp_run_script(&packet, state == REQUESTING ? "bound" : "renew"); |
1763 | already_waited_sec = (unsigned)monotonic_sec() - start; | 1762 | already_waited_sec = (unsigned)monotonic_sec() - start; |
1763 | timeout = lease_seconds / 2; | ||
1764 | if ((unsigned)timeout < already_waited_sec) { | ||
1765 | /* Something went wrong. Back to discover state */ | ||
1766 | timeout = already_waited_sec = 0; | ||
1767 | } | ||
1764 | 1768 | ||
1765 | state = BOUND; | 1769 | state = BOUND; |
1766 | change_listen_mode(LISTEN_NONE); | 1770 | change_listen_mode(LISTEN_NONE); |