diff options
author | Michael Brown <mcb30@ipxe.org> | 2015-11-10 14:05:46 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2015-11-10 14:05:46 +0000 |
commit | ed0d7c4f6f8db7bda1e74567693a0c525b9cf159 (patch) | |
tree | 9445c55745f75db057fb88d91c2989b0c7a68c4e /src/net/udp | |
parent | d5f7ee60e7228d8d62507087bbb39c733a622939 (diff) | |
download | ipxe-ed0d7c4f6f8db7bda1e74567693a0c525b9cf159.tar.gz |
[dhcp] Limit maximum number of DHCP discovery deferrals
For switches which remain permanently in the non-forwarding state (or
which erroneously report a non-forwarding state), ensure that iPXE
will eventually give up waiting for the link to become unblocked.
Originally-fixed-by: Wissam Shoukair <wissams@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/udp')
-rw-r--r-- | src/net/udp/dhcp.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c index 9c7b2fdc2..9342ad21e 100644 --- a/src/net/udp/dhcp.c +++ b/src/net/udp/dhcp.c @@ -444,7 +444,8 @@ 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 ) ) { + 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, @@ -1115,7 +1116,7 @@ static int dhcp_tx ( struct dhcp_session *dhcp ) { * 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 ) ); @@ -1259,6 +1260,9 @@ static void dhcp_timer_expired ( struct retry_timer *timer, int fail ) { return; } + /* Increment transmission counter */ + dhcp->count++; + /* Handle timer expiry based on current state */ dhcp->state->expired ( dhcp ); } |