Project

General

Profile

Actions

Bug #4931

closed

dhcpleases misses some DHCP lease changes

Added by Karl Kec over 9 years ago. Updated about 9 years ago.

Status:
Resolved
Priority:
High
Category:
DNS Resolver
Target version:
Start date:
08/12/2015
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
All
Affected Architecture:
All

Description

Some changes to dhcp leases made by dhcpd to its database in /var/dhcpd/var/db/dhcpd.leases, are being missed by dhcpleases. When this happens unbound is not made aware of new or expired leases.

dhcpd changes the dhcpd.leases file as dhcp leases change, but once per hour it rewrites the file from scratch. When it rewrites it, the existing file is first moved out of the way and a new file created. It appears kevent in dhcpleases (watching for changes to dhcpd.leases) is then watching the moved file, which no longer is changed as dhcp leases come and go, so unbound is unaware of dhcp lease changes. After another hour, dhcpd again re-creates the dhcpd.leases file, which causes a kqueue error in dhcpleases. dhcpleases traps this and re-opens the dhcpd.leases file. Then for the next hour dhcpleases again sees lease changes, until the file is again moved and the process starts over. So it can take up to an hour for unbound to see a new dhcp lease.

As a test, I added a 5-minute timeout to the kevent in dhcpleases, and when the timeout occurs the file is closed and re-opened (see attached patch). This hack reduces delay for unbound to see a new lease to 5 minutes, but is now essentially polling for changes to the file. Five minutes works in my environment, but may not be appropriate for others.

I think this hack could work, but ideally what's needed is a better mechanism for tracking recreation of the dhcpd.leases file.


Files

dhcpleases.patch (917 Bytes) dhcpleases.patch Karl Kec, 08/12/2015 11:39 AM
Actions

Also available in: Atom PDF