summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2024-01-12 14:11:37 +0100
committerFrancis Dupont <fdupont@isc.org>2024-01-17 11:06:16 +0100
commit511e9c43a4ba2964dcc11d6258edb509cd8f8ead (patch)
tree2c8a22a4923497d33036e27b09975c7430506e97 /src/lib
parent[#3149] Simplified getLinks (diff)
downloadkea-511e9c43a4ba2964dcc11d6258edb509cd8f8ead.tar.xz
kea-511e9c43a4ba2964dcc11d6258edb509cd8f8ead.zip
[#3149] Moved to getLeases6 overload
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dhcpsrv/dhcpsrv_messages.cc12
-rw-r--r--src/lib/dhcpsrv/dhcpsrv_messages.h6
-rw-r--r--src/lib/dhcpsrv/dhcpsrv_messages.mes27
-rw-r--r--src/lib/dhcpsrv/lease_mgr.h26
-rw-r--r--src/lib/dhcpsrv/memfile_lease_mgr.cc116
-rw-r--r--src/lib/dhcpsrv/memfile_lease_mgr.h51
-rw-r--r--src/lib/dhcpsrv/mysql_lease_mgr.cc130
-rw-r--r--src/lib/dhcpsrv/mysql_lease_mgr.h28
-rw-r--r--src/lib/dhcpsrv/pgsql_lease_mgr.cc114
-rw-r--r--src/lib/dhcpsrv/pgsql_lease_mgr.h28
-rw-r--r--src/lib/dhcpsrv/tests/memfile_lease_extended_info_unittest.cc22
-rw-r--r--src/lib/dhcpsrv/testutils/concrete_lease_mgr.cc14
-rw-r--r--src/lib/dhcpsrv/testutils/concrete_lease_mgr.h19
-rw-r--r--src/lib/dhcpsrv/testutils/generic_lease_extended_info_unittest.h24
14 files changed, 314 insertions, 303 deletions
diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.cc b/src/lib/dhcpsrv/dhcpsrv_messages.cc
index 7ec251da82..b3b3b3b5f4 100644
--- a/src/lib/dhcpsrv/dhcpsrv_messages.cc
+++ b/src/lib/dhcpsrv/dhcpsrv_messages.cc
@@ -113,7 +113,6 @@ extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_HOSTNAME6 = "DHCPSRV_MEMFIL
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_HWADDR = "DHCPSRV_MEMFILE_GET_HWADDR";
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_IAID_DUID = "DHCPSRV_MEMFILE_GET_IAID_DUID";
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID = "DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID";
-extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_LINKADDR6 = "DHCPSRV_MEMFILE_GET_LINKADDR6";
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_PAGE4 = "DHCPSRV_MEMFILE_GET_PAGE4";
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_PAGE6 = "DHCPSRV_MEMFILE_GET_PAGE6";
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_RELAYID4 = "DHCPSRV_MEMFILE_GET_RELAYID4";
@@ -124,6 +123,7 @@ extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID4 = "DHCPSRV_MEMFILE_G
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID6 = "DHCPSRV_MEMFILE_GET_SUBID6";
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_CLIENTID = "DHCPSRV_MEMFILE_GET_SUBID_CLIENTID";
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_HWADDR = "DHCPSRV_MEMFILE_GET_SUBID_HWADDR";
+extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_PAGE6 = "DHCPSRV_MEMFILE_GET_SUBID_PAGE6";
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_VERSION = "DHCPSRV_MEMFILE_GET_VERSION";
extern const isc::log::MessageID DHCPSRV_MEMFILE_LEASE_FILE_LOAD = "DHCPSRV_MEMFILE_LEASE_FILE_LOAD";
extern const isc::log::MessageID DHCPSRV_MEMFILE_LEASE_LOAD = "DHCPSRV_MEMFILE_LEASE_LOAD";
@@ -171,7 +171,6 @@ extern const isc::log::MessageID DHCPSRV_MYSQL_GET_HOSTNAME6 = "DHCPSRV_MYSQL_GE
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_HWADDR = "DHCPSRV_MYSQL_GET_HWADDR";
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_IAID_DUID = "DHCPSRV_MYSQL_GET_IAID_DUID";
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_IAID_SUBID_DUID = "DHCPSRV_MYSQL_GET_IAID_SUBID_DUID";
-extern const isc::log::MessageID DHCPSRV_MYSQL_GET_LINKADDR6 = "DHCPSRV_MYSQL_GET_LINKADDR6";
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_PAGE4 = "DHCPSRV_MYSQL_GET_PAGE4";
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_PAGE6 = "DHCPSRV_MYSQL_GET_PAGE6";
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_RELAYID4 = "DHCPSRV_MYSQL_GET_RELAYID4";
@@ -182,6 +181,7 @@ extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID4 = "DHCPSRV_MYSQL_GET_S
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID6 = "DHCPSRV_MYSQL_GET_SUBID6";
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_CLIENTID = "DHCPSRV_MYSQL_GET_SUBID_CLIENTID";
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_HWADDR = "DHCPSRV_MYSQL_GET_SUBID_HWADDR";
+extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_PAGE6 = "DHCPSRV_MYSQL_GET_SUBID_PAGE6";
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_VERSION = "DHCPSRV_MYSQL_GET_VERSION";
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB = "DHCPSRV_MYSQL_HOST_DB";
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_GET_VERSION = "DHCPSRV_MYSQL_HOST_DB_GET_VERSION";
@@ -231,7 +231,6 @@ extern const isc::log::MessageID DHCPSRV_PGSQL_GET_HOSTNAME6 = "DHCPSRV_PGSQL_GE
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_HWADDR = "DHCPSRV_PGSQL_GET_HWADDR";
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_IAID_DUID = "DHCPSRV_PGSQL_GET_IAID_DUID";
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_IAID_SUBID_DUID = "DHCPSRV_PGSQL_GET_IAID_SUBID_DUID";
-extern const isc::log::MessageID DHCPSRV_PGSQL_GET_LINKADDR6 = "DHCPSRV_PGSQL_GET_LINKADDR6";
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_PAGE4 = "DHCPSRV_PGSQL_GET_PAGE4";
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_PAGE6 = "DHCPSRV_PGSQL_GET_PAGE6";
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_RELAYID4 = "DHCPSRV_PGSQL_GET_RELAYID4";
@@ -242,6 +241,7 @@ extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID4 = "DHCPSRV_PGSQL_GET_S
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID6 = "DHCPSRV_PGSQL_GET_SUBID6";
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_CLIENTID = "DHCPSRV_PGSQL_GET_SUBID_CLIENTID";
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_HWADDR = "DHCPSRV_PGSQL_GET_SUBID_HWADDR";
+extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_PAGE6 = "DHCPSRV_PGSQL_GET_SUBID_PAGE6";
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_VERSION = "DHCPSRV_PGSQL_GET_VERSION";
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB = "DHCPSRV_PGSQL_HOST_DB";
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_GET_VERSION = "DHCPSRV_PGSQL_HOST_DB_GET_VERSION";
@@ -400,7 +400,6 @@ const char* values[] = {
"DHCPSRV_MEMFILE_GET_HWADDR", "obtaining IPv4 leases for hardware address %1",
"DHCPSRV_MEMFILE_GET_IAID_DUID", "obtaining IPv6 leases for IAID %1 and DUID %2 and lease type %3",
"DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID", "obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3 and lease type %4",
- "DHCPSRV_MEMFILE_GET_LINKADDR6", "obtaining at most %1 IPv6 leases starting from address %2 with link %3",
"DHCPSRV_MEMFILE_GET_PAGE4", "obtaining at most %1 IPv4 leases starting from address %2",
"DHCPSRV_MEMFILE_GET_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2",
"DHCPSRV_MEMFILE_GET_RELAYID4", "obtaining at most %1 IPv4 leases starting from address %2 with relay id %3 and cltt between %4 and %5",
@@ -411,6 +410,7 @@ const char* values[] = {
"DHCPSRV_MEMFILE_GET_SUBID6", "obtaining IPv6 leases for subnet ID %1",
"DHCPSRV_MEMFILE_GET_SUBID_CLIENTID", "obtaining IPv4 lease for subnet ID %1 and client ID %2",
"DHCPSRV_MEMFILE_GET_SUBID_HWADDR", "obtaining IPv4 lease for subnet ID %1 and hardware address %2",
+ "DHCPSRV_MEMFILE_GET_SUBID_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3",
"DHCPSRV_MEMFILE_GET_VERSION", "obtaining schema version information",
"DHCPSRV_MEMFILE_LEASE_FILE_LOAD", "loading leases from file %1",
"DHCPSRV_MEMFILE_LEASE_LOAD", "loading lease %1",
@@ -458,7 +458,6 @@ const char* values[] = {
"DHCPSRV_MYSQL_GET_HWADDR", "obtaining IPv4 leases for hardware address %1",
"DHCPSRV_MYSQL_GET_IAID_DUID", "obtaining IPv6 leases for IAID %1, DUID %2, lease type %3",
"DHCPSRV_MYSQL_GET_IAID_SUBID_DUID", "obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3, lease type %4",
- "DHCPSRV_MYSQL_GET_LINKADDR6", "obtaining at most %1 IPv6 leases starting from address %2 with link %3",
"DHCPSRV_MYSQL_GET_PAGE4", "obtaining at most %1 IPv4 leases starting from address %2",
"DHCPSRV_MYSQL_GET_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2",
"DHCPSRV_MYSQL_GET_RELAYID4", "obtaining at most %1 IPv4 leases starting from address %2 with relay id %3 and cltt between %4 and %5",
@@ -469,6 +468,7 @@ const char* values[] = {
"DHCPSRV_MYSQL_GET_SUBID6", "obtaining IPv6 leases for subnet ID %1",
"DHCPSRV_MYSQL_GET_SUBID_CLIENTID", "obtaining IPv4 lease for subnet ID %1 and client ID %2",
"DHCPSRV_MYSQL_GET_SUBID_HWADDR", "obtaining IPv4 lease for subnet ID %1 and hardware address %2",
+ "DHCPSRV_MYSQL_GET_SUBID_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3",
"DHCPSRV_MYSQL_GET_VERSION", "obtaining schema version information",
"DHCPSRV_MYSQL_HOST_DB", "opening MySQL hosts database: %1",
"DHCPSRV_MYSQL_HOST_DB_GET_VERSION", "obtaining schema version information for the MySQL hosts database",
@@ -518,7 +518,6 @@ const char* values[] = {
"DHCPSRV_PGSQL_GET_HWADDR", "obtaining IPv4 leases for hardware address %1",
"DHCPSRV_PGSQL_GET_IAID_DUID", "obtaining IPv4 leases for IAID %1 and DUID %2, lease type %3",
"DHCPSRV_PGSQL_GET_IAID_SUBID_DUID", "obtaining IPv4 leases for IAID %1, Subnet ID %2, DUID %3, and lease type %4",
- "DHCPSRV_PGSQL_GET_LINKADDR6", "obtaining at most %1 IPv6 leases starting from address %2 with link %3",
"DHCPSRV_PGSQL_GET_PAGE4", "obtaining at most %1 IPv4 leases starting from address %2",
"DHCPSRV_PGSQL_GET_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2",
"DHCPSRV_PGSQL_GET_RELAYID4", "obtaining at most %1 IPv4 leases starting from address %2 with relay id %3 and cltt between %4 and %5",
@@ -529,6 +528,7 @@ const char* values[] = {
"DHCPSRV_PGSQL_GET_SUBID6", "obtaining IPv6 leases for subnet ID %1",
"DHCPSRV_PGSQL_GET_SUBID_CLIENTID", "obtaining IPv4 lease for subnet ID %1 and client ID %2",
"DHCPSRV_PGSQL_GET_SUBID_HWADDR", "obtaining IPv4 lease for subnet ID %1 and hardware address %2",
+ "DHCPSRV_PGSQL_GET_SUBID_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3",
"DHCPSRV_PGSQL_GET_VERSION", "obtaining schema version information",
"DHCPSRV_PGSQL_HOST_DB", "opening PostgreSQL hosts database: %1",
"DHCPSRV_PGSQL_HOST_DB_GET_VERSION", "obtaining schema version information for the PostgreSQL hosts database",
diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.h b/src/lib/dhcpsrv/dhcpsrv_messages.h
index be10d79340..28f9e45233 100644
--- a/src/lib/dhcpsrv/dhcpsrv_messages.h
+++ b/src/lib/dhcpsrv/dhcpsrv_messages.h
@@ -114,7 +114,6 @@ extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_HOSTNAME6;
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_HWADDR;
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_IAID_DUID;
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID;
-extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_LINKADDR6;
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_PAGE4;
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_PAGE6;
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_RELAYID4;
@@ -125,6 +124,7 @@ extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID4;
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID6;
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_CLIENTID;
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_HWADDR;
+extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_PAGE6;
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_VERSION;
extern const isc::log::MessageID DHCPSRV_MEMFILE_LEASE_FILE_LOAD;
extern const isc::log::MessageID DHCPSRV_MEMFILE_LEASE_LOAD;
@@ -172,7 +172,6 @@ extern const isc::log::MessageID DHCPSRV_MYSQL_GET_HOSTNAME6;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_HWADDR;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_IAID_DUID;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_IAID_SUBID_DUID;
-extern const isc::log::MessageID DHCPSRV_MYSQL_GET_LINKADDR6;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_PAGE4;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_PAGE6;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_RELAYID4;
@@ -183,6 +182,7 @@ extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID4;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID6;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_CLIENTID;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_HWADDR;
+extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_PAGE6;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_VERSION;
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB;
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_GET_VERSION;
@@ -232,7 +232,6 @@ extern const isc::log::MessageID DHCPSRV_PGSQL_GET_HOSTNAME6;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_HWADDR;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_IAID_DUID;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_IAID_SUBID_DUID;
-extern const isc::log::MessageID DHCPSRV_PGSQL_GET_LINKADDR6;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_PAGE4;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_PAGE6;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_RELAYID4;
@@ -243,6 +242,7 @@ extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID4;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID6;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_CLIENTID;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_HWADDR;
+extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_PAGE6;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_VERSION;
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB;
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_GET_VERSION;
diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.mes b/src/lib/dhcpsrv/dhcpsrv_messages.mes
index 8ccce89699..e2b13b5fc0 100644
--- a/src/lib/dhcpsrv/dhcpsrv_messages.mes
+++ b/src/lib/dhcpsrv/dhcpsrv_messages.mes
@@ -599,10 +599,6 @@ A debug message issued when the server is attempting to obtain an IPv6
lease from the memory file database for a client with the specified IAID
(Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
-% DHCPSRV_MEMFILE_GET_LINKADDR6 obtaining at most %1 IPv6 leases starting from address %2 with link %3
-A debug message issued when the server is attempting to obtain a page of
-IPv6 leases beginning with the specified address within a link.
-
% DHCPSRV_MEMFILE_GET_PAGE4 obtaining at most %1 IPv4 leases starting from address %2
A debug message issued when the server is attempting to obtain a page
of leases beginning with the specified address.
@@ -647,6 +643,11 @@ A debug message issued when the server is attempting to obtain an IPv4
lease from the memory file database for a client with the specified
subnet ID and hardware address.
+% DHCPSRV_MEMFILE_GET_SUBID_PAGE6 obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3
+A debug message issued when the server is attempting to obtain a page of
+IPv6 leases from the memory file database beginning with the specified
+address for a given subnet identifier.
+
% DHCPSRV_MEMFILE_GET_VERSION obtaining schema version information
A debug message issued when the server is about to obtain schema version
information from the memory file database.
@@ -887,10 +888,6 @@ A debug message issued when the server is attempting to obtain an IPv6
lease from the MySQL database for a client with the specified IAID
(Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
-% DHCPSRV_MYSQL_GET_LINKADDR6 obtaining at most %1 IPv6 leases starting from address %2 with link %3
-A debug message issued when the server is attempting to obtain a page of
-IPv6 leases beginning with the specified address within a link.
-
% DHCPSRV_MYSQL_GET_PAGE4 obtaining at most %1 IPv4 leases starting from address %2
A debug message issued when the server is attempting to obtain a page
of leases beginning with the specified address.
@@ -935,6 +932,11 @@ A debug message issued when the server is attempting to obtain an IPv4
lease from the MySQL database for a client with the specified subnet ID
and hardware address.
+% DHCPSRV_MYSQL_GET_SUBID_PAGE6 obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3
+A debug message issued when the server is attempting to obtain a page of
+IPv6 leases from the MySQL database beginning with the specified address
+for the specified subnet identifier.
+
% DHCPSRV_MYSQL_GET_VERSION obtaining schema version information
A debug message issued when the server is about to obtain schema version
information from the MySQL database.
@@ -1167,10 +1169,6 @@ A debug message issued when the server is attempting to obtain an IPv6
lease from the PostgreSQL database for a client with the specified IAID
(Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
-% DHCPSRV_PGSQL_GET_LINKADDR6 obtaining at most %1 IPv6 leases starting from address %2 with link %3
-A debug message issued when the server is attempting to obtain a page of
-IPv6 leases beginning with the specified address within a link.
-
% DHCPSRV_PGSQL_GET_PAGE4 obtaining at most %1 IPv4 leases starting from address %2
A debug message issued when the server is attempting to obtain a page
of leases beginning with the specified address.
@@ -1215,6 +1213,11 @@ A debug message issued when the server is attempting to obtain an IPv4
lease from the PostgreSQL database for a client with the specified subnet ID
and hardware address.
+% DHCPSRV_PGSQL_GET_SUBID_PAGE6 obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3
+A debug message issued when the server is attempting to obtain a page of
+IPv6 leases from the PostgreSQL database beginning with the specified address
+for the specified subnet identifier.
+
% DHCPSRV_PGSQL_GET_VERSION obtaining schema version information
A debug message issued when the server is about to obtain schema version
information from the PostgreSQL database.
diff --git a/src/lib/dhcpsrv/lease_mgr.h b/src/lib/dhcpsrv/lease_mgr.h
index d61155ce65..8e4f168832 100644
--- a/src/lib/dhcpsrv/lease_mgr.h
+++ b/src/lib/dhcpsrv/lease_mgr.h
@@ -517,6 +517,19 @@ public:
getLeases6(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const = 0;
+ /// @brief Returns a page of IPv6 leases for a subnet identifier.
+ ///
+ /// @param subnet_id subnet identifier.
+ /// @param lower_bound_address IPv6 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
+ getLeases6(SubnetID subnet_id,
+ const asiolink::IOAddress& lower_bound_address,
+ const LeasePageSize& page_size) const = 0;
+
/// @brief Returns a collection of expired DHCPv4 leases.
///
/// This method returns at most @c max_leases expired leases. The leases
@@ -965,19 +978,6 @@ public:
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) = 0;
- /// @brief Returns existing IPv6 leases with on a given link.
- ///
- /// @param subnet_id subnet identifier.
- /// @param lower_bound_address IPv6 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(SubnetID subnet_id,
- const asiolink::IOAddress& lower_bound_address,
- const LeasePageSize& page_size) = 0;
-
/// @brief Write V4 leases to a file.
///
/// @param filename File name to write leases.
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc
index eb4ab39408..bac19f49b9 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.cc
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc
@@ -1686,6 +1686,64 @@ Memfile_LeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
return (collection);
}
+Lease6Collection
+Memfile_LeaseMgr::getLeases6Internal(SubnetID subnet_id,
+ const IOAddress& lower_bound_address,
+ const LeasePageSize& page_size) const {
+ Lease6Collection collection;
+ const Lease6StorageSubnetIdIndex& idx = storage6_.get<SubnetIdIndexTag>();
+ Lease6StorageSubnetIdIndex::const_iterator lb =
+ idx.lower_bound(boost::make_tuple(subnet_id, lower_bound_address));
+
+ // Return all leases being within the page size.
+ IOAddress last_addr = lower_bound_address;
+ for (auto it = lb; it != idx.end(); ++it) {
+ if ((*it)->addr_ == last_addr) {
+ // Already seen: skip it.
+ continue;
+ }
+ if ((*it)->subnet_id_ != subnet_id) {
+ // Gone after the subnet id index.
+ break;
+ }
+ last_addr = (*it)->addr_;
+ collection.push_back(Lease6Ptr(new Lease6(**it)));
+ if (collection.size() >= page_size.page_size_) {
+ break;
+ }
+ }
+ return (collection);
+}
+
+Lease6Collection
+Memfile_LeaseMgr::getLeases6(SubnetID subnet_id,
+ const IOAddress& lower_bound_address,
+ const LeasePageSize& page_size) const {
+ LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
+ DHCPSRV_MEMFILE_GET_SUBID_PAGE6)
+ .arg(page_size.page_size_)
+ .arg(lower_bound_address.toText())
+ .arg(subnet_id);
+
+ // Expecting IPv6 valid address.
+ if (!lower_bound_address.isV6()) {
+ isc_throw(InvalidAddressFamily, "expected IPv6 address while "
+ "retrieving leases from the lease database, got "
+ << lower_bound_address);
+ }
+
+ if (MultiThreadingMgr::instance().getMode()) {
+ std::lock_guard<std::mutex> lock(*mutex_);
+ return (getLeases6Internal(subnet_id,
+ lower_bound_address,
+ page_size));
+ } else {
+ return (getLeases6Internal(subnet_id,
+ lower_bound_address,
+ page_size));
+ }
+}
+
void
Memfile_LeaseMgr::getExpiredLeases4Internal(Lease4Collection& expired_leases,
const size_t max_leases) const {
@@ -3171,64 +3229,6 @@ Memfile_LeaseMgr::getLeases6ByRemoteIdInternal(const OptionBuffer& remote_id,
return (collection);
}
-Lease6Collection
-Memfile_LeaseMgr::getLeases6ByLink(SubnetID subnet_id,
- const IOAddress& lower_bound_address,
- const LeasePageSize& page_size) {
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
- DHCPSRV_MEMFILE_GET_LINKADDR6)
- .arg(page_size.page_size_)
- .arg(lower_bound_address.toText())
- .arg(subnet_id);
-
- // Expecting IPv6 valid address.
- if (!lower_bound_address.isV6()) {
- isc_throw(InvalidAddressFamily, "expected IPv6 address while "
- "retrieving leases from the lease database, got "
- << lower_bound_address);
- }
-
- if (MultiThreadingMgr::instance().getMode()) {
- std::lock_guard<std::mutex> lock(*mutex_);
- return (getLeases6ByLinkInternal(subnet_id,
- lower_bound_address,
- page_size));
- } else {
- return (getLeases6ByLinkInternal(subnet_id,
- lower_bound_address,
- page_size));
- }
-}
-
-Lease6Collection
-Memfile_LeaseMgr::getLeases6ByLinkInternal(SubnetID subnet_id,
- const IOAddress& lower_bound_address,
- const LeasePageSize& page_size) {
- Lease6Collection collection;
- const Lease6StorageSubnetIdIndex& idx = storage6_.get<SubnetIdIndexTag>();
- Lease6StorageSubnetIdIndex::const_iterator lb =
- idx.lower_bound(boost::make_tuple(subnet_id, lower_bound_address));
-
- // Return all leases being within the page size.
- IOAddress last_addr = lower_bound_address;
- for (auto it = lb; it != idx.end(); ++it) {
- if ((*it)->addr_ == last_addr) {
- // Already seen: skip it.
- continue;
- }
- if ((*it)->subnet_id_ != subnet_id) {
- // Gone after the subnet id index.
- break;
- }
- last_addr = (*it)->addr_;
- collection.push_back(Lease6Ptr(new Lease6(**it)));
- if (collection.size() >= page_size.page_size_) {
- break;
- }
- }
- return (collection);
-}
-
size_t
Memfile_LeaseMgr::extractExtendedInfo4(bool update, bool current) {
CfgConsistencyPtr cfg;
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.h b/src/lib/dhcpsrv/memfile_lease_mgr.h
index 1d1f3412c7..54072dffc8 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.h
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.h
@@ -373,6 +373,19 @@ public:
getLeases6(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const override;
+ /// @brief Returns a page of IPv6 leases for a subnet identifier.
+ ///
+ /// @param subnet_id subnet identifier.
+ /// @param lower_bound_address IPv6 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
+ getLeases6(SubnetID subnet_id,
+ const asiolink::IOAddress& lower_bound_address,
+ const LeasePageSize& page_size) const override;
+
/// @brief Returns a collection of expired DHCPv4 leases.
///
/// This method returns at most @c max_leases expired leases. The leases
@@ -719,6 +732,19 @@ private:
const LeasePageSize& page_size,
Lease6Collection& collection) const;
+ /// @brief Returns a page of IPv6 leases for a subnet identifier.
+ ///
+ /// @param subnet_id subnet identifier.
+ /// @param lower_bound_address IPv6 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
+ getLeases6Internal(SubnetID subnet_id,
+ const asiolink::IOAddress& lower_bound_address,
+ const LeasePageSize& page_size) const;
+
/// @brief Returns a collection of expired DHCPv4 leases.
///
/// @param [out] expired_leases A container to which expired leases returned
@@ -1383,19 +1409,6 @@ public:
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) override;
- /// @brief Returns existing IPv6 leases with on a given link.
- ///
- /// @param subnet_id subnet identifier.
- /// @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(SubnetID subnet_id,
- const asiolink::IOAddress& lower_bound_address,
- const LeasePageSize& page_size) override;
-
/// @brief Extract extended info for v4 leases.
///
/// For v4 relay and remote identifiers are stored inside leases vs.
@@ -1492,18 +1505,6 @@ private:
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size);
- /// @brief Returns existing IPv6 leases with on a given link.
- ///
- /// @param subnet_id subnet identifier.
- /// @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
- Lease6Collection
- getLeases6ByLinkInternal(SubnetID subnet_id,
- const asiolink::IOAddress& lower_bound_address,
- const LeasePageSize& page_size);
public:
/// @brief Write V4 leases to a file.
diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc
index c4c4197509..e6b4d443ec 100644
--- a/src/lib/dhcpsrv/mysql_lease_mgr.cc
+++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc
@@ -359,6 +359,17 @@ tagged_statements = { {
"state, user_context, pool_id "
"FROM lease6 "
"WHERE subnet_id = ?"},
+ {MySqlLeaseMgr::GET_LEASE6_SUBID_PAGE,
+ "SELECT address, duid, valid_lifetime, "
+ "expire, subnet_id, pref_lifetime, "
+ "lease_type, iaid, prefix_len, "
+ "fqdn_fwd, fqdn_rev, hostname, "
+ "hwaddr, hwtype, hwaddr_source, "
+ "state, user_context, pool_id "
+ "FROM lease6 "
+ "WHERE subnet_id = ? AND address > ? "
+ "ORDER BY address "
+ "LIMIT ?"},
{MySqlLeaseMgr::GET_LEASE6_DUID,
"SELECT address, duid, valid_lifetime, "
"expire, subnet_id, pref_lifetime, "
@@ -390,17 +401,6 @@ tagged_statements = { {
"AND expire < ? "
"ORDER BY expire ASC "
"LIMIT ?"},
- {MySqlLeaseMgr::GET_LEASE6_LINK,
- "SELECT address, duid, valid_lifetime, "
- "expire, subnet_id, pref_lifetime, "
- "lease_type, iaid, prefix_len, "
- "fqdn_fwd, fqdn_rev, hostname, "
- "hwaddr, hwtype, hwaddr_source, "
- "state, user_context, pool_id "
- "FROM lease6 "
- "WHERE subnet_id = ? AND address > ? "
- "ORDER BY address "
- "LIMIT ?"},
{MySqlLeaseMgr::INSERT_LEASE4,
"INSERT INTO lease4(address, hwaddr, client_id, "
"valid_lifetime, expire, subnet_id, "
@@ -3042,6 +3042,60 @@ MySqlLeaseMgr::getLeases6(SubnetID subnet_id) const {
}
Lease6Collection
+MySqlLeaseMgr::getLeases6(SubnetID subnet_id,
+ const IOAddress& lower_bound_address,
+ const LeasePageSize& page_size) const {
+ LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
+ DHCPSRV_MYSQL_GET_SUBID_PAGE6)
+ .arg(page_size.page_size_)
+ .arg(lower_bound_address.toText())
+ .arg(subnet_id);
+
+ // Expecting IPv6 valid address.
+ if (!lower_bound_address.isV6()) {
+ isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
+ "retrieving leases from the lease database, got "
+ << lower_bound_address);
+ }
+
+ Lease6Collection result;
+ // Prepare WHERE clause
+ MYSQL_BIND inbind[3];
+ memset(inbind, 0, sizeof(inbind));
+
+ // Bind the subnet id.
+ inbind[0].buffer_type = MYSQL_TYPE_LONG;
+ inbind[0].buffer = reinterpret_cast<char*>(&subnet_id);
+ inbind[0].is_unsigned = MLM_TRUE;
+
+ // Bind the lower bound address.
+ std::vector<uint8_t> lb_addr_data = lower_bound_address.toBytes();
+ unsigned long lb_addr_size = lb_addr_data.size();
+ if (lb_addr_size != 16) {
+ isc_throw(DbOperationError, "lower bound address is not 16 bytes long");
+ }
+ inbind[1].buffer_type = MYSQL_TYPE_BLOB;
+ inbind[1].buffer = reinterpret_cast<char*>(&lb_addr_data[0]);
+ inbind[1].buffer_length = lb_addr_size;
+ inbind[1].length = &lb_addr_size;
+
+ // Bind page size value
+ uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
+ inbind[2].buffer_type = MYSQL_TYPE_LONG;
+ inbind[2].buffer = reinterpret_cast<char*>(&ps);
+ inbind[2].is_unsigned = MLM_TRUE;
+
+ // Get a context
+ MySqlLeaseContextAlloc get_context(*this);
+ MySqlLeaseContextPtr ctx = get_context.ctx_;
+
+ // Get the leases
+ getLeaseCollection(ctx, GET_LEASE6_SUBID_PAGE, inbind, result);
+
+ return (result);
+}
+
+Lease6Collection
MySqlLeaseMgr::getLeases6() const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET6);
@@ -4467,60 +4521,6 @@ MySqlLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& remote_id,
return (result);
}
-Lease6Collection
-MySqlLeaseMgr::getLeases6ByLink(SubnetID subnet_id,
- const IOAddress& lower_bound_address,
- const LeasePageSize& page_size) {
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
- DHCPSRV_MYSQL_GET_LINKADDR6)
- .arg(page_size.page_size_)
- .arg(lower_bound_address.toText())
- .arg(subnet_id);
-
- // Expecting IPv6 valid address.
- if (!lower_bound_address.isV6()) {
- isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
- "retrieving leases from the lease database, got "
- << lower_bound_address);
- }
-
- Lease6Collection result;
- // Prepare WHERE clause
- MYSQL_BIND inbind[3];
- memset(inbind, 0, sizeof(inbind));
-
- // Bind the subnet id.
- inbind[0].buffer_type = MYSQL_TYPE_LONG;
- inbind[0].buffer = reinterpret_cast<char*>(&subnet_id);
- inbind[0].is_unsigned = MLM_TRUE;
-
- // Bind the lower bound address.
- std::vector<uint8_t> lb_addr_data = lower_bound_address.toBytes();
- unsigned long lb_addr_size = lb_addr_data.size();
- if (lb_addr_size != 16) {
- isc_throw(DbOperationError, "lower bound address is not 16 bytes long");
- }
- inbind[1].buffer_type = MYSQL_TYPE_BLOB;
- inbind[1].buffer = reinterpret_cast<char*>(&lb_addr_data[0]);
- inbind[1].buffer_length = lb_addr_size;
- inbind[1].length = &lb_addr_size;
-
- // Bind page size value
- uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
- inbind[2].buffer_type = MYSQL_TYPE_LONG;
- inbind[2].buffer = reinterpret_cast<char*>(&ps);
- inbind[2].is_unsigned = MLM_TRUE;
-
- // Get a context
- MySqlLeaseContextAlloc get_context(*this);
- MySqlLeaseContextPtr ctx = get_context.ctx_;
-
- // Get the leases
- getLeaseCollection(ctx, GET_LEASE6_LINK, inbind, result);
-
- return (result);
-}
-
size_t
MySqlLeaseMgr::upgradeExtendedInfo6(const LeasePageSize& page_size) {
auto check = CfgMgr::instance().getCurrentCfg()->
diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.h b/src/lib/dhcpsrv/mysql_lease_mgr.h
index 4fe8a185a9..6f32d0053d 100644
--- a/src/lib/dhcpsrv/mysql_lease_mgr.h
+++ b/src/lib/dhcpsrv/mysql_lease_mgr.h
@@ -432,6 +432,19 @@ public:
getLeases6(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const override;
+ /// @brief Returns a page of IPv6 leases for a subnet identifier.
+ ///
+ /// @param subnet_id subnet identifier.
+ /// @param lower_bound_address IPv6 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
+ getLeases6(SubnetID subnet_id,
+ const asiolink::IOAddress& lower_bound_address,
+ const LeasePageSize& page_size) const override;
+
/// @brief Returns a collection of expired DHCPv4 leases.
///
/// This method returns at most @c max_leases expired leases. The leases
@@ -748,10 +761,10 @@ public:
GET_LEASE6_PAGE, // Get page of leases beginning with an address
GET_LEASE6_UCTX_PAGE, // Get page of leases with user context
GET_LEASE6_SUBID, // Get IPv6 leases by subnet ID
+ GET_LEASE6_SUBID_PAGE, // Get page of IPv6 leases by subnet ID
GET_LEASE6_DUID, // Get IPv6 leases by DUID
GET_LEASE6_HOSTNAME, // Get IPv6 leases by hostname
GET_LEASE6_EXPIRE, // Get lease6 by expiration.
- GET_LEASE6_LINK, // Get page of lease6 by link
INSERT_LEASE4, // Add entry to lease4 table
INSERT_LEASE6, // Add entry to lease6 table
UPDATE_LEASE4, // Update a Lease4 entry
@@ -1139,19 +1152,6 @@ public:
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) override;
- /// @brief Returns existing IPv6 leases with on a given link.
- ///
- /// @param subnet_id subnet identifier.
- /// @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(SubnetID subnet_id,
- const asiolink::IOAddress& lower_bound_address,
- const LeasePageSize& page_size) override;
-
/// @brief Upgrade extended info (v4).
///
/// For all leases with a not null user context.
diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc
index d9e80283a3..5f223953af 100644
--- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc
+++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc
@@ -372,6 +372,19 @@ PgSqlTaggedStatement tagged_statements[] = {
"FROM lease6 "
"WHERE subnet_id = $1" },
+ // GET_LEASE6_SUBID_PAGE
+ { 3, { OID_INT8, OID_VARCHAR, OID_INT8 },
+ "get_lease6_subid_page",
+ "SELECT host(address), duid, valid_lifetime, "
+ "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
+ "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
+ "hwaddr, hwtype, hwaddr_source, "
+ "state, user_context, pool_id "
+ "FROM lease6 "
+ "WHERE subnet_id = $1 AND address > cast($2 as inet) "
+ "ORDER BY address "
+ "LIMIT $3" },
+
// GET_LEASE6_DUID
{ 1, { OID_BYTEA },
"get_lease6_duid",
@@ -408,19 +421,6 @@ PgSqlTaggedStatement tagged_statements[] = {
"ORDER BY expire "
"LIMIT $3" },
- // GET_LEASE6_LINK
- { 3, { OID_INT8, OID_VARCHAR, OID_INT8 },
- "get_lease6_link",
- "SELECT host(address), duid, valid_lifetime, "
- "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
- "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
- "hwaddr, hwtype, hwaddr_source, "
- "state, user_context, pool_id "
- "FROM lease6 "
- "WHERE subnet_id = $1 AND address > cast($2 as inet) "
- "ORDER BY address "
- "LIMIT $3" },
-
// INSERT_LEASE4
{ 14, { OID_INT8, OID_BYTEA, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8,
OID_BOOL, OID_BOOL, OID_VARCHAR, OID_INT8, OID_TEXT, OID_BYTEA,
@@ -2304,6 +2304,50 @@ PgSqlLeaseMgr::getLeases6(SubnetID subnet_id) const {
}
Lease6Collection
+PgSqlLeaseMgr::getLeases6(SubnetID subnet_id,
+ const IOAddress& lower_bound_address,
+ const LeasePageSize& page_size) const {
+ LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
+ DHCPSRV_PGSQL_GET_SUBID_PAGE6)
+ .arg(page_size.page_size_)
+ .arg(lower_bound_address.toText())
+ .arg(subnet_id);
+
+ // Expecting IPv6 valid address.
+ if (!lower_bound_address.isV6()) {
+ isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
+ "retrieving leases from the lease database, got "
+ << lower_bound_address);
+ }
+
+ Lease6Collection result;
+ // Prepare WHERE clause
+ PsqlBindArray bind_array;
+
+ // Bind subnet id.
+ std::string subnet_id_str = boost::lexical_cast<std::string>(subnet_id);
+ bind_array.add(subnet_id_str);
+
+ // Bind lower bound address
+ std::string lb_address_str = lower_bound_address.toText();
+ bind_array.add(lb_address_str);
+
+ // Bind page size value
+ std::string page_size_data =
+ boost::lexical_cast<std::string>(page_size.page_size_);
+ bind_array.add(page_size_data);
+
+ // Get a context
+ PgSqlLeaseContextAlloc get_context(*this);
+ PgSqlLeaseContextPtr ctx = get_context.ctx_;
+
+ // Get the leases
+ getLeaseCollection(ctx, GET_LEASE6_SUBID_PAGE, bind_array, result);
+
+ return (result);
+}
+
+Lease6Collection
PgSqlLeaseMgr::getLeases6(const DUID& duid) const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_DUID)
.arg(duid.toText());
@@ -3529,50 +3573,6 @@ PgSqlLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& remote_id,
return (result);
}
-Lease6Collection
-PgSqlLeaseMgr::getLeases6ByLink(SubnetID subnet_id,
- const IOAddress& lower_bound_address,
- const LeasePageSize& page_size) {
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
- DHCPSRV_PGSQL_GET_LINKADDR6)
- .arg(page_size.page_size_)
- .arg(lower_bound_address.toText())
- .arg(subnet_id);
-
- // Expecting IPv6 valid address.
- if (!lower_bound_address.isV6()) {
- isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
- "retrieving leases from the lease database, got "
- << lower_bound_address);
- }
-
- Lease6Collection result;
- // Prepare WHERE clause
- PsqlBindArray bind_array;
-
- // Bind subnet id.
- std::string subnet_id_str = boost::lexical_cast<std::string>(subnet_id);
- bind_array.add(subnet_id_str);
-
- // Bind lower bound address
- std::string lb_address_str = lower_bound_address.toText();
- bind_array.add(lb_address_str);
-
- // Bind page size value
- std::string page_size_data =
- boost::lexical_cast<std::string>(page_size.page_size_);
- bind_array.add(page_size_data);
-
- // Get a context
- PgSqlLeaseContextAlloc get_context(*this);
- PgSqlLeaseContextPtr ctx = get_context.ctx_;
-
- // Get the leases
- getLeaseCollection(ctx, GET_LEASE6_LINK, bind_array, result);
-
- return (result);
-}
-
size_t
PgSqlLeaseMgr::upgradeExtendedInfo6(const LeasePageSize& page_size) {
auto check = CfgMgr::instance().getCurrentCfg()->
diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.h b/src/lib/dhcpsrv/pgsql_lease_mgr.h
index 5617f058c7..4f4332826d 100644
--- a/src/lib/dhcpsrv/pgsql_lease_mgr.h
+++ b/src/lib/dhcpsrv/pgsql_lease_mgr.h
@@ -408,6 +408,19 @@ public:
getLeases6(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const override;
+ /// @brief Returns a page of IPv6 leases for a subnet identifier.
+ ///
+ /// @param subnet_id subnet identifier.
+ /// @param lower_bound_address IPv6 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
+ getLeases6(SubnetID subnet_id,
+ const asiolink::IOAddress& lower_bound_address,
+ const LeasePageSize& page_size) const override;
+
/// @brief Returns a collection of expired DHCPv4 leases.
///
/// This method returns at most @c max_leases expired leases. The leases
@@ -724,10 +737,10 @@ public:
GET_LEASE6_PAGE, // Get page of leases beginning with an address
GET_LEASE6_UCTX_PAGE, // Get page of leases with user context
GET_LEASE6_SUBID, // Get IPv6 leases by subnet ID
+ GET_LEASE6_SUBID_PAGE, // Get page of IPv6 lease by subnet ID
GET_LEASE6_DUID, // Get IPv6 leases by DUID
GET_LEASE6_HOSTNAME, // Get IPv6 leases by hostname
GET_LEASE6_EXPIRE, // Get lease6 by expiration.
- GET_LEASE6_LINK, // Get page of lease6 by link
INSERT_LEASE4, // Add entry to lease4 table
INSERT_LEASE6, // Add entry to lease6 table
UPDATE_LEASE4, // Update a Lease4 entry
@@ -1093,19 +1106,6 @@ public:
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) override;
- /// @brief Returns existing IPv6 leases with on a given link.
- ///
- /// @param subnet_id subnet identifier.
- /// @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(SubnetID subnet_id,
- const asiolink::IOAddress& lower_bound_address,
- const LeasePageSize& page_size) override;
-
/// @brief Upgrade extended info (v4).
///
/// For all leases with a not null user context.
diff --git a/src/lib/dhcpsrv/tests/memfile_lease_extended_info_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_extended_info_unittest.cc
index 27813a89a7..9aee4fc31b 100644
--- a/src/lib/dhcpsrv/tests/memfile_lease_extended_info_unittest.cc
+++ b/src/lib/dhcpsrv/tests/memfile_lease_extended_info_unittest.cc
@@ -987,7 +987,7 @@ TEST_F(MemfileExtendedInfoTest, getLeases6ByRemoteIdMultiThreading) {
testGetLeases6ByRemoteId();
}
-/// @brief Verifies that getLeases6ByLink works as expected.
+/// @brief Verifies that paged getLeases6 by subnet id works as expected.
void
MemfileExtendedInfoTest::testGetLeases6ByLink() {
// Lease manager is created with empty tables.
@@ -1007,13 +1007,13 @@ MemfileExtendedInfoTest::testGetLeases6ByLink() {
Lease6Collection got;
// Other link: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(10, zero,
- LeasePageSize(10)));
+ EXPECT_NO_THROW(got = lease_mgr_->getLeases6(10, zero,
+ LeasePageSize(10)));
EXPECT_EQ(0, got.size());
// Link: 8 entries.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, zero,
- LeasePageSize(10)));
+ EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, zero,
+ LeasePageSize(10)));
ASSERT_EQ(8, got.size());
Lease6Ptr lease;
@@ -1024,8 +1024,8 @@ MemfileExtendedInfoTest::testGetLeases6ByLink() {
}
// Link: initial partial: 4 entries.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, zero,
- LeasePageSize(4)));
+ EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, zero,
+ LeasePageSize(4)));
ASSERT_EQ(4, got.size());
for (size_t i = 0; i < 4; ++i) {
lease = got[i];
@@ -1034,8 +1034,8 @@ MemfileExtendedInfoTest::testGetLeases6ByLink() {
}
// Link: next partial: 4 entries.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, lease->addr_,
- LeasePageSize(4)));
+ EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, lease->addr_,
+ LeasePageSize(4)));
ASSERT_EQ(4, got.size());
for (size_t i = 0; i < 4; ++i) {
lease = got[i];
@@ -1044,8 +1044,8 @@ MemfileExtendedInfoTest::testGetLeases6ByLink() {
}
// Link: further partial: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, lease->addr_,
- LeasePageSize(4)));
+ EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, lease->addr_,
+ LeasePageSize(4)));
EXPECT_EQ(0, got.size());
}
diff --git a/src/lib/dhcpsrv/testutils/concrete_lease_mgr.cc b/src/lib/dhcpsrv/testutils/concrete_lease_mgr.cc
index 0c162c7b78..45ba6af02c 100644
--- a/src/lib/dhcpsrv/testutils/concrete_lease_mgr.cc
+++ b/src/lib/dhcpsrv/testutils/concrete_lease_mgr.cc
@@ -125,6 +125,13 @@ ConcreteLeaseMgr::getLeases6(const IOAddress& /* lower_bound_address */,
return (Lease6Collection());
};
+Lease6Collection
+ConcreteLeaseMgr::getLeases6(SubnetID /* subnet_id */,
+ const IOAddress& /* lower_bound_address */,
+ const LeasePageSize& /* page_size */) const {
+ return (Lease6Collection());
+}
+
void
ConcreteLeaseMgr::getExpiredLeases6(Lease6Collection&, const size_t) const {
isc_throw(NotImplemented, "ConcreteLeaseMgr::getExpiredLeases6 is not"
@@ -279,13 +286,6 @@ ConcreteLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& /* remote_id */,
isc_throw(NotImplemented, "ConcreteLeaseMgr::getLeases6ByRemoteId not implemented");
}
-Lease6Collection
-ConcreteLeaseMgr::getLeases6ByLink(SubnetID /* subnet_id */,
- const IOAddress& /* lower_bound_address */,
- const LeasePageSize& /* page_size */) {
- isc_throw(NotImplemented, "ConcreteLeaseMgr::getLeases6ByLink not implemented");
-}
-
size_t
ConcreteLeaseMgr::upgradeExtendedInfo4(const LeasePageSize& /* page_size */) {
return (0);
diff --git a/src/lib/dhcpsrv/testutils/concrete_lease_mgr.h b/src/lib/dhcpsrv/testutils/concrete_lease_mgr.h
index caab063290..c51a79bcde 100644
--- a/src/lib/dhcpsrv/testutils/concrete_lease_mgr.h
+++ b/src/lib/dhcpsrv/testutils/concrete_lease_mgr.h
@@ -220,6 +220,19 @@ public:
getLeases6(const asiolink::IOAddress& /* lower_bound_address */,
const LeasePageSize& /* page_size */) const override;
+ /// @brief Returns a page of IPv6 leases for a subnet identifier.
+ ///
+ /// @param subnet_id subnet identifier.
+ /// @param lower_bound_address IPv6 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
+ getLeases6(SubnetID /* subnet_id */,
+ const asiolink::IOAddress& /* lower_bound_address */,
+ const LeasePageSize& /* page_size */) const override;
+
/// @brief Returns expired DHCPv6 leases.
///
/// This method is not implemented.
@@ -367,12 +380,6 @@ public:
const LeasePageSize& /* page_size*/) override;
/// @brief Stub implementation.
- Lease6Collection
- getLeases6ByLink(SubnetID /* subnet_id */,
- const asiolink::IOAddress& /* lower_bound_address */,
- const LeasePageSize& /* page_size */) override;
-
- /// @brief Stub implementation.
virtual size_t
upgradeExtendedInfo4(const LeasePageSize& /* page_size */) override;
diff --git a/src/lib/dhcpsrv/testutils/generic_lease_extended_info_unittest.h b/src/lib/dhcpsrv/testutils/generic_lease_extended_info_unittest.h
index 45f41ca64e..8595884704 100644
--- a/src/lib/dhcpsrv/testutils/generic_lease_extended_info_unittest.h
+++ b/src/lib/dhcpsrv/testutils/generic_lease_extended_info_unittest.h
@@ -189,7 +189,7 @@ public:
/// @brief Test getLeases6ByRemoteId.
void testGetLeases6ByRemoteId();
- /// @brief Test getLeases6ByLink.
+ /// @brief Test paged getLeases6 by subnet id.
void testGetLeases6ByLink();
/// @brief Test upgradeExtendedInfo6.
@@ -1208,7 +1208,7 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByRemoteId() {
EXPECT_EQ(lease_addr2, lease->addr_);
}
-/// @brief Verifies that getLeases6ByLink works as expected.
+/// @brief Verifies that paged getLeases6 by subnet id works as expected.
template<typename NakedLeaseMgrType> void
GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
// Lease manager is created with empty tables.
@@ -1228,13 +1228,13 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
Lease6Collection got;
// Other link: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(100, zero,
- LeasePageSize(10)));
+ EXPECT_NO_THROW(got = lease_mgr_->getLeases6(100, zero,
+ LeasePageSize(10)));
EXPECT_EQ(0, got.size());
// Link: 8 entries.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, zero,
- LeasePageSize(10)));
+ EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, zero,
+ LeasePageSize(10)));
ASSERT_EQ(8, got.size());
Lease6Ptr lease;
@@ -1245,8 +1245,8 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
}
// Link: initial partial: 4 entries.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, zero,
- LeasePageSize(4)));
+ EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, zero,
+ LeasePageSize(4)));
ASSERT_EQ(4, got.size());
for (size_t i = 0; i < 4; ++i) {
lease = got[i];
@@ -1255,8 +1255,8 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
}
// Link: next partial: 4 entries.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, lease->addr_,
- LeasePageSize(4)));
+ EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, lease->addr_,
+ LeasePageSize(4)));
ASSERT_EQ(4, got.size());
for (size_t i = 0; i < 4; ++i) {
lease = got[i];
@@ -1265,8 +1265,8 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
}
// Link: further partial: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, lease->addr_,
- LeasePageSize(4)));
+ EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, lease->addr_,
+ LeasePageSize(4)));
EXPECT_EQ(0, got.size());
}