You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DHCPv6 Prefix Delegation not assigning prefixes #9591
This should be uint32_t since it overflows if prefix is larger than /60. RFC says it can assign prefixes between /48 and /64, in case of /48 number of /64 prefixes would be 65535, which means uint32_t is the only on that fit, uint16_t will overflow by 1.
Second the prefix is never announced by RADV, i see advertisements but not with the prefix option.
Also prefixes is not split in multiple /64 networks, currently at least according to logs all it does it just take the prefix received and put on a /64 mask. And thereby doing this on all interfaces it's trying to assign to, resulting in assigning the same prefix to multiple interfaces.
Steps to reproduce the problem
Setup prefix delegation with the following config:
Other
I would love to get some clearity in how this is supposed to work. Is RADV annoncment the goal, or should it also add addresses to the interface?
I'd go even further and use a 64 bit integer, as 32 bit would still overflow when using a prefix size of /32 or larger (should not happen often, but possible with RFC-violating ULA ranges). I tried to do so in #9592, but that broke compatibility with 32-bit platforms, and I don't feel qualified to properly fix that.
Another possibility would be to to use 32 bit and instead reject prefixes > /48 (or /33), as they make little sense in real-world applications anyway.
BTW, I can confirm the integer overflow on v239 on Arch Linux.
I also noticed something strange today with how networkd assigns prefixes with this fix applied (this should not be caused by this fix). What i noticed was networkd not taking the prefix length into consideration when auto generating /64 prefixes from the bigger prefix assigned from upstream.
Prefix assigned: 2001:db8:8080:fe00::/56
Prefixes (/64) generated from that prefix: (Notice how it changes the first 2 bits of the fourth group even if mask says it only can change the 2 last of fourth group).
Prefix 1: 2001:db8:8080:fe00::/64 (This is ok)
Prefix 2: 2001:db8:8080:ff00::/64 (This is not ok as prefix assigned would need to be a /52 in order for this to be within range).
What's happening here is that probably networkd is increasing by 1 without taking the prefix length into consideration. This needs to be replaced with more intelligent prefix allocation code.
3.1. Number and Length of Delegated Prefixes
The prefix delegation mechanism should allow for delegation of
prefixes of lengths between /48 and /64, inclusively. Other lengths
should also be supported. The mechanism should allow for delegation
of more than one prefix to the customer.
@Gigadoc2 Since the RFC actually says that all prefixes should be supported, think uint64_t would be in order. But maybe add a notice to logs notifying user that prefixes not between /48 and /64 is abnormal to be assigned thru PD?
I wounder if networkd supports multiple prefixes thru prefix delegation, i assume it will use all available /64 networks in the first one assigned first, and then move on the the next assigned prefix?
I wounder if networkd supports multiple prefixes thru prefix delegation, i assume it will use all available /64 networks in the first one assigned first, and then move on the the next assigned prefix?
@halvors I think this is exactly whats happening. In dhcp6_pd_prefix_distribute, if all the /64 prefixes are assigned, it will return EAGAIN, which in dhcp6_lease_pd_prefix_acquired (the calling function) will cause sd_dhcp6_lease_get_pd to be called again, which gets the next PD-assigned prefix (if available) and then calls dhcp6_pd_prefix_distribute again, with the new prefix.
@poettering Nice work! Did you also understand what i meant with auto generation of /64 networks from prefix assigned from upstream do not follow prefix length limitations?
Activity
Gigadoc2 commentedon Jul 16, 2018
I'd go even further and use a 64 bit integer, as 32 bit would still overflow when using a prefix size of /32 or larger (should not happen often, but possible with RFC-violating ULA ranges). I tried to do so in #9592, but that broke compatibility with 32-bit platforms, and I don't feel qualified to properly fix that.
Another possibility would be to to use 32 bit and instead reject prefixes > /48 (or /33), as they make little sense in real-world applications anyway.
BTW, I can confirm the integer overflow on v239 on Arch Linux.
halvors commentedon Jul 17, 2018
I also noticed something strange today with how networkd assigns prefixes with this fix applied (this should not be caused by this fix). What i noticed was networkd not taking the prefix length into consideration when auto generating /64 prefixes from the bigger prefix assigned from upstream.
Prefix assigned: 2001:db8:8080:fe00::/56
Prefixes (/64) generated from that prefix: (Notice how it changes the first 2 bits of the fourth group even if mask says it only can change the 2 last of fourth group).
What's happening here is that probably networkd is increasing by 1 without taking the prefix length into consideration. This needs to be replaced with more intelligent prefix allocation code.
halvors commentedon Jul 17, 2018
From RFC 3769 (https://tools.ietf.org/html/rfc3769)
@Gigadoc2 Since the RFC actually says that all prefixes should be supported, think
uint64_twould be in order. But maybe add a notice to logs notifying user that prefixes not between /48 and /64 is abnormal to be assigned thru PD?I wounder if networkd supports multiple prefixes thru prefix delegation, i assume it will use all available /64 networks in the first one assigned first, and then move on the the next assigned prefix?
networkd: fix overflow check
poettering commentedon Jul 17, 2018
Fix waiting in #9613
Gigadoc2 commentedon Jul 17, 2018
@halvors I think this is exactly whats happening. In
dhcp6_pd_prefix_distribute, if all the /64 prefixes are assigned, it will return EAGAIN, which indhcp6_lease_pd_prefix_acquired(the calling function) will causesd_dhcp6_lease_get_pdto be called again, which gets the next PD-assigned prefix (if available) and then callsdhcp6_pd_prefix_distributeagain, with the new prefix.halvors commentedon Jul 17, 2018
@poettering Nice work! Did you also understand what i meant with auto generation of /64 networks from prefix assigned from upstream do not follow prefix length limitations?
The code here needs to take prefix length into concideration:
https://github.com/systemd/systemd/blob/master/src/basic/in-addr-util.c#L182
Instead of unconditionally just increasing by 1 which is does now.
Gigadoc2 commentedon Jul 17, 2018
I think the "counting problem" is a separate issue, so I created another one in #9626.
halvors commentedon Jul 17, 2018
@Gigadoc2 Yeah, nice work :)
networkd: fix overflow check
networkd: fix overflow check