Page MenuHomeVyOS Platform

"show dhcpv6 server leases" shows leases from wrong file
Closed, ResolvedPublicBUG


"show dhcpv6 server leases" shows outdated (very old) leases from "/opt/vyatta/etc/config/dhcpdv6.leases".
Instead it should use "/config/dhcpd6.leases" which is used by dhcpd.

ps shows dhcpd using /config/dhcpd6.leases:

/usr/sbin/dhcpd -q -6 -lf /config/dhcpd6.leases -cf /etc/dhcp/dhcpd6.conf -pf /var/run/

(edit): fixed typo in filename


Difficulty level
Easy (less than an hour)
Why the issue appeared?
Implementation mistake

Event Timeline

After some more investigation, dhcpd6.leases in /config/ and /opt/vyatta/etc/config/ are the same.
In the same config folder there's also dhcpdv6.leases (with the letter "v" before 6) that's a leftover from an older image.

-rw-r--r-- 1 root root       3262 Jun 12 14:55 dhcpd6.leases
-rw-r--r-- 1 root root       2615 Jun 12 14:23 dhcpd6.leases~
-rw-r--r-- 1 root root      27726 Jun 12 14:30 dhcpd.leases
-rw-r--r-- 1 root root      28072 Jun 12 14:22 dhcpd.leases~
-rwxrwxr-x 1 root vyattacfg  8141 Oct 27  2018 dhcpdv6.leases
-rwxrwxr-x 1 root vyattacfg 17618 Oct 27  2018 dhcpdv6.leases~

If I delete these two, I get a nice traceback when running show dhcpv6 server leases:

vyos@vyos:~$ show dhcpv6 server leases 
Traceback (most recent call last):
  File "/usr/libexec/vyos/op_mode/", line 81, in <module>
    leases = get_leases(lease_file, state='active')
  File "/usr/libexec/vyos/op_mode/", line 44, in get_leases
    leases = IscDhcpLeases(lease_file).get()
  File "/usr/lib/python3/dist-packages/isc_dhcp_leases/", line 110, in get
    with open(self.filename) as lease_file:
FileNotFoundError: [Errno 2] No such file or directory: '/config/dhcpdv6.leases'

So it seems that at some point the dhcpd leases filename was changed without updating the name everywhere else (and leaving the old files dangling).

c-po changed the task status from Open to Backport pending.Jun 16 2019, 12:05 AM
c-po triaged this task as Normal priority.

Please verify the fix with latest rolling release

@c-po The commits only fix the generated config filename, not the one used by dhcpd (set in /etc/default/isc-dhcpdv6-server) so it would probably break the dhcpv6-server. Even if both were updated, that would cause the server to forget all the cached leases on upgrade that are stored in the old leases file as there is no migration script to copy the old filename to new.

I'd revert both commits and change just src/op_mode/ line 27 to show the current filename.

I‘d keep it as it is as it was previously a bug accessibg the wrong file. As DHCP clients usually request their last assigned address not to many systems will break.

@c-po Line 115 and 116 of src/conf_mode/ (that generate /etc/default/isc-dhcpdv6-server) still reference the dhcpd6 name and would need to be changed also.
Are you sure we should change all these filenames and the leases filename without migrating it? I guess if you wanted the naming with "dhcpv6" consistent, but IMO it's unnecessary.
The alternative would be to just fix src/op_mode/ and keep the old lease file naming, thus not breaking the cache on upgrade for all users.
I'll create a PR with the version you decide...

c-po moved this task from In Progress to Finished on the VyOS 1.2 Crux (VyOS 1.2.2) board.
dmbaturin changed Difficulty level from Unknown (require assessment) to Easy (less than an hour).Jul 1 2019, 8:57 AM
dmbaturin changed Why the issue appeared? from Will be filled on close to Implementation mistake.