On Wed, Jan 21, 2015 at 11:00 PM, Tim Hentenaar <[email protected]> wrote:
> Howdy y'all,
>
> I've noticed an interesting issue with udhcpd and auto_time.
>
> Some paths within the while loop don't go through continue_with_autotime.
> Thus, if it takes a bit too long to reset timeout_end, the monotonic
> timer may be far enough along that the subtraction which sets tv.tv_sec
> will overflow, like so:
>
> Jan 21 19:38:13 10.0.0.1 udhcpd[75]: Waking from select()
> Jan 21 19:38:13 10.0.0.1 udhcpd[75]: tv_sec = 10
> Jan 21 19:38:21 10.0.0.1 udhcpd[75]: Waking from select()
> Jan 21 19:38:23 10.0.0.1 udhcpd[75]: Sending OFFER of 10.0.0.2
> Jan 21 19:38:23 10.0.0.1 udhcpd[75]: tv_sec = -1
> Jan 21 19:38:23 10.0.0.1 udhcpd[75]: Waking from select()
> Jan 21 19:38:23 10.0.0.1 udhcpd[75]: Sending ACK to 10.0.0.2
> Jan 21 19:38:23 10.0.0.1 udhcpd[75]: tv_sec = -1
> Jan 21 19:38:43 10.0.0.2 udhcpc[47]: Sending renew...
> Jan 21 19:38:43 10.0.0.2 udhcpc[47]: Lease of 10.0.0.2 obtained, lease time 30
> Jan 21 19:38:43 10.0.0.1 udhcpd[75]: Waking from select()
> Jan 21 19:38:43 10.0.0.1 udhcpd[75]: Sending ACK to 10.0.0.2
> Jan 21 19:38:43 10.0.0.1 udhcpd[75]: tv_sec = -21
> Jan 21 19:39:03 10.0.0.2 udhcpc[47]: Sending renew...
> Jan 21 19:39:03 10.0.0.1 udhcpd[75]: Waking from select()
> Jan 21 19:39:03 10.0.0.1 udhcpd[75]: Sending ACK to 10.0.0.2
> Jan 21 19:39:03 10.0.0.2 udhcpc[47]: Lease of 10.0.0.2 obtained, lease time 30
> Jan 21 19:39:03 10.0.0.1 udhcpd[75]: tv_sec = -41
>
> This patch adds a quick and easy check for it, resetting tv_sec to 0,
> which should fall through to write_leases() and continue_with_autotime,
> resetting timeout_end again.

I don't understand why current code does not reach write_leases().
If tv.tv_sec is negative, we should not reach select() here -

                retval = 0;
                if (!server_config.auto_time || tv.tv_sec > 0) {
                        retval = select(max_sock + 1, &rfds, NULL, NULL,
                                        server_config.auto_time ? &tv : NULL);
                }
                if (retval == 0) {
                        write_leases();
                        goto continue_with_autotime;
                }

and therefore, retval == 0 and we should reach write_leases().

What am I missing?
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to