From: Jeff Wieland (wieland@purdue.edu)
Date: Thu Feb 06 2003 - 11:05:12 CST
Brian Johnson wrote:
> Hello List,
>
> First off, I'd like to say thank you to all the people who've worked on
> NetReg. We put it into production at the beginning of this semester and
> have been incredibly pleased!
>
> Unfortunately we do have a small problem...
>
> Our NetReg server is running isc-dhcpd-V3.0pl1, which is pretty harsh with
> regards to duplicate hostnames -- so harsh, it just kills the server. I
> know that when NetReg enters the host names in dhcpd.conf.new, it appends
> a "-1, -2, etc" to the username to allow for users with multiple computers
> and avoid duplicate names in the conf file. This seems to work well for
> the most part, but we've found on several occasions (and twice in only a
> matter of a couple of days recently) that somehow they got through. From
> our bootplog:
>
> Feb 4 22:43:02 netreg dhcpd: /usr1/dhcp/dhcpd.conf line 6257: host vm-1:
> already exists
>
> Feb 4 22:43:02 netreg dhcpd: host vm-1 { hardware ethernet
> 00:30:F1:13:7B:DE ; }
>
> Is anyone else running into the same problem using dhcpd v. 3 and higher?
> We've considered going back to an earlier version of dhcp, but would like
> to see if someone having the same problem has gotten a way to
> prevent dupes from happening. Thanks in advance for your help!
>
> Brian
>
> -------------
> Brian Johnson
> ECI Data
> brian@netcom.duke.edu
> 919-668-6492
> **********************************************************************
> To unsubscribe from this list, send an e-mail message to
> majordomo@southwestern.edu containing a single line with the words:
> unsubscribe netreg
> Send requests for assistance to: owner-netreg@southwestern.edu
> **********************************************************************
Since there is no locking of the dhcpd.conf.new file, there is nothing
to prevent race conditions. I added a sub to the register.cgi script
to use a seperate file, called "serial" that contains the serial number.
It locks the file while it is being updated.
Here is the routine:
#
# Routine to find the next serial number. We read it from a file, locking
# the file to prevent race conditions. The old netreg method just scanned
# through the dhcpconf file to find the highest serial (slow, slow) and
# did no locking!
#
# Author: Jeff Wieland, VPIT-ITT. Purdue University
#
# Date: 4/29/2002
sub get_serial {
my $LOCK_SH = 1;
my $LOCK_EX = 2;
my $LOCK_NB = 4;
my $LOCK_UN = 8;
if (-e "$DHCPDCONFPATH/serial") {
open SERIAL, "+<$DHCPDCONFPATH/serial" or die "ERROR: Can't open serial
file" ;
flock SERIAL, $LOCK_EX;
$serial = <SERIAL>;
chomp $serial;
$serial++;
seek SERIAL, 0, 0;
}
else {
open SERIAL, ">serial" or die "ERROR: Can't open serial file" ;
flock SERIAL, $LOCK_EX;
$serial = 0;
}
print SERIAL "$serial\n";
flock SERIAL, $LOCK_UN;
close SERIAL;
return $serial;
}
-- Jeff Wieland | Purdue University Network Analyst/Engineer | IT Telecommunications Voice: (765)496-8234 | 150 North University Street FAX: (765)494-0566 | West Lafayette, IN 47907-2067********************************************************************** To unsubscribe from this list, send an e-mail message to majordomo@southwestern.edu containing a single line with the words: unsubscribe netreg Send requests for assistance to: owner-netreg@southwestern.edu **********************************************************************
This archive was generated by hypermail 2.1.4 : Thu Aug 12 2004 - 12:01:38 CDT