Page MenuHomeVyOS Platform

dhcp-server time-offset fails to validate
Closed, ResolvedPublic

Description

# set service dhcp-server shared-network-name FOO subnet 192.0.2.0/24 time-offset 3600


  usage: validate-value.py [-h] [--regex REGEX] [--exec EXEC] [--value VALUE]
  validate-value.py: error: argument --regex: expected one argument
  
  Invalid time offset value
  Value validation failed
  Set failed

Validator is regex in vyos-1x interface-definitions/dhcp-server.xml:

<leafNode name="time-offset">
  <properties>
    <help>Offset of the client's subnet in seconds from Coordinated Universal Time (UTC)</help>
    <valueHelp>
      <format>[-]N</format>
      <description>Time offset (number, may be negative)</description>
    </valueHelp>
    <constraint>
      <regex>-?[0-9]+</regex>
    </constraint>
    <constraintErrorMessage>Invalid time offset value</constraintErrorMessage>

At first I thought this may be due to my recent commit 377c04cb:

 -                        <regex>^-?[0-9]+$</regex>
+                        <regex>-?[0-9]+</regex>

It was my understanding that ^ and $ are unecessary as they are implied by default. Indeed removing them from other regexes in the same file had no negative effects. But the validator seems to be broken in some other way as it complains about expecting one argument, suggesting it gets 0 or more than 1 arguments.

Details

Difficulty level
Unknown (require assessment)
Version
1.2.0-rolling+201906210337
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)

Event Timeline

jjakob created this object in space S1 VyOS Public.
Viacheslav claimed this task.
Viacheslav added a subscriber: Viacheslav.

Fixed. 1.2.7, VyOS 1.3.0-rc3, VyOS 1.4-rolling-202104041918

set service dhcp-server shared-network-name NET-01 subnet 192.0.2.0/24 default-router '192.0.2.1'
set service dhcp-server shared-network-name NET-01 subnet 192.0.2.0/24 range 0 start '192.0.2.10'
set service dhcp-server shared-network-name NET-01 subnet 192.0.2.0/24 range 0 stop '192.0.2.100'
set service dhcp-server shared-network-name NET-01 subnet 192.0.2.0/24 time-offset '3600'

Dhcpd.conf

# Shared network configration(s)
shared-network NET-01 {
    subnet 192.0.2.0 netmask 255.255.255.0 {
        option routers 192.0.2.1;
        option time-offset 3600;
        default-lease-time 86400;
        max-lease-time 86400;
        range 192.0.2.10 192.0.2.100;
    }
    on commit {
        set shared-networkname = "NET-01";
    }
}
erkin set Is it a breaking change? to Unspecified (possibly destroys the router).Aug 31 2021, 6:57 PM
erkin set Issue type to Bug (incorrect behavior).