[PATCH] udhcpc: give up on repeated errors

Paul Fox pgf at brightstareng.com
Tue May 20 05:22:18 PDT 2008


 > From: Peter Korsgaard <jacmet at sunsite.dk>
 > 
 > udhcpc never time out if errors occur (E.G. if the network
 > interface didn't detect a link), as the file descriptor keeps
 > on being readable with the error condition (E.G. -ENETDOWN).
 > 
 > Add a max_errors and give up if it is exceeded.

if this behavior is desirable, i think it should be made
conditional, and, in my opinion, it should be made conditional in
a way that preserves current behavior by default.  i suspect
there should probably be a delay before we continue looping.

paul

 > 
 > Signed-off-by: Peter Korsgaard <jacmet at sunsite.dk>
 > ---
 >  networking/udhcp/dhcpc.c |    9 +++++++++
 >  1 files changed, 9 insertions(+), 0 deletions(-)
 > 
 > diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
 > index fb328cb..8154db3 100644
 > --- a/networking/udhcp/dhcpc.c
 > +++ b/networking/udhcp/dhcpc.c
 > @@ -140,6 +140,8 @@ int udhcpc_main(int argc ATTRIBUTE_UNUSED, char **argv)
 >  	int tryagain_timeout = 20;
 >  	int discover_timeout = 3;
 >  	int discover_retries = 3;
 > +	int errors = 0;
 > +	int max_errors = 5;
 >  	uint32_t xid = 0;
 >  	uint32_t lease_seconds = 0; /* can be given as 32-bit quantity */
 >  	int packet_num;
 > @@ -477,6 +479,13 @@ int udhcpc_main(int argc ATTRIBUTE_UNUSED, char **argv)
 >  			if (len == -1) { /* error is severe, reopen socket */
 >  				DEBUG("error on read, %s, reopening socket", strerror(errno));
 >  				change_listen_mode(listen_mode); /* just close and reopen */
 > +				if (++errors >= max_errors) {
 > +					bb_info_msg("Too many errors, failing");
 > +					retval = 2;
 > +					goto ret;
 > +				}
 > +			} else {
 > +				errors = 0;
 >  			}
 >  			if (len < 0) continue;
 >  
 > -- 
 > 1.5.5.1
 > 
 > _______________________________________________
 > busybox mailing list
 > busybox at busybox.net
 > http://busybox.net/cgi-bin/mailman/listinfo/busybox

=---------------------
 paul fox, pgf at brightstareng.com


More information about the busybox mailing list