Page MenuHomeVyOS Platform

DHCP server statistic is empty in 1.2
Closed, ResolvedPublic

Description

1. DHCP server has active leases but column "Pool" is empty. (in 1.1.8 this column is populated with dhcp shared-network-name 'LAN')
ma@ipsec-left:~$ sh dhcp server leases

IP address       Hardware address   Lease expiration     Pool                      Client Name
----------       ----------------   ----------------     ----                      -----------
192.168.0.128    00:0c:29:89:19:94  2018/07/02 18:00:00                            ipsec-l2tp

2. DHCP statistics is empty. Column "Leased" is 0 but in fact we have one active lease.

ma@ipsec-left:~$ show dhcp server statistics 

Pool                      Pool size   # Leased    # Avail
----                      ---------   --------    -------
LAN                       127         0           127

3. DHCP server configuration

ma@ipsec-left# show service dhcp-server 
 disabled false
 hostfile-update disable
 shared-network-name LAN {
     authoritative enable
     subnet 192.168.0.0/24 {
         default-router 192.168.0.1
         dns-server 192.168.0.1
         domain-name internal-net
         lease 86400
         start 192.168.0.128 {
             stop 192.168.0.254
         }
     }
 }

4. Current VYOS version

ma@ipsec-left:~$ sh ver
Version:          VyOS 1.2.0-rolling+201807011342
Built by:         [email protected]
Built on:         Sun 01 Jul 2018 13:42 UTC
Build ID:         308061e6-61c9-4e27-a4cf-b291df102ef1

Architecture:     x86_64
Boot via:         installed image
System type:      VMware guest

Hardware vendor:  VMware, Inc.
Hardware model:   VMware Virtual Platform
Hardware S/N:     Unknown
Hardware UUID:    Unknown

Copyright:        VyOS maintainers and contributors

Details

Difficulty level
Unknown (require assessment)
Version
VyOS 1.2.0-rolling+201807011342
Why the issue appeared?
Will be filled on close

Event Timeline

syncer triaged this task as Normal priority.Jul 6 2018, 8:42 PM
syncer changed the visibility from "Subscribers" to "Public (No Login Required)".
syncer edited subscribers, added: Active contributors, Maintainers; removed: oleksandr.mamenko.
hagbard changed the task status from Open to In progress.Jul 6 2018, 10:26 PM

I can replicate it, looking into it.

Due to the newer dhcp-server package in jessie, the entries in dhcp.leases have changed and shared-network is not exposed in there, that is where the vyatta parser module fails ( /opt/vyatta/share/perl5/Vyatta/DHCPServerOpMode.pm ) in function get_active().

hagbard changed the task status from In progress to Open.Jul 9 2018, 3:35 PM

vyatta deployed their own and modified dhcpd, their modification is to set the shared-networkname in the lease file (https://github.com/vyos/vyatta-dhcp3/blob/lithium/server/db.c#L135), which is parsed by get_active() (/opt/vyatta/share/perl5/Vyatta/DHCPServerOpMode.pm).
It's possible to set variables on a lease event (more events like release are possible as well, or executing scripts on a lease etc.). However, since there are multiple new features available, I think the best is to rewrite the dhcp-server (ipv4) stuff first.

The below does work, if the parser now looks for shared-networkname (line 66 in /opt/vyatta/share/perl5/Vyatta/DHCPServerOpMode.pm needs to be modified), however that feels like a nasty hack rather than a solution.
I would think to rewrite the dhcp interface first.
All opinions welcome.

ddns-update-style none;
shared-network TEST {

authoritative;
subnet 192.168.0.0 netmask 255.255.255.0 {
        default-lease-time 86400;
        max-lease-time 86400;
        range 192.168.0.1 192.168.0.10;
}
on commit { set shared-networkname = "TEST"; }

}

I implemented the hack I proposed, in my tests it did work quite well. Let me know if there are still issues.

status set to resolved. git repo needs to be merged.