Project

General

Profile

Actions

Bug #13321

open

dhcpleases handles duplicate hostnames incorrectly

Added by Adrian Fonseca about 2 months ago. Updated about 1 month ago.

Status:
Pull Request Review
Priority:
Normal
Assignee:
-
Category:
DHCP (IPv4)
Target version:
-
Start date:
Due date:
% Done:

0%

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

Description

--- Problem ---
If the 'dhcpd.leases' file parsed by dhcpleases contains an expired lease and non-expired lease for the same hostname, it will not produce any output if the non-expired lease appears in the file before the expired lease.

For example if 'dhcpd.leases' contains:
1) Non-Expired Lease for host1
2) Expired Lease for host1

No output will be produced. However, swapping entries 1) and 2) will result in the correct output.

--- How to Reproduce ---
Using the attached 'dhcpd.leases' file, run:

dhcpleases -f -d home -l dhcpd.leases -u /dev/null -h /dev/null

Notice that it finds both the leases but does not produce an unbound entry.
If you switch the order of the leases in 'dhcp.leases' and re-run, the unbound entry is now produced.

--- Possible cause ---
This appears to be caused by the fact that as dhcpleases populates its list of leases, if another lease (B) with the same hostname as a previous lease (A) is found, instead of having a duplicate entry it will update the expiry date of lease A with the expiry date of lease B (without checking if lease A or B have expired). After populating the list, it then purges all expired leases (thus in this case leaving the list empty). A possible solution is to only add non-expired leases to the list as they are processed and avoid the purge at the end.

--- Workarounds ---
1) Manually purge expired leases in /var/dhcpd/var/db/dhcpd.leases
OR
2) In the web interface: Status -> DHCP Leases -> Click 'Show all Expired Leases' at bottom of page -> manually remove all expired leases


Files

dhcpd.leases (488 Bytes) dhcpd.leases Adrian Fonseca, 06/29/2022 11:08 PM
Actions #2

Updated by Jim Pingle about 1 month ago

  • Status changed from New to Pull Request Review
Actions

Also available in: Atom PDF