mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +00:00
[#2868] Checkpoint: finished upgradeBinaryAddress6
This commit is contained in:
@@ -4038,6 +4038,84 @@ MySqlLeaseMgr::getLeases6ByLink(const IOAddress& /* link_addr */,
|
||||
isc_throw(NotImplemented, "MySqlLeaseMgr::getLeases6ByLink not implemented");
|
||||
}
|
||||
|
||||
size_t
|
||||
MySqlLeaseMgr::upgradeBinaryAddress6(const LeasePageSize& page_size) {
|
||||
auto check = CfgMgr::instance().getCurrentCfg()->
|
||||
getConsistency()->getExtendedInfoSanityCheck();
|
||||
|
||||
size_t pages = 0;
|
||||
size_t updated = 0;
|
||||
IOAddress start_addr = IOAddress::IPV6_ZERO_ADDRESS();
|
||||
for (;;) {
|
||||
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
|
||||
DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_PAGE)
|
||||
.arg(pages)
|
||||
.arg(start_addr.toText())
|
||||
.arg(updated);
|
||||
|
||||
// Prepare WHERE clause.
|
||||
MYSQL_BIND inbind[2];
|
||||
memset(inbind, 0, sizeof(inbind));
|
||||
|
||||
// Bind start address.
|
||||
std::string start_addr_str = "0";
|
||||
if (!start_addr.isV6Zero()) {
|
||||
start_addr_str = start_addr.toText();
|
||||
}
|
||||
unsigned long start_addr_size = start_addr_str.size();
|
||||
inbind[0].buffer_type = MYSQL_TYPE_STRING;
|
||||
inbind[0].buffer = const_cast<char*>(start_addr_str.c_str());
|
||||
inbind[0].buffer_length = start_addr_size;
|
||||
inbind[0].length = &start_addr_size;
|
||||
|
||||
// Bind page size value.
|
||||
uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
|
||||
inbind[1].buffer_type = MYSQL_TYPE_LONG;
|
||||
inbind[1].buffer = reinterpret_cast<char*>(&ps);
|
||||
inbind[1].is_unsigned = MLM_TRUE;
|
||||
|
||||
Lease6Collection leases;
|
||||
|
||||
// Get a context.
|
||||
{
|
||||
MySqlLeaseContextAlloc get_context(*this);
|
||||
MySqlLeaseContextPtr ctx = get_context.ctx_;
|
||||
|
||||
getLeaseCollection(ctx, GET_LEASE6_BINADDR_PAGE, inbind, leases);
|
||||
}
|
||||
|
||||
if (leases.empty()) {
|
||||
// Done.
|
||||
break;
|
||||
}
|
||||
|
||||
++pages;
|
||||
start_addr = leases.back()->addr_;
|
||||
for (auto lease : leases) {
|
||||
try {
|
||||
updateLease6(lease);
|
||||
++updated;
|
||||
} catch (const NoSuchLease&) {
|
||||
// The lease was modified in parallel:
|
||||
// as its extended info was processed just ignore.
|
||||
continue;
|
||||
} catch (const std::exception& ex) {
|
||||
// Something when wrong, for instance extract failed.
|
||||
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE,
|
||||
DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_ERROR)
|
||||
.arg(lease->addr_.toText())
|
||||
.arg(ex.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6)
|
||||
.arg(pages)
|
||||
.arg(updated);
|
||||
|
||||
return (updated);
|
||||
}
|
||||
|
||||
size_t
|
||||
MySqlLeaseMgr::buildExtendedInfoTables6(bool /* update */, bool /* current */) {
|
||||
isc_throw(isc::NotImplemented,
|
||||
|
Reference in New Issue
Block a user