Skip to content

DHCPv6 Prefix Delegation not assigning prefixes #9591

Closed

Description

@halvors

systemd version the issue has been seen with

237

Used distribution

Ubuntu 18.04

Expected behaviour you didn't see

Prefix assigned thru DHCPv6-PD should be assigned to LAN interfaces, and announced by RADV. This is not working.

Unexpected behaviour you saw

First of all there is a bug preventing prefix assignment to even start (found by @Damjan). It's here:

uint8_t n_prefixes, n_used = 0;

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:

Configuration on interface facing ISP:

[Match]
Name=eth0

[Network]
DHCP=yes
IPv6AcceptRA=true

Configuration on LAN interface:

[Match]
Name=eth1

[Network]
IPv6AcceptRA=false
IPv6PrefixDelegation=dhcpv6

[IPv6PrefixDelegation]
RouterLifetimeSec=1800

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?

Activity

  1. Gigadoc2 commented on Jul 16, 2018

    @Gigadoc2
    Contributor

    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.

  2. added
    bug 🐛
    on Jul 16, 2018
  3. added this to the v240 milestone on Jul 16, 2018
  4. halvors commented on Jul 17, 2018

    @halvors
    Author

    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.

  5. halvors commented on Jul 17, 2018

    @halvors
    Author

    From RFC 3769 (https://tools.ietf.org/html/rfc3769)

    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?

  6. added a commit that references this issue on Jul 17, 2018
    0c93c94
  7. poettering commented on Jul 17, 2018

    @poettering
    Member

    Fix waiting in #9613

  8. Gigadoc2 commented on Jul 17, 2018

    @Gigadoc2
    Contributor

    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.

  9. halvors commented on Jul 17, 2018

    @halvors
    Author

    @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.

  10. Gigadoc2 commented on Jul 17, 2018

    @Gigadoc2
    Contributor

    I think the "counting problem" is a separate issue, so I created another one in #9626.

  11. halvors commented on Jul 17, 2018

    @halvors
    Author

    @Gigadoc2 Yeah, nice work :)

  12. added a commit that references this issue on Jul 25, 2018
    9fb96ab
  13. added a commit that references this issue on Oct 31, 2018
    9a6f2a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛dhcp

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions