aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Grishenko <themiron@mail.ru>2011-10-18 01:37:47 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2011-10-18 01:37:47 +0200
commit6464f15ddb67f7c3fac9eb99a1336965537c4d67 (patch)
treec6fcacf1e864a9449fd0bbbfdcb8d90756610c5a
parent6c9c0a1dc9de48b59c103600a1f574a4a234b3d6 (diff)
downloadbusybox-w32-6464f15ddb67f7c3fac9eb99a1336965537c4d67.tar.gz
busybox-w32-6464f15ddb67f7c3fac9eb99a1336965537c4d67.tar.bz2
busybox-w32-6464f15ddb67f7c3fac9eb99a1336965537c4d67.zip
udhcpc: on SIGUSR1, limit renew attempts time to 20 seconds; then do total reconfig
Scenario: 1. udhcpc gets lease for 86400 secs and sleeps for 43200 before renew attempt 2. PC gets physically disconnected and connected to another network 3. some phy control software sends SIGUSR1 to renew the lease, SIGUSR2 isn't used because newly connected network could be the same as before 4. udhcpc sends unicast renew requests until lease timeout fall to 60 sec. They are ignored by new network dhcp servers 5. udhcpc sends broadcast rebind requests for 60 seconds, which are NAKed or ignored too 6. udhcpc deconfigs and starting from discover state, gets new lease for the new network So, pt.4+5 it could take up to 86400 secs without correct lease, which is too long and not acceptable. Second SIGUSR1 will immediately run into deconfig/discover state, which is not preferable in case of the same subnet replugged. This patch makes sure after SIGUSR1 timeout is no more than -A NUM (usually 20 sec). It means that renew will be requested via broadcast, and if no replies come back, full deconf/reconf cycle will be initiated in 20 seconds. Signed-off-by: Vladislav Grishenko <themiron@mail.ru> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/udhcp/dhcpc.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 29a6cd5a1..ddfe3ccc0 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -1355,9 +1355,23 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1355 switch (udhcp_sp_read(&rfds)) { 1355 switch (udhcp_sp_read(&rfds)) {
1356 case SIGUSR1: 1356 case SIGUSR1:
1357 client_config.first_secs = 0; /* make secs field count from 0 */ 1357 client_config.first_secs = 0; /* make secs field count from 0 */
1358 already_waited_sec = 0;
1358 perform_renew(); 1359 perform_renew();
1359 if (state == RENEW_REQUESTED) 1360 if (state == RENEW_REQUESTED) {
1361 /* We might be either on the same network
1362 * (in which case renew might work),
1363 * or we might be on a completely different one
1364 * (in which case renew won't ever succeed).
1365 * For the second case, must make sure timeout
1366 * is not too big, or else we can send
1367 * futile renew requests for hours.
1368 * (Ab)use -A TIMEOUT value (usually 20 sec)
1369 * as a cap on the timeout.
1370 */
1371 if (timeout > tryagain_timeout)
1372 timeout = tryagain_timeout;
1360 goto case_RENEW_REQUESTED; 1373 goto case_RENEW_REQUESTED;
1374 }
1361 /* Start things over */ 1375 /* Start things over */
1362 packet_num = 0; 1376 packet_num = 0;
1363 /* Kill any timeouts, user wants this to hurry along */ 1377 /* Kill any timeouts, user wants this to hurry along */