[En-Nut-Discussion] patch for NutDHCPClientThread to overcome lease renewal bug

Iskander Verkroost iskander.verkroost at picell.com
Tue Mar 3 16:19:25 CET 2009


Hi all,

We made a small patch to the \pro\dhcpc.c file which prevents the
DHCP client thread from sending lease renewal requests (or any other
requests)
because everything behind the the API timeout check will not be executed.

The problem lies in the following piece of code:

Nut/Os 4.3.3 \pro\dhcpc.c THREAD(NutDhcpClient, arg()

        /*
         * 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;
            }
        }

IMHO this code should only be active during the initial fase e.g. when
NutDhcpIfConfig()
is called the first time, that is during the init, selecting and
requesting state, after that this code
should become inert like so:

        /*
         * Keep track of the API timeout.

            new fix, API timeout is only active in states

            DHCPST_INIT, DHCPST_SELECTING, DHCPST_REQUESTING

        */
        if (dhcpState != DHCPST_BOUND &&
            dhcpState != DHCPST_RENEWING &&
            dhcpState != DHCPST_REBINDING &&
            dhcpState != DHCPST_INFORMING &&
            dhcpState != DHCPST_RELEASING &&
            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;
            }
        }

Kind regards
Iskander Verkroost








More information about the En-Nut-Discussion mailing list