diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2014-12-21 16:10:22 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-12-21 16:10:22 +0100 |
commit | 28634924f0950f1938ea74a7808d412dc1063fd0 (patch) | |
tree | c53fad75d9803252f71f16d0191360db2d49265f | |
parent | ad0d009e0c1968a14f17189264d3aa8008ea2e3b (diff) | |
download | busybox-w32-28634924f0950f1938ea74a7808d412dc1063fd0.tar.gz busybox-w32-28634924f0950f1938ea74a7808d412dc1063fd0.tar.bz2 busybox-w32-28634924f0950f1938ea74a7808d412dc1063fd0.zip |
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>
-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 35e7c2070..a34829c3a 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -1697,6 +1697,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1697 | case RENEW_REQUESTED: | 1697 | case RENEW_REQUESTED: |
1698 | case REBINDING: | 1698 | case REBINDING: |
1699 | if (*message == DHCPACK) { | 1699 | if (*message == DHCPACK) { |
1700 | unsigned start; | ||
1700 | uint32_t lease_seconds; | 1701 | uint32_t lease_seconds; |
1701 | struct in_addr temp_addr; | 1702 | struct in_addr temp_addr; |
1702 | uint8_t *temp; | 1703 | uint8_t *temp; |
@@ -1756,7 +1757,10 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1756 | bb_info_msg("Lease of %s obtained, lease time %u", | 1757 | bb_info_msg("Lease of %s obtained, lease time %u", |
1757 | inet_ntoa(temp_addr), (unsigned)lease_seconds); | 1758 | inet_ntoa(temp_addr), (unsigned)lease_seconds); |
1758 | requested_ip = packet.yiaddr; | 1759 | requested_ip = packet.yiaddr; |
1760 | |||
1761 | start = monotonic_sec(); | ||
1759 | udhcp_run_script(&packet, state == REQUESTING ? "bound" : "renew"); | 1762 | udhcp_run_script(&packet, state == REQUESTING ? "bound" : "renew"); |
1763 | already_waited_sec = (unsigned)monotonic_sec() - start; | ||
1760 | 1764 | ||
1761 | state = BOUND; | 1765 | state = BOUND; |
1762 | change_listen_mode(LISTEN_NONE); | 1766 | change_listen_mode(LISTEN_NONE); |
@@ -1774,7 +1778,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1774 | #endif | 1778 | #endif |
1775 | /* make future renew packets use different xid */ | 1779 | /* make future renew packets use different xid */ |
1776 | /* xid = random_xid(); ...but why bother? */ | 1780 | /* xid = random_xid(); ...but why bother? */ |
1777 | already_waited_sec = 0; | 1781 | |
1778 | continue; /* back to main loop */ | 1782 | continue; /* back to main loop */ |
1779 | } | 1783 | } |
1780 | if (*message == DHCPNAK) { | 1784 | if (*message == DHCPNAK) { |