dhcpstart and dhcpend pitfall

I got burnt by the dhcpstart and dhcpend parameters so I would like
to bring the subject matter up for discussion :-

I have set up a configuration :-

dynip 10.130.8.160/255.255.255.224
dhcpstart 161
dhcpend 189

Then chilli start to dispense out :-

10.130.9.65

as the first IP. This is obviously wrong as it's already falling out
of the '255.255.255.224' range.

The correct dhcpstart should be 1 and dhcpend should be 29.

I know this is a 'user problem' of wrongly understood the
meaning of dhcpstart and dhcpend. But I thought it will be
good that the system does some idiot/foolproof checking to
avoid this pitfall, that could save the users a lot of trouble
trying to figure out what's wrong with the system.

Regards

Add to it, a configuration

Add to it, a configuration like this is also accepted :-

dynip 10.130.8.254/255.255.255.224

which is also wrong as it is already outside the netmask.

Here is my proposed patch to

Here is my proposed patch to perform stricter dhcpstart and dhcpend check -
( sorry can't do attachment )

diff -Nur a/src/ippool.c b/src/ippool.c
--- a/src/ippool.c 2009-07-11 10:32:51.000000000 +0800
+++ b/src/ippool.c 2009-07-11 10:35:31.000000000 +0800
@@ -131,6 +131,14 @@

m = ntohl(mask.s_addr);
dynsize = ((~m)+1);
+ if ( ((ntohl(addr.s_addr) + start)&m) != (ntohl(addr.s_addr)&m) ) {
+ log_err(0, "Invalid dhcpstart (outside of subnet)!");
+ return -1;
+ }
+ if ( ((ntohl(addr.s_addr) + end)&m) != (ntohl(addr.s_addr)&m) ) {
+ log_err(0, "Invalid dhcpend (outside of subnet)!");
+ return -1;
+ }

if (start > 0 && end > 0) {

Thanks. I'll test it out.

Thanks. I'll test it out. And, you are right about dhcpstart/dhcpend. It should be explained better in the man pages.