<div dir="ltr">I'm running Kea 1.4.0-P1 and attempting to implement the new HA features in hot-standby mode across two servers. <div>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. </div><div><br></div><div>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). </div><div><br></div><div>lease.cc / line 621</div><div><br></div><div>    if (type_ == Lease::TYPE_PD) {</div><div>        map->set("prefix-len", Element::create(prefixlen_));</div><div>    }</div><div> </div><div>When the lease is then created on the standby node, it ends up with a prefix len of 0 in the lease database. </div><div>The dhcp6 server then errors because a prefix len of 0 for a host lease is invalid:</div><div><br></div><div><div>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</div></div><div><br></div><div>The root cause of this appears to be the way that the Lease is created in the lease_cmds hook.</div><div>There are three constructors for Lease6, two of these default the prefix len to 128, e.g: </div><div><br></div><div>lease.h / line 532</div><div><br></div><div><div>Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr, DuidPtr duid,</div><div>           uint32_t iaid, uint32_t preferred, uint32_t valid, uint32_t t1,</div><div>           uint32_t t2, SubnetID subnet_id, const bool fqdn_fwd,</div><div>           const bool fqdn_rev, const std::string& hostname,</div><div>           const HWAddrPtr& hwaddr = HWAddrPtr(), uint8_t prefixlen = 128);</div></div><div><br></div><div>However, when the lease_cmds hook adds a new lease it first creates a lease using the empty constructor and then populates it. </div><div>The empty constructor creates a Lease with prefix len 0:</div><div><br></div><div>lease.cc / line 493</div><div><br></div><div><div>Lease6::Lease6()</div><div>    : Lease(isc::asiolink::IOAddress("::"), 0, 0, 0, 0, 0, false, false, "",</div><div>            HWAddrPtr()), type_(TYPE_NA), prefixlen_(0), iaid_(0),</div><div>            duid_(DuidPtr()), preferred_lft_(0) {</div><div>}</div></div><div><br></div><div>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.</div><div><br></div><div>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.<br></div><div><br></div><div><br></div><div><br></div><div>Simon </div></div>