// client rather than a query for each subnet within this shared network.
// The only case when it is going to be less efficient is when there are
// more host identifier types in use than subnets within a shared network.
- // As it breaks RADIUS and host caching this can be disabled by the
+ // As it breaks RADIUS use of host caching this can be disabled by the
// host manager.
const bool use_single_query = network &&
- !HostMgr::instance().getPreventCollection() &&
+ !HostMgr::instance().getDisableSingleQuery() &&
(network->getAllSubnets()->size() > ctx.host_identifiers_.size());
if (use_single_query) {
// client rather than a query for each subnet within this shared network.
// The only case when it is going to be less efficient is when there are
// more host identifier types in use than subnets within a shared network.
- // As it breaks RADIUS and host caching this can be disabled by the
+ // As it breaks RADIUS use of host caching this can be disabled by the
// host manager.
const bool use_single_query = network &&
- !HostMgr::instance().getPreventCollection() &&
+ !HostMgr::instance().getDisableSingleQuery() &&
(network->getAllSubnets()->size() > ctx.host_identifiers_.size());
if (use_single_query) {
negative_caching_ = negative_caching;
}
- /// @brief Returns the prevent collection flag.
+ /// @brief Returns the disable single query flag.
///
- /// @return the prevent collection flag.
- bool getPreventCollection() const {
- return (prevent_collection_);
+ /// @return the disable single query flag.
+ bool getDisableSingleQuery() const {
+ return (disable_single_query_);
}
- /// @brief Sets the prevent collection flag.
+ /// @brief Sets the disable single query flag.
///
- void setPreventCollection(bool prevent_collection) {
- prevent_collection_ = prevent_collection;
+ void setDisableSingleQuery(bool disable_single_query) {
+ disable_single_query_ = disable_single_query;
}
protected:
/// This works for get[46] for a subnet and an identifier.
bool negative_caching_;
- /// @brief The prevent collection flag.
+ /// @brief The disable single query flag.
///
- /// When true prevent the use of lookup methods returning a
- /// collection when methods returning a single object are usable instead.
- bool prevent_collection_;
+ /// When true prevent the use of lookup methods returning a collection
+ /// aka single queries when methods returning a host object are usable
+ /// instead.
+ bool disable_single_query_;
/// @brief Cache an answer.
///
private:
/// @brief Private default constructor.
- HostMgr() : negative_caching_(false), prevent_collection_(false) { }
+ HostMgr() : negative_caching_(false), disable_single_query_(false) { }
/// @brief List of alternate host data sources.
HostDataSourceList alternate_sources_;
// reservations belong.
TEST_F(SharedNetworkAlloc4Test, discoverSharedNetworkReservations) {
+ EXPECT_FALSE(HostMgr::instance().getDisableSingleQuery());
+
// Create reservation for the client.
HostPtr host(new Host(&hwaddr_->hwaddr_[0], hwaddr_->hwaddr_.size(),
Host::IDENT_HWADDR, subnet2_->getID(),
// Test that reservations within shared network take precedence over the
// existing leases regardless in which subnet belonging to a shared network
// reservations belong. Host lookups returning a collection are disabled.
+// As it is only an optimization the behavior (so the test) must stay
+// unchanged.
TEST_F(SharedNetworkAlloc4Test, discoverSharedNetworkReservationsNoColl) {
// Disable host lookups returning a collection.
- ASSERT_FALSE(HostMgr::instance().getPreventCollection());
- HostMgr::instance().setPreventCollection(true);
+ ASSERT_FALSE(HostMgr::instance().getDisableSingleQuery());
+ HostMgr::instance().setDisableSingleQuery(true);
// Create reservation for the client.
HostPtr host(new Host(&hwaddr_->hwaddr_[0], hwaddr_->hwaddr_.size(),
// reservations belong (DHCPREQUEST case).
TEST_F(SharedNetworkAlloc4Test, requestSharedNetworkReservations) {
+ EXPECT_FALSE(HostMgr::instance().getDisableSingleQuery());
+
// Create reservation for the client.
HostPtr host(new Host(&hwaddr_->hwaddr_[0], hwaddr_->hwaddr_.size(),
Host::IDENT_HWADDR, subnet2_->getID(),
// Test that reservations within shared network take precedence over the
// existing leases regardless in which subnet belonging to a shared network
// reservations belong (DHCPREQUEST case). Host lookups returning a collection
-// are disabled.
+// are disabled. As it is only an optimization the behavior (so the test)
+// must stay unchanged.
TEST_F(SharedNetworkAlloc4Test, requestSharedNetworkReservationsNoColl) {
// Disable host lookups returning a collection.
- ASSERT_FALSE(HostMgr::instance().getPreventCollection());
- HostMgr::instance().setPreventCollection(true);
+ ASSERT_FALSE(HostMgr::instance().getDisableSingleQuery());
+ HostMgr::instance().setDisableSingleQuery(true);
// Create reservation for the client.
HostPtr host(new Host(&hwaddr_->hwaddr_[0], hwaddr_->hwaddr_.size(),
// even if this address belongs to another subnet within the same
// shared network.
TEST_F(SharedNetworkAlloc6Test, solicitSharedNetworkReservations) {
+ EXPECT_FALSE(HostMgr::instance().getDisableSingleQuery());
+
// Create reservation for the client in the second subnet.
subnet_ = subnet2_;
createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8:2::15"), 128);
// This test verifies that the client is offerred a reserved address
// even if this address belongs to another subnet within the same
// shared network. Host lookups returning a collection are disabled.
+// As it is only an optimization the behavior (so the test) must stay
+// unchanged.
TEST_F(SharedNetworkAlloc6Test, solicitSharedNetworkReservationsNoColl) {
// Disable host lookups returning a collection.
- ASSERT_FALSE(HostMgr::instance().getPreventCollection());
- HostMgr::instance().setPreventCollection(true);
+ ASSERT_FALSE(HostMgr::instance().getDisableSingleQuery());
+ HostMgr::instance().setDisableSingleQuery(true);
// Create reservation for the client in the second subnet.
subnet_ = subnet2_;
// even if this address belongs to another subnet within the same
// shared network.
TEST_F(SharedNetworkAlloc6Test, requestSharedNetworkReservations) {
+ EXPECT_FALSE(HostMgr::instance().getDisableSingleQuery());
+
// Create reservation for the client in the second subnet.
subnet_ = subnet2_;
createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8:2::15"), 128);
// This test verifies that the client is allocated a reserved address
// even if this address belongs to another subnet within the same
// shared network. Host lookups returning a collection are disabled.
+// As it is only an optimization the behavior (so the test) must stay
+// unchanged.
TEST_F(SharedNetworkAlloc6Test, requestSharedNetworkReservationsNoColl) {
// Disable host lookups returning a collection.
- ASSERT_FALSE(HostMgr::instance().getPreventCollection());
- HostMgr::instance().setPreventCollection(true);
+ ASSERT_FALSE(HostMgr::instance().getDisableSingleQuery());
+ HostMgr::instance().setDisableSingleQuery(true);
// Create reservation for the client in the second subnet.
subnet_ = subnet2_;