From: Thomas Markwalder Date: Thu, 22 Sep 2022 15:38:19 +0000 (-0400) Subject: [#2571] Added BLQ query stubs to lease mgrs X-Git-Tag: Kea-2.3.1~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9477ed85c0049fbfa31026d15da4ce671e67f5a6;p=thirdparty%2Fkea.git [#2571] Added BLQ query stubs to lease mgrs src/lib/dhcpsrv/lease_mgr.* Removed BQL query implemenetations src/lib/dhcpsrv/memfile_lease_mgr.* src/lib/dhcpsrv/mysql_lease_mgr.* src/lib/dhcpsrv/pgsql_lease_mgr.* Added BQL query implemenetations --- diff --git a/src/lib/dhcpsrv/lease_mgr.cc b/src/lib/dhcpsrv/lease_mgr.cc index 56534eac3f..6cd02c3d8e 100644 --- a/src/lib/dhcpsrv/lease_mgr.cc +++ b/src/lib/dhcpsrv/lease_mgr.cc @@ -356,46 +356,5 @@ LeaseMgr::getDBVersion() { } -Lease4Collection -LeaseMgr::getLeases4ByRelayId(const OptionBuffer& /* relay_id */, - const IOAddress& /* lower_bound_address */, - const LeasePageSize& /* page_size */, - const time_t& /* qry_start_time = 0 */, - const time_t& /* qry_end_time = 0 */) { - isc_throw(NotImplemented, "LeaseMgr::getLeases4ByRelayId not implemented"); -} - -Lease4Collection -LeaseMgr::getLeases4ByRemoteId(const OptionBuffer& /* remote_id */, - const IOAddress& /* lower_bound_address */, - const LeasePageSize& /* page_size */, - const time_t& /* qry_start_time = 0 */, - const time_t& /* qry_end_time = 0 */) { - isc_throw(NotImplemented, "LeaseMgr::getLeases4ByRemoteId not implemented"); -} - -Lease6Collection -LeaseMgr::getLeases6ByRelayId(const DUID& /* relay_id */, - const IOAddress& /* link_addr */, - const IOAddress& /* lower_bound_address */, - const LeasePageSize& /* page_size */) { - isc_throw(NotImplemented, "LeaseMgr::getLeases6ByRelayId not implemented"); -} - -Lease6Collection -LeaseMgr::getLeases6ByRemoteId(const OptionBuffer& /* remote_id */, - const IOAddress& /* link_addr */, - const IOAddress& /* lower_bound_address */, - const LeasePageSize& /* page_size*/) { - isc_throw(NotImplemented, "LeaseMgr::getLeases6ByRemoteId not implemented"); -} - -Lease6Collection -LeaseMgr::getLeases6ByLink(const IOAddress& /* link_addr */, - const IOAddress& /* lower_bound_address */, - const LeasePageSize& /* page_size */) { - isc_throw(NotImplemented, "LeaseMgr::getLeases6ByLink not implemented"); -} - } // namespace isc::dhcp } // namespace isc diff --git a/src/lib/dhcpsrv/lease_mgr.h b/src/lib/dhcpsrv/lease_mgr.h index c61e966dbc..04764cbe35 100644 --- a/src/lib/dhcpsrv/lease_mgr.h +++ b/src/lib/dhcpsrv/lease_mgr.h @@ -833,7 +833,7 @@ public: const asiolink::IOAddress& lower_bound_address, const LeasePageSize& page_size, const time_t& qry_start_time = 0, - const time_t& qry_end_time = 0); + const time_t& qry_end_time = 0) = 0; /// @brief Returns existing IPv4 leases with a given remote-id. /// @@ -851,7 +851,7 @@ public: const asiolink::IOAddress& lower_bound_address, const LeasePageSize& page_size, const time_t& qry_start_time = 0, - const time_t& qry_end_time = 0); + const time_t& qry_end_time = 0) = 0; /// @brief Returns existing IPv6 leases with a given relay-id. /// @@ -865,7 +865,7 @@ public: virtual Lease6Collection getLeases6ByRelayId(const DUID& relay_id, const asiolink::IOAddress& link_addr, const asiolink::IOAddress& lower_bound_address, - const LeasePageSize& page_size); + const LeasePageSize& page_size) = 0; /// @brief Returns existing IPv6 leases with a given remote-id. /// @@ -879,7 +879,7 @@ public: virtual Lease6Collection getLeases6ByRemoteId(const OptionBuffer& remote_id, const asiolink::IOAddress& link_addr, const asiolink::IOAddress& lower_bound_address, - const LeasePageSize& page_size); + const LeasePageSize& page_size) = 0; /// @brief Returns existing IPv6 leases with on a given link. /// @@ -891,7 +891,7 @@ public: /// @return collection of IPv6 leases virtual Lease6Collection getLeases6ByLink(const asiolink::IOAddress& link_addr, const asiolink::IOAddress& lower_bound_address, - const LeasePageSize& page_size); + const LeasePageSize& page_size) = 0; private: /// The IOService object, used for all ASIO operations. diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc index 9352cf9746..131667b5b3 100644 --- a/src/lib/dhcpsrv/memfile_lease_mgr.cc +++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc @@ -2387,7 +2387,46 @@ Memfile_LeaseMgr::getLeaseLimit(ConstElementPtr parent, Lease::Type ltype, size_ return (false); } +Lease4Collection +Memfile_LeaseMgr::getLeases4ByRelayId(const OptionBuffer& /* relay_id */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size */, + const time_t& /* qry_start_time = 0 */, + const time_t& /* qry_end_time = 0 */) { + isc_throw(NotImplemented, "Memfile_LeaseMgr::getLeases4ByRelayId not implemented"); +} +Lease4Collection +Memfile_LeaseMgr::getLeases4ByRemoteId(const OptionBuffer& /* remote_id */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size */, + const time_t& /* qry_start_time = 0 */, + const time_t& /* qry_end_time = 0 */) { + isc_throw(NotImplemented, "Memfile_LeaseMgr::getLeases4ByRemoteId not implemented"); +} + +Lease6Collection +Memfile_LeaseMgr::getLeases6ByRelayId(const DUID& /* relay_id */, + const IOAddress& /* link_addr */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size */) { + isc_throw(NotImplemented, "Memfile_LeaseMgr::getLeases6ByRelayId not implemented"); +} + +Lease6Collection +Memfile_LeaseMgr::getLeases6ByRemoteId(const OptionBuffer& /* remote_id */, + const IOAddress& /* link_addr */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size*/) { + isc_throw(NotImplemented, "Memfile_LeaseMgr::getLeases6ByRemoteId not implemented"); +} + +Lease6Collection +Memfile_LeaseMgr::getLeases6ByLink(const IOAddress& /* link_addr */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size */) { + isc_throw(NotImplemented, "Memfile_LeaseMgr::getLeases6ByLink not implemented"); +} } // namespace dhcp } // namespace isc diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.h b/src/lib/dhcpsrv/memfile_lease_mgr.h index 5f3cbac3ea..44d9cae823 100644 --- a/src/lib/dhcpsrv/memfile_lease_mgr.h +++ b/src/lib/dhcpsrv/memfile_lease_mgr.h @@ -1271,6 +1271,86 @@ public: /// /// Must be called from a thread-safe context. virtual void clearClassLeaseCounts() override; + + /// The following queries are used to fulfill Bulk LeaseQuery queries. They rely + /// on relay data contained in lease's user-context when the extended-store-info flag + /// is enabled. + + /// @brief Returns existing IPv4 leases with a given relay-id. + /// + /// @param relay_id RAI Relay-ID sub-option value for relay_id of interest + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// @param qry_start_time when not zero, only leases whose CLTT is greater than + /// or equal to this value will be included + /// @param qry_end_time when not zero, only leases whose CLTT is less than + /// or equal to this value will be included + /// + /// @return collection of IPv4 leases + virtual Lease4Collection getLeases4ByRelayId(const OptionBuffer& relay_id, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size, + const time_t& qry_start_time = 0, + const time_t& qry_end_time = 0); + + /// @brief Returns existing IPv4 leases with a given remote-id. + /// + /// @param remote_id RAI Remote-ID sub-option value for remote-id of interest + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// @param qry_start_time when not zero, only leases whose CLTT is greater than + /// or equal to this value will be included. Defaults to zero. + /// @param qry_end_time when not zero, only leases whose CLTT is less than + /// or equal to this value will be included. Defaults to zero. + /// + /// @return collection of IPv4 leases + virtual Lease4Collection getLeases4ByRemoteId(const OptionBuffer& remote_id, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size, + const time_t& qry_start_time = 0, + const time_t& qry_end_time = 0); + + /// @brief Returns existing IPv6 leases with a given relay-id. + /// + /// @param relay_id DUID for relay_id of interest + /// @param link_addr limit results to leases on this link when not :: + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// + /// @return collection of IPv6 leases + virtual Lease6Collection getLeases6ByRelayId(const DUID& relay_id, + const asiolink::IOAddress& link_addr, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size); + + /// @brief Returns existing IPv6 leases with a given remote-id. + /// + /// @param remote_id remote-id option data of interest + /// @param link_addr limit results to leases on this link when not :: + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// + /// @return collection of IPv6 leases + virtual Lease6Collection getLeases6ByRemoteId(const OptionBuffer& remote_id, + const asiolink::IOAddress& link_addr, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size); + + /// @brief Returns existing IPv6 leases with on a given link. + /// + /// @param link_addr limit results to leases on this link when not :: + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// + /// @return collection of IPv6 leases + virtual Lease6Collection getLeases6ByLink(const asiolink::IOAddress& link_addr, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size); }; } // namespace dhcp diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc index dfdb097f5b..d541cc82db 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.cc +++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc @@ -3352,5 +3352,46 @@ MySqlLeaseMgr::checkError(MySqlLeaseContextPtr& ctx, ctx->conn_.checkError(status, index, what); } +Lease4Collection +MySqlLeaseMgr::getLeases4ByRelayId(const OptionBuffer& /* relay_id */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size */, + const time_t& /* qry_start_time = 0 */, + const time_t& /* qry_end_time = 0 */) { + isc_throw(NotImplemented, "MySqlLeaseMgr::getLeases4ByRelayId not implemented"); +} + +Lease4Collection +MySqlLeaseMgr::getLeases4ByRemoteId(const OptionBuffer& /* remote_id */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size */, + const time_t& /* qry_start_time = 0 */, + const time_t& /* qry_end_time = 0 */) { + isc_throw(NotImplemented, "MySqlLeaseMgr::getLeases4ByRemoteId not implemented"); +} + +Lease6Collection +MySqlLeaseMgr::getLeases6ByRelayId(const DUID& /* relay_id */, + const IOAddress& /* link_addr */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size */) { + isc_throw(NotImplemented, "MySqlLeaseMgr::getLeases6ByRelayId not implemented"); +} + +Lease6Collection +MySqlLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& /* remote_id */, + const IOAddress& /* link_addr */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size*/) { + isc_throw(NotImplemented, "MySqlLeaseMgr::getLeases6ByRemoteId not implemented"); +} + +Lease6Collection +MySqlLeaseMgr::getLeases6ByLink(const IOAddress& /* link_addr */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size */) { + isc_throw(NotImplemented, "MySqlLeaseMgr::getLeases6ByLink not implemented"); +} + } // namespace dhcp } // namespace isc diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.h b/src/lib/dhcpsrv/mysql_lease_mgr.h index 6bafd05f44..1218b62345 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.h +++ b/src/lib/dhcpsrv/mysql_lease_mgr.h @@ -1012,6 +1012,86 @@ private: int status, StatementIndex index, const char* what) const; + /// The following queries are used to fulfill Bulk LeaseQuery queries. They rely + /// on relay data contained in lease's user-context when the extended-store-info flag + /// is enabled. + + /// @brief Returns existing IPv4 leases with a given relay-id. + /// + /// @param relay_id RAI Relay-ID sub-option value for relay_id of interest + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// @param qry_start_time when not zero, only leases whose CLTT is greater than + /// or equal to this value will be included + /// @param qry_end_time when not zero, only leases whose CLTT is less than + /// or equal to this value will be included + /// + /// @return collection of IPv4 leases + virtual Lease4Collection getLeases4ByRelayId(const OptionBuffer& relay_id, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size, + const time_t& qry_start_time = 0, + const time_t& qry_end_time = 0); + + /// @brief Returns existing IPv4 leases with a given remote-id. + /// + /// @param remote_id RAI Remote-ID sub-option value for remote-id of interest + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// @param qry_start_time when not zero, only leases whose CLTT is greater than + /// or equal to this value will be included. Defaults to zero. + /// @param qry_end_time when not zero, only leases whose CLTT is less than + /// or equal to this value will be included. Defaults to zero. + /// + /// @return collection of IPv4 leases + virtual Lease4Collection getLeases4ByRemoteId(const OptionBuffer& remote_id, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size, + const time_t& qry_start_time = 0, + const time_t& qry_end_time = 0); + + /// @brief Returns existing IPv6 leases with a given relay-id. + /// + /// @param relay_id DUID for relay_id of interest + /// @param link_addr limit results to leases on this link when not :: + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// + /// @return collection of IPv6 leases + virtual Lease6Collection getLeases6ByRelayId(const DUID& relay_id, + const asiolink::IOAddress& link_addr, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size); + + /// @brief Returns existing IPv6 leases with a given remote-id. + /// + /// @param remote_id remote-id option data of interest + /// @param link_addr limit results to leases on this link when not :: + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// + /// @return collection of IPv6 leases + virtual Lease6Collection getLeases6ByRemoteId(const OptionBuffer& remote_id, + const asiolink::IOAddress& link_addr, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size); + + /// @brief Returns existing IPv6 leases with on a given link. + /// + /// @param link_addr limit results to leases on this link when not :: + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// + /// @return collection of IPv6 leases + virtual Lease6Collection getLeases6ByLink(const asiolink::IOAddress& link_addr, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size); + /// @brief Context RAII Allocator. class MySqlLeaseContextAlloc { public: diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc index 3701d9a811..c4c4d8dc34 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc @@ -2546,5 +2546,46 @@ PgSqlLeaseMgr::rollback() { LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_ROLLBACK); } +Lease4Collection +PgSqlLeaseMgr::getLeases4ByRelayId(const OptionBuffer& /* relay_id */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size */, + const time_t& /* qry_start_time = 0 */, + const time_t& /* qry_end_time = 0 */) { + isc_throw(NotImplemented, "PgSqlLeaseMgr::getLeases4ByRelayId not implemented"); +} + +Lease4Collection +PgSqlLeaseMgr::getLeases4ByRemoteId(const OptionBuffer& /* remote_id */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size */, + const time_t& /* qry_start_time = 0 */, + const time_t& /* qry_end_time = 0 */) { + isc_throw(NotImplemented, "PgSqlLeaseMgr::getLeases4ByRemoteId not implemented"); +} + +Lease6Collection +PgSqlLeaseMgr::getLeases6ByRelayId(const DUID& /* relay_id */, + const IOAddress& /* link_addr */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size */) { + isc_throw(NotImplemented, "PgSqlLeaseMgr::getLeases6ByRelayId not implemented"); +} + +Lease6Collection +PgSqlLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& /* remote_id */, + const IOAddress& /* link_addr */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size*/) { + isc_throw(NotImplemented, "PgSqlLeaseMgr::getLeases6ByRemoteId not implemented"); +} + +Lease6Collection +PgSqlLeaseMgr::getLeases6ByLink(const IOAddress& /* link_addr */, + const IOAddress& /* lower_bound_address */, + const LeasePageSize& /* page_size */) { + isc_throw(NotImplemented, "PgSqlLeaseMgr::getLeases6ByLink not implemented"); +} + } // namespace dhcp } // namespace isc diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.h b/src/lib/dhcpsrv/pgsql_lease_mgr.h index 7ef28e65fa..039c5a97ab 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.h +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.h @@ -971,6 +971,86 @@ private: /// @brief Clears the class-lease count map. virtual void clearClassLeaseCounts() override; + /// The following queries are used to fulfill Bulk LeaseQuery queries. They rely + /// on relay data contained in lease's user-context when the extended-store-info flag + /// is enabled. + + /// @brief Returns existing IPv4 leases with a given relay-id. + /// + /// @param relay_id RAI Relay-ID sub-option value for relay_id of interest + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// @param qry_start_time when not zero, only leases whose CLTT is greater than + /// or equal to this value will be included + /// @param qry_end_time when not zero, only leases whose CLTT is less than + /// or equal to this value will be included + /// + /// @return collection of IPv4 leases + virtual Lease4Collection getLeases4ByRelayId(const OptionBuffer& relay_id, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size, + const time_t& qry_start_time = 0, + const time_t& qry_end_time = 0); + + /// @brief Returns existing IPv4 leases with a given remote-id. + /// + /// @param remote_id RAI Remote-ID sub-option value for remote-id of interest + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// @param qry_start_time when not zero, only leases whose CLTT is greater than + /// or equal to this value will be included. Defaults to zero. + /// @param qry_end_time when not zero, only leases whose CLTT is less than + /// or equal to this value will be included. Defaults to zero. + /// + /// @return collection of IPv4 leases + virtual Lease4Collection getLeases4ByRemoteId(const OptionBuffer& remote_id, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size, + const time_t& qry_start_time = 0, + const time_t& qry_end_time = 0); + + /// @brief Returns existing IPv6 leases with a given relay-id. + /// + /// @param relay_id DUID for relay_id of interest + /// @param link_addr limit results to leases on this link when not :: + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// + /// @return collection of IPv6 leases + virtual Lease6Collection getLeases6ByRelayId(const DUID& relay_id, + const asiolink::IOAddress& link_addr, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size); + + /// @brief Returns existing IPv6 leases with a given remote-id. + /// + /// @param remote_id remote-id option data of interest + /// @param link_addr limit results to leases on this link when not :: + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// + /// @return collection of IPv6 leases + virtual Lease6Collection getLeases6ByRemoteId(const OptionBuffer& remote_id, + const asiolink::IOAddress& link_addr, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size); + + /// @brief Returns existing IPv6 leases with on a given link. + /// + /// @param link_addr limit results to leases on this link when not :: + /// @param lower_bound_address IPv4 address used as lower bound for the + /// returned range. + /// @param page_size maximum size of the page returned. + /// + /// @return collection of IPv6 leases + virtual Lease6Collection getLeases6ByLink(const asiolink::IOAddress& link_addr, + const asiolink::IOAddress& lower_bound_address, + const LeasePageSize& page_size); + /// @brief Context RAII Allocator. class PgSqlLeaseContextAlloc { public: