From: Francis Dupont Date: Wed, 18 Nov 2020 23:49:20 +0000 (+0100) Subject: [#1418] Finished rebase, did CB X-Git-Tag: Kea-1.9.4~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d0ca1d54b660358c25b27ca4282dbe085d6d46d;p=thirdparty%2Fkea.git [#1418] Finished rebase, did CB --- diff --git a/src/bin/admin/tests/mysql_tests.sh.in b/src/bin/admin/tests/mysql_tests.sh.in index ee348f0c67..a6444078c0 100644 --- a/src/bin/admin/tests/mysql_tests.sh.in +++ b/src/bin/admin/tests/mysql_tests.sh.in @@ -809,6 +809,22 @@ insert into hosts(dhcp_identifier, dhcp_identifier_type, dhcp4_subnet_id, ipv4_a count=$(echo "${OUTPUT}" | grep -Fci reservation) || true assert_eq 0 "${count}" "dhcp6_subnet has still reservation_mode column. (returned count %d, expected %d)" + # table: dhcp4_shared_network new cache_threshold and cache_max_age columns + qry="select cache_threshold, cache_max_age from dhcp4_shared_network" + run_statement "dhcp4_shared_network" "$qry" + + # table: dhcp4_subnet new cache_threshold and cache_max_age columns + qry="select cache_threshold, cache_max_age from dhcp4_subnet" + run_statement "dhcp4_shared_network" "$qry" + + # table: dhcp6_shared_network new cache_threshold and cache_max_age columns + qry="select cache_threshold, cache_max_age from dhcp6_shared_network" + run_statement "dhcp6_shared_network" "$qry" + + # table: dhcp6_subnet new cache_threshold and cache_max_age columns + qry="select cache_threshold, cache_max_age from dhcp6_subnet" + run_statement "dhcp6_shared_network" "$qry" + # Verify upgraded schema reports version 9.5 version=$("${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}") assert_str_eq "9.5" "${version}" "Expected kea-admin to return %s, returned value was %s" diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc index c0ff04d954..4a0bfaa4db 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc @@ -326,6 +326,8 @@ public: MySqlBinding::createString(DNS_NAME_BUF_LENGTH), // ddns_qualifying_suffix MySqlBinding::createInteger(), // reservations_in_subnet MySqlBinding::createInteger(), // reservations_out_of_pool + MySqlBinding::createInteger(), // cache_threshold + MySqlBinding::createInteger(), // cache_max_age MySqlBinding::createString(SERVER_TAG_BUF_LENGTH) // server_tag }; @@ -574,7 +576,17 @@ public: last_subnet->setReservationsOutOfPool(out_bindings[65]->getBool()); } - // server_tag at 66. + // cache_threshold at 66. + if (!out_bindings[66]->amNull()) { + last_subnet->setCacheThreshold(out_bindings[66]->getFloat()); + } + + // cache_max_age at 67. + if (!out_bindings[67]->amNull()) { + last_subnet->setCacheMaxAge(out_bindings[67]->getInteger()); + } + + // server_tag at 68. // Subnet ready. Add it to the list. auto ret = subnets.insert(last_subnet); @@ -587,10 +599,10 @@ public: } } - // Check for new server tags at 66. - if (!out_bindings[66]->amNull() && - (last_tag != out_bindings[66]->getString())) { - last_tag = out_bindings[66]->getString(); + // Check for new server tags at 68. + if (!out_bindings[68]->amNull() && + (last_tag != out_bindings[68]->getString())) { + last_tag = out_bindings[68]->getString(); if (!last_tag.empty() && !last_subnet->hasServerTag(ServerTag(last_tag))) { last_subnet->setServerTag(last_tag); } @@ -1067,7 +1079,9 @@ public: MySqlBinding::condCreateString(subnet->getDdnsGeneratedPrefix(Network::Inheritance::NONE)), MySqlBinding::condCreateString(subnet->getDdnsQualifyingSuffix(Network::Inheritance::NONE)), MySqlBinding::condCreateBool(subnet->getReservationsInSubnet(Network::Inheritance::NONE)), - MySqlBinding::condCreateBool(subnet->getReservationsOutOfPool(Network::Inheritance::NONE)) + MySqlBinding::condCreateBool(subnet->getReservationsOutOfPool(Network::Inheritance::NONE)), + MySqlBinding::condCreateFloat(subnet->getCacheThreshold(Network::Inheritance::NONE)), + condCreateInteger(subnet->getCacheMaxAge(Network::Inheritance::NONE)) }; MySqlTransaction transaction(conn_); @@ -1315,6 +1329,8 @@ public: MySqlBinding::createString(DNS_NAME_BUF_LENGTH), // ddns_qualifying_suffix MySqlBinding::createInteger(), // reservations_in_subnet MySqlBinding::createInteger(), // reservations_out_of_pool + MySqlBinding::createInteger(), // cache_threshold + MySqlBinding::createInteger(), // cache_max_age MySqlBinding::createString(SERVER_TAG_BUF_LENGTH) // server_tag }; @@ -1511,7 +1527,17 @@ public: last_network->setReservationsOutOfPool(out_bindings[41]->getBool()); } - // server_tag at 42. + // cache_threshold at 42. + if (!out_bindings[42]->amNull()) { + last_network->setCacheThreshold(out_bindings[42]->getFloat()); + } + + // cache_max_age at 43. + if (!out_bindings[43]->amNull()) { + last_network->setCacheMaxAge(out_bindings[43]->getInteger()); + } + + // server_tag at 44. // Add the shared network. auto ret = shared_networks.push_back(last_network); @@ -1525,9 +1551,9 @@ public: } // Check for new server tags. - if (!out_bindings[42]->amNull() && - (last_tag != out_bindings[42]->getString())) { - last_tag = out_bindings[42]->getString(); + if (!out_bindings[44]->amNull() && + (last_tag != out_bindings[44]->getString())) { + last_tag = out_bindings[44]->getString(); if (!last_tag.empty() && !last_network->hasServerTag(ServerTag(last_tag))) { last_network->setServerTag(last_tag); } @@ -1682,7 +1708,9 @@ public: MySqlBinding::condCreateString(shared_network->getDdnsGeneratedPrefix(Network::Inheritance::NONE)), MySqlBinding::condCreateString(shared_network->getDdnsQualifyingSuffix(Network::Inheritance::NONE)), MySqlBinding::condCreateBool(shared_network->getReservationsInSubnet(Network::Inheritance::NONE)), - MySqlBinding::condCreateBool(shared_network->getReservationsOutOfPool(Network::Inheritance::NONE)) + MySqlBinding::condCreateBool(shared_network->getReservationsOutOfPool(Network::Inheritance::NONE)), + MySqlBinding::condCreateFloat(shared_network->getCacheThreshold(Network::Inheritance::NONE)), + condCreateInteger(shared_network->getCacheMaxAge(Network::Inheritance::NONE)) }; MySqlTransaction transaction(conn_); @@ -2626,9 +2654,11 @@ TaggedStatementArray tagged_statements = { { " ddns_generated_prefix," " ddns_qualifying_suffix," " reservations_in_subnet," - " reservations_out_of_pool" - ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," - "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" }, + " reservations_out_of_pool," + " cache_threshold," + " cache_max_age" + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," + " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" }, // Insert association of the subnet with a server. { MySqlConfigBackendDHCPv4Impl::INSERT_SUBNET4_SERVER, @@ -2671,8 +2701,10 @@ TaggedStatementArray tagged_statements = { { " ddns_generated_prefix," " ddns_qualifying_suffix," " reservations_in_subnet," - " reservations_out_of_pool" - ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," + " reservations_out_of_pool," + " cache_threshold," + " cache_max_age" + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" }, // Insert association of the shared network with a server. @@ -2746,7 +2778,9 @@ TaggedStatementArray tagged_statements = { { " ddns_generated_prefix = ?," " ddns_qualifying_suffix = ?," " reservations_in_subnet = ?," - " reservations_out_of_pool = ? " + " reservations_out_of_pool = ?," + " cache_threshold = ?," + " cache_max_age = ? " "WHERE subnet_id = ? OR subnet_prefix = ?" }, // Update existing shared network. @@ -2780,7 +2814,9 @@ TaggedStatementArray tagged_statements = { { " ddns_generated_prefix = ?," " ddns_qualifying_suffix = ?," " reservations_in_subnet = ?," - " reservations_out_of_pool = ? " + " reservations_out_of_pool = ?," + " cache_threshold = ?," + " cache_max_age = ? " "WHERE name = ?" }, // Update existing option definition. diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc index c11f6728c9..f87a2018f1 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc @@ -360,6 +360,8 @@ public: MySqlBinding::createString(DNS_NAME_BUF_LENGTH), // ddns_qualifying_suffix MySqlBinding::createInteger(), // reservations_in_subnet MySqlBinding::createInteger(), // reservations_out_of_pool + MySqlBinding::createInteger(), // cache_threshold + MySqlBinding::createInteger(), // cache_max_age MySqlBinding::createString(SERVER_TAG_BUF_LENGTH) // server_tag }; @@ -598,7 +600,17 @@ public: last_subnet->setReservationsOutOfPool(out_bindings[88]->getBool()); } - // server_tag (89 / last) + // cache_threshold (89) + if (!out_bindings[89]->amNull()) { + last_subnet->setCacheThreshold(out_bindings[89]->getFloat()); + } + + // cache_max_age (90) + if (!out_bindings[90]->amNull()) { + last_subnet->setCacheMaxAge(out_bindings[90]->getInteger()); + } + + // server_tag (91 / last) // Subnet ready. Add it to the list. auto ret = subnets.insert(last_subnet); @@ -612,9 +624,9 @@ public: } // Check for new server tags. - if (!out_bindings[89]->amNull() && - (last_tag != out_bindings[89]->getString())) { - last_tag = out_bindings[89]->getString(); + if (!out_bindings[91]->amNull() && + (last_tag != out_bindings[91]->getString())) { + last_tag = out_bindings[91]->getString(); if (!last_tag.empty() && !last_subnet->hasServerTag(ServerTag(last_tag))) { last_subnet->setServerTag(last_tag); } @@ -1316,7 +1328,9 @@ public: MySqlBinding::condCreateString(subnet->getDdnsGeneratedPrefix(Network::Inheritance::NONE)), MySqlBinding::condCreateString(subnet->getDdnsQualifyingSuffix(Network::Inheritance::NONE)), MySqlBinding::condCreateBool(subnet->getReservationsInSubnet(Network::Inheritance::NONE)), - MySqlBinding::condCreateBool(subnet->getReservationsOutOfPool(Network::Inheritance::NONE)) + MySqlBinding::condCreateBool(subnet->getReservationsOutOfPool(Network::Inheritance::NONE)), + MySqlBinding::condCreateFloat(subnet->getCacheThreshold(Network::Inheritance::NONE)), + condCreateInteger(subnet->getCacheMaxAge(Network::Inheritance::NONE)) }; MySqlTransaction transaction(conn_); @@ -1640,6 +1654,8 @@ public: MySqlBinding::createString(DNS_NAME_BUF_LENGTH), // ddns_qualifying_suffix MySqlBinding::createInteger(), // reservations_in_subnet MySqlBinding::createInteger(), // reservations_out_of_pool + MySqlBinding::createInteger(), // cache_threshold + MySqlBinding::createInteger(), // cache_max_age MySqlBinding::createString(SERVER_TAG_BUF_LENGTH) // server_tag }; @@ -1836,7 +1852,17 @@ public: last_network->setReservationsOutOfPool(out_bindings[42]->getBool()); } - // server_tag at 43. + // cache_threshold at 43. + if (!out_bindings[43]->amNull()) { + last_network->setCacheThreshold(out_bindings[43]->getFloat()); + } + + // cache_max_age at 44. + if (!out_bindings[44]->amNull()) { + last_network->setCacheMaxAge(out_bindings[44]->getInteger()); + } + + // server_tag at 45. // Add the shared network. auto ret = shared_networks.push_back(last_network); @@ -1861,9 +1887,9 @@ public: } // Check for new server tags. - if (!out_bindings[43]->amNull() && - (last_tag != out_bindings[43]->getString())) { - last_tag = out_bindings[43]->getString(); + if (!out_bindings[45]->amNull() && + (last_tag != out_bindings[45]->getString())) { + last_tag = out_bindings[45]->getString(); if (!last_tag.empty() && !last_network->hasServerTag(ServerTag(last_tag))) { last_network->setServerTag(last_tag); } @@ -2018,7 +2044,9 @@ public: MySqlBinding::condCreateString(shared_network->getDdnsGeneratedPrefix(Network::Inheritance::NONE)), MySqlBinding::condCreateString(shared_network->getDdnsQualifyingSuffix(Network::Inheritance::NONE)), MySqlBinding::condCreateBool(shared_network->getReservationsInSubnet(Network::Inheritance::NONE)), - MySqlBinding::condCreateBool(shared_network->getReservationsOutOfPool(Network::Inheritance::NONE)) + MySqlBinding::condCreateBool(shared_network->getReservationsOutOfPool(Network::Inheritance::NONE)), + MySqlBinding::condCreateFloat(shared_network->getCacheThreshold(Network::Inheritance::NONE)), + condCreateInteger(shared_network->getCacheMaxAge(Network::Inheritance::NONE)) }; MySqlTransaction transaction(conn_); @@ -3087,8 +3115,10 @@ TaggedStatementArray tagged_statements = { { " ddns_generated_prefix," " ddns_qualifying_suffix," " reservations_in_subnet," - " reservations_out_of_pool" - ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," + " reservations_out_of_pool," + " cache_threshold," + " cache_max_age" + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" }, // Insert association of the subnet with a server. @@ -3137,8 +3167,10 @@ TaggedStatementArray tagged_statements = { { " ddns_generated_prefix," " ddns_qualifying_suffix," " reservations_in_subnet," - " reservations_out_of_pool" - ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," + " reservations_out_of_pool," + " cache_threshold," + " cache_max_age" + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" }, // Insert association of the shared network with a server. @@ -3209,7 +3241,9 @@ TaggedStatementArray tagged_statements = { { " ddns_generated_prefix = ?," " ddns_qualifying_suffix = ?," " reservations_in_subnet = ?," - " reservations_out_of_pool = ? " + " reservations_out_of_pool = ?," + " cache_threshold = ?," + " cache_max_age = ? " "WHERE subnet_id = ? OR subnet_prefix = ?" }, // Update existing shared network. @@ -3243,7 +3277,9 @@ TaggedStatementArray tagged_statements = { { " ddns_generated_prefix = ?," " ddns_qualifying_suffix = ?," " reservations_in_subnet = ?," - " reservations_out_of_pool = ? " + " reservations_out_of_pool = ?," + " cache_threshold = ?," + " cache_max_age = ? " "WHERE name = ?" }, // Update existing option definition. diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h index 59d6bee941..f07000d756 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h @@ -114,6 +114,21 @@ public: /// @brief Destructor. virtual ~MySqlConfigBackendImpl(); + /// @brief Creates MySQL binding from an integer. + /// + /// @tparam T Numeric type corresponding to the binding type, e.g. + /// @c uint8_t, @c uint16_t etc. + /// @param value Optional integet of type T. + /// @return Pointer to a null binding if the value is "unspecified" or + /// a pointer to a binding representing integer value. + template + static db::MySqlBindingPtr condCreateInteger(const util::Optional& value) { + if (value.unspecified()) { + return (db::MySqlBinding::createNull()); + } + return (db::MySqlBinding::createInteger(value)); + } + /// @brief Creates MySQL binding from a @c Triplet. /// /// @param triplet Triplet value from which the binding should be created. diff --git a/src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h b/src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h index 01d7ca1708..15a76c205f 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h +++ b/src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h @@ -117,6 +117,8 @@ namespace { " s.ddns_qualifying_suffix," \ " s.reservations_in_subnet," \ " s.reservations_out_of_pool," \ + " s.cache_threshold," \ + " s.cache_max_age," \ " srv.tag " \ "FROM dhcp4_subnet AS s " \ server_join \ @@ -244,6 +246,8 @@ namespace { " s.ddns_qualifying_suffix," \ " s.reservations_in_subnet," \ " s.reservations_out_of_pool," \ + " s.cache_threshold," \ + " s.cache_max_age," \ " srv.tag " \ "FROM dhcp6_subnet AS s " \ server_join \ @@ -451,6 +455,8 @@ namespace { " n.ddns_qualifying_suffix," \ " n.reservations_in_subnet," \ " n.reservations_out_of_pool," \ + " n.cache_threshold," \ + " n.cache_max_age," \ " s.tag " \ "FROM dhcp4_shared_network AS n " \ server_join \ @@ -530,6 +536,8 @@ namespace { " n.ddns_qualifying_suffix," \ " n.reservations_in_subnet," \ " n.reservations_out_of_pool," \ + " n.cache_threshold," \ + " n.cache_max_age," \ " s.tag " \ "FROM dhcp6_shared_network AS n " \ server_join \ diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 11997b1cfc..6bcec65e4f 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -1403,7 +1403,7 @@ AllocEngine::allocateGlobalReservedLeases6(ClientContext6& ctx, } // Got a lease for a reservation in this IA. - return(true); + return; } } diff --git a/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc index 156d8e13d9..13c3e80c0b 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc @@ -4054,8 +4054,8 @@ TEST_F(AllocEngine4Test, discoverCacheBadThreshold4) { uint32_t valid = 500; subnet_->setValid(valid); - // Set the threshold to 25%. - subnet_->setCacheThreshold(.25); + // Set the threshold to 10%. + subnet_->setCacheThreshold(.10); IOAddress addr("192.0.2.105"); time_t now = time(NULL) - 100; // Allocated 100 seconds ago. @@ -4211,8 +4211,8 @@ TEST_F(AllocEngine4Test, discoverCacheRevDDNS4) { uint32_t valid = 500; subnet_->setValid(valid); - // Set the threshold to 10%. - subnet_->setCacheThreshold(.1); + // Set the threshold to 25%. + subnet_->setCacheThreshold(.25); // Set the max age to 200. subnet_->setCacheMaxAge(200); diff --git a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc index 4ae41d9dc8..118c058279 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc @@ -3728,14 +3728,8 @@ TEST_F(AllocEngine6Test, mixedHostReservedAddress) { EXPECT_EQ("2001:db8:1::1c", lease->addr_.toText()); // We're going to rollback the clock a little so we can verify a renewal. - // We verify the "time" change in case the lease returned to us - // by expectOneLease ever becomes a copy and not what is in the lease mgr. --lease->cltt_; - lease->updateCurrentExpirationTime(); - Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_, - lease->addr_); - ASSERT_TRUE(from_mgr); - EXPECT_EQ(from_mgr->cltt_, lease->cltt_); + EXPECT_NO_THROW(LeaseMgrFactory::instance().updateLease6(lease)); // This is what the client will send in his renew message. AllocEngine::HintContainer hints; @@ -3794,14 +3788,8 @@ TEST_F(AllocEngine6Test, mixedHostReservedPrefix) { EXPECT_EQ("2001:db8:1:2::", lease->addr_.toText()); // We're going to rollback the clock a little so we can verify a renewal. - // We verify the "time" change in case the lease returned to us - // by expectOneLease ever becomes a copy and not what is in the lease mgr. --lease->cltt_; - lease->updateCurrentExpirationTime(); - Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_, - lease->addr_); - ASSERT_TRUE(from_mgr); - EXPECT_EQ(from_mgr->cltt_, lease->cltt_); + EXPECT_NO_THROW(LeaseMgrFactory::instance().updateLease6(lease)); // This is what the client will send in his renew message. AllocEngine::HintContainer hints; @@ -3872,14 +3860,8 @@ TEST_F(AllocEngine6Test, bothHostReservedAddress) { EXPECT_EQ("2001:db8:1::1c", lease->addr_.toText()); // We're going to rollback the clock a little so we can verify a renewal. - // We verify the "time" change in case the lease returned to us - // by expectOneLease ever becomes a copy and not what is in the lease mgr. --lease->cltt_; - lease->updateCurrentExpirationTime(); - Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_, - lease->addr_); - ASSERT_TRUE(from_mgr); - EXPECT_EQ(from_mgr->cltt_, lease->cltt_); + EXPECT_NO_THROW(LeaseMgrFactory::instance().updateLease6(lease)); // This is what the client will send in his renew message. AllocEngine::HintContainer hints; @@ -3947,14 +3929,8 @@ TEST_F(AllocEngine6Test, bothHostReservedPrefix) { EXPECT_EQ("2001:db8:1:2::", lease->addr_.toText()); // We're going to rollback the clock a little so we can verify a renewal. - // We verify the "time" change in case the lease returned to us - // by expectOneLease ever becomes a copy and not what is in the lease mgr. --lease->cltt_; - lease->updateCurrentExpirationTime(); - Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_, - lease->addr_); - ASSERT_TRUE(from_mgr); - EXPECT_EQ(from_mgr->cltt_, lease->cltt_); + EXPECT_NO_THROW(LeaseMgrFactory::instance().updateLease6(lease)); // This is what the client will send in his renew message. AllocEngine::HintContainer hints; diff --git a/src/share/database/scripts/mysql/dhcpdb_create.mysql b/src/share/database/scripts/mysql/dhcpdb_create.mysql index 0718370810..5ff88e91f9 100644 --- a/src/share/database/scripts/mysql/dhcpdb_create.mysql +++ b/src/share/database/scripts/mysql/dhcpdb_create.mysql @@ -3054,6 +3054,23 @@ ALTER TABLE dhcp4_shared_network DROP COLUMN reservation_mode; ALTER TABLE dhcp6_subnet DROP COLUMN reservation_mode; ALTER TABLE dhcp6_shared_network DROP COLUMN reservation_mode; +# Add new lease cache parameters. +ALTER TABLE dhcp4_subnet + ADD COLUMN cache_threshold FLOAT DEFAULT NULL, + ADD COLUMN cache_max_age INT(10) DEFAULT NULL; + +ALTER TABLE dhcp4_shared_network + ADD COLUMN cache_threshold FLOAT DEFAULT NULL, + ADD COLUMN cache_max_age INT(10) DEFAULT NULL; + +ALTER TABLE dhcp6_subnet + ADD COLUMN cache_threshold FLOAT DEFAULT NULL, + ADD COLUMN cache_max_age INT(10) DEFAULT NULL; + +ALTER TABLE dhcp6_shared_network + ADD COLUMN cache_threshold FLOAT DEFAULT NULL, + ADD COLUMN cache_max_age INT(10) DEFAULT NULL; + # Update the schema version number UPDATE schema_version SET version = '9', minor = '5'; diff --git a/src/share/database/scripts/mysql/upgrade_9.4_to_9.5.sh.in b/src/share/database/scripts/mysql/upgrade_9.4_to_9.5.sh.in index fb5a7d72c2..3fce7b9bf0 100644 --- a/src/share/database/scripts/mysql/upgrade_9.4_to_9.5.sh.in +++ b/src/share/database/scripts/mysql/upgrade_9.4_to_9.5.sh.in @@ -161,6 +161,23 @@ ALTER TABLE dhcp6_shared_network DROP COLUMN reservation_mode; # Enable audit in this session SET @disable_audit = 0; +# Add new lease cache parameters. +ALTER TABLE dhcp4_subnet + ADD COLUMN cache_threshold FLOAT DEFAULT NULL, + ADD COLUMN cache_max_age INT(10) DEFAULT NULL; + +ALTER TABLE dhcp4_shared_network + ADD COLUMN cache_threshold FLOAT DEFAULT NULL, + ADD COLUMN cache_max_age INT(10) DEFAULT NULL; + +ALTER TABLE dhcp6_subnet + ADD COLUMN cache_threshold FLOAT DEFAULT NULL, + ADD COLUMN cache_max_age INT(10) DEFAULT NULL; + +ALTER TABLE dhcp6_shared_network + ADD COLUMN cache_threshold FLOAT DEFAULT NULL, + ADD COLUMN cache_max_age INT(10) DEFAULT NULL; + # Update the schema version number UPDATE schema_version SET version = '9', minor = '5';