+src/share/api/binary-address6-upgrade.json
src/share/api/build-report.json
src/share/api/cache-clear.json
src/share/api/cache-flush.json
Bulk Lease Query required additions to the lease data stored. With SQL lease
backends, leases created prior to the server being configured for Bulk Lease
Query will not contain the new data required. In order to populate this data
-it is necessary to run an API command:
+it is necessary to run API commands:
.. _command-extended-info4-upgrade:
"command": "extended-info4-upgrade"
}
+.. _command-binary-address6-upgrade:
+
+For DHCPv6 lease data, there are two commands, for upgrading the binary
+address used for by link address query the command is:
+
+::
+
+ {
+ "command": "binary-address6-upgrade"
+ }
+
.. _command-extended-info6-upgrade:
-For DHCPv6 lease data, the command is (TO BE IMPLEMENTED):
+for extended info used for by relay id and by remote id the command is
+(TO BE IMPLEMENTED):
::
}
-In either case the response will indicate whether it succeeded or failed
+In all cases the response will indicate whether it succeeded or failed
and include either the count of leases updated or the nature of the failure:
::
}
-The command's operation is governed by ``extended-info-checks`` parameter
-under the sanity-checks element. Please see :ref:`sanity-checks4` or
-:ref:`sanity-checks6`.
+The operation of extended info command is governed by ``extended-info-checks``
+parameter under the sanity-checks element. Please see :ref:`sanity-checks4`
+or :ref:`sanity-checks6`.
For large numbers of leases this command may take some time to complete.
.. note::
Existing leases must have been created by Kea with ``store-extended-info``
- enabled in order for the new data to be extracted and stored.
+ enabled in order for the new data from extended info to be extracted
+ and stored.
extern const isc::log::MessageID DHCPSRV_MYSQL_TLS_CIPHER = "DHCPSRV_MYSQL_TLS_CIPHER";
extern const isc::log::MessageID DHCPSRV_MYSQL_UPDATE_ADDR4 = "DHCPSRV_MYSQL_UPDATE_ADDR4";
extern const isc::log::MessageID DHCPSRV_MYSQL_UPDATE_ADDR6 = "DHCPSRV_MYSQL_UPDATE_ADDR6";
+extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6 = "DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6";
+extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_ERROR = "DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_ERROR";
+extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_PAGE = "DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_PAGE";
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_PGSQL_TLS_SUPPORT = "DHCPSRV_PGSQL_TLS_SUPPORT";
extern const isc::log::MessageID DHCPSRV_PGSQL_UPDATE_ADDR4 = "DHCPSRV_PGSQL_UPDATE_ADDR4";
extern const isc::log::MessageID DHCPSRV_PGSQL_UPDATE_ADDR6 = "DHCPSRV_PGSQL_UPDATE_ADDR6";
+extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6 = "DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6";
+extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6_ERROR = "DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6_ERROR";
+extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6_PAGE = "DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6_PAGE";
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";
"DHCPSRV_MYSQL_TLS_CIPHER", "TLS cipher: %1",
"DHCPSRV_MYSQL_UPDATE_ADDR4", "updating IPv4 lease for address %1",
"DHCPSRV_MYSQL_UPDATE_ADDR6", "updating IPv6 lease for address %1, lease type %2",
+ "DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6", "upgrading IPv6 leases done in %1 pages with %2 updated leases",
+ "DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_ERROR", "upgrading binary address for IPv6 lease at %1 failed with %2",
+ "DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_PAGE", "upgrading IPv6 lease binary addresses at page %1 starting at %2 (updated %3)",
"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_PGSQL_TLS_SUPPORT", "Attempt to configure TLS: %1",
"DHCPSRV_PGSQL_UPDATE_ADDR4", "updating IPv4 lease for address %1",
"DHCPSRV_PGSQL_UPDATE_ADDR6", "updating IPv6 lease for address %1, lease type %2",
+ "DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6", "upgrading IPv6 leases done in %1 pages with %2 updated leases",
+ "DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6_ERROR", "upgrading binary address for IPv6 lease at %1 failed with %2",
+ "DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6_PAGE", "upgrading IPv6 lease binary addresses at page %1 starting at %2 (updated %3)",
"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)",
extern const isc::log::MessageID DHCPSRV_MYSQL_TLS_CIPHER;
extern const isc::log::MessageID DHCPSRV_MYSQL_UPDATE_ADDR4;
extern const isc::log::MessageID DHCPSRV_MYSQL_UPDATE_ADDR6;
+extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6;
+extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_ERROR;
+extern const isc::log::MessageID DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_PAGE;
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_PGSQL_TLS_SUPPORT;
extern const isc::log::MessageID DHCPSRV_PGSQL_UPDATE_ADDR4;
extern const isc::log::MessageID DHCPSRV_PGSQL_UPDATE_ADDR6;
+extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6;
+extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6_ERROR;
+extern const isc::log::MessageID DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6_PAGE;
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;
A debug message issued when the server is attempting to update IPv6
lease from the MySQL database for the specified address.
+% DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6 upgrading IPv6 leases done in %1 pages with %2 updated leases
+The server upgraded binary addresses. The number of pages and the
+final count of updated leases are displayed.
+
+% DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_ERROR upgrading binary address for IPv6 lease at %1 failed with %2
+A debug message issued when the server failed to upgrade a binary address.
+The address of the lease and the error message are displayed.
+
+% DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_PAGE upgrading IPv6 lease binary addresses at page %1 starting at %2 (updated %3)
+A debug message issued when the server upgrades IPv6 lease binary addresses.
+The page number and started address, and the count of already updated leases
+are displayed.
+
% DHCPSRV_MYSQL_UPGRADE_EXTENDED_INFO4 upgrading IPv4 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.
A debug message issued when the server is attempting to update IPv6
lease from the PostgreSQL database for the specified address.
+% DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6 upgrading IPv6 leases done in %1 pages with %2 updated leases
+The server upgraded binary addresses. The number of pages and the
+final count of updated leases are displayed.
+
+% DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6_ERROR upgrading binary address for IPv6 lease at %1 failed with %2
+A debug message issued when the server failed to upgrade a binary address.
+The address of the lease and the error message are displayed.
+
+% DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6_PAGE upgrading IPv6 lease binary addresses at page %1 starting at %2 (updated %3)
+A debug message issued when the server upgrades IPv6 lease binary addresses.
+The page number and started address, and the count of already updated leases
+are displayed.
+
% DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4 upgrading IPv4 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.
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,
/// @return The number of updates in the database.
virtual size_t upgradeExtendedInfo4(const LeasePageSize& page_size) override;
+ /// @brief Upgrade binary address (v6).
+ ///
+ /// On SQL backends for all leases with null binary address set this
+ /// new column. Memfile uses IOAddress objets so does not need it.
+ /// This function implements the new BLQ hook command named
+ /// "binary-address6-upgrade".
+ ///
+ /// @param page_size The page size used for retrieval.
+ /// @return The number of updates in the database.
+ virtual size_t upgradeBinaryAddress6(const LeasePageSize& page_size) override;
+
/// @brief Build extended info v6 tables.
///
/// @param update Update extended info in database.
isc_throw(NotImplemented, "PgSqlLeaseMgr::getLeases6ByLink not implemented");
}
+size_t
+PgSqlLeaseMgr::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_PGSQL_UPGRADE_BINARY_ADDRESS6_PAGE)
+ .arg(pages)
+ .arg(start_addr.toText())
+ .arg(updated);
+
+ // Prepare WHERE clause.
+ PsqlBindArray bind_array;
+
+ // Bind start address.
+ std::string start_addr_data = "0";
+ if (!start_addr.isV6Zero()) {
+ start_addr_data = start_addr.toText();
+ }
+ bind_array.add(start_addr_data);
+
+ // 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_BINADDR_PAGE, bind_array, 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_PGSQL_UPGRADE_BINARY_ADDRESS6_ERROR)
+ .arg(lease->addr_.toText())
+ .arg(ex.what());
+ }
+ }
+ }
+
+ LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_UPGRADE_BINARY_ADDRESS6)
+ .arg(pages)
+ .arg(updated);
+
+ return (updated);
+}
+
size_t
PgSqlLeaseMgr::buildExtendedInfoTables6(bool /* update */, bool /* current */) {
isc_throw(isc::NotImplemented,
/// @return The number of updates in the database.
virtual size_t upgradeExtendedInfo4(const LeasePageSize& page_size) override;
+ /// @brief Upgrade binary address (v6).
+ ///
+ /// On SQL backends for all leases with null binary address set this
+ /// new column. Memfile uses IOAddress objets so does not need it.
+ /// This function implements the new BLQ hook command named
+ /// "binary-address6-upgrade".
+ ///
+ /// @param page_size The page size used for retrieval.
+ /// @return The number of updates in the database.
+ virtual size_t upgradeBinaryAddress6(const LeasePageSize& page_size) override;
+
/// @brief Build extended info v6 tables.
///
/// @param update Update extended info in database.
+api_files += $(top_srcdir)/src/share/api/binary-address6-upgrade.json
api_files += $(top_srcdir)/src/share/api/build-report.json
api_files += $(top_srcdir)/src/share/api/cache-clear.json
api_files += $(top_srcdir)/src/share/api/cache-flush.json
--- /dev/null
+{
+ "access": "write",
+ "avail": "2.3.8",
+ "brief": [
+ "This command fills the binary address column for all IPv6 leases where it is NULL in the SQL lease database."
+ ],
+ "cmd-syntax": [
+ "{",
+ " \"command\": \"binary-address6-upgrade\"",
+ " }",
+ "}"
+ ],
+ "description": "See <xref linkend=\"command-binary-address6-upgrade\"/>",
+ "hook": "lease_query",
+ "name": "binary-address6-upgrade",
+ "resp-comment": [
+ "This command should be used when some old IPv6 leases are present in the lease database using a SQL backend."
+ ],
+ "resp-syntax": [
+ "{",
+ " \"arguments\": {",
+ " },",
+ " \"result\": 0,",
+ " \"text\": \"to be done\"",
+ "}"
+ ],
+ "support": [
+ "kea-dhcp6"
+ ]
+}
"hook": "lease_query",
"name": "extended-info4-upgrade",
"resp-comment": [
- "This command should be used when some old leases are present in the lease database using a SQL backend."
+ "This command should be used when some old IPv4 leases are present in the lease database using a SQL backend."
],
"resp-syntax": [
"{",
"}"
],
"support": [
- "kea-dhcp6"
+ "kea-dhcp4"
]
}