[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    RE: udhcpc: limit renew/rebind timeout
From:       "Vladislav Grishenko" <themiron () mail ! ru>
Date:       2011-09-14 11:34:33
Message-ID: 00e601cc72d2$46ecbb80$d4c63280$ () mail ! ru
[Download RAW message or body]

This is a multipart message in MIME format.


Sorry, server has eaten the first email text.

Hello,
In some cases it's good to have control over manual renew/rebind timeout
before deconfig state.
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 up to 60 timeout, which are ignored
by new network dhcp servers
5. udhcpc sends broadcast rebind requests, which could be naked or ignored
too, if there's no authority dhcp servers configured
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 in my case.
Second SIGUSR1 will immediately run into deconfig/discover state, which is
not preferable in case of the same subnet replugged.

With the patch, it's possible to limit pt.4 and pt.5 stage timeouts, for
example:
By specifying -N61 option udhcpc will make one  unicast renew attempt
(timeout greater than 60) and will get 61/2 timeout for broadcast rebind, if
original timeout before signal is greater than 61 sec.
By specifying -N60 and lower, no unicast renew attempt will be made, only
broadcast rebind.
Default behavior - is to continue use of unchanged timeouts, like before
patch.

Best Regards, theMIROn
ICQ: 303357
MSN: themiron@mail.ru
Skype: the.miron

> -----Original Message-----
> From: busybox-bounces@busybox.net [mailto:busybox-
> bounces@busybox.net] On Behalf Of Vladislav Grishenko
> Sent: Wednesday, September 14, 2011 5:30 PM
> To: busybox@busybox.net
> Cc: 'Leonid Lisovskiy'
> Subject: udhcpc: limit renew/rebind timeout
> 
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox

["dhcpc-renew-timeout.patch" (application/octet-stream)]

udhcpc: add -N option

diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 3be09f4..c2af4bc 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -49,6 +49,7 @@ static const char udhcpc_longopts[] ALIGN1 =
 	"version\0"        No_argument       "v"
 	"retries\0"        Required_argument "t"
 	"tryagain\0"       Required_argument "A"
+	"renew-timeout\0"  Required_argument "N"
 	"syslog\0"         No_argument       "S"
 	"request-option\0" Required_argument "O"
 	"no-default-options\0" No_argument   "o"
@@ -82,8 +83,9 @@ enum {
 	OPT_x = 1 << 18,
 	OPT_f = 1 << 19,
 	OPT_B = 1 << 20,
+	OPT_N = 1 << 21,
 /* The rest has variable bit positions, need to be clever */
-	OPTBIT_B = 20,
+	OPTBIT_N = 21,
 	USE_FOR_MMU(             OPTBIT_b,)
 	IF_FEATURE_UDHCPC_ARPING(OPTBIT_a,)
 	IF_FEATURE_UDHCP_PORT(   OPTBIT_P,)
@@ -969,6 +971,7 @@ static void client_background(void)
 //usage:     "\n	-t,--retries N		Send up to N discover packets"
 //usage:     "\n	-T,--timeout N		Pause between packets (default 3 seconds)"
 //usage:     "\n	-A,--tryagain N		Wait N seconds after failure (default 20)"
+//usage:     "\n	-N,--renew-timeout N	Wait N seconds for requested renew"
 //usage:     "\n	-f,--foreground		Run in foreground"
 //usage:	USE_FOR_MMU(
 //usage:     "\n	-b,--background		Background if lease is not obtained"
@@ -1007,6 +1010,7 @@ static void client_background(void)
 //usage:     "\n	-t N		Send up to N discover packets"
 //usage:     "\n	-T N		Pause between packets (default 3 seconds)"
 //usage:     "\n	-A N		Wait N seconds (default 20) after failure"
+//usage:     "\n	-N N		Wait N seconds for requested renew"
 //usage:     "\n	-f		Run in foreground"
 //usage:	USE_FOR_MMU(
 //usage:     "\n	-b		Background if lease is not obtained"
@@ -1054,6 +1058,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 	int tryagain_timeout = 20;
 	int discover_timeout = 3;
 	int discover_retries = 3;
+	int renew_timeout = 0;
 	uint32_t server_addr = server_addr; /* for compiler */
 	uint32_t requested_ip = 0;
 	uint32_t xid = 0;
@@ -1077,13 +1082,13 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 
 	/* Parse command line */
 	/* O,x: list; -T,-t,-A take numeric param */
-	opt_complementary = "O::x::T+:t+:A+"
+	opt_complementary = "O::x::T+:t+:A+:N+"
 #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1
 		":vv"
 #endif
 		;
 	IF_LONG_OPTS(applet_long_options = udhcpc_longopts;)
-	opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fB"
+	opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fBN:"
 		USE_FOR_MMU("b")
 		IF_FEATURE_UDHCPC_ARPING("a")
 		IF_FEATURE_UDHCP_PORT("P:")
@@ -1094,6 +1099,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 		, &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */
 		, &list_O
 		, &list_x
+		, &renew_timeout /* N */
 		IF_FEATURE_UDHCP_PORT(, &str_P)
 #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1
 		, &dhcp_verbose
@@ -1362,8 +1368,15 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 		case SIGUSR1:
 			client_config.first_secs = 0; /* make secs field count from 0 */
 			perform_renew();
-			if (state == RENEW_REQUESTED)
+			if (state == RENEW_REQUESTED) {
+				/* We will probably restart the wait */
+				timeout -= already_waited_sec;
+				already_waited_sec = 0;
+				/* Use user supplied timeout */
+				if (renew_timeout && timeout > renew_timeout)
+					timeout = renew_timeout;
 				goto case_RENEW_REQUESTED;
+			}
 			/* Start things over */
 			packet_num = 0;
 			/* Kill any timeouts, user wants this to hurry along */


_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic