Browse Source

[dhcp] Defer discovery if link is blocked

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>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
d73982f098
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      src/net/udp/dhcp.c

+ 9
- 0
src/net/udp/dhcp.c View File

@@ -436,6 +436,15 @@ static void dhcp_discovery_rx ( struct dhcp_session *dhcp,
436 436
 static void dhcp_discovery_expired ( struct dhcp_session *dhcp ) {
437 437
 	unsigned long elapsed = ( currticks() - dhcp->start );
438 438
 
439
+	/* If link is blocked, defer DHCP discovery (and reset timeout) */
440
+	if ( netdev_link_blocked ( dhcp->netdev ) ) {
441
+		DBGC ( dhcp, "DHCP %p deferring discovery\n", dhcp );
442
+		start_timer_fixed ( &dhcp->timer,
443
+				    ( DHCP_DISC_START_TIMEOUT_SEC *
444
+				      TICKS_PER_SEC ) );
445
+		return;
446
+	}
447
+
439 448
 	/* Give up waiting for ProxyDHCP before we reach the failure point */
440 449
 	if ( dhcp->offer.s_addr &&
441 450
 	     ( elapsed > DHCP_DISC_PROXY_TIMEOUT_SEC * TICKS_PER_SEC ) ) {

Loading…
Cancel
Save