mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
udhcpc: account for script run time
Based on the following user report: I ran into an issue where I was seeing a long delay in the scripts called in udhcp_run_script. I was using an old version of OpenWrt (kamikaze) and a satellite modem. An NTP script was being called and the modem would sometimes take a long time to respond to the DNS lookup when it was offline. This delay started affecting my lease time. The lease that I would get from my satellite modem before it was online would be short: only 60 seconds. The delay with NTP and the modem would typically be about 18 seconds. This would cause the first DHCP renew request from dhcpc to be a little late. Under certain circumstances, I could even see the first DHCP renew to occur after the lease had expired! function old new delta udhcpc_main 2816 2837 +21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
ad0d009e0c
commit
28634924f0
@ -1697,6 +1697,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
case RENEW_REQUESTED:
|
case RENEW_REQUESTED:
|
||||||
case REBINDING:
|
case REBINDING:
|
||||||
if (*message == DHCPACK) {
|
if (*message == DHCPACK) {
|
||||||
|
unsigned start;
|
||||||
uint32_t lease_seconds;
|
uint32_t lease_seconds;
|
||||||
struct in_addr temp_addr;
|
struct in_addr temp_addr;
|
||||||
uint8_t *temp;
|
uint8_t *temp;
|
||||||
@ -1756,7 +1757,10 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
bb_info_msg("Lease of %s obtained, lease time %u",
|
bb_info_msg("Lease of %s obtained, lease time %u",
|
||||||
inet_ntoa(temp_addr), (unsigned)lease_seconds);
|
inet_ntoa(temp_addr), (unsigned)lease_seconds);
|
||||||
requested_ip = packet.yiaddr;
|
requested_ip = packet.yiaddr;
|
||||||
|
|
||||||
|
start = monotonic_sec();
|
||||||
udhcp_run_script(&packet, state == REQUESTING ? "bound" : "renew");
|
udhcp_run_script(&packet, state == REQUESTING ? "bound" : "renew");
|
||||||
|
already_waited_sec = (unsigned)monotonic_sec() - start;
|
||||||
|
|
||||||
state = BOUND;
|
state = BOUND;
|
||||||
change_listen_mode(LISTEN_NONE);
|
change_listen_mode(LISTEN_NONE);
|
||||||
@ -1774,7 +1778,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
/* make future renew packets use different xid */
|
/* make future renew packets use different xid */
|
||||||
/* xid = random_xid(); ...but why bother? */
|
/* xid = random_xid(); ...but why bother? */
|
||||||
already_waited_sec = 0;
|
|
||||||
continue; /* back to main loop */
|
continue; /* back to main loop */
|
||||||
}
|
}
|
||||||
if (*message == DHCPNAK) {
|
if (*message == DHCPNAK) {
|
||||||
|
Loading…
Reference in New Issue
Block a user