[En-Nut-Discussion] Fwd: Problem with NutDhcpClient thread (\pro\dhcpc.c)

Arlind Cela arlind.cela at gmail.com
Thu May 15 15:55:23 CEST 2008


Hello all,

I guess you have your DHCP leasetime set to a "Forever", or we should have
gotten some replies by now :)

Maybe my first e-mail was not clear enough, but we believe that this is an
issue that everyone who "really" uses DHCP comes accross.
When the lease time is other that "Forever"...renewing is supposed to happen
in certain intervals, but it never does. The reason for that is explained in
my first e-mail.


Kind regards,
-Arlind Cela



---------- Forwarded message ----------
From: Arlind Cela <arlind.cela at gmail.com>
Date: Thu, May 8, 2008 at 5:24 PM
Subject: Problem with NutDhcpClient thread (\pro\dhcpc.c)
To: en-nut-discussion at egnite.de


Hello group,

While tracing the dhcp traffic, we realized a problem related to
NutDhcpClient thread. The situation is as follows:

We start this thread with NutDhcpIfConfig(). The device gets the IP settings
from the DHCP server, with a lease of 30 minutes. After 15 minutes (50%
lease), we are supposed to send a request for renewal, but it goes wrong…

 -debug-

[1.DHCP-BOUND 900]
[1.DHCP-ERROR 1]

- -

After taking a look into it, we realized that the problem was caused from
the following peace of code:

/*

 * Keep track of the API timeout.

 */

if (dhcpState != DHCPST_IDLE && dhcpApiTimeout != NUT_WAIT_INFINITE) {

    u_long tt = NutGetMillis() - dhcpApiStart;

    if (dhcpApiTimeout <= tt) {

        dhcpError = DHCPERR_TIMEOUT;

        dhcpState = DHCPST_IDLE;

        continue;

    }

    if ((tt = dhcpApiTimeout - tt) < tmo) {

        tmo = tt;

    }

}



dhcpApiTimeout (we use 20000) is always smaller than tt, because
dhcpApiStart only gets the value of NutGetMillis() when the thread is
started (@DhcpKick); in the meanwhile the value of NutGetMillis() has
increased by 15 minutes...

We figured that a workaround would be to update the value of dhcpApiStart
every time we enter the DHCPST_BOUND state

 if (dhcpState == DHCPST_BOUND) {

    dhcpApiStart = NutGetMillis();

}

Has anyone come accross this problem, or does anyone have a better
implementation?

Thank you in advance,


-Arlind Cela



More information about the En-Nut-Discussion mailing list