diff --git a/changelog_unreleased/266-adaptive-lease-time-threshold b/changelog_unreleased/226-adaptive-lease-time-threshold similarity index 79% rename from changelog_unreleased/266-adaptive-lease-time-threshold rename to changelog_unreleased/226-adaptive-lease-time-threshold index 9802eca838..bffd3217b9 100644 --- a/changelog_unreleased/266-adaptive-lease-time-threshold +++ b/changelog_unreleased/226-adaptive-lease-time-threshold @@ -1,7 +1,7 @@ [func] fdupont Added the new "adaptive-lease-time-threshold" parameter for the FLQ (Free Lease Queue) allocator which reduces - lifetime of leases when pools of a subnet have an + the lifetime of leases when pools of a subnet have an occupancy rate above a configured threshold (new feature from ISC DHCP). (Gitlab #226) diff --git a/doc/examples/kea4/all-keys.json b/doc/examples/kea4/all-keys.json index 14bc800074..89465c33e1 100644 --- a/doc/examples/kea4/all-keys.json +++ b/doc/examples/kea4/all-keys.json @@ -989,8 +989,8 @@ // lease is returned as it was "cached". "cache-max-age": 1000, - // Adaptive lease time threshold = 1. (disabled). - "adaptive-lease-time-threshold": 1., + // Adaptive lease time threshold (1.0 is disabled). + "adaptive-lease-time-threshold": 0.8, // Specify whether the server should look up global reservations. "reservations-global": false, @@ -1280,8 +1280,8 @@ // Subnet-level cache maximum. "cache-max-age": 1000, - // Adaptive lease time threshold = 1. (disabled). - "adaptive-lease-time-threshold": 1., + // Adaptive lease time threshold (1.0 is disabled). + "adaptive-lease-time-threshold": 0.8, // List of static IPv4 reservations assigned to clients belonging // to this subnet. For a detailed example, see reservations.json. @@ -1425,8 +1425,8 @@ // Global cache maximum. "cache-max-age": 1000, - // Adaptive lease time threshold = 1. (disabled). - "adaptive-lease-time-threshold": 1., + // Adaptive lease time threshold (1.0 is disabled). + "adaptive-lease-time-threshold": 0.8, // String of zero or more characters with which to replace each // invalid character in the hostname or Client FQDN. The default diff --git a/doc/examples/kea6/all-keys.json b/doc/examples/kea6/all-keys.json index 7b857daa94..4b8d344650 100644 --- a/doc/examples/kea6/all-keys.json +++ b/doc/examples/kea6/all-keys.json @@ -939,8 +939,8 @@ // lease is returned as it was "cached". "cache-max-age": 1000, - // Adaptive lease time threshold = 1. (disabled). - "adaptive-lease-time-threshold": 1., + // Adaptive lease time threshold (1.0 is disabled). + "adaptive-lease-time-threshold": 0.8, // Specify whether the server should look up global reservations. "reservations-global": false, @@ -1273,8 +1273,8 @@ // Subnet-level cache maximum. "cache-max-age": 1000, - // Adaptive lease time threshold = 1. (disabled). - "adaptive-lease-time-threshold": 1., + // Adaptive lease time threshold (1.0 is disabled). + "adaptive-lease-time-threshold": 0.8, // List of static IPv6 reservations assigned to clients belonging // to this subnet. For a detailed example, see reservations.json. @@ -1414,8 +1414,8 @@ // Global cache maximum. "cache-max-age": 1000, - // Adaptive lease time threshold = 1.0 (disabled) - "adaptive-lease-time-threshold": 1.0, + // Adaptive lease time threshold (1.0 is disabled) + "adaptive-lease-time-threshold": 0.8, // String of zero or more characters with which to replace each // invalid character in the Client FQDN. The default diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index 5b37376c76..335337bca3 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -8988,9 +8988,9 @@ avoiding unnecessary impact on the server's startup time. In Kea 3.1.1 a new parameter ``adaptive-lease-time-threshold`` was added. It can be specified at global, shared network and subnet levels and -takes a floating point value between ``0.`` (excluded) and ``1.``. -It is disabled by default or when set to ``1.``. It is active only with -he FLQ allocator and when the occupancy rate of pools of subnet is +takes a floating point value between ``0.0`` (excluded) and ``1.0``. +It is disabled by default or when set to ``1.0``. It is only supported +by the FLQ allocator. When the occupancy rate of pools in a subnet is above the specified value the server decreases the lease valid lifetime to the applicable ``min-valid-lifetime`` for new clients. Clients renewing an already existing lease get at least the remaining lifetime diff --git a/doc/sphinx/arm/dhcp6-srv.rst b/doc/sphinx/arm/dhcp6-srv.rst index 52649b8cc1..2bc7ded5f2 100644 --- a/doc/sphinx/arm/dhcp6-srv.rst +++ b/doc/sphinx/arm/dhcp6-srv.rst @@ -8733,9 +8733,9 @@ avoiding unnecessary impact on the server's startup time. In Kea 3.1.1 a new parameter ``adaptive-lease-time-threshold`` was added. It can be specified at global, shared network and subnet levels and -takes a floating point value between ``0.`` (excluded) and ``1.``. -It is disabled by default or when set to ``1.``. It is active only with -he FLQ allocator and when the occupancy rate of pools of subnet is +takes a floating point value between ``0.0`` (excluded) and ``1.0``. +It is disabled by default or when set to ``1.0``. It is only supported +by the FLQ allocator. When the occupancy rate of pools in a subnet is above the specified value the server decreases the lease valid lifetime to the applicable ``min-valid-lifetime`` for new clients. Clients renewing an already existing lease get at least the remaining lifetime diff --git a/src/lib/dhcpsrv/allocator.cc b/src/lib/dhcpsrv/allocator.cc index 5175ff985d..a86d3cfc0b 100644 --- a/src/lib/dhcpsrv/allocator.cc +++ b/src/lib/dhcpsrv/allocator.cc @@ -78,5 +78,18 @@ Allocator::initAfterConfigure() { inited_ = true; } +double +Allocator::getOccupancyRate(const asiolink::IOAddress&ddr, + const ClientClasses&) const { + return (0.); +} + +double +Allocator::getOccupancyRate(const asiolink::IOAddress&, + const uint8_t, + const ClientClasses&) const { + return (0.); +} + } } diff --git a/src/lib/dhcpsrv/allocator.h b/src/lib/dhcpsrv/allocator.h index 44a5309a82..01e117edaf 100644 --- a/src/lib/dhcpsrv/allocator.h +++ b/src/lib/dhcpsrv/allocator.h @@ -152,9 +152,7 @@ public: /// @param client_classes list of classes client belongs to. virtual double getOccupancyRate(const asiolink::IOAddress& addr, - const ClientClasses& client_classes) const { - return (0.); - } + const ClientClasses& client_classes) const; /// @brief Returns the occupancy rate (v6 prefixes). /// @@ -170,9 +168,7 @@ public: virtual double getOccupancyRate(const asiolink::IOAddress& pref, const uint8_t plen, - const ClientClasses& client_classes) const { - return (0.); - } + const ClientClasses& client_classes) const; /// @brief Check if the pool matches the selection criteria relative to the /// provided hint prefix length. diff --git a/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc b/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc index e185509e4a..cb02517d7a 100644 --- a/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc @@ -1894,7 +1894,7 @@ TEST(CfgSubnets4Test, cacheParamValidation) { // This test verifies the Subnet4 parser's validation logic for // adaptive lease time parameter. -TEST(CfgSubnets4Test, AdaptiveLeaseTimeParamValidation) { +TEST(CfgSubnets4Test, adaptiveLeaseTimeParamValidation) { // Describes a single test scenario. struct Scenario { diff --git a/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc b/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc index 3445e9f2e1..51f38cee85 100644 --- a/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc @@ -1675,7 +1675,7 @@ TEST(CfgSubnets6Test, cacheParamValidation) { // This test verifies the Subnet6 parser's validation logic for // adaptive lease time parameter. -TEST(CfgSubnets6Test, AdaptiveLeaseTimeParamValidation) { +TEST(CfgSubnets6Test, adaptiveLeaseTimeParamValidation) { // Describes a single test scenario. struct Scenario {