DHCPv6 lease updates failing for some clients (postgresql)
As reported to Support in ticket RT 14761
Describe the bug This is a possible bug inside the postgresql lease manager which makes ipv6 lease updates impossible for some clients.
The ipv6 ia_id is stored in a column called "iaid" in the "lease6" table. We noticed that sometimes there is a negative value inside this column, and this are exactly the hosts, for which ipv6 lease updates fail.
The dhcpv6 ia_id is a 32 bit unsigned integer, which is (for database compatibility) obviously casted to a 32 bit signed integer inside pgsql_lease_mgr.cc.
But when one of the functions
- PgSqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid, uint32_t iaid);
- PgSqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid, uint32_t iaid, SubnetID subnet_id); is called, inside the function the iaid is not being converted/casted to a signed int, which leads to a wrong database query. As a result the dhcp lease with the searched iaid is not found and a new ipv6 lease is created for this client with every dhcpv6 request.
As a (temporary) fix we created a simple patch for the pgsql_lease_mgr.cc, which is attached to this ticket. With this patch the dhcpv6 lease update works as expected.
Environment: We are using kea 1.4.0-P1 with postgresql as database backend.
The bug seems to be present also in version 1.5.0/1.6.0, although we didn't test it.
Additional Information This looks like it might be similar to #181 (closed) ?