//#define DHCP_DISC_START_TIMEOUT_SEC 4 /* as per PXE spec */
//#define DHCP_DISC_END_TIMEOUT_SEC 32 /* as per PXE spec */
+/*
+ * Maximum number of discovery deferrals due to blocked links
+ * (e.g. from non-forwarding STP ports)
+ */
+#define DHCP_DISC_MAX_DEFERRALS 60
+
/*
* ProxyDHCP offers are given precedence by continue to wait for them
* after a valid DHCPOFFER is received. We'll wait through this
unsigned long elapsed = ( currticks() - dhcp->start );
/* If link is blocked, defer DHCP discovery (and reset timeout) */
- if ( netdev_link_blocked ( dhcp->netdev ) ) {
+ if ( netdev_link_blocked ( dhcp->netdev ) &&
+ ( dhcp->count <= DHCP_DISC_MAX_DEFERRALS ) ) {
DBGC ( dhcp, "DHCP %p deferring discovery\n", dhcp );
dhcp->start = currticks();
start_timer_fixed ( &dhcp->timer,
* session state into packet traces. Useful for extracting
* debug information from non-debug builds.
*/
- dhcppkt.dhcphdr->secs = htons ( ( ++(dhcp->count) << 2 ) |
+ dhcppkt.dhcphdr->secs = htons ( ( dhcp->count << 2 ) |
( dhcp->offer.s_addr ? 0x02 : 0 ) |
( dhcp->proxy_offer ? 0x01 : 0 ) );
return;
}
+ /* Increment transmission counter */
+ dhcp->count++;
+
/* Handle timer expiry based on current state */
dhcp->state->expired ( dhcp );
}