[dhcp] Don't consider invalid offers to be duplicates
authorJoshua Oreman <oremanj@rwcr.net>
Wed, 26 May 2010 21:22:03 +0000 (14:22 -0700)
committerJoshua Oreman <oremanj@rwcr.net>
Wed, 26 May 2010 21:27:50 +0000 (14:27 -0700)
This fixes a regression in BOOTP support; since BOOTP requests often have
the `siaddr' field set to 0.0.0.0, they would be considered duplicates
of the first zeroed-out offer slot.

Signed-off-by: Joshua Oreman <oremanj@rwcr.net>
src/net/udp/dhcp.c

index fa09741..5f2d719 100644 (file)
@@ -417,13 +417,13 @@ static void dhcp_rx_offer ( struct dhcp_session *dhcp,
 
        /* Enqueue an offer to be filled in */
        for ( i = 0 ; i < DHCP_MAX_OFFERS ; i++ ) {
+               if ( ! dhcp->offers[i].valid )
+                       break;
+
                if ( dhcp->offers[i].server.s_addr == server_id.s_addr ) {
                        DBGC ( dhcp, " dup\n" );
                        return;
                }
-
-               if ( ! dhcp->offers[i].valid )
-                       break;
        }
        if ( i == DHCP_MAX_OFFERS ) {
                DBGC ( dhcp, " dropped\n" );