[BusyBox] udhcpc renew on signal bug - Busybox 1.0 CVS

Joshua Jackson busybox at vortech.net
Fri Oct 24 01:01:23 UTC 2003

I sent a message to the list a little while back about a DHCP client renew 
"storm" and am pretty sure I have figured out what is going on, but am a 
little stumped by the way udhcpc handles signals...

In the event that udhcpc receives a SIGTERM, it will frequently lauch a dozen 
or so renew requests onto the network. During a system reboot, init will kill 
off syslogd prior the udhcpc client (at least the way my systems are 
configured) and it looks pretty goofy seeing a dozen or better renew requests 
being sent during the system shutdown.

The best I can figure without spending a whole lot of time trying to figure 
out why udhcpc uses an FDSET to listen for signals is that the fact that the 
state machine is in a "BOUND" state when the signal is initially received - 
as the same state loop is used for signal processing and normal operation, 
sending a SIGTERM triggers "case BOUND:" as it runs through the pile of 
if/case statements and triggers the following code block:

			case BOUND:
				/* Lease is starting to run out, time to enter renewing state */
				state = RENEWING;
				DEBUG(LOG_INFO, "Entering renew state");
				/* fall right through */
			case RENEWING:
				/* Either set a new T1, or enter REBINDING state */
				if ((t2 - t1) <= (lease / 14400 + 1)) {
					/* timed out, enter rebinding state */
					state = REBINDING;
					timeout = now + (t2 - t1);
					DEBUG(LOG_INFO, "Entering rebinding state");
				} else {
					/* send a request packet */
					send_renew(xid, server_addr, requested_ip); /* unicast */

					t1 = (t2 - t1) / 2 + t1;
					timeout = t1 + start;

As the presence of an actual signal is not checked until last, a bunch of code 
that should not be run gets launched.

Just my $.02, and I may be way off base here... I only spent about 10 minutes 
looking at the code. Most of the busybox code has been very easy for me to 
work with... In this case, the difference in coding style from my own makes 
my brain hurt :P

However, the dozen or so extraneous requests is definately not proper 
behaviour for a DHCP client.

Joshua Jackson
Vortech Consulting, LLC

More information about the busybox mailing list