status->set("extended-info-tables",
Element::create(LeaseMgrFactory::instance().getExtendedInfoTablesEnabled()));
- status->set("by-relay-id-table-size",
- Element::create(static_cast<long long>(LeaseMgrFactory::instance().byRelayId6size())));
- status->set("by-remote-id-table-size",
- Element::create(static_cast<long long>(LeaseMgrFactory::instance().byRemoteId6size())));
// Iterate through the interfaces and get all the errors.
ElementPtr socket_errors(Element::createList());
ASSERT_TRUE(found_extended_info_tables);
EXPECT_FALSE(found_extended_info_tables->boolValue());
- auto found_by_relay_id_table_size = arguments->get("by-relay-id-table-size");
- ASSERT_TRUE(found_by_relay_id_table_size);
- EXPECT_LE(0, found_by_relay_id_table_size->intValue());
-
- auto found_by_remote_id_table_size = arguments->get("by-remote-id-table-size");
- ASSERT_TRUE(found_by_remote_id_table_size);
- EXPECT_LE(0, found_by_remote_id_table_size->intValue());
-
MultiThreadingMgr::instance().setMode(true);
MultiThreadingMgr::instance().setThreadPoolSize(4);
MultiThreadingMgr::instance().setPacketQueueSize(64);
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
-An error 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
-An error 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.
extended_info_tables_enabled_ = enabled;
}
- /// @brief Build extended info v6 tables.
- ///
- /// @param update Update extended info in database.
- /// @param current specify whether to use current (true) or staging
- /// (false) config.
- /// @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.
.arg(processed);
}
-size_t
-Memfile_LeaseMgr::buildExtendedInfoTables6(bool update, bool current) {
- if (MultiThreadingMgr::instance().getMode()) {
- std::lock_guard<std::mutex> lock(*mutex_);
- return (buildExtendedInfoTables6Internal(update, current));
- } else {
- return (buildExtendedInfoTables6Internal(update, current));
- }
-}
-
size_t
Memfile_LeaseMgr::upgradeExtendedInfo6(const LeasePageSize& /* page_size */) {
return (0);
/// @return The number of updates in the database or 0.
size_t extractExtendedInfo4(bool update, bool current);
- /// @brief Build extended info v6 tables.
- ///
- /// @param update Update extended info in database.
- /// @param current specify whether to use current (true) or staging
- /// (false) config.
- /// @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.
memset(inbind, 0, sizeof(inbind));
// Bind the lease address.
- std::string addr_data = addr.toText();
- unsigned long addr_size = addr_data.size();
- inbind[0].buffer_type = MYSQL_TYPE_STRING;
- inbind[0].buffer = const_cast<char*>(addr_data.c_str());
- inbind[0].buffer_length = addr_size;
- inbind[0].length = &addr_size;
+ std::vector<uint8_t>addr_bytes = addr.toBytes();
+ unsigned long addr_length = addr_bytes.size();
+ if (addr_length != 16) {
+ isc_throw(DbOperationError, "lease6 address is not 16 bytes long");
+ }
+ inbind[0].buffer_type = MYSQL_TYPE_BLOB;
+ inbind[0].buffer = reinterpret_cast<char*>(&addr_bytes[0]);
+ inbind[0].buffer_length = addr_length;
+ inbind[0].length = &addr_length;
// Get the lease.
Lease6Ptr lease;
memset(inbind, 0, sizeof(inbind));
// Bind the lease address.
- std::string addr_data = addr.toText();
- unsigned long addr_size = addr_data.size();
- inbind[0].buffer_type = MYSQL_TYPE_STRING;
- inbind[0].buffer = const_cast<char*>(addr_data.c_str());
- inbind[0].buffer_length = addr_size;
- inbind[0].length = &addr_size;
+ std::vector<uint8_t>addr_bytes = addr.toBytes();
+ unsigned long addr_length = addr_bytes.size();
+ if (addr_length != 16) {
+ isc_throw(DbOperationError, "lease6 address is not 16 bytes long");
+ }
+ inbind[0].buffer_type = MYSQL_TYPE_BLOB;
+ inbind[0].buffer = reinterpret_cast<char*>(&addr_bytes[0]);
+ inbind[0].buffer_length = addr_length;
+ inbind[0].length = &addr_length;
// Get the lease.
Lease6Ptr lease;
return (result);
}
-size_t
-MySqlLeaseMgr::buildExtendedInfoTables6(bool /* update */, bool /* current */) {
- isc_throw(isc::NotImplemented,
- "MySqlLeaseMgr::buildExtendedInfoTables6 not implemented");
-}
-
size_t
MySqlLeaseMgr::upgradeExtendedInfo6(const LeasePageSize& page_size) {
auto check = CfgMgr::instance().getCurrentCfg()->
memset(inbind, 0, sizeof(inbind));
// Bind start address.
- std::string start_addr_str = "";
- if (!start_addr.isV6Zero()) {
- start_addr_str = start_addr.toText();
+ std::vector<uint8_t>start_addr_bytes = start_addr.toBytes();
+ if (start_addr_bytes.size() != 16) {
+ isc_throw(DbOperationError, "start address is not 16 bytes long");
}
- 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;
+
+ unsigned long start_addr_size = 16;
+ inbind[0].buffer_type = MYSQL_TYPE_BLOB;
+ inbind[0].buffer = reinterpret_cast<char*>(&start_addr_bytes[0]);
+ inbind[0].buffer_length = 16;
inbind[0].length = &start_addr_size;
// Bind page size value.
/// @return The number of updates in the database.
virtual size_t upgradeExtendedInfo4(const LeasePageSize& page_size) override;
- /// @brief Build extended info v6 tables.
- ///
- /// @param update Update extended info in database.
- /// @param current specify whether to use current (true) or staging
- /// (false) config.
- /// @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.
"hwaddr, hwtype, hwaddr_source, "
"state, user_context, pool_id "
"FROM lease6 "
- "WHERE address = $1" },
+ "WHERE address = cast($1 as inet)" },
// GET_LEASE6_DUID_IAID
{ 3, { OID_BYTEA, OID_INT8, OID_INT2 },
return (result);
}
-size_t
-PgSqlLeaseMgr::buildExtendedInfoTables6(bool /* update */, bool /* current */) {
- isc_throw(isc::NotImplemented,
- "PgSqlLeaseMgr::buildExtendedInfoTables6 not implemented");
-}
-
size_t
PgSqlLeaseMgr::upgradeExtendedInfo6(const LeasePageSize& page_size) {
auto check = CfgMgr::instance().getCurrentCfg()->
PsqlBindArray bind_array;
// Bind start address.
- std::string start_addr_str = "0";
- if (!start_addr.isV6Zero()) {
- start_addr_str = start_addr.toText();
- }
+ std::string start_addr_str = start_addr.toText();
bind_array.add(start_addr_str);
// Bind page size value.
/// @return The number of updates in the database.
virtual size_t upgradeExtendedInfo4(const LeasePageSize& page_size) override;
- /// @brief Build extended info v6 tables.
- ///
- /// @param update Update extended info in database.
- /// @param current specify whether to use current (true) or staging
- /// (false) config.
- /// @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.
// Check for extended info tables.
const char* EX_INFO = "extended-info-tables=true";
- EXPECT_THROW(LeaseMgrFactory::create(connectionString(
- MYSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD, EX_INFO)),
- NotImplemented);
+ EXPECT_NO_THROW(LeaseMgrFactory::create(connectionString(
+ MYSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD, EX_INFO)));
+ LeaseMgrFactory::destroy();
// Tidy up after the test
destroyMySQLSchema(true);
// Check for extended info tables.
const char* EX_INFO = "extended-info-tables=true";
- EXPECT_THROW(LeaseMgrFactory::create(connectionString(
- PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD, EX_INFO)),
- NotImplemented);
+ EXPECT_NO_THROW(LeaseMgrFactory::create(connectionString(
+ PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD, EX_INFO)));
+ LeaseMgrFactory::destroy();
// Tidy up after the test
destroyPgSQLSchema();
return (0);
}
-size_t
-ConcreteLeaseMgr::buildExtendedInfoTables6(bool /* update */,
- bool /* current */) {
- isc_throw(isc::NotImplemented, "ConcreteLeaseMgr:buildExtendedInfoTables6 not implemented");
-}
-
size_t
ConcreteLeaseMgr::upgradeExtendedInfo6(const LeasePageSize& /* page_size */) {
return (0);
virtual size_t
upgradeExtendedInfo4(const LeasePageSize& /* page_size */) override;
- /// @brief Stub implementation.
- virtual size_t buildExtendedInfoTables6(bool /* update */,
- bool /* current */) override;
-
/// @brief Stub implementation.
virtual size_t
upgradeExtendedInfo6(const LeasePageSize& /* page_size */) override;
{
"access": "write",
- "avail": "2.3.9",
+ "avail": "2.5.0",
"brief": [
"This command sanitizes extended info of all IPv6 leases and rebuilds when they are enabled relay and remote ID tables in the SQL lease database."
],