From: Thomas Markwalder Date: Mon, 6 Mar 2023 19:58:05 +0000 (-0500) Subject: [#2719] Updated the ARM, added ChangeLog X-Git-Tag: Kea-2.3.6~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afff930a7ac8e35d644a567510d3fc4c1d3df3ad;p=thirdparty%2Fkea.git [#2719] Updated the ARM, added ChangeLog --- diff --git a/ChangeLog b/ChangeLog index c2e512fad5..b5742af4ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2115. [func] tmark + Added the parameter, offer-lifetime, to kea-dhcp4. When + greater than zero, the server temporarily allocates and + persists leases during DHCPOFFER processing. + (Gitlab #2719) + 2114. [func] razvan Added the -T command line parameter to kea-dhcp4 and kea-dhcp6 for testing configuration files, similar to -t, but with extra diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index 8ddf548f9e..5077af4495 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -4488,6 +4488,65 @@ i.e. the expiration date does not change. Other options based on the valid lifetime e.g. ``dhcp-renewal-time`` and ``dhcp-rebinding-time``, also depend on the reusable lifetime. +Temporary Allocation on DHCPDISCOVER +------------------------------------ + +By default, kea-dhcp4 does not allocate or store a lease when offering an address +to a client in response to a DHCPDISCOVER. In general, kea-dhcp4, can fulfill client +demands faster by deferring lease allocation and storage until it receives DHCPREQUESTs +for them. Release 2.3.6 added a new parameter to kea-dhcp4, ``offer-lifetime``, which +(when not zero) instructs the server to allocate and persist a lease when generating an +DHCPOFFER and: + +- The persisted lease's lifetime is equal to ``offer-lifetime`` (in seconds). + +- The lifetime sent to the client in the DHCPOFFER via option 51 will still be based + on ``valid-lifetime``. This avoids issues with clients that may reject offers lifetimes they + perceive as too short. + +- DDNS updates are not performed. As with the default behavior, that occurs on DHCPREQUEST. + +- Updates are not sent to HA peers. + +- Assigned lease statistics are incremented. + +- Expiration processing and reclamation behave just as they do for leases allocated + during DHCPREQUEST processing. + +- Lease caching, if enabled, is honored. + +- In sites running multiple instances of kea-dhcp4 against a single, shared lease store, races + for given address values are lost during DHCPDISCOVER processing rather than during DHCPREQUEST + processing. Servers that lose the race for the address will simply not respond the client + rather than NAK them. The client in turn will simply retry DHCPDISCOVER. This should reduce + the amount of traffic such conflicts incur. + +- Clients repeating DHCPDISCOVERs will be offered the same address each time. + +An example subnet configuration is shown below: + +:: + + "subnet4": [ + { + "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ], + "subnet": "192.0.2.0/24", + "offer-lifetime": 60, + "valid-lifetime": 2000, + ... + } + ], + +Here ``offer-lifetime`` has been configured to be 60 seconds with a ``valid-lifetime`` +of 2000 seconds. This instructs kea-dhcp4 to persist leases for 60 seconds when +sending them back in DHCPOFFERs and then extending them to 2000 seconds when clients +DHCPREQUEST them. + +The value, which defaults to zero, is supported at the global, shared-network, subnet, +and class levels. Choosing an appropriate value for offer-lifetime is extremely +site-dependent but a value between 60 and 120 seconds would be a reasonable starting +point. + .. _host-reservation-v4: Host Reservations in DHCPv4 diff --git a/src/bin/admin/tests/mysql_tests.sh.in b/src/bin/admin/tests/mysql_tests.sh.in index 403d51ea98..596b3884c2 100644 --- a/src/bin/admin/tests/mysql_tests.sh.in +++ b/src/bin/admin/tests/mysql_tests.sh.in @@ -687,6 +687,34 @@ mysql_upgrade_13_to_14_test() { done } +mysql_upgrade_14_to_15_test() { + # table: dhcp4_options new cancelled column. + qry="select cancelled from dhcp4_options" + run_statement "dhcp4_options" "$qry" + + # table: dhcp6_options new cancelled column. + qry="select cancelled from dhcp6_options" + run_statement "dhcp6_options" "$qry" + + # Check if offer_lifetime was added to dhcp4_shared_network table. + qry="SELECT offer_lifetime from dhcp4_shared_network limit 1;" + run_command \ + mysql_execute "${qry}" + assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)" + + # Check if offer_lifetime was added to dhcp4_subnet table. + qry="SELECT offer_lifetime from dhcp4_subnet limit 1;" + run_command \ + mysql_execute "${qry}" + assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)" + + # Check if offer_lifetime was added to dhcp4_client_class table. + qry="SELECT offer_lifetime from dhcp4_client_class limit 1;" + run_command \ + mysql_execute "${qry}" + assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)" +} + mysql_upgrade_test() { test_start "mysql.upgrade" @@ -1336,14 +1364,7 @@ SET @disable_audit = 0;" mysql_upgrade_13_to_14_test # Check upgrade from 14.0 to 15.0. - - # table: dhcp4_options new cancelled column. - qry="select cancelled from dhcp4_options" - run_statement "dhcp4_options" "$qry" - - # table: dhcp6_options new cancelled column. - qry="select cancelled from dhcp6_options" - run_statement "dhcp6_options" "$qry" + mysql_upgrade_14_to_15_test # Let's wipe the whole database mysql_wipe diff --git a/src/bin/admin/tests/pgsql_tests.sh.in b/src/bin/admin/tests/pgsql_tests.sh.in index 275f4df958..456a66b6c8 100644 --- a/src/bin/admin/tests/pgsql_tests.sh.in +++ b/src/bin/admin/tests/pgsql_tests.sh.in @@ -770,6 +770,24 @@ pgsql_upgrade_13_to_14_test() { run_command \ pgsql_execute "select cancelled from dhcp6_options;" assert_eq 0 "${EXIT_CODE}" "dhcp6_options is missing cancelled column. (expected status code %d, returned %d)" + + # Check if offer_lifetime was added to dhcp4_shared_network table. + qry="SELECT offer_lifetime from dhcp4_shared_network limit 1;" + run_command \ + pgsql_execute "${qry}" + assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)" + + # Check if offer_lifetime was added to dhcp4_subnet table. + qry="SELECT offer_lifetime from dhcp4_subnet limit 1;" + run_command \ + pgsql_execute "${qry}" + assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)" + + # Check if offer_lifetime was added to dhcp4_client_class table. + qry="SELECT offer_lifetime from dhcp4_client_class limit 1;" + run_command \ + pgsql_execute "${qry}" + assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)" } pgsql_upgrade_test() { diff --git a/src/share/database/scripts/mysql/dhcpdb_create.mysql b/src/share/database/scripts/mysql/dhcpdb_create.mysql index bb68eb8914..656b54ec9d 100644 --- a/src/share/database/scripts/mysql/dhcpdb_create.mysql +++ b/src/share/database/scripts/mysql/dhcpdb_create.mysql @@ -5073,6 +5073,16 @@ ALTER TABLE dhcp4_options ALTER TABLE dhcp6_options ADD COLUMN cancelled TINYINT(1) NOT NULL DEFAULT 0; +-- Add offer_lifetime column to v4 tables. +ALTER TABLE dhcp4_shared_network + ADD COLUMN offer_lifetime INT(10) DEFAULT NULL; + +ALTER TABLE dhcp4_subnet + ADD COLUMN offer_lifetime INT(10) DEFAULT NULL; + +ALTER TABLE dhcp4_client_class + ADD COLUMN offer_lifetime INT(10) DEFAULT NULL; + -- Update the schema version number. UPDATE schema_version SET version = '15', minor = '0'; diff --git a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql index 37cb3824a5..910ec2e42c 100644 --- a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql +++ b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql @@ -5633,6 +5633,16 @@ UPDATE schema_version ALTER TABLE dhcp4_options ADD COLUMN cancelled BOOLEAN NOT NULL DEFAULT 'f'; ALTER TABLE dhcp6_options ADD COLUMN cancelled BOOLEAN NOT NULL DEFAULT 'f'; +-- Add offer_lifetime column to v4 tables. +ALTER TABLE dhcp4_shared_network + ADD COLUMN offer_lifetime BIGINT DEFAULT NULL; + +ALTER TABLE dhcp4_subnet + ADD COLUMN offer_lifetime BIGINT DEFAULT NULL; + +ALTER TABLE dhcp4_client_class + ADD COLUMN offer_lifetime BIGINT DEFAULT NULL; + -- Update the schema version number. UPDATE schema_version SET version = '14', minor = '0';