Skip to content

Commit

Permalink
Extend DHCP timeou
Browse files Browse the repository at this point in the history
Per  Alex Williamson <alex.williamson@redhat.com>:
For discovery, both the DHCP and PXE specs suggest timeouts of 4, 8,
16, and 32 seconds.  This gives us a maximum timeout of 60 seconds,
versus the current timeout of 15 seconds at timeouts of 1, 2, 4, and
8 seconds.

On the request phase, the specs are quite different.  RFC2131 for DHCP
suggests the same intervals as above for discovery, while the PXE spec
recommends intervals of 1, 2, 3, and 4 seconds.  Our timer only wants
to do exponential back-off, so we compromise and adjust to intervals
of 1, 2, 4, and 8 seconds.  PXE boot server discovery appears to want
the same timeouts as the DHCP request phase.
  • Loading branch information
Jarrod Johnson committed Mar 7, 2014
1 parent ab7d5e8 commit 2058e73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
4 changes: 0 additions & 4 deletions src/include/ipxe/dhcp.h
Expand Up @@ -643,10 +643,6 @@ 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 )

Expand Down
21 changes: 12 additions & 9 deletions src/net/udp/dhcp.c
Expand Up @@ -185,8 +185,8 @@ struct dhcp_session_state {
void ( * expired ) ( struct dhcp_session *dhcp );
/** Transmitted message type */
uint8_t tx_msgtype;
/** Apply minimum timeout */
uint8_t apply_min_timeout;
uint8_t min_timeout;
uint8_t max_timeout;
};

static struct dhcp_session_state dhcp_state_discover;
Expand Down Expand Up @@ -286,9 +286,8 @@ static void dhcp_set_state ( struct dhcp_session *dhcp,
dhcp->state = state;
dhcp->start = currticks();
stop_timer ( &dhcp->timer );
dhcp->timer.min_timeout =
( state->apply_min_timeout ? DHCP_MIN_TIMEOUT : 0 );
dhcp->timer.max_timeout = DHCP_MAX_TIMEOUT;
dhcp->timer.min_timeout = state->min_timeout * TICKS_PER_SEC;
dhcp->timer.max_timeout = state->max_timeout * TICKS_PER_SEC;
start_timer_nodelay ( &dhcp->timer );
}

Expand Down Expand Up @@ -461,7 +460,8 @@ static struct dhcp_session_state dhcp_state_discover = {
.rx = dhcp_discovery_rx,
.expired = dhcp_discovery_expired,
.tx_msgtype = DHCPDISCOVER,
.apply_min_timeout = 1,
.min_timeout = 4,
.max_timeout = 32,
};

/**
Expand Down Expand Up @@ -598,7 +598,8 @@ static struct dhcp_session_state dhcp_state_request = {
.rx = dhcp_request_rx,
.expired = dhcp_request_expired,
.tx_msgtype = DHCPREQUEST,
.apply_min_timeout = 0,
.min_timeout = 1,
.max_timeout = 8,
};

/**
Expand Down Expand Up @@ -699,7 +700,8 @@ static struct dhcp_session_state dhcp_state_proxy = {
.rx = dhcp_proxy_rx,
.expired = dhcp_proxy_expired,
.tx_msgtype = DHCPREQUEST,
.apply_min_timeout = 0,
.min_timeout = 1,
.max_timeout = 8,
};

/**
Expand Down Expand Up @@ -846,7 +848,8 @@ static struct dhcp_session_state dhcp_state_pxebs = {
.rx = dhcp_pxebs_rx,
.expired = dhcp_pxebs_expired,
.tx_msgtype = DHCPREQUEST,
.apply_min_timeout = 1,
.min_timeout = 1,
.max_timeout = 8,
};

/****************************************************************************
Expand Down

0 comments on commit 2058e73

Please sign in to comment.