From: Marcin Siodelski Date: Thu, 28 Jun 2018 12:02:32 +0000 (+0200) Subject: [5651] Removed lease queries by ranges and total lease count. X-Git-Tag: trac5694_base~5^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1911064d76dad68037fa722741eb804e75ac9ee0;p=thirdparty%2Fkea.git [5651] Removed lease queries by ranges and total lease count. --- diff --git a/src/hooks/dhcp/lease_cmds/lease_cmds.cc b/src/hooks/dhcp/lease_cmds/lease_cmds.cc index 955e75d6da..e1a1e9056a 100644 --- a/src/hooks/dhcp/lease_cmds/lease_cmds.cc +++ b/src/hooks/dhcp/lease_cmds/lease_cmds.cc @@ -691,7 +691,6 @@ LeaseCmdsImpl::leaseGetPageHandler(CalloutHandle& handle) { // Put gathered data into arguments map. args->set("leases", leases_json); args->set("count", Element::create(static_cast(leases_json->size()))); - args->set("total-count", Element::create(total_leases)); // Create the response. ConstElementPtr response = diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc index 315a86f1e5..bf9eb6c103 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc @@ -1638,15 +1638,7 @@ TEST_F(LeaseCmdsTest, Lease4GetPaged) { ASSERT_TRUE(args); ASSERT_EQ(Element::map, args->getType()); - // Each response must include total number of leases to allow the - // controlling client to track progress (e.g. percentage of leases - // already viewed). - ConstElementPtr total_count = args->get("total-count"); - ASSERT_TRUE(total_count); - ASSERT_EQ(Element::integer, total_count->getType()); - EXPECT_EQ(4, total_count->intValue()); - - // For convenience, we also return the number of returned leases, + // For convenience, we return the number of returned leases, // so as the client can check whether there was anything returned // before parsing the leases structure. ConstElementPtr page_count = args->get("count"); @@ -1981,15 +1973,7 @@ TEST_F(LeaseCmdsTest, Lease6GetPaged) { ASSERT_TRUE(args); ASSERT_EQ(Element::map, args->getType()); - // Each response must include total number of leases to allow the - // controlling client to track progress (e.g. percentage of leases - // already viewed). - ConstElementPtr total_count = args->get("total-count"); - ASSERT_TRUE(total_count); - ASSERT_EQ(Element::integer, total_count->getType()); - EXPECT_EQ(4, total_count->intValue()); - - // For convenience, we also return the number of returned leases, + // For convenience, we return the number of returned leases, // so as the client can check whether there was anything returned // before parsing the leases structure. ConstElementPtr page_count = args->get("count"); diff --git a/src/lib/dhcpsrv/cql_lease_mgr.cc b/src/lib/dhcpsrv/cql_lease_mgr.cc index e1c995dce1..ae29d44667 100644 --- a/src/lib/dhcpsrv/cql_lease_mgr.cc +++ b/src/lib/dhcpsrv/cql_lease_mgr.cc @@ -2192,42 +2192,6 @@ CqlLeaseMgr::getLeases4(const asiolink::IOAddress& lower_bound_address, return (result); } -Lease4Collection -CqlLeaseMgr::getLeases4(const IOAddress& lower_bound_address, - const IOAddress& upper_bound_address) const { - // Expecting two IPv4 addresses. - if (!lower_bound_address.isV4() || !upper_bound_address.isV4()) { - isc_throw(InvalidAddressFamily, "expected two IPv4 addresses for " - "retrieving a range of leases, got " - << lower_bound_address << " and " << upper_bound_address); - } - - if (upper_bound_address < lower_bound_address) { - isc_throw(InvalidRange, "upper bound address " << upper_bound_address - << " is lower than lower bound address " << lower_bound_address); - } - - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_GET_ADDR_RANGE4) - .arg(lower_bound_address.toText()) - .arg(upper_bound_address.toText()); - - // Set up the WHERE clause value - AnyArray data; - - cass_int32_t lb_address_data = static_cast(lower_bound_address.toUint32()); - data.add(&lb_address_data); - - cass_int32_t ub_address_data = static_cast(upper_bound_address.toUint32()); - data.add(&ub_address_data); - - // Get the data. - Lease4Collection result; - std::unique_ptr exchange4(new CqlLease4Exchange(dbconn_)); - exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4_RANGE, data, result); - - return (result); -} - Lease6Ptr CqlLeaseMgr::getLease6(Lease::Type lease_type, const IOAddress &addr) const { std::string addr_data = addr.toText(); @@ -2380,13 +2344,6 @@ CqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address, return (result); } -Lease6Collection -CqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const { - isc_throw(NotImplemented, "getLeases6(lower_bound_address, upper_bound_address) " - "is not implemented"); -} - void CqlLeaseMgr::getExpiredLeases4(Lease4Collection &expired_leases, const size_t max_leases) const { diff --git a/src/lib/dhcpsrv/cql_lease_mgr.h b/src/lib/dhcpsrv/cql_lease_mgr.h index c47708a61d..39382b2f4e 100644 --- a/src/lib/dhcpsrv/cql_lease_mgr.h +++ b/src/lib/dhcpsrv/cql_lease_mgr.h @@ -243,20 +243,6 @@ public: getLeases4(const asiolink::IOAddress& lower_bound_address, const LeasePageSize& page_size) const override; - /// @brief Returns a range of IPv4 leases. - /// - /// @param lower_bound_address IPv4 address used as a lower bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// @param upper_bound_address IPv4 address used as an upper bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// - /// @return Lease collection (may be empty if no IPv4 lease found). - virtual Lease4Collection - getLeases4(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const override; - /// @brief Returns existing IPv6 lease for a given IPv6 address. /// /// For a given address, we assume that there will be only one lease. @@ -367,20 +353,6 @@ public: getLeases6(const asiolink::IOAddress& lower_bound_address, const LeasePageSize& page_size) const override; - /// @brief Returns a range of IPv6 leases. - /// - /// @param lower_bound_address IPv6 address used as a lower bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// @param upper_bound_address IPv6 address used as an upper bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// - /// @return Lease collection (may be empty if no IPv6 lease found). - virtual Lease6Collection - getLeases6(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const override; - /// @brief Returns a collection of expired DHCPv4 leases. /// /// This method returns at most @c max_leases expired leases. The leases diff --git a/src/lib/dhcpsrv/lease_mgr.h b/src/lib/dhcpsrv/lease_mgr.h index 81e2dc93a9..852e5b2da8 100644 --- a/src/lib/dhcpsrv/lease_mgr.h +++ b/src/lib/dhcpsrv/lease_mgr.h @@ -392,20 +392,6 @@ public: getLeases4(const asiolink::IOAddress& lower_bound_address, const LeasePageSize& page_size) const = 0; - /// @brief Returns a range of IPv4 leases. - /// - /// @param lower_bound_address IPv4 address used as a lower bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// @param upper_bound_address IPv4 address used as an upper bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// - /// @return Lease collection (may be empty if no IPv4 lease found). - virtual Lease4Collection - getLeases4(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const = 0; - /// @brief Returns existing IPv6 lease for a given IPv6 address. /// /// For a given address, we assume that there will be only one lease. @@ -514,20 +500,6 @@ public: getLeases6(const asiolink::IOAddress& lower_bound_address, const LeasePageSize& page_size) const = 0; - /// @brief Returns a range of IPv6 leases. - /// - /// @param lower_bound_address IPv6 address used as a lower bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// @param upper_bound_address IPv6 address used as an upper bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// - /// @return Lease collection (may be empty if no IPv6 lease found). - virtual Lease6Collection - getLeases6(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const = 0; - /// @brief Returns a collection of expired DHCPv4 leases. /// /// This method returns at most @c max_leases expired leases. The leases diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc index 4541b59aae..a4b4a1114c 100644 --- a/src/lib/dhcpsrv/memfile_lease_mgr.cc +++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc @@ -917,40 +917,6 @@ Memfile_LeaseMgr::getLeases4(const asiolink::IOAddress& lower_bound_address, return (collection); } -Lease4Collection -Memfile_LeaseMgr::getLeases4(const IOAddress& lower_bound_address, - const IOAddress& upper_bound_address) const { - // Expecting two IPv4 addresses. - if (!lower_bound_address.isV4() || !upper_bound_address.isV4()) { - isc_throw(InvalidAddressFamily, "expected two IPv4 addresses for " - "retrieving a range of leases, got " - << lower_bound_address << " and " << upper_bound_address); - } - - // Check if the range boundaries aren't swapped. - if (upper_bound_address < lower_bound_address) { - isc_throw(InvalidRange, "upper bound address " << upper_bound_address - << " is lower than lower bound address " << lower_bound_address); - } - - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_GET_ADDR_RANGE4) - .arg(lower_bound_address.toText()) - .arg(upper_bound_address.toText()); - - Lease4Collection collection; - const Lease4StorageAddressIndex& idx = storage4_.get(); - std::pair l = - std::make_pair(idx.lower_bound(lower_bound_address), - idx.upper_bound(upper_bound_address)); - - for (auto lease = l.first; lease != l.second; ++lease) { - collection.push_back(Lease4Ptr(new Lease4(**lease))); - } - - return (collection); -} - Lease6Ptr Memfile_LeaseMgr::getLease6(Lease::Type type, const isc::asiolink::IOAddress& addr) const { @@ -1082,40 +1048,6 @@ Memfile_LeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address, return (collection); } -Lease6Collection -Memfile_LeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const { - // Expecting two IPv6 addresses. - if (!lower_bound_address.isV6() || !upper_bound_address.isV6()) { - isc_throw(InvalidAddressFamily, "expected two IPv6 addresses for " - "retrieving a range of leases, got " - << lower_bound_address << " and " << upper_bound_address); - } - - // Check if the range boundaries aren't swapped. - if (upper_bound_address < lower_bound_address) { - isc_throw(InvalidRange, "upper bound address " << upper_bound_address - << " is lower than lower bound address " << lower_bound_address); - } - - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_GET_ADDR_RANGE6) - .arg(lower_bound_address.toText()) - .arg(upper_bound_address.toText()); - - Lease6Collection collection; - const Lease6StorageAddressIndex& idx = storage6_.get(); - std::pair l = - std::make_pair(idx.lower_bound(lower_bound_address), - idx.upper_bound(upper_bound_address)); - - for (auto lease = l.first; lease != l.second; ++lease) { - collection.push_back(Lease6Ptr(new Lease6(**lease))); - } - - return (collection); -} - void Memfile_LeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases, const size_t max_leases) const { diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.h b/src/lib/dhcpsrv/memfile_lease_mgr.h index b9fce8e799..8d77df4788 100644 --- a/src/lib/dhcpsrv/memfile_lease_mgr.h +++ b/src/lib/dhcpsrv/memfile_lease_mgr.h @@ -260,20 +260,6 @@ public: getLeases4(const asiolink::IOAddress& lower_bound_address, const LeasePageSize& page_size) const; - /// @brief Returns a range of IPv4 leases. - /// - /// @param lower_bound_address IPv4 address used as a lower bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// @param upper_bound_address IPv4 address used as an upper bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// - /// @return Lease collection (may be empty if no IPv4 lease found). - virtual Lease4Collection - getLeases4(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const; - /// @brief Returns existing IPv6 lease for a given IPv6 address. /// /// This function returns a copy of the lease. The modification in the @@ -353,20 +339,6 @@ public: getLeases6(const asiolink::IOAddress& lower_bound_address, const LeasePageSize& page_size) const; - /// @brief Returns a range of IPv6 leases. - /// - /// @param lower_bound_address IPv6 address used as a lower bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// @param upper_bound_address IPv6 address used as an upper bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// - /// @return Lease collection (may be empty if no IPv6 lease found). - virtual Lease6Collection - getLeases6(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const; - /// @brief Returns a collection of expired DHCPv4 leases. /// /// This method returns at most @c max_leases expired leases. The leases diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc index b437856a7b..c52cf94acb 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.cc +++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc @@ -1977,48 +1977,6 @@ MySqlLeaseMgr::getLeases4(const asiolink::IOAddress& lower_bound_address, return (result); } -Lease4Collection -MySqlLeaseMgr::getLeases4(const IOAddress& lower_bound_address, - const IOAddress& upper_bound_address) const { - // Expecting two IPv4 addresses. - if (!lower_bound_address.isV4() || !upper_bound_address.isV4()) { - isc_throw(InvalidAddressFamily, "expected two IPv4 addresses for " - "retrieving a range of leases, got " - << lower_bound_address << " and " << upper_bound_address); - } - - if (upper_bound_address < lower_bound_address) { - isc_throw(InvalidRange, "upper bound address " << upper_bound_address - << " is lower than lower bound address " << lower_bound_address); - } - - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_ADDR_RANGE4) - .arg(lower_bound_address.toText()) - .arg(upper_bound_address.toText()); - - // Prepare WHERE clause - MYSQL_BIND inbind[2]; - memset(inbind, 0, sizeof(inbind)); - - // Bind lower bound address as uint32 value - uint32_t lb_address_data = lower_bound_address.toUint32(); - inbind[0].buffer_type = MYSQL_TYPE_LONG; - inbind[0].buffer = reinterpret_cast(&lb_address_data); - inbind[0].is_unsigned = MLM_TRUE; - - // Bind upper bound address as uint32 value - uint32_t ub_address_data = upper_bound_address.toUint32(); - inbind[1].buffer_type = MYSQL_TYPE_LONG; - inbind[1].buffer = reinterpret_cast(&ub_address_data); - inbind[1].is_unsigned = MLM_TRUE; - - // Get the leases - Lease4Collection result; - getLeaseCollection(GET_LEASE4_RANGE, inbind, result); - - return (result); -} - Lease6Ptr MySqlLeaseMgr::getLease6(Lease::Type lease_type, const isc::asiolink::IOAddress& addr) const { @@ -2221,52 +2179,6 @@ MySqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address, return (result); } -Lease6Collection -MySqlLeaseMgr::getLeases6(const IOAddress& lower_bound_address, - const IOAddress& upper_bound_address) const { - // Expecting two IPv6 addresses. - if (!lower_bound_address.isV6() || !upper_bound_address.isV6()) { - isc_throw(InvalidAddressFamily, "expected two IPv6 addresses for " - "retrieving a range of leases, got " - << lower_bound_address << " and " << upper_bound_address); - } - - if (upper_bound_address < lower_bound_address) { - isc_throw(InvalidRange, "upper bound address " << upper_bound_address - << " is lower than lower bound address " << lower_bound_address); - } - - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_ADDR_RANGE6) - .arg(lower_bound_address.toText()) - .arg(upper_bound_address.toText()); - - // Prepare WHERE clause - MYSQL_BIND inbind[2]; - memset(inbind, 0, sizeof(inbind)); - - // Bind lower bound address - std::string lb_address_data = lower_bound_address.toText(); - unsigned long lb_address_data_size = lb_address_data.size(); - inbind[0].buffer_type = MYSQL_TYPE_STRING; - inbind[0].buffer = const_cast(lb_address_data.c_str()); - inbind[0].buffer_length = lb_address_data_size; - inbind[0].length = &lb_address_data_size; - - // Bind upper bound address - std::string ub_address_data = upper_bound_address.toText(); - unsigned long ub_address_data_size = ub_address_data.size(); - inbind[1].buffer_type = MYSQL_TYPE_STRING; - inbind[1].buffer = const_cast(ub_address_data.c_str()); - inbind[1].buffer_length = ub_address_data_size; - inbind[1].length = &ub_address_data_size; - - // Get the leases - Lease6Collection result; - getLeaseCollection(GET_LEASE6_RANGE, inbind, result); - - return (result); -} - void MySqlLeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases, const size_t max_leases) const { diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.h b/src/lib/dhcpsrv/mysql_lease_mgr.h index b8f5555db3..bb1a7738a9 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.h +++ b/src/lib/dhcpsrv/mysql_lease_mgr.h @@ -234,20 +234,6 @@ public: getLeases4(const asiolink::IOAddress& lower_bound_address, const LeasePageSize& page_size) const; - /// @brief Returns a range of IPv4 leases. - /// - /// @param lower_bound_address IPv4 address used as a lower bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// @param upper_bound_address IPv4 address used as an upper bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// - /// @return Lease collection (may be empty if no IPv4 lease found). - virtual Lease4Collection - getLeases4(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const; - /// @brief Returns existing IPv6 lease for a given IPv6 address. /// /// For a given address, we assume that there will be only one lease. @@ -351,20 +337,6 @@ public: getLeases6(const asiolink::IOAddress& lower_bound_address, const LeasePageSize& page_size) const; - /// @brief Returns a range of IPv6 leases. - /// - /// @param lower_bound_address IPv6 address used as a lower bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// @param upper_bound_address IPv6 address used as an upper bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// - /// @return Lease collection (may be empty if no IPv6 lease found). - virtual Lease6Collection - getLeases6(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const; - /// @brief Returns a collection of expired DHCPv4 leases. /// /// This method returns at most @c max_leases expired leases. The leases diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc index 8676c0185f..561a2e7187 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc @@ -1374,45 +1374,6 @@ PgSqlLeaseMgr::getLeases4(const asiolink::IOAddress& lower_bound_address, return (result); } -Lease4Collection -PgSqlLeaseMgr::getLeases4(const IOAddress& lower_bound_address, - const IOAddress& upper_bound_address) const { - // Expecting two IPv4 addresses. - if (!lower_bound_address.isV4() || !upper_bound_address.isV4()) { - isc_throw(InvalidAddressFamily, "expected two IPv4 addresses for " - "retrieving a range of leases, got " - << lower_bound_address << " and " << upper_bound_address); - } - - if (upper_bound_address < lower_bound_address) { - isc_throw(InvalidRange, "upper bound address " << upper_bound_address - << " is lower than lower bound address " << lower_bound_address); - } - - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_ADDR_RANGE4) - .arg(lower_bound_address.toText()) - .arg(upper_bound_address.toText()); - - // Prepare WHERE clause - PsqlBindArray bind_array; - - // Bind lower bound address - std::string lb_address_data = boost::lexical_cast - (lower_bound_address.toUint32()); - bind_array.add(lb_address_data); - - // Bind upper bound address - std::string ub_address_data = boost::lexical_cast - (upper_bound_address.toUint32()); - bind_array.add(ub_address_data); - - // Get the leases - Lease4Collection result; - getLeaseCollection(GET_LEASE4_RANGE, bind_array, result); - - return (result); -} - Lease6Ptr PgSqlLeaseMgr::getLease6(Lease::Type lease_type, const isc::asiolink::IOAddress& addr) const { @@ -1531,7 +1492,7 @@ PgSqlLeaseMgr::getLeases6() const { Lease6Collection PgSqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address, - const LeasePageSize& page_size) const { + const LeasePageSize& page_size) const { // Expecting IPv6 address. if (!lower_bound_address.isV6()) { isc_throw(InvalidAddressFamily, "expected IPv6 address while " @@ -1568,41 +1529,6 @@ PgSqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address, return (result); } -Lease6Collection -PgSqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const { - // Expecting two IPv6 addresses. - if (!lower_bound_address.isV6() || !upper_bound_address.isV6()) { - isc_throw(InvalidAddressFamily, "expected two IPv6 addresses for " - "retrieving a range of leases, got " - << lower_bound_address << " and " << upper_bound_address); - } - - if (upper_bound_address < lower_bound_address) { - isc_throw(InvalidRange, "upper bound address " << upper_bound_address - << " is lower than lower bound address " << lower_bound_address); - } - - LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_ADDR_RANGE6) - .arg(lower_bound_address.toText()) - .arg(upper_bound_address.toText()); - - // Prepare WHERE clause - PsqlBindArray bind_array; - - std::string lb_address_data = lower_bound_address.toText(); - bind_array.add(lb_address_data); - - std::string ub_address_data = upper_bound_address.toText(); - bind_array.add(ub_address_data); - - // Get the leases - Lease6Collection result; - getLeaseCollection(GET_LEASE6_RANGE, bind_array, result); - - return (result); -} - void PgSqlLeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases, const size_t max_leases) const { diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.h b/src/lib/dhcpsrv/pgsql_lease_mgr.h index 84ab7a6382..9df8cf9c00 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.h +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.h @@ -215,20 +215,6 @@ public: getLeases4(const asiolink::IOAddress& lower_bound_address, const LeasePageSize& page_size) const; - /// @brief Returns a range of IPv4 leases. - /// - /// @param lower_bound_address IPv4 address used as a lower bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// @param upper_bound_address IPv4 address used as an upper bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// - /// @return Lease collection (may be empty if no IPv4 lease found). - virtual Lease4Collection - getLeases4(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const; - /// @brief Returns existing IPv6 lease for a given IPv6 address. /// /// For a given address, we assume that there will be only one lease. @@ -323,20 +309,6 @@ public: getLeases6(const asiolink::IOAddress& lower_bound_address, const LeasePageSize& page_size) const; - /// @brief Returns a range of IPv6 leases. - /// - /// @param lower_bound_address IPv6 address used as a lower bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// @param upper_bound_address IPv6 address used as an upper bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// - /// @return Lease collection (may be empty if no IPv6 lease found). - virtual Lease6Collection - getLeases6(const asiolink::IOAddress& lower_bound_address, - const asiolink::IOAddress& upper_bound_address) const; - /// @brief Returns a collection of expired DHCPv4 leases. /// /// This method returns at most @c max_leases expired leases. The leases diff --git a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc index ba95b0b7c2..dca9146727 100644 --- a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc @@ -592,11 +592,6 @@ TEST_F(CqlLeaseMgrTest, getLeases4Paged) { testGetLeases4Paged(); } -// Test that a range of IPv4 leases is returmed. -TEST_F(CqlLeaseMgrTest, getLeases4Range) { - testGetLeases4Range(); -} - /// @brief Basic Lease4 Checks /// /// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id), diff --git a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc index 289da233b2..2fb01f6218 100644 --- a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc @@ -1311,51 +1311,6 @@ GenericLeaseMgrTest::testGetLeases4Paged() { InvalidAddressFamily); } -void -GenericLeaseMgrTest::testGetLeases4Range() { - // Get the leases to be used for the test and add to the database. - vector leases = createLeases4(); - for (size_t i = 0; i < leases.size(); ++i) { - EXPECT_TRUE(lmptr_->addLease(leases[i])); - } - - // All addresses in the specified range should be returned. - Lease4Collection returned = lmptr_->getLeases4(IOAddress("192.0.2.2"), - IOAddress("192.0.2.6")); - EXPECT_EQ(5, returned.size()); - - // The lower bound address is below the range, so the first two addresses - // in the database should be returned. - returned = lmptr_->getLeases4(IOAddress("192.0.1.0"), IOAddress("192.0.2.1")); - EXPECT_EQ(2, returned.size()); - - // The lower bound address is the last address in the database, so only this - // address should be returned. - returned = lmptr_->getLeases4(IOAddress("192.0.2.7"), IOAddress("192.0.2.15")); - EXPECT_EQ(1, returned.size()); - - // The lower bound is below the range and the upper bound is above the range, - // so the whole range should be returned. - returned = lmptr_->getLeases4(IOAddress("192.0.1.7"), IOAddress("192.0.2.15")); - EXPECT_EQ(8, returned.size()); - - // No addresses should be returned because our desired range does not - // overlap with leases in the database. - returned = lmptr_->getLeases4(IOAddress("192.0.2.8"), IOAddress("192.0.2.15")); - EXPECT_TRUE(returned.empty()); - - // Swapping the lower bound and upper bound should cause an error. - EXPECT_THROW(lmptr_->getLeases4(IOAddress("192.0.2.8"), IOAddress("192.0.2.1")), - InvalidRange); - - // Both must be IPv4 addresses. - EXPECT_THROW(lmptr_->getLeases4(IOAddress("192.0.2.3"), IOAddress("2001:db8::8")), - InvalidAddressFamily); - - EXPECT_THROW(lmptr_->getLeases4(IOAddress("2001:db8::2"), IOAddress("192.0.2.7")), - InvalidAddressFamily); -} - void GenericLeaseMgrTest::testGetLeases6SubnetId() { // Get the leases to be used for the test and add to the database. @@ -1437,51 +1392,6 @@ GenericLeaseMgrTest::testGetLeases6Paged() { } -void -GenericLeaseMgrTest::testGetLeases6Range() { - // Get the leases to be used for the test and add to the database. - vector leases = createLeases6(); - for (size_t i = 0; i < leases.size(); ++i) { - EXPECT_TRUE(lmptr_->addLease(leases[i])); - } - - // All addresses in the specified range should be returned. - Lease6Collection returned = lmptr_->getLeases6(IOAddress("2001:db8::2"), - IOAddress("2001:db8::6")); - EXPECT_EQ(5, returned.size()); - - // The lower bound address is below the range, so the first two addresses - // in the database should be returned. - returned = lmptr_->getLeases6(IOAddress("2001::"), IOAddress("2001:db8::1")); - EXPECT_EQ(2, returned.size()); - - // The lower bound address is the last address in the database, so only this - // address should be returned. - returned = lmptr_->getLeases6(IOAddress("2001:db8::7"), IOAddress("2001:db8::15")); - EXPECT_EQ(1, returned.size()); - - // The lower bound is below the range and the upper bound is above the range, - // so the whole range should be returned. - returned = lmptr_->getLeases6(IOAddress("2001::"), IOAddress("2001:db8::15")); - EXPECT_EQ(8, returned.size()); - - // No addresses should be returned because our desired range does not - // overlap with leases in the database. - returned = lmptr_->getLeases6(IOAddress("2001:db8::8"), IOAddress("2001:db8::15")); - EXPECT_TRUE(returned.empty()); - - // Swapping the lower bound and upper bound should cause an error. - EXPECT_THROW(lmptr_->getLeases6(IOAddress("2001:db8::8"), IOAddress("2001:db8::1")), - InvalidRange); - - // Both must be IPv6 addresses. - EXPECT_THROW(lmptr_->getLeases6(IOAddress("192.0.2.3"), IOAddress("2001:db8::8")), - InvalidAddressFamily); - - EXPECT_THROW(lmptr_->getLeases6(IOAddress("2001:db8::2"), IOAddress("192.0.2.7")), - InvalidAddressFamily); -} - void GenericLeaseMgrTest::testGetLeases6DuidIaid() { // Get the leases to be used for the test. diff --git a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h index 34de9f1abd..77ef96dd70 100644 --- a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h +++ b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h @@ -206,9 +206,6 @@ public: /// @brief Test method which returns range of IPv4 leases with paging. void testGetLeases4Paged(); - /// @brief Test method which returns range of IPv4 leases. - void testGetLeases4Range(); - /// @brief Test method which returns all IPv6 leases for Subnet ID. void testGetLeases6SubnetId(); @@ -218,9 +215,6 @@ public: /// @brief Test method which returns range of IPv6 leases with paging. void testGetLeases6Paged(); - /// @brief Test method which returns range of IPv6 leases. - void testGetLeases6Range(); - /// @brief Basic Lease4 Checks /// /// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id), diff --git a/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc index 8ded197f5f..d32379fe8d 100644 --- a/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc @@ -175,24 +175,6 @@ public: return (Lease4Collection()); } - /// @brief Returns a range of IPv4 leases. - /// - /// Returned leases are ordered by IPv4 addresses. - /// - /// @param lower_bound_address IPv4 address used as a lower bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// @param upper_bound_address IPv4 address used as an upper bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// - /// @return Lease collection (may be empty if no IPv4 lease found). - virtual Lease4Collection - getLeases4(const asiolink::IOAddress& /* lower_bound_address */, - const asiolink::IOAddress& /* upper_bound_address */) const { - return (Lease4Collection()); - } - /// @brief Returns existing IPv6 lease for a given IPv6 address. /// /// @param addr address of the searched lease @@ -242,22 +224,6 @@ public: return (Lease6Collection()); } - /// @brief Returns a range of IPv6 leases. - /// - /// @param lower_bound_address IPv6 address used as a lower bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// @param upper_bound_address IPv6 address used as an upper bound for the - /// returned range. The lease for this address is included in the returned - /// range if the lease exists. - /// - /// @return Lease collection (may be empty if no IPv6 lease found). - virtual Lease6Collection - getLeases6(const asiolink::IOAddress& /* lower_bound_address */, - const asiolink::IOAddress& /* upper_bound_address */) const { - return (Lease6Collection()); - } - /// @brief Returns range of IPv6 leases using paging. /// /// This method implements paged browsing of the lease database. The first diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc index 26f157b866..417feca8e3 100644 --- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc @@ -936,12 +936,6 @@ TEST_F(MemfileLeaseMgrTest, getLeases4Paged) { testGetLeases4Paged(); } -// Test that a range of IPv4 leases is returmed. -TEST_F(MemfileLeaseMgrTest, getLeases4Range) { - startBackend(V4); - testGetLeases4Range(); -} - // This test checks that all IPv6 leases for a specified subnet id are returned. TEST_F(MemfileLeaseMgrTest, getLeases6SubnetId) { startBackend(V6); @@ -960,12 +954,6 @@ TEST_F(MemfileLeaseMgrTest, getLeases6Paged) { testGetLeases6Paged(); } -// Test that a range of IPv6 leases is returmed. -TEST_F(MemfileLeaseMgrTest, getLeases6Range) { - startBackend(V6); - testGetLeases6Range(); -} - /// @brief Basic Lease6 Checks /// /// Checks that the addLease, getLease6 (by address) and deleteLease (with an diff --git a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc index 5f92bac4f7..35aeaaaffc 100644 --- a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc @@ -360,11 +360,6 @@ TEST_F(MySqlLeaseMgrTest, getLeases4Paged) { testGetLeases4Paged(); } -// Test that a range of IPv4 leases is returmed. -TEST_F(MySqlLeaseMgrTest, getLeases4Range) { - testGetLeases4Range(); -} - // This test checks that all IPv6 leases for a specified subnet id are returned. TEST_F(MySqlLeaseMgrTest, getLeases6SubnetId) { testGetLeases6SubnetId(); @@ -380,11 +375,6 @@ TEST_F(MySqlLeaseMgrTest, getLeases6Paged) { testGetLeases6Paged(); } -// Test that a range of IPv6 leases is returmed. -TEST_F(MySqlLeaseMgrTest, getLeases6Range) { - testGetLeases6Range(); -} - /// @brief Basic Lease4 Checks /// /// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id), diff --git a/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc index 62334514d2..e288e96ea1 100644 --- a/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc @@ -349,11 +349,6 @@ TEST_F(PgSqlLeaseMgrTest, getLeases4Paged) { testGetLeases4Paged(); } -// Test that a range of IPv4 leases is returmed. -TEST_F(PgSqlLeaseMgrTest, getLeases4Range) { - testGetLeases4Range(); -} - // This test checks that all IPv6 leases for a specified subnet id are returned. TEST_F(PgSqlLeaseMgrTest, getLeases6SubnetId) { testGetLeases6SubnetId(); @@ -369,11 +364,6 @@ TEST_F(PgSqlLeaseMgrTest, getLeases6Paged) { testGetLeases6Paged(); } -// Test that a range of IPv6 leases is returmed. -TEST_F(PgSqlLeaseMgrTest, getLeases6Range) { - testGetLeases6Range(); -} - /// @brief Basic Lease4 Checks /// /// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),