]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[dhcp] Defer discovery if link is blocked
authorMichael Brown <mcb30@ipxe.org>
Thu, 25 Jun 2015 16:30:49 +0000 (17:30 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 25 Jun 2015 16:32:24 +0000 (17:32 +0100)
If the link is blocked (e.g. due to a Spanning Tree Protocol port not
yet forwarding packets) then defer DHCP discovery until the link
becomes unblocked.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/udp/dhcp.c

index 8fe2774fdc202a43ed383d45e5d90afbcc7491dc..61bef998575f526461f01f8f13bc5b929048e214 100644 (file)
@@ -436,6 +436,15 @@ static void dhcp_discovery_rx ( struct dhcp_session *dhcp,
 static void dhcp_discovery_expired ( struct dhcp_session *dhcp ) {
        unsigned long elapsed = ( currticks() - dhcp->start );
 
+       /* If link is blocked, defer DHCP discovery (and reset timeout) */
+       if ( netdev_link_blocked ( dhcp->netdev ) ) {
+               DBGC ( dhcp, "DHCP %p deferring discovery\n", dhcp );
+               start_timer_fixed ( &dhcp->timer,
+                                   ( DHCP_DISC_START_TIMEOUT_SEC *
+                                     TICKS_PER_SEC ) );
+               return;
+       }
+
        /* Give up waiting for ProxyDHCP before we reach the failure point */
        if ( dhcp->offer.s_addr &&
             ( elapsed > DHCP_DISC_PROXY_TIMEOUT_SEC * TICKS_PER_SEC ) ) {