On 2011-03-16, Grant Edwards<grant.b.edwards@gmail.com> wrote:
We've been having intermittent problems with RedBoot's DHCP client
failing to acquire an address. I've tracked it down to what looks
like a race condition in RedBoot's DHCP code.
Apart from the race condition that's overwriting the saved bp_info
struct, I'm a little baffled by the "retry" counter in
__bootp_find_local_ip. It doesn't appear to count attempts to get an
IP address. It appears to count passes through the foreground state
machine loop. It takes 3 passes through that loop to obtain an IP
address via DHCP.
In our build, somebody had set MAX_RETRIES to 4. With 4 retries, I
presume they assumed that up to 5 attempts would be made, but only 1
is made.
I changed the code so that it's only decremented once for each
attempted DHCP transaction, and then I ended up with cases where it
looped indefinitely because the retry counter is re-initialized by the
state machine when an OFFER packet is received.
Can somebody explain how the retry counter is supposed to work?