From 2b388f9ea94e7f66c553381968bd1566c0a88565 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 7 Jul 2014 13:36:19 -0400 Subject: [PATCH] Revert "Extend DHCP timeout" This reverts commit fea8166abfa856884792021d61d4095ebd00a984. --- src/include/ipxe/dhcp.h | 4 ++++ src/net/udp/dhcp.c | 21 +++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/include/ipxe/dhcp.h b/src/include/ipxe/dhcp.h index 595f0c19..bcfb85cc 100644 --- a/src/include/ipxe/dhcp.h +++ b/src/include/ipxe/dhcp.h @@ -639,6 +639,10 @@ struct dhcphdr { */ #define DHCP_MIN_LEN 552 +/** Timeouts for sending DHCP packets */ +#define DHCP_MIN_TIMEOUT ( 1 * TICKS_PER_SEC ) +#define DHCP_MAX_TIMEOUT ( 10 * TICKS_PER_SEC ) + /** Maximum time that we will wait for ProxyDHCP responses */ #define PROXYDHCP_MAX_TIMEOUT ( 2 * TICKS_PER_SEC ) diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c index 849e2ad1..7a4f40a7 100644 --- a/src/net/udp/dhcp.c +++ b/src/net/udp/dhcp.c @@ -171,8 +171,8 @@ struct dhcp_session_state { void ( * expired ) ( struct dhcp_session *dhcp ); /** Transmitted message type */ uint8_t tx_msgtype; - uint8_t min_timeout; - uint8_t max_timeout; + /** Apply minimum timeout */ + uint8_t apply_min_timeout; }; static struct dhcp_session_state dhcp_state_discover; @@ -272,8 +272,9 @@ static void dhcp_set_state ( struct dhcp_session *dhcp, dhcp->state = state; dhcp->start = currticks(); stop_timer ( &dhcp->timer ); - dhcp->timer.min_timeout = state->min_timeout * TICKS_PER_SEC; - dhcp->timer.max_timeout = state->max_timeout * TICKS_PER_SEC; + dhcp->timer.min_timeout = + ( state->apply_min_timeout ? DHCP_MIN_TIMEOUT : 0 ); + dhcp->timer.max_timeout = DHCP_MAX_TIMEOUT; start_timer_nodelay ( &dhcp->timer ); } @@ -446,8 +447,7 @@ static struct dhcp_session_state dhcp_state_discover = { .rx = dhcp_discovery_rx, .expired = dhcp_discovery_expired, .tx_msgtype = DHCPDISCOVER, - .min_timeout = 4, - .max_timeout = 32, + .apply_min_timeout = 1, }; /** @@ -584,8 +584,7 @@ static struct dhcp_session_state dhcp_state_request = { .rx = dhcp_request_rx, .expired = dhcp_request_expired, .tx_msgtype = DHCPREQUEST, - .min_timeout = 1, - .max_timeout = 8, + .apply_min_timeout = 0, }; /** @@ -686,8 +685,7 @@ static struct dhcp_session_state dhcp_state_proxy = { .rx = dhcp_proxy_rx, .expired = dhcp_proxy_expired, .tx_msgtype = DHCPREQUEST, - .min_timeout = 1, - .max_timeout = 8, + .apply_min_timeout = 0, }; /** @@ -834,8 +832,7 @@ static struct dhcp_session_state dhcp_state_pxebs = { .rx = dhcp_pxebs_rx, .expired = dhcp_pxebs_expired, .tx_msgtype = DHCPREQUEST, - .min_timeout = 1, - .max_timeout = 8, + .apply_min_timeout = 1, }; /****************************************************************************