extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4 = "DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4";
extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4_ERROR = "DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4_ERROR";
extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4_PAGE = "DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4_PAGE";
+extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6 = "DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6";
+extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6_ERROR = "DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6_ERROR";
+extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6_PAGE = "DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6_PAGE";
extern const isc::log::MessageID DHCPSRV_NOTYPE_DB = "DHCPSRV_NOTYPE_DB";
extern const isc::log::MessageID DHCPSRV_NO_SOCKETS_OPEN = "DHCPSRV_NO_SOCKETS_OPEN";
extern const isc::log::MessageID DHCPSRV_OPEN_SOCKET_FAIL = "DHCPSRV_OPEN_SOCKET_FAIL";
extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4 = "DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4";
extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4_ERROR = "DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4_ERROR";
extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4_PAGE = "DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4_PAGE";
+extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6 = "DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6";
+extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6_ERROR = "DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6_ERROR";
+extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6_PAGE = "DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6_PAGE";
extern const isc::log::MessageID DHCPSRV_QUEUE_NCR = "DHCPSRV_QUEUE_NCR";
extern const isc::log::MessageID DHCPSRV_QUEUE_NCR_FAILED = "DHCPSRV_QUEUE_NCR_FAILED";
extern const isc::log::MessageID DHCPSRV_QUEUE_NCR_SKIP = "DHCPSRV_QUEUE_NCR_SKIP";
"DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4", "upgrading IPv4 leases done in %1 pages with %2 updated leases",
"DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4_ERROR", "upgrading extending info for IPv4 lease at %1 failed with %2",
"DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4_PAGE", "upgrading IPv4 lease extended info at page %1 starting at %2 (updated %3)",
+ "DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6", "upgrading IPv6 leases done in %1 pages with %2 updated leases",
+ "DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6_ERROR", "upgrading extending info for IPv6 lease at %1 failed with %2",
+ "DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6_PAGE", "upgrading IPv6 lease extended info at page %1 starting at %2 (updated %3)",
"DHCPSRV_NOTYPE_DB", "no 'type' keyword to determine database backend: %1",
"DHCPSRV_NO_SOCKETS_OPEN", "no interface configured to listen to DHCP traffic",
"DHCPSRV_OPEN_SOCKET_FAIL", "failed to open socket: %1",
"DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4", "upgrading IPv4 leases done in %1 pages with %2 updated leases",
"DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4_ERROR", "upgrading extending info for IPv4 lease at %1 failed with %2",
"DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4_PAGE", "upgrading IPv4 lease extended info at page %1 starting at %2 (updated %3)",
+ "DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6", "upgrading IPv6 leases done in %1 pages with %2 updated leases",
+ "DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6_ERROR", "upgrading extending info for IPv6 lease at %1 failed with %2",
+ "DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6_PAGE", "upgrading IPv6 lease extended info at page %1 starting at %2 (updated %3)",
"DHCPSRV_QUEUE_NCR", "%1: Name change request to %2 DNS entry queued: %3",
"DHCPSRV_QUEUE_NCR_FAILED", "%1: queuing %2 name change request failed for lease %3: %4",
"DHCPSRV_QUEUE_NCR_SKIP", "%1: skip queuing name change request for lease: %2",
extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4;
extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4_ERROR;
extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4_PAGE;
+extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6;
+extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6_ERROR;
+extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6_PAGE;
extern const isc::log::MessageID DHCPSRV_NOTYPE_DB;
extern const isc::log::MessageID DHCPSRV_NO_SOCKETS_OPEN;
extern const isc::log::MessageID DHCPSRV_OPEN_SOCKET_FAIL;
extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4;
extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4_ERROR;
extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4_PAGE;
+extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6;
+extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6_ERROR;
+extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6_PAGE;
extern const isc::log::MessageID DHCPSRV_QUEUE_NCR;
extern const isc::log::MessageID DHCPSRV_QUEUE_NCR_FAILED;
extern const isc::log::MessageID DHCPSRV_QUEUE_NCR_SKIP;
The page number and started address, and the count of already updated leases
are displayed.
+% DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6 upgrading IPv6 leases done in %1 pages with %2 updated leases
+The server upgraded extended info. The number of pages and the final count of
+updated leases are displayed.
+
+% DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6_ERROR upgrading extending info for IPv6 lease at %1 failed with %2
+A debug message issued when the server failed to upgrade an extended info.
+The address of the lease and the error message are displayed.
+
+% DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6_PAGE upgrading IPv6 lease extended info at page %1 starting at %2 (updated %3)
+A debug message issued when the server upgrades IPv6 lease extended info.
+The page number and started address, and the count of already updated leases
+are displayed.
+
% DHCPSRV_NOTYPE_DB no 'type' keyword to determine database backend: %1
This is an error message, logged when an attempt has been made to access
a database backend, but where no 'type' keyword has been included in
The page number and started address, and the count of already updated leases
are displayed.
+% DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6 upgrading IPv6 leases done in %1 pages with %2 updated leases
+The server upgraded extended info. The number of pages and the final count of
+updated leases are displayed.
+
+% DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6_ERROR upgrading extending info for IPv6 lease at %1 failed with %2
+A debug message issued when the server failed to upgrade an extended info.
+The address of the lease and the error message are displayed.
+
+% DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6_PAGE upgrading IPv6 lease extended info at page %1 starting at %2 (updated %3)
+A debug message issued when the server upgrades IPv6 lease extended info.
+The page number and started address, and the count of already updated leases
+are displayed.
+
% DHCPSRV_QUEUE_NCR %1: Name change request to %2 DNS entry queued: %3
A debug message which is logged when the NameChangeRequest to add or remove
a DNS entries for a particular lease has been queued. The first argument
/// @return The number of updates in the database or 0.
virtual size_t buildExtendedInfoTables6(bool update, bool current) = 0;
+ /// @brief Upgrade extended info (v6).
+ ///
+ /// On SQL backends for all leases with a not null user context.
+ /// - sanitize the user context
+ /// - update relay and remote id tables
+ /// - when the lease was modified update it in the database
+ /// On memfile backend a similar action is done when the database is
+ /// loaded from the file. This function implements the new BLQ hook
+ /// command named "extended-info6-upgrade".
+ ///
+ /// @param page_size The page size used for retrieval.
+ /// @return The number of updates in the database.
+ virtual size_t upgradeExtendedInfo6(const LeasePageSize& page_size) = 0;
+
/// @brief Wipe extended info table (v6).
virtual void wipeExtendedInfoTables6() = 0;
}
}
+size_t
+Memfile_LeaseMgr::upgradeExtendedInfo6(const LeasePageSize& /* page_size */) {
+ return (0);
+}
+
void
Memfile_LeaseMgr::deleteExtendedInfo6(const IOAddress& addr) {
LeaseAddressRelayIdIndex& relay_id_idx =
/// @return The number of updates in the database or 0.
virtual size_t buildExtendedInfoTables6(bool update, bool current) override;
+ /// @brief Upgrade extended info (v6).
+ ///
+ /// @param page_size The page size used for retrieval.
+ /// @return Always return 0 as this function is a noop for not SQL backends.
+ virtual size_t upgradeExtendedInfo6(const LeasePageSize& page_size) override;
+
/// @brief Wipe extended info table (v6).
virtual void wipeExtendedInfoTables6() override;
"MySqlLeaseMgr::buildExtendedInfoTables6 not implemented");
}
+size_t
+MySqlLeaseMgr::upgradeExtendedInfo6(const LeasePageSize& page_size) {
+ auto check = CfgMgr::instance().getCurrentCfg()->
+ getConsistency()->getExtendedInfoSanityCheck();
+
+ // First step is to wipe tables if enabled.
+ if (getExtendedInfoTablesEnabled()) {
+ wipeExtendedInfoTables6();
+ }
+
+ 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_EXTENDED_INFO6_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 = "";
+ 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_UCTX_PAGE, inbind, leases);
+ }
+
+ if (leases.empty()) {
+ // Done.
+ break;
+ }
+
+ ++pages;
+ start_addr = leases.back()->addr_;
+ for (auto lease : leases) {
+ try {
+ bool modified = upgradeLease6ExtendedInfo(lease, check);
+ if (modified) {
+ updateLease6(lease);
+ }
+ bool added = (getExtendedInfoTablesEnabled() &&
+ addExtendedInfo6(lease));
+ if (modified || added) {
+ ++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_EXTENDED_INFO6_ERROR)
+ .arg(lease->addr_.toText())
+ .arg(ex.what());
+ }
+ }
+ }
+
+ LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO6)
+ .arg(pages)
+ .arg(updated);
+
+ return (updated);
+}
+
void
MySqlLeaseMgr::wipeExtendedInfoTables6() {
// Get a context.
/// @return The number of updates in the database or 0.
virtual size_t buildExtendedInfoTables6(bool update, bool current) override;
+ /// @brief Upgrade extended info (v6).
+ ///
+ /// All leases with a not null user context.
+ /// - sanitize the user context
+ /// - update relay and remote id tables
+ /// - when the lease was modified update it in the database
+ /// This function implements the new BLQ hook command named
+ /// "extended-info6-upgrade".
+ ///
+ /// @param page_size The page size used for retrieval.
+ /// @return The number of updates in the database.
+ virtual size_t upgradeExtendedInfo6(const LeasePageSize& page_size) override;
+
/// @brief Wipe by-relay-id table (v6).
virtual void wipeExtendedInfoTables6() override;
"PgSqlLeaseMgr::buildExtendedInfoTables6 not implemented");
}
+size_t
+PgSqlLeaseMgr::upgradeExtendedInfo6(const LeasePageSize& page_size) {
+ auto check = CfgMgr::instance().getCurrentCfg()->
+ getConsistency()->getExtendedInfoSanityCheck();
+
+ // First step is to wipe tables if enabled.
+ if (getExtendedInfoTablesEnabled()) {
+ wipeExtendedInfoTables6();
+ }
+
+ 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_PGSQL_UPGRADE_EXTENDED_INFO6_PAGE)
+ .arg(pages)
+ .arg(start_addr.toText())
+ .arg(updated);
+
+ // Prepare WHERE clause.
+ PsqlBindArray bind_array;
+
+ // Bind start address.
+ std::string start_addr_str = "0";
+ if (!start_addr.isV6Zero()) {
+ start_addr_str = start_addr.toText();
+ }
+ bind_array.add(start_addr_str);
+
+ // Bind page size value.
+ std::string page_size_data =
+ boost::lexical_cast<std::string>(page_size.page_size_);
+ bind_array.add(page_size_data);
+
+ Lease6Collection leases;
+
+ // Get a context.
+ {
+ PgSqlLeaseContextAlloc get_context(*this);
+ PgSqlLeaseContextPtr ctx = get_context.ctx_;
+
+ getLeaseCollection(ctx, GET_LEASE6_UCTX_PAGE, bind_array, leases);
+ }
+
+ if (leases.empty()) {
+ // Done.
+ break;
+ }
+
+ ++pages;
+ start_addr = leases.back()->addr_;
+ for (auto lease : leases) {
+ try {
+ bool modified = upgradeLease6ExtendedInfo(lease, check);
+ if (modified) {
+ updateLease6(lease);
+ }
+ bool added = (getExtendedInfoTablesEnabled() &&
+ addExtendedInfo6(lease));
+ if (modified || added) {
+ ++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_PGSQL_UPGRADE_EXTENDED_INFO6_ERROR)
+ .arg(lease->addr_.toText())
+ .arg(ex.what());
+ }
+ }
+ }
+
+ LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6)
+ .arg(pages)
+ .arg(updated);
+
+ return (updated);
+}
+
void
PgSqlLeaseMgr::wipeExtendedInfoTables6() {
// Get a context.
/// @return The number of updates in the database or 0.
virtual size_t buildExtendedInfoTables6(bool update, bool current) override;
+ /// @brief Upgrade extended info (v6).
+ ///
+ /// All leases with a not null user context.
+ /// - sanitize the user context
+ /// - update relay and remote id tables
+ /// - when the lease was modified update it in the database
+ /// This function implements the new BLQ hook command named
+ /// "extended-info6-upgrade".
+ ///
+ /// @param page_size The page size used for retrieval.
+ /// @return The number of updates in the database.
+ virtual size_t upgradeExtendedInfo6(const LeasePageSize& page_size) override;
+
/// @brief Wipe extended info table (v6).
virtual void wipeExtendedInfoTables6() override;
isc_throw(isc::NotImplemented, "ConcreteLeaseMgr:buildExtendedInfoTables6 not implemented");
}
+size_t
+ConcreteLeaseMgr::upgradeExtendedInfo6(const LeasePageSize& /* page_size */) {
+ return (0);
+}
+
void
ConcreteLeaseMgr::wipeExtendedInfoTables6() {
isc_throw(NotImplemented, "ConcreteLeaseMgr::wipeExtendedInfoTables6() not implemented");
virtual size_t buildExtendedInfoTables6(bool /* update */,
bool /* current */) override;
+ /// @brief Stub implementation.
+ virtual size_t
+ upgradeExtendedInfo6(const LeasePageSize& /* page_size */) override;
+
/// @brief Stub implementation.
virtual void
wipeExtendedInfoTables6() override;