Order that ranges are dolled out?

David W. Hankins David_Hankins at isc.org
Fri Mar 2 19:21:37 UTC 2007


On Fri, Mar 02, 2007 at 01:25:09PM -0500, Keith Lawson wrote:
> I'm sure this has been asked here before but I can't seem to find anything in the archives. 

The trouble is we have two archives because the list name changed
not long ago (dhcp-client and dhcp-server formed dhcp-users).

I'm not sure it would help if you knew that anyway since the last
thread on the topic was fairly long and included some stuff I later
determined isn't quite right.

Anyway we probably need a new entry for this for the new archives.


> When dhcpd dolls out leases from a range does it do it in numerical order starting at the lowest number and going up until it finds the next available IP? 

Initially it provides the leases in "inverse hash order".  Because
of the vast size of the lease hash (so ranges don't usually stride
the edge boundaries), this usually means they go in reverse order.

As leases get used up by returning clients, they get handed out
in "oldest order".

The leases whose previous clients haven't returned in the longest
time get handed out first...the inverse hash order only applies to
'untouched' leases.


I used to think this was because of the order in which the leases
were pushed to a stack during initialization, but someone who
actually sent me a patch to reverse the order discovered the
problem was considerably more complex.

That complexity made it something that couldn't really be a
(likely new default) configuration option the way we wanted it
to be, so it didn't make 3.1.0.

As it turns out we're considering restructuring how some of
this works - so that the leases are kept in state-based heaps
rather than today's linear lists, to cut down on the insertion
penalty.

When that's done we'll probably introduce a "tiebreaker" for the
free and backup heaps when expiration time is equal (or zero), and
I think we'll be able to introduce that with the "implicit config
file order" (probably by placing a config order serial number on
the lease structure).

Eg the end result I'm hoping for is for:

	range 10.0.0.1 10.0.0.254;

And:

	range 10.0.0.254 10.0.0.1;

To produce opposite, and intuitive, results.

We'll be able to cut down a lot on cpu use on big installations
at the same time.

-- 
ISC Training!  http://www.isc.org/training/  training at isc.org
Washington DC area, April 16-20 2007.  DNS & BIND, DDNS & DHCP.
-- 
David W. Hankins	"If you don't do it right the first time,
Software Engineer		you'll just have to do it again."
Internet Systems Consortium, Inc.	-- Jack T. Hankins


More information about the dhcp-users mailing list