[Kea-users] DHCP6 HA fails due to prefix len of 0

Simon Marsh simon at burble.com
Wed Sep 19 08:41:10 UTC 2018


I'm running Kea 1.4.0-P1 and attempting to implement the new HA features in
hot-standby mode across two servers.
I have DHCP4 working fine, but with DHCP6 the two servers appear to sync
leases ok, but then the dhcp6 server errors after a fail over.

What happens is that when leases are transferred between the two servers
the prefix len field is not transferred. This can be verified by checking
the kea-ctrl-agent logs, and the relevant Lease6::toElement code which only
includes the prefix len field if it was a PD lease (rather than a host
lease).

lease.cc / line 621

    if (type_ == Lease::TYPE_PD) {
        map->set("prefix-len", Element::create(prefixlen_));
    }

When the lease is then created on the standby node, it ends up with a
prefix len of 0 in the lease database.
The dhcp6 server then errors because a prefix len of 0 for a host lease is
invalid:

ERROR [kea-dhcp6.alloc-engine/22008] ALLOC_ENGINE_V6_ALLOC_ERROR
duid=[00:02:00:00:ab:11:a2:2e:96:99:f5:65:86:03], tid=0x3eacc1: error
during attempt to allocate an IPv6 address: invalid prefix length '0' for
reserved IPv6 address, expected 128

The root cause of this appears to be the way that the Lease is created in
the lease_cmds hook.
There are three constructors for Lease6, two of these default the prefix
len to 128, e.g:

lease.h / line 532

Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr, DuidPtr duid,
           uint32_t iaid, uint32_t preferred, uint32_t valid, uint32_t t1,
           uint32_t t2, SubnetID subnet_id, const bool fqdn_fwd,
           const bool fqdn_rev, const std::string& hostname,
           const HWAddrPtr& hwaddr = HWAddrPtr(), uint8_t prefixlen = 128);

However, when the lease_cmds hook adds a new lease it first creates a lease
using the empty constructor and then populates it.
The empty constructor creates a Lease with prefix len 0:

lease.cc / line 493

Lease6::Lease6()
    : Lease(isc::asiolink::IOAddress("::"), 0, 0, 0, 0, 0, false, false, "",
            HWAddrPtr()), type_(TYPE_NA), prefixlen_(0), iaid_(0),
            duid_(DuidPtr()), preferred_lft_(0) {
}

Because the prefix len is not part of the JSON message, the net result is
that the prefix len never gets populated and stays at 0.

I think the simple fix for this would be to update the empty constructor to
set the prefix to 128 as this is the 'default' what the rest of the code
seems to expect.



Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/kea-users/attachments/20180919/ff75208b/attachment.htm>


More information about the Kea-users mailing list