Editing dhcpd.conf without corrupting leases

Mr. Jan Walter hopping_hol at yahoo.com
Mon Apr 13 17:12:28 UTC 2009


It's also not clear from one paragraph what you're really doing, so don't get huffy when others' assumptions don't correspond to your reality. Really - sorry for trying to help.

There isn't any locking done on the leases or conf file by dhcpd itself. What's most likely happening (without me reading through all that source) is that if your web app's write of the config file is not complete, while your cron is sending the SIGHUP to dhcpd, some internal check fails and the leases file is considered corrupt.

So - have your web app write a lock file to disk to tell your cron script there is an update in progress, and don't HUP it until that lockfile is gone. This should eliminate any "if"s about race conditions. The other option/possibility is have your web app update a database, and your cron script updates the dhcpd.conf (or better yet, something it includes) and then HUPs dhcpd. You could even test the config file before letting dhcpd get serious with it.

Before doing all this, see what happens when you HUP dhcpd without the config file changing. If your leases corrupts then there something else wrong.

Cheers,

Jan



----- Original Message ----
From: Sean Kelly <smkelly at rooster.creighton.edu>
To: Users of ISC DHCP <dhcp-users at lists.isc.org>
Sent: Monday, April 13, 2009 12:32:33 PM
Subject: Re: Editing dhcpd.conf without corrupting leases

On Mon, Apr 13, 2009 at 09:28:18AM -0700, Mr. Jan Walter wrote:
> I think the easy answer to this one is to add some more logic, like lockfiles, to your dhcp updating scheme - as in, don't SIGHUP it when you know the file isn't complete. If you're having this problem, how do you know you're not processing two update requests simultaneously and then hopelessly corrupting the file?

Unless I'm missing something, there is no proper locking done of the lease
file now for me to leverage or become "smart" about. As for double updates,
my updaters on.y touch dhcpd.conf. The corruption is being seen on
dhcpd.leases, which I do not touch at all. I can't have two updates at once
because the update runs from cron, not triggered directly by a web
registration.

> ----- Original Message ----
> From: Sean Kelly <smkelly at rooster.creighton.edu>
> To: dhcp-users at lists.isc.org
> Sent: Monday, April 13, 2009 12:18:17 PM
> Subject: Editing dhcpd.conf without corrupting leases
> 
> Good morning.
> 
> We have a web application here that allows users to register their IPs and
> a process comes along and updates /etc/dhcpd.conf every minute or so and
> restarts dhcpd as needed. However, ew're starting to see issues where our
> dhcpd.leases file is truncated and dhcpd refuses to start back up.
> 
> My working theory is that the SIGTERM from `/etc/init.d/dhcpd restart` is
> happening in the middle of a lease file append, thus causing it to become a
> corrupt leasefile and then making dhcpd fail on restart. That is the
> easiest explanation I've been able to come up with.
> 
> What are people doing to prevent this sort of thing when automatically
> restarting dhcpd? There doesn't appear to be any locking of dhcpd.leases,
> so I can't have my restart process wait for an exclusive write lock to know
> the file is in a consistent state. I'm also not sure whether OMAPI is the
> right solution, or even supportd/maintained anymore. There is no SIGHUP to
> do a config file reload.
> 
> How can I reload dhcpd.conf without accidentally corrupting dhcpd.leases
> due to a restart? This is starting to be a bigger problem here.
> 
> Thanks.
> -- 
> Sean M. Kelly
> Associate Director
> Division of Information Technology
> Creighton University
> (402) 280-2264
> AIM: smkellyg5
> _______________________________________________
> dhcp-users mailing list
> dhcp-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/dhcp-users
> 
> 
> 
>      
> _______________________________________________
> dhcp-users mailing list
> dhcp-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/dhcp-users

-- 
Sean M. Kelly
Associate Director
Division of Information Technology
Creighton University
(402) 280-2264
AIM: smkellyg5
_______________________________________________
dhcp-users mailing list
dhcp-users at lists.isc.org
https://lists.isc.org/mailman/listinfo/dhcp-users



      



More information about the dhcp-users mailing list