Page MenuHomeVyOS Platform

DHCPv6 does not have prefix range validation
Closed, ResolvedPublicBUG

Description

Reproducing steps:

set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 address-range start 2001:db8:3456::100 stop '2001:db8:3456::1ff'
set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 name-server '2001:db8:daad::1'
set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 prefix-delegation start 2001:db8:290::500 prefix-length '64'
set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 prefix-delegation start 2001:db8:290::500 stop '2001:db8:290::5ff'

It allows to apply the setting, but DHCPv6 server does not start and die with error in logs

Apr 23 11:30:01 vyos systemd[1]: Starting ISC DHCP IPv6 server...
Apr 23 11:30:01 vyos dhcpd[8404]: /run/dhcp-server/dhcpdv6.conf line 13: network mask too short
Apr 23 11:30:01 vyos dhcpd[8404]:         prefix6 2001:db8:290::500 2001:db8:290::5ff/64;
Apr 23 11:30:01 vyos dhcpd[8404]:                                                     ^
Apr 23 11:30:01 vyos dhcpd[8404]: Configuration file errors encountered -- exiting
Apr 23 11:30:01 vyos dhcpd[8404]: 
Apr 23 11:30:01 vyos dhcpd[8404]: If you think you have received this message due to a bug rather
Apr 23 11:30:01 vyos dhcpd[8404]: than a configuration issue please read the section on submitting
Apr 23 11:30:01 vyos dhcpd[8404]: bugs on either our web page at www.isc.org or in the README file
Apr 23 11:30:01 vyos dhcpd[8404]: before submitting a bug.  These pages explain the proper
Apr 23 11:30:01 vyos dhcpd[8404]: process and the information we find helpful for debugging.
Apr 23 11:30:01 vyos dhcpd[8404]: 
Apr 23 11:30:01 vyos dhcpd[8404]: exiting.

Details

Version
1.4-rolling-202104221210
Is it a breaking change?
Perfectly compatible
Issue type
Unspecified (please specify)

Event Timeline

Unknown Object (User) created this task.Apr 23 2021, 1:55 PM
dmbaturin set Issue type to Unspecified (please specify).
dmbaturin subscribed.

Should be easy to do now that ipaddrcheck supports range validation.

Can I claim this? will submit a Draft PR for review, I have it resolved (see test output below)

Test 1: Prefix start address is not within Subnet

set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 address-range start 2001:db8:3456::100 stop '2001:db8:3456::1ff'
set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 name-server '2001:db8:daad::1'
set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 prefix-delegation start 2001:db8:290::500 prefix-length '64'
set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 prefix-delegation start 2001:db8:290::500 stop '2001:db8:290::5ff'

	ConfigError output:
	Prefix delegation start address "2001:db8:290::500" is not in subnet
    "2001:db8:3456::/64"

Test 2: Prefix stop address is not within Subnet

set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 address-range start 2001:db8:3456::100 stop '2001:db8:3456::1ff'
set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 name-server '2001:db8:daad::1'
set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 prefix-delegation start 2001:db8:3456::500 prefix-length '64'
set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 prefix-delegation start 2001:db8:3456::500 stop '2001:db8:290::5ff'

	ConfigError output: 
	Prefix delegation stop address "2001:db8:290::5ff" is not in subnet
	"2001:db8:3456::/64"

Does 1.5 has the same bug?

Prefixes are handled differently in 1.5/Kea there's no option to set a prefix delegation start/stop address like before.

vyos@vyos-A# set service dhcpv6-server shared-network-name VyOS-DHCPv6 subnet 2001:db8:3456::/64 prefix-delegation prefix 3000:1::
Possible completions:
   delegated-length            Length in bits of prefixes to be delegated
   excluded-prefix             IPv6 prefix to be excluded from prefix delegation
   excluded-prefix-length      Length in bits of excluded prefix
   prefix-length               Length in bits of prefix

This is actually a "wrong" error, or a real error with a wrong fix.

Apr 23 11:30:01 vyos dhcpd[8404]: /run/dhcp-server/dhcpdv6.conf line 13: network mask too short
Apr 23 11:30:01 vyos dhcpd[8404]:         prefix6 2001:db8:290::500 2001:db8:290::5ff/64;

The issue is that the config syntax is incorrect. Both 2001:db8:290::500 and 2001:db8:290::5ff are full 128bit IPv6 addresses and thus cannot slice /64s out of it. The proper ranges you wanted to express are most likely: 2001:db8:290:500:: to 2001:db8:290:5ff::
I will revert the verify() logic as this is legit ISC DHCPv6 behavior to assign a PD from outside of the subnet6 in use.

set service dhcpv6-server shared-network-name SMOKE-2 subnet 2001:db8:f00::/64 address-range start 2001:db8:f00::100 stop '2001:db8:f00::ffff'
set service dhcpv6-server shared-network-name SMOKE-2 subnet 2001:db8:f00::/64 prefix-delegation start 2001:db8:ee:: prefix-length '56'
set service dhcpv6-server shared-network-name SMOKE-2 subnet 2001:db8:f00::/64 prefix-delegation start 2001:db8:ee:: stop '2001:db8:ee:ff00::'

gives

# Shared network configration(s)
shared-network SMOKE-2 {
    subnet6 2001:db8:f00::/64 {
        range6 2001:db8:f00::100 2001:db8:f00::ffff;
        prefix6 2001:db8:ee:: 2001:db8:ee:ff00:: /56;
    }
    on commit {
        set shared-networkname = "SMOKE-2";
    }
}

And using this subnet on a client by DHCPv6-PD logs:

May 26 08:43:46 dhcpd[7613]: Solicit message from fe80::250:56ff:febf:c56d port 546, transaction ID 0x9085200
May 26 08:43:46 dhcpd[7613]: Advertise NA: address 2001:db8:f00::917d to client with duid 00:04:73:67:3f:42:df:77:80:c4:42:c9:42:af:ff:15:de:0b iaid = 0 valid for 43200 seconds
May 26 08:43:46 dhcpd[7613]: Picking pool prefix 2001:db8:ee:ff00::/56
May 26 08:43:46 dhcpd[7613]: Advertise PD: address 2001:db8:ee:ff00::/56 to client with duid 00:04:73:67:3f:42:df:77:80:c4:42:c9:42:af:ff:15:de:0b iaid = 0 valid for 4294967295 seconds
May 26 08:43:46 dhcpd[7613]: Sending Advertise to fe80::250:56ff:febf:c56d port 546
May 26 08:43:47 dhcpd[7613]: Request message from fe80::250:56ff:febf:c56d port 546, transaction ID 0x3AAB5E00
May 26 08:43:47 dhcpd[7613]: Reply NA: address 2001:db8:f00::917d to client with duid 00:04:73:67:3f:42:df:77:80:c4:42:c9:42:af:ff:15:de:0b iaid = 0 valid for 43200 seconds
May 26 08:43:47 dhcpd[7613]: Reply PD: address 2001:db8:ee:ff00::/56 to client with duid 00:04:73:67:3f:42:df:77:80:c4:42:c9:42:af:ff:15:de:0b iaid = 0 valid for 4294967295 seconds
May 26 08:43:47 dhcpd[7613]: Sending Reply to fe80::250:56ff:febf:c56d port 546
c-po reopened this task as In progress.May 26 2024, 8:26 AM
c-po claimed this task.