[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] udhcpd: account for script delay in lease
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2014-12-25 20:15:41
Message-ID: CAK1hOcOdxcD1xNofx2UanE296sdnEdibT8TixGDb1+HS29+weA () mail ! gmail ! com
[Download RAW message or body]
On Mon, Dec 22, 2014 at 6:57 AM, John Schroeder <jschroed@gmail.com> wrote:
> That solution is much better and simpler. It nicely covers the typical case
> of a short delay caused by scripts.
>
> The thing wrong with immediately going to the renew state is that the renew
> state could continue after the lease expired. (Possibly only a late renew
> request but the unlikely worst-case scenario being a renew attempt after the
> lease expired.)
>
> It might be superfluous but how about going to the discover state (init
> selecting) if the timeout (half the lease time) has been exceeded? This
> correctly handles the case when the lease has expired. The very rare case of
> being in the last half of the lease is also dealt with cleanly (rather than
> continuing beyond the lease expiration).
>
> Below is a patch with a check if the timeout is exceeded. I am not certain
> if it is worth the trade off of having the extra code but it does handle
> these cases. Again, this case is very unlikely so it might not be worth
> having this code since the current code (plus script duration) would work
> most of the time.
>
>
> Signed-off-by: John Schroeder <jschroed@gmail.com>
> --- a/networking/udhcp/dhcpc.c
> +++ b/networking/udhcp/dhcpc.c
> @@ -1742,7 +1742,14 @@
> bb_info_msg("Lease of %s obtained, lease time %u",
> inet_ntoa(temp_addr), (unsigned)lease_seconds);
> requested_ip = packet.yiaddr;
> +
> + timestamp_before_wait = monotonic_sec();
> udhcp_run_script(&packet, state == REQUESTING ? "bound" :
> "renew");
> + already_waited_sec = (unsigned)monotonic_sec() -
> timestamp_before_wait;
> +
> + if (already_waited_sec > timeout) { /* immediately go to
> discover */
> + timeout = 0;
> + }
>
> state = BOUND;
> change_listen_mode(LISTEN_NONE);
> @@ -1760,7 +1767,6 @@
> #endif
> /* make future renew packets use different xid */
> /* xid = random_xid(); ...but why bother? */
> - already_waited_sec = 0;
> continue; /* back to main loop */
> }
> if (*message == DHCPNAK) {
Applied, thanks.
_______________________________________________
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