]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[master] Finishing merge of trac5469 (lease6-get-all)
authorFrancis Dupont <fdupont@isc.org>
Sat, 31 Mar 2018 14:49:15 +0000 (16:49 +0200)
committerFrancis Dupont <fdupont@isc.org>
Sat, 31 Mar 2018 14:49:15 +0000 (16:49 +0200)
20 files changed:
1  2 
ChangeLog
doc/guide/hooks.xml
src/hooks/dhcp/lease_cmds/lease_cmds.cc
src/hooks/dhcp/lease_cmds/lease_cmds.h
src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc
src/lib/dhcpsrv/cql_lease_mgr.cc
src/lib/dhcpsrv/cql_lease_mgr.h
src/lib/dhcpsrv/dhcpsrv_messages.mes
src/lib/dhcpsrv/lease_mgr.h
src/lib/dhcpsrv/memfile_lease_mgr.cc
src/lib/dhcpsrv/memfile_lease_mgr.h
src/lib/dhcpsrv/mysql_lease_mgr.cc
src/lib/dhcpsrv/mysql_lease_mgr.h
src/lib/dhcpsrv/pgsql_lease_mgr.cc
src/lib/dhcpsrv/pgsql_lease_mgr.h
src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc

diff --cc ChangeLog
index 7502918f261717b13c4fc294a84e063337993ec2,08d36b4849bf4f0973c8a922fafde5fb8e1b7c4c..7887b14acfe2d467c5dd3d41dfea345b60c0787d
+++ b/ChangeLog
++1377. [func]          fdupont
++      Implemented lease6-get-all command in lease_cmds hooks library.
++      (Trac #5469, git xxx)
++
 +1376. [func, bug]     marcin
 +      The network_state argument is provided to the callouts in
 +      the dhcp4_srv_configured hook point. Also, fixed a couple
 +      of minor bugs in the HTTP client classes.
 +      (Trac #5470, git 93e2b2198c3163afb81d51fdf5ec547602a12415)
 +
 +1375. [doc]           tomek
 +      New parameter subnets-action for network4-del and network6-del
 +      commands is now documented.
 +      (Trac #5441, git 8b2ffabb3d1ba709f319df2b34d0804ee824446b)
 +
 +1374. [doc]           tomek
 +      New parameters for Cassandra are now documented.
 +      (Trac #5484, git 56e7026ea2bfab99dbfa1a047dc920ec2f743540)
 +
 +1374. [func]          razvan
 +      Cassandra backend improvements: get all IPv4 leases, delete
 +      hosts, ability to store fixed DHCPv4 fields (next-server,
 +      server-hostname, boot-file-name) and user contexts in host
 +      reservations. Also, the ability to store MAC address details
 +        in DHCPv6 leases on PostgreSQL has been improved.
 +      (Github #70, git 8cd0c1ae416be88baf69c2243e83a429d6d5c965)
 +      (Trac #5506, git 8cd0c1ae416be88baf69c2243e83a429d6d5c965)
 +      (Trac #5507, git 8cd0c1ae416be88baf69c2243e83a429d6d5c965)
 +      (Trac #5508, git 8cd0c1ae416be88baf69c2243e83a429d6d5c965)
 +      (Trac #4530, git 8cd0c1ae416be88baf69c2243e83a429d6d5c965)
 +
 +1373. [func]          tmark
 +      When encountering errors unpacking vendor specific options,
 +      both kea-dhcp4 and kea-dhcp6 will now log the error, skip
 +      unpacking any remaining options, and then attempt to process
 +      the packet as is.  Prior to this the servers would log the issue
 +      and then drop the packet.
 +      (Trac #5551, git 59ef33ee17672c55cee4ec86ff59737b361a3c21)
 +
 +1372. [func]          tmark
 +      kea-dhp4 and kea-dhcp6 can now be configured to attempt to
 +      reconnect to Postgresql backends if connectivity is lost.
 +      (Trac #5477, git 8e62a058382b2245d418cfbf829776934c638e5e)
 +
 +1371. [func]          marcin
 +      Implemented leases parsing from JSON in libkea-dhcpsrv.
 +      (Trac #5466, git 84c2a2084b0fb7c086fc6b9502f7ff58b708174e)
 +
 +1370. [func]          marcin
 +      Implemented new hook points "dhcp4_srv_configured" and
 +      "leases4_committed" in the DHCPv4 server. The latter supports
 +      new next step status NEXT_STEP_PARK which causes the server
 +      to "park" the client's DHCP packet.
 +      (Trac #5457, git af43f07b0e227ccabcdf07a046a64cebb11bdccf)
 +
 +1369. [bug]           fdupont
 +      Fixed a bug in JSONfeed tool which did not correctly handle
 +      strings and interpret their content.
 +      (Trac #5513, git 231e923a85db7fb8305c7baa4d15f766fdf60942)
 +
 +1368. [bug]           tmark
 +      Fixed a bug which prevented inserting multiple host reservations
 +      where IPv4 address was unspecified or when selected subnet identifier
 +      was not specified (5416).  Corrected inconsistent data types for
 +      subnet id columns in both Postgres and MySQL schemas.  Now both
 +      schemas support upto MAX UINT32 in all subnet id columns. Exiting
 +      databases may be updated without data migration.
 +      (Trac #5416, #5522, git d1dd0f2e27ffa49515c17cf68d54f162359b6384)
 +
 +1367. [bug]           marcin
 +      Multiple critical performance optimizations in the allocation
 +      engine for shared networks.
 +      (Trac #5437, git 9d8bcd39802795d48c737a05ef3de3634a28ca4e)
 +
 +1366. [func]          tmark
 +      kea-dhcp4 now explicitly logs packets dropped due to a lack
 +      message type as a log type DHCP4_PACKET_DROP_0009.  Prior
 +      to this such packets were logged has having an unsupported
 +      message type of 0.
 +      (Trac #5553, git ff97e5ffb5f3478be71aae8130b6eff3208bd69a)
 +
 +1365. [func]          fdupont
 +      Added initial skeleton implementation for Radius hook library.
 +      (Trac #5524, git 832aa23b89eab71875bcbdb1e955eb92fdc0e01a)
 +
 +1364. [func]          fdupont
 +      Implemented FNV hashing function. Cassandra backend no longer
 +      explicitly depends on OpenSSL.
 +      (Trac #5502, git 71de75c3bb099f21fdef0d41806da281d6271287)
 +
 +1363. [func]          fdupont
 +      Both DHCPv4 and DHCPv6 servers can now listen on loopback
 +      interfaces. This capability requires setting socket type to UDP in
 +      DHCPv4. Note the feature has not been thoroughly tested.
 +      (Trac #5390, git f38cbd73581a7a0f8634a63cb17f9b60407e3acc)
 +
 +1362. [func]          fdupont
 +      Extended forensic (aka legal) logging with database capability.
 +      (Trac #5420, git 94bd3cc313e9f2a982ef8f8adf0cf44024c76499)
 +
 +1361. [func]          tmark
 +      Added support for automatically recalculating lease statistics
 +      to the CQL backend.
 +      (Trac #5487, git c807388d581ee1c3e479324f3c399f27feba1c96)
 +
 +1360. [func]          razvan, andrei
 +      A new parameter exit-wait-time has been added to perfdhcp. It is
 +      now possible to tell perfdhcp to wait certain amount of time after
 +      exit conditions are met before actuallying terminating.
 +      (Github #55, git 0cd1178ae092fa0c2f122d0e16fb673b4074a6e6)
 +
 +1359. [func]          razvan, andrei, tomek
 +      Support for Google Benchmark has been added. To compile
 +      benchmarking support, please use --with-benchmark option.
 +      (Github #36, git d6819971410b460d7742c762844e2e75ba580944)
 +
 +1358. [build,bug]     fdupont
 +      Cassandra build fixes for macOS.
 +      (Trac #5494, git cb0d735628aefd6bca2acc11b73d1f66b45d1c40)
 +
 +1357. [bug]           rcgoodfellow
 +      Fixed bug in kea-admin causing error on lease-dump.
 +      (Github #61, git 2c9454ec56edc8f3cff8a23329f53ced0d172280)
 +
 +1356. [func]          andreipavelQ,tomek
 +      The logging configuration is now applied early, which helps
 +      seeing errors in case the new configuration is faulty.
 +      (Github #41, git d77fbec5a003a69cab207aa741133015f2657878)
 +
 +1355. [build]         andreipavelQ
 +      --with-dhcp-mysql renamed to --with-mysql and
 +      --with-dhcp-pgsql renamed to --with-pgsql. These names were
 +      leftovers from old BIND10 times when Kea was part of bigger
 +      solution that also provided DNS services. Kea is now a stand-alone
 +      software, thus the -dhcp- doesn't make sense in those options any
 +      more.
 +      (Github #40, git 318c9e3d3db9bb938ced27932d8401172529a2ff)
 +
 +1354. [doc]           andreipavelQ
 +      Documentation has been upgraded to DocBook 5.0.
 +      (Github #39, git 9b6705bd6c534128ec18820ff0cbdd72b7fce9e9)
 +
 +1353. [func]          tomek
 +      Lightweight 4over6 options reinstantiated. Definitions for DHCPv6
 +      options 89 through 96 were added back. DHCPv4 v4 Parameters Option
 +        159 has its definition tweaked slightly.
 +      (Trac #5514, git 6a4aac2b3bfffe41460db6d1cd3c55b1430aa50c)
 +
 +1352. [build]         andrei
 +      Support for coverage tests has been improved.
 +      (Github #43, git 1949bb3abf71fb3997044d239eb683095166c39f)
 +
 +1351. [build,bug]     andrei, razvan
 +      Various small changes and bugfixes. Thank you to Andrei Pavel
 +      and Razvan Becheriu for submitting their patch.
 +      (Github #54, git 2efa7494228a1797dff8d9d74107a452c61e2386)
 +
 +1350. [func]          fdupont
 +      It is now possible to specify client classification restrictions
 +      on per pool basis. This capability will be useful for grouping
 +      certain types of devices into specific address and/or prefix
 +      pools.
 +      (Trac #5425, git 5f3a89d6e32e90cd9cbb2347c7b2208c3e1561e0)
 +
 +1349. [build]         andreipavelQ
 +      Compilation parameters unified (every file now includes config.h,
 +      several makefile tweaks).
 +      (Github #38, git 7206aa79c57be7466c4ab3dd558663c6c4f858b7)
 +
 +1348. [func]          fdupont
 +      Several hook points now support next step status DROP. This allows
 +      more flexibility with dropping packets from within hooks.
 +      (Trac #5443, git ff22a906915a34df327174f550f69a396a05bb2c)
 +
 +1347. [func]          marcin
 +      Implemented HTTP client classes in libkea-http.
 +      (Trac #5451, git 94267e252b372650e4235389251b49d6f5501322)
 +
 +1346. [build]         fdupont
 +      Modified configure.ac to include premium module m4 macros, if the
 +      module is present. Prior to this it relied on premium having it's
 +      own configure.ac script.
 +      (Trac #5400, git 38c4f2fb8fc8c8874a0e4671cc295a049acf675f)
 +
 +1345. [build]         fdupont
 +      Added support of boost 1.66.0 ASIO.
 +      (Github #60/Trac #5496, git bc2947de4296bd99b74e50e65f272c7ad5312429)
 +
 +1344. [func]          marcin
 +      Implemented lease4-get-all command in lease_cmds hooks library.
 +      (Trac #5468, git a378ec28489e98df64830d1f26c3bebd20e256b2)
 +
 +1343. [func]          marcin
 +      Implemented "force-create" parameter for lease4-update and
 +      lease6-update commands.
 +      (Trac #5472, git 369245e4c5308a701fd483123f2cb2fd7d3d0966)
 +
 +1342. [func]          andrei, razvan
 +      Support for host reservations stored in Cassandra added. The core
 +      functionality was added. There are some limitations (delete,
 +      client classes, fixed DHCPv4 fields, statistics recount, etc.)
 +      These will be addressed in upcoming tickets.
 +      (github #37, git e37606fd2d0c02234a55f7445c52a12b2e7a82ec)
 +
  1343. [func]          fdupont
        User-context and comments are now supported in many new scopes:
        global, shared-network, subnet, pool, host reservation, option,
Simple merge
index 05dcc323d91a3817da32dfa0140ffe7ad2a8f838,8fc6972af65d365f61690271bf42adb11e1ea503..c088fce65982c8dece0a175b7d9dd16f42eb0ff1
@@@ -515,14 -532,19 +534,18 @@@ LeaseCmdsImpl::leaseGetAllHandler(Callo
          }
  
          std::ostringstream s;
-         s << leases_json->size() << " IPv4 lease(s) found.";
+         s << leases_json->size()
+           << " IPv" << (v4 ? "4" : "6")
+           << " lease(s) found.";
          ElementPtr args = Element::createMap();
          args->set("leases", leases_json);
-         ConstElementPtr response = createAnswer((leases_json->size() == 0 ? CONTROL_RESULT_EMPTY :
-                                                  CONTROL_RESULT_SUCCESS), s.str(), args);
+         ConstElementPtr response =
+             createAnswer(leases_json->size() > 0 ?
+                          CONTROL_RESULT_SUCCESS :
+                          CONTROL_RESULT_EMPTY,
+                          s.str(), args);
          setResponse(handle, response);
  
--
      } catch (const std::exception& ex) {
          setErrorResponse(handle, ex.what());
          return (CONTROL_RESULT_ERROR);
Simple merge
index 15c59f11beb275df61d73c5ee52a567941b8d652,91d6151a8f445ec68b2a106756b89bc5804462d7..92f933a88fb5800d05b7c84765e7567b99cdee90
@@@ -268,7 -272,23 +272,23 @@@ public
                                          uint32_t iaid,
                                          SubnetID subnet_id) const override;
  
 -    /// @brief Returns a collection of expired DHCPv6 leases.
+     /// @brief Returns all IPv6 leases for the particular subnet identifier.
+     ///
+     /// @param subnet_id subnet identifier.
+     ///
+     /// @return Lease collection (may be empty if no IPv6 lease found).
+     /// @throw NotImplemented because this method is currently not implemented for
+     /// this backend.
+     virtual Lease6Collection getLeases6(SubnetID subnet_id) const override;
+     /// @brief Returns all IPv6 leases.
+     ///
+     /// @return Lease collection (may be empty if no IPv6 lease found).
+     /// @throw NotImplemented because this method is currently not implemented for
+     /// this backend.
+     virtual Lease6Collection getLeases6() const override;
 +    /// @brief Returns a collection of expired DHCPv4 leases.
      ///
      /// This method returns at most @c max_leases expired leases. The leases
      /// returned haven't been reclaimed, i.e. the database query must exclude
Simple merge
index 56507195f7e7bb60bc7989e9b90fb7e4febe347e,f7775845bd80467cf1d50d03fe6caff4e7f93231..f0fd431cc4e23d0cbbd7bf9c86998692690a81e9
@@@ -364,7 -341,19 +364,19 @@@ public
      Lease6Ptr getLease6(Lease::Type type, const DUID& duid,
                          uint32_t iaid, SubnetID subnet_id) const;
  
 -    /// @brief Returns a collection of expired DHCPv6 leases.
+     /// @brief Returns all IPv6 leases for the particular subnet identifier.
+     ///
+     /// @param subnet_id subnet identifier.
+     ///
+     /// @return Lease collection (may be empty if no IPv6 lease found).
+     virtual Lease6Collection getLeases6(SubnetID subnet_id) const = 0;
+     /// @brief Returns all IPv6 leases.
+     ///
+     /// @return Lease collection (may be empty if no IPv6 lease found).
+     virtual Lease6Collection getLeases6() const = 0;
 +    /// @brief Returns a collection of expired DHCPv4 leases.
      ///
      /// This method returns at most @c max_leases expired leases. The leases
      /// returned haven't been reclaimed, i.e. the database query must exclude
index e2186868b48af913b1e087effdb469af16e0628b,61aaf577b1f73c1de33f054c3ad65524b1b38468..336fe8be1c077b29472d09d81ef67bdce0cabdec
@@@ -831,10 -831,40 +831,40 @@@ Memfile_LeaseMgr::getLeases6(Lease::Typ
      return (collection);
  }
  
+ Lease6Collection
+ Memfile_LeaseMgr::getLeases6(SubnetID subnet_id) const {
+     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_GET_SUBID6)
+         .arg(subnet_id);
+     Lease6Collection collection;
+     const Lease6StorageSubnetIdIndex& idx = storage6_.get<SubnetIdIndexTag>();
+     std::pair<Lease6StorageSubnetIdIndex::const_iterator,
+               Lease6StorageSubnetIdIndex::const_iterator> l =
+         idx.equal_range(subnet_id);
+     for (auto lease = l.first; lease != l.second; ++lease) {
+         collection.push_back(Lease6Ptr(new Lease6(**lease)));
+     }
+     return (collection);
+ }
+ Lease6Collection
+ Memfile_LeaseMgr::getLeases6() const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_GET6);
+    Lease6Collection collection;
+    for (auto lease = storage6_.begin(); lease != storage6_.end(); ++lease ) {
+        collection.push_back(Lease6Ptr(new Lease6(**lease)));
+    }
+    return (collection);
+ }
  void
 -Memfile_LeaseMgr::getExpiredLeases6(Lease6Collection& expired_leases,
 +Memfile_LeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases,
                                      const size_t max_leases) const {
 -    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_GET_EXPIRED6)
 +    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_GET_EXPIRED4)
          .arg(max_leases);
  
      // Obtain the index which segragates leases by state and time.
index dea6d920859169d3833a9fcfd04e47001d7c996a,0cb5bc829b42a2d3bb3cc074c5b83f7ab34519fe..81586566a874f2cc083555c266679dbdac01702e
@@@ -271,7 -271,19 +271,19 @@@ public
                                          uint32_t iaid,
                                          SubnetID subnet_id) const;
  
 -    /// @brief Returns a collection of expired DHCPv6 leases.
+     /// @brief Returns all IPv6 leases for the particular subnet identifier.
+     ///
+     /// @param subnet_id subnet identifier.
+     ///
+     /// @return Lease collection (may be empty if no IPv6 lease found).
+     virtual Lease6Collection getLeases6(SubnetID subnet_id) const;
+     /// @brief Returns all IPv6 leases.
+     ///
+     /// @return Lease collection (may be empty if no IPv6 lease found).
+     virtual Lease6Collection getLeases6() const;
 +    /// @brief Returns a collection of expired DHCPv4 leases.
      ///
      /// This method returns at most @c max_leases expired leases. The leases
      /// returned haven't been reclaimed, i.e. the database query must exclude
index e12302b962b307d36bcc62da6a36dc5e4a9ad008,9f035564886677a2ae2b813b204fbb8dedef28a9..b4e489b144f4a3e989280a8860f73c64040d4e58
@@@ -1900,12 -1926,43 +1917,43 @@@ MySqlLeaseMgr::getLeases6(Lease::Type l
      return (result);
  }
  
+ Lease6Collection
+ MySqlLeaseMgr::getLeases6(SubnetID subnet_id) const {
+     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_SUBID6)
+         .arg(subnet_id);
+     // Set up the WHERE clause value
+     MYSQL_BIND inbind[1];
+     memset(inbind, 0, sizeof(inbind));
+     // Subnet ID
+     inbind[0].buffer_type = MYSQL_TYPE_LONG;
+     inbind[0].buffer = reinterpret_cast<char*>(&subnet_id);
+     inbind[0].is_unsigned = MLM_TRUE;
+     // ... and get the data
+     Lease6Collection result;
+     getLeaseCollection(GET_LEASE6_SUBID, inbind, result);
+     return (result);
+ }
+ Lease6Collection
+ MySqlLeaseMgr::getLeases6() const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET6);
+     Lease6Collection result;
+     getLeaseCollection(GET_LEASE6, 0, result);
+     return (result);
+ }
  void
 -MySqlLeaseMgr::getExpiredLeases6(Lease6Collection& expired_leases,
 +MySqlLeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases,
                                   const size_t max_leases) const {
 -    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_EXPIRED6)
 +    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_EXPIRED4)
          .arg(max_leases);
 -    getExpiredLeasesCommon(expired_leases, max_leases, GET_LEASE6_EXPIRE);
 +    getExpiredLeasesCommon(expired_leases, max_leases, GET_LEASE4_EXPIRE);
  }
  
  void
index ac7fc7bcf83e087235ccc0d44c57296113d6159b,91265cc72ba5ca12e6d0cad356ddfb3f80e42c58..db87cf812bcc2bf742832fb6c9b0839e08f289af
@@@ -268,7 -268,19 +268,19 @@@ public
      virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
                                          uint32_t iaid, SubnetID subnet_id) const;
  
 -    /// @brief Returns a collection of expired DHCPv6 leases.
+     /// @brief Returns all IPv6 leases for the particular subnet identifier.
+     ///
+     /// @param subnet_id subnet identifier.
+     ///
+     /// @return Lease collection (may be empty if no IPv6 lease found).
+     virtual Lease6Collection getLeases6(SubnetID subnet_id) const;
+     /// @brief Returns all IPv6 leases.
+     ///
+     /// @return Lease collection (may be empty if no IPv6 lease found).
+     virtual Lease6Collection getLeases6() const;
 +    /// @brief Returns a collection of expired DHCPv4 leases.
      ///
      /// This method returns at most @c max_leases expired leases. The leases
      /// returned haven't been reclaimed, i.e. the database query must exclude
index 4d353392681a640886c8cce78dc68b0935cef82c,c9e68499dd31682490bb554aedbc475d7fd141fa..34572f73f6cea1b3b2ba45792ed31048edc79bae
@@@ -125,14 -121,22 +125,23 @@@ PgSqlTaggedStatement tagged_statements[
      { 3, { OID_INT8, OID_TIMESTAMP, OID_INT8 },
        "get_lease4_expire",
        "SELECT address, hwaddr, client_id, "
 -          "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
 -          "fqdn_fwd, fqdn_rev, hostname, state "
 -              "FROM lease4 "
 -              "WHERE state != $1 AND expire < $2 "
 -              "ORDER BY expire "
 -              "LIMIT $3"},
 +        "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
 +        "fqdn_fwd, fqdn_rev, hostname, "
 +        "state "
 +      "FROM lease4 "
 +      "WHERE state != $1 AND expire < $2 "
 +      "ORDER BY expire "
 +      "LIMIT $3"},
  
+     // GET_LEASE6
+     { 0, { OID_NONE },
+       "get_lease6",
+       "SELECT address, duid, valid_lifetime, "
+         "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
+         "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
+         "state "
+       "FROM lease6"},
      // GET_LEASE6_ADDR
      { 2, { OID_VARCHAR, OID_INT2 },
        "get_lease6_addr",
@@@ -1270,12 -1224,44 +1289,44 @@@ PgSqlLeaseMgr::getLeases6(Lease::Type l
      return (result);
  }
  
+ Lease6Collection
+ PgSqlLeaseMgr::getLeases6(SubnetID subnet_id) const {
+     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_SUBID6)
+         .arg(subnet_id);
+     // Set up the WHERE clause value
+     PsqlBindArray bind_array;
+     // SUBNET_ID
+     std::string subnet_id_str = boost::lexical_cast<std::string>(subnet_id);
+     bind_array.add(subnet_id_str);
+     // ... and get the data
+     Lease6Collection result;
+     getLeaseCollection(GET_LEASE6_SUBID, bind_array, result);
+     return (result);
+ }
+ Lease6Collection
+ PgSqlLeaseMgr::getLeases6() const {
+     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET6);
+     // Provide empty binding array because our query has no parameters in
+     // WHERE clause.
+     PsqlBindArray bind_array;
+     Lease6Collection result;
+     getLeaseCollection(GET_LEASE6, bind_array, result);
+     return (result);
+ }
  void
 -PgSqlLeaseMgr::getExpiredLeases6(Lease6Collection& expired_leases,
 +PgSqlLeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases,
                                   const size_t max_leases) const {
 -    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_EXPIRED6)
 +    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_EXPIRED4)
          .arg(max_leases);
 -    getExpiredLeasesCommon(expired_leases, max_leases, GET_LEASE6_EXPIRE);
 +    getExpiredLeasesCommon(expired_leases, max_leases, GET_LEASE4_EXPIRE);
  }
  
  void
index 105f4a4666cb57ca4690507821b79921fe8500b5,54ca6df8ecbe585cc4115cedfd9b7e36e54caaeb..badc4efb39ba8d5514a1410fdde28309a8c0e42a
@@@ -241,7 -242,19 +241,19 @@@ public
      virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
                                          uint32_t iaid, SubnetID subnet_id) const;
  
 -    /// @brief Returns a collection of expired DHCPv6 leases.
+     /// @brief Returns all IPv6 leases for the particular subnet identifier.
+     ///
+     /// @param subnet_id subnet identifier.
+     ///
+     /// @return Lease collection (may be empty if no IPv6 lease found).
+     virtual Lease6Collection getLeases6(SubnetID subnet_id) const;
+     /// @brief Returns all IPv6 leases.
+     ///
+     /// @return Lease collection (may be empty if no IPv6 lease found).
+     virtual Lease6Collection getLeases6() const;
 +    /// @brief Returns a collection of expired DHCPv4 leases.
      ///
      /// This method returns at most @c max_leases expired leases. The leases
      /// returned haven't been reclaimed, i.e. the database query must exclude