[En-Nut-Discussion] Bug in dhcpc.c

Peter Keitler peter.keitler at baltech.de
Thu Jun 29 16:41:18 CEST 2006


Hi,

I believe that I have found a bug in module dhcpc.c porting the ethernut 
network stack to our proprietary AVR platform.

In method DhcpKick(), global variable dhcpApiTimeout is set to the 
timeout value specified by the application or main task. It is never 
reset to an infinite value, even after DhcpKick() has returned. I 
suppose that the thread NutDhcpClient is intended to run independently, 
sleeping most of the time and renewing or rebinding as necessary. 
However, in the beginning of the thread loop, where the comment "Keep 
track of the API timeout" stands, dhcpState will be set to DHCPST_IDLE, 
as soon as the loop starts over again. This happens after the first nap 
in state DHCPST_BOUND has ended! Thus DHCP will never be able to renew 
or rebind its lease. I solved this issue by resetting dhcpApiTimeout to 
infinite when DHCPST_BOUND is entered...

        /*
         * Maintain lease time.
         */
        else if (dhcpState == DHCPST_BOUND) {
            ucRetryCnt = 0;
            os_set_event( &evDhcpDone );
            // API timeout no longer needed. Let DHCP work unattended.
            dhcpApiTimeout = OS_NOTIMEOUT;

Note, that we use a different operating system. Maybe there is a better 
solution!?

Peter


More information about the En-Nut-Discussion mailing list