udhcp discovery takes minutes
Denis Vlasenko
vda.linux at googlemail.com
Sun Jan 27 16:04:50 PST 2008
On Monday 14 January 2008 23:40, Danny Sung wrote:
> I'm using udhcpc as packaged in busybox 1.9.0. For some reason initial
> discovery can sometimes take several minutes (though once in a while
> it'll complete in seconds). I had previously been using busybox 1.6.1,
> which didn't have any of these problems.
>
> Glancing at the 1.9.0 code, I should be using the default
> 'discover_timeout' of 3 seconds. But I noticed that 'timeout' is
> initialized as a global to 0, which would cause the select call in the
> main loop (line 341) to hang forever if it never gets a reply.
state = INIT_SELECTING;
for (;;) {
tv.tv_sec = timeout;
tv.tv_usec = 0;
if (listen_mode != LISTEN_NONE && sockfd < 0) {
...creates socket...
}
max_fd = udhcp_sp_fd_set(&rfds, sockfd);
retval = 0; /* If we already timed out, fall through, else... */
if (tv.tv_sec > 0) {
we do NOT go in here on first pass -
tv.tv_sec == timeout == 0!
DEBUG("Waiting on select...");
retval = select(max_fd + 1, &rfds, NULL, NULL, &tv);
}
if (retval < 0) {...}
/* If timeout dropped to zero, time to become active:
* resend discover/renew/whatever
*/
if (retval == 0) {
switch (state) {
case INIT_SELECTING:
so we have to end up here
if (packet_num < discover_retries) {
if (packet_num == 0)
xid = random_xid();
/* send discover packet */
and send discover here
send_discover(xid, requested_ip); /* broadcast */
timeout = discover_timeout;
packet_num++;
continue;
}
Can you verify that it indeed happens as expected
(by adding bb_error_msg("DEBUG: we are here") style markers)?
If not, where it goes instead?
> Looking at my DHCP server logs, it seems my server never sees the first
> discovery request. But that would explain the hang. I tried to set
> timeout to 1 in line 22, but that doesn't appear to solve the problem.
>
> In fact when I do a network trace, I only see packets coming out when it
> finally does succeed. So apparently I'm having strange issues even
> sending out packets. You can also tell that the "Sending discover..."
> message only gets sent once and just hangs, rather than timeout out once
> a second (or 3 seconds?). Busybox 1.6.1 appears to be doing the correct
> thing and sending discovers once a second until it gets something.
--
vda
More information about the busybox
mailing list