From 23f7d80c412ea64d1c0b912577cf0cd6471a4fbb Mon Sep 17 00:00:00 2001 From: Razvan Becheriu Date: Tue, 7 May 2024 15:47:11 +0300 Subject: [PATCH] [#2959] removed deprecated parameter reservation-mode --- doc/examples/kea4/all-keys-netconf.json | 19 --- doc/examples/kea4/all-keys.json | 19 --- doc/examples/kea4/global-reservations.json | 3 - doc/examples/kea4/reservations.json | 14 +- doc/examples/kea4/shared-network.json | 13 -- doc/examples/kea6/all-keys-netconf.json | 19 --- doc/examples/kea6/all-keys.json | 19 --- doc/examples/kea6/global-reservations.json | 3 - doc/examples/kea6/reservations.json | 5 +- doc/examples/kea6/shared-network.json | 13 -- doc/sphinx/arm/dhcp4-srv.rst | 106 ++++++------- doc/sphinx/arm/dhcp6-srv.rst | 105 ++++++------ doc/sphinx/arm/hooks-subnet-cmds.rst | 4 - src/bin/dhcp4/dhcp4_lexer.ll | 56 ------- src/bin/dhcp4/dhcp4_parser.yy | 23 --- src/bin/dhcp4/json_config_parser.cc | 5 - src/bin/dhcp4/parser_context.cc | 2 - src/bin/dhcp4/parser_context.h | 3 - src/bin/dhcp4/tests/parser_unittest.cc | 3 +- src/bin/dhcp6/dhcp6_lexer.ll | 56 ------- src/bin/dhcp6/dhcp6_parser.yy | 23 --- src/bin/dhcp6/json_config_parser.cc | 5 - src/bin/dhcp6/parser_context.cc | 2 - src/bin/dhcp6/parser_context.h | 3 - src/bin/dhcp6/tests/parser_unittest.cc | 3 +- src/lib/dhcpsrv/cfg_globals.cc | 1 - src/lib/dhcpsrv/cfg_globals.h | 1 - .../dhcpsrv/parsers/base_network_parser.cc | 71 --------- src/lib/dhcpsrv/parsers/base_network_parser.h | 18 --- src/lib/dhcpsrv/parsers/dhcp_parsers.cc | 6 - .../dhcpsrv/parsers/shared_network_parser.cc | 4 - src/lib/dhcpsrv/parsers/simple_parser4.cc | 11 +- src/lib/dhcpsrv/parsers/simple_parser6.cc | 3 - src/lib/dhcpsrv/srv_config.cc | 10 -- src/lib/dhcpsrv/tests/network_unittest.cc | 149 ------------------ 35 files changed, 118 insertions(+), 682 deletions(-) diff --git a/doc/examples/kea4/all-keys-netconf.json b/doc/examples/kea4/all-keys-netconf.json index 1b7f08a8c9..d5246b26be 100644 --- a/doc/examples/kea4/all-keys-netconf.json +++ b/doc/examples/kea4/all-keys-netconf.json @@ -801,13 +801,6 @@ // lease is returned as it was "cached". "cache-max-age": 1000, - // Enumeration specifying the server's mode of operation when it - // fetches host reservations. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" - // parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, @@ -1001,13 +994,6 @@ // Subnet-level value of the renew timer. "renew-timer": 30, - // Enumeration specifying the server's mode of operation when it - // fetches host reservations. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and - // "reservations-out-of-pool" parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, @@ -1144,11 +1130,6 @@ "capacity": 64 }, - // Fetches host reservations. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, diff --git a/doc/examples/kea4/all-keys.json b/doc/examples/kea4/all-keys.json index 716afdd202..ff62093877 100644 --- a/doc/examples/kea4/all-keys.json +++ b/doc/examples/kea4/all-keys.json @@ -828,13 +828,6 @@ // lease is returned as it was "cached". "cache-max-age": 1000, - // Enumeration specifying the server's mode of operation when it - // fetches host reservations. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" - // parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, @@ -1033,13 +1026,6 @@ // Subnet-level value of the renew timer. "renew-timer": 30, - // Enumeration specifying the server's mode of operation when it - // fetches host reservations. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and - // "reservations-out-of-pool" parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, @@ -1180,11 +1166,6 @@ "capacity": 64 }, - // Fetches host reservations. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, diff --git a/doc/examples/kea4/global-reservations.json b/doc/examples/kea4/global-reservations.json index 37cba508f5..be020af56d 100644 --- a/doc/examples/kea4/global-reservations.json +++ b/doc/examples/kea4/global-reservations.json @@ -51,9 +51,6 @@ // This directive tells Kea that reservations are global. Note that this // can also be specified at shared network and/or subnet level. -// "reservation-mode": "global", -// It is replaced by the "reservations-global", "reservations-in-subnet", and -// "reservations-out-of-pool" parameters. // Specify whether the server should look up global reservations. "reservations-global": true, diff --git a/doc/examples/kea4/reservations.json b/doc/examples/kea4/reservations.json index da44c1b4bc..94d3541e2d 100644 --- a/doc/examples/kea4/reservations.json +++ b/doc/examples/kea4/reservations.json @@ -48,11 +48,10 @@ // to the dynamic pool. Kea is able to handle this case, but it is not // recommended from a performance perspective, as Kea would not only need to // check if a given address is free, but also whether it is reserved. -// To avoid this check, one can change reservation-mode to out-of-pool, rather -// than 'all'. If a subnet does not have reservations at all, the reservation -// lookup can be skipped altogether (reservation-mode is set to 'disabled'). -// The reservation-mode has been replaced by reservations-global, -// reservations-in-subnet and reservations-out-of-pool. +// To avoid this check, one can set "reservations-out-of-pool", beside +// the "reservations-in-subnet". If a subnet does not have reservations at all, +// the reservation lookup can be skipped altogether by disabling +// "reservations-in-subnet". // Note that the second reservation is for an address which is within the // range of the pool of the dynamically allocated address. The server will @@ -66,12 +65,9 @@ "interface": "eth0", // This directive tells Kea that reservations may be made both in-pool // and out-of-pool. For improved performance, you may move all reservations - // out of the dynamic pool and change reservation-mode to "out-of-pool". + // out of the dynamic pool and set "reservations-out-of-pool". // Kea will then be able to skip querying for host reservations when // assigning leases from dynamic pool. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", "reservations-in-subnet" - // and "reservations-out-of-pool" parameters. // Specify whether the server should look up global reservations. "reservations-global": false, diff --git a/doc/examples/kea4/shared-network.json b/doc/examples/kea4/shared-network.json index ae9881300d..3407cf79f6 100644 --- a/doc/examples/kea4/shared-network.json +++ b/doc/examples/kea4/shared-network.json @@ -65,11 +65,6 @@ // Timer values can be overridden here. "renew-timer": 100, - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" - // parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, @@ -102,10 +97,6 @@ "ip-addresses": [ "0.0.0.0" ] }, "renew-timer": 10, - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" - // parameters. // Specify whether the server should look up global reservations. "reservations-global": false, // Specify whether the server should look up in-subnet reservations. @@ -127,10 +118,6 @@ "pools": [ ], "rebind-timer": 20, "renew-timer": 10, - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" - // parameters. // Specify whether the server should look up global reservations. "reservations-global": false, // Specify whether the server should look up in-subnet reservations. diff --git a/doc/examples/kea6/all-keys-netconf.json b/doc/examples/kea6/all-keys-netconf.json index 23f5c6f7af..16fe6ef725 100644 --- a/doc/examples/kea6/all-keys-netconf.json +++ b/doc/examples/kea6/all-keys-netconf.json @@ -751,13 +751,6 @@ // lease is returned as it was "cached". "cache-max-age": 1000, - // Enumeration specifying the server's mode of operation when it - // fetches host reservations. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" - // parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, @@ -975,13 +968,6 @@ // Subnet-level renew timer. "renew-timer": 30, - // Enumeration specifying the server's mode of operation when it - // fetches host reservations. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and - // "reservations-out-of-pool" parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, @@ -1115,11 +1101,6 @@ "capacity": 64 }, - // Fetches host reservations. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, diff --git a/doc/examples/kea6/all-keys.json b/doc/examples/kea6/all-keys.json index cbf615c190..cde5ee61e5 100644 --- a/doc/examples/kea6/all-keys.json +++ b/doc/examples/kea6/all-keys.json @@ -778,13 +778,6 @@ // lease is returned as it was "cached". "cache-max-age": 1000, - // Enumeration specifying the server's mode of operation when it - // fetches host reservations. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" - // parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, @@ -1007,13 +1000,6 @@ // Subnet-level renew timer. "renew-timer": 30, - // Enumeration specifying the server's mode of operation when it - // fetches host reservations. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and - // "reservations-out-of-pool" parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, @@ -1147,11 +1133,6 @@ "capacity": 64 }, - // Fetches host reservations. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, diff --git a/doc/examples/kea6/global-reservations.json b/doc/examples/kea6/global-reservations.json index b98b3e0ede..20173b0db1 100644 --- a/doc/examples/kea6/global-reservations.json +++ b/doc/examples/kea6/global-reservations.json @@ -40,9 +40,6 @@ // This directive tells Kea that reservations are global. Note that this // can also be specified at shared network and/or subnet level. -// "reservation-mode": "global", -// It is replaced by the "reservations-global", "reservations-in-subnet", and -// "reservations-out-of-pool" parameters. // Specify whether the server should look up global reservations. "reservations-global": true, diff --git a/doc/examples/kea6/reservations.json b/doc/examples/kea6/reservations.json index c793cb8c42..4dd47908f1 100644 --- a/doc/examples/kea6/reservations.json +++ b/doc/examples/kea6/reservations.json @@ -47,12 +47,9 @@ // This directive tells Kea that reservations may be made both in-pool // and out-of-pool. For improved performance, you may move all reservations - // out of the dynamic pool and change reservation-mode to "out-of-pool". + // out of the dynamic pool and set "reservations-out-of-pool". // Kea will then be able to skip querying for host reservations when // assigning leases from dynamic pool. - // "reservation-mode": "all", - // It is replaced by the "reservations-global", "reservations-in-subnet" - // and "reservations-out-of-pool" parameters. // Specify whether the server should look up global reservations. "reservations-global": false, diff --git a/doc/examples/kea6/shared-network.json b/doc/examples/kea6/shared-network.json index c0405bb8d4..e54aa54d4c 100644 --- a/doc/examples/kea6/shared-network.json +++ b/doc/examples/kea6/shared-network.json @@ -71,11 +71,6 @@ }, "renew-timer": 100, - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" - // parameters. - // Specify whether the server should look up global reservations. "reservations-global": false, @@ -102,10 +97,6 @@ "ip-addresses": [ "2001:db8:1::123" ] }, "renew-timer": 10, - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" - // parameters. // Specify whether the server should look up global reservations. "reservations-global": false, // Specify whether the server should look up in-subnet reservations. @@ -130,10 +121,6 @@ "ip-addresses": [ "3000::1" ] }, "renew-timer": 10, - // "reservation-mode": "all", - // It is replaced by the "reservations-global", - // "reservations-in-subnet", and "reservations-out-of-pool" - // parameters. // Specify whether the server should look up global reservations. "reservations-global": false, // Specify whether the server should look up in-subnet reservations. diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index 2651e90af2..dcb083144d 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -5316,61 +5316,60 @@ address should be revoked and the reserved one be used instead. Some of those checks may be unnecessary in certain deployments, and not performing them may improve performance. The Kea server provides the -``reservation-mode`` configuration parameter to select the types of +``reservations-global``, ``reservations-in-subnet`` and +``reservations-out-of-pool`` configuration parameters to select the types of reservations allowed for a particular subnet. Each reservation type has different constraints for the checks to be performed by the server when -allocating or renewing a lease for the client. Although ``reservation-mode`` -was deprecated in Kea 1.9.1, it is still available; the allowed values are: - -- ``all`` - enables both in-pool and out-of-pool host reservation - types. This setting is the default value, and is the safest and most - flexible. However, as all checks are conducted, it is also the slowest. - It does not check against global reservations. - -- ``out-of-pool`` - allows only out-of-pool host reservations. With - this setting in place, the server assumes that all host - reservations are for addresses that do not belong to the dynamic - pool. Therefore, it can skip the reservation checks when dealing with - in-pool addresses, thus improving performance. Do not use this mode - if any reservations use in-pool addresses. Caution is advised - when using this setting; Kea does not sanity-check the reservations - against ``reservation-mode`` and misconfiguration may cause problems. - -- ``global`` - allows only global host reservations. With this setting - in place, the server searches for reservations for a client only - among the defined global reservations. If an address is specified, - the server skips the reservation checks carried out in - other modes, thus improving performance. Caution is advised when - using this setting; Kea does not sanity-check reservations when - ``global`` is set, and misconfiguration may cause problems. - -- ``disabled`` - host reservation support is disabled. As there are no - reservations, the server skips all checks. Any reservations - defined are completely ignored. As checks are skipped, the - server may operate faster in this mode. - -Since Kea 1.9.1, the ``reservation-mode`` parameter is replaced by the -``reservations-global``, ``reservations-in-subnet``, and -``reservations-out-of-pool`` flags. -The flags can be activated independently and can produce various combinations, -some of which were not supported by the deprecated ``reservation-mode``. - -The ``reservation-mode`` parameter can be specified at: - -- global level: ``.Dhcp4["reservation-mode"]`` (lowest priority: gets overridden +allocating or renewing a lease for the client. + +Configuration flags are: + +- ``reservations-in-subnet`` - enables in-pool host reservation types. This + setting is the default value, and is the safest and most flexible. However, + as all checks are conducted, it is also the slowest. It does not check + against global reservations. + +- ``reservations-out-of-pool`` - allows only out-of-pool host reservations. + With this setting in place, the server assumes that all host reservations are + for addresses that do not belong to the dynamic pool. Therefore, it can skip + the reservation checks when dealing with in-pool addresses, thus improving + performance. Do not use this mode if any reservations use in-pool addresses. + Caution is advised when using this setting; Kea does not sanity-check the + reservations against ``reservations-out-of-pool`` and misconfiguration may + cause problems. + +- ``reservations-global`` - allows global host reservations. With this setting + in place, the server searches for reservations for a client among the defined + global reservations. If an address is specified, the server skips the + reservation checks carried out in other modes, thus improving performance. + Caution is advised when using this setting; Kea does not sanity-check the + reservations when ``reservations-global`` is set, and misconfiguration may + cause problems. + +Note: disabling all flags disables host reservation support. As there are no + reservations, the server skips all checks. Any reservations defined are + completely ignored. As checks are skipped, the server may operate faster in + this mode. + +Since Kea 1.9.1 the ``reservations-global``, ``reservations-in-subnet`` and +``reservations-out-of-pool`` flags are suported. + +The ``reservations-global``, ``reservations-in-subnet`` and +``reservations-out-of-pool`` parameters can be specified at: + +- global level: ``.Dhcp4["reservations-global"]`` (lowest priority: gets overridden by all others) -- subnet level: ``.Dhcp4.subnet4[]["reservation-mode"]`` (low priority) +- subnet level: ``.Dhcp4.subnet4[]["reservations-in-subnet"]`` (low priority) -- shared-network level: ``.Dhcp4["shared-networks"][]["reservation-mode"]`` +- shared-network level: ``.Dhcp4["shared-networks"][]["reservations-out-of-pool"]`` (high priority) - shared-network subnet-level: - ``.Dhcp4["shared-networks"][].subnet4[]["reservation-mode"]`` (highest + ``.Dhcp4["shared-networks"][].subnet4[]["reservations-out-of-pool"]`` (highest priority: overrides all others) -To decide which ``reservation-mode`` to choose, the -following decision diagram may be useful: +To decide which flags to use, the following decision diagram may be useful: :: @@ -5422,7 +5421,7 @@ following decision diagram may be useful: | | | | | yes| no| | | | | V - +----------------+ +--> "all" + +----------------+ +--> "in-subnet" An example configuration that disables reservations looks as follows: @@ -5438,7 +5437,8 @@ An example configuration that disables reservations looks as follows: "pool": "192.0.2.10-192.0.2.100" } ], - "reservation-mode": "disabled", + "reservations-global": false, + "reservations-in-subnet": false, "subnet": "192.0.2.0/24" } ] @@ -5451,7 +5451,7 @@ An example configuration using global reservations is shown below: { "Dhcp4": { - "reservation-mode": "global", + "reservations-global": true, "reservations": [ { "hostname": "host-one", @@ -5493,7 +5493,7 @@ The meaning of the reservation flags are: the respective reservations from inside the dynamic pools (if any) can be dynamically assigned to any client. -The ``disabled`` value from the deprecated ``reservation-mode`` corresponds to: +The ``disabled`` configuration corresponds to: .. code-block:: json @@ -5504,7 +5504,7 @@ The ``disabled`` value from the deprecated ``reservation-mode`` corresponds to: } } -The ``global`` value from the deprecated ``reservation-mode`` corresponds to: +The ``global``configuration using ``reservations-global`` corresponds to: .. code-block:: json @@ -5515,7 +5515,7 @@ The ``global`` value from the deprecated ``reservation-mode`` corresponds to: } } -The ``out-of-pool`` value from the deprecated ``reservation-mode`` corresponds to: +The ``out-of-pool`` configuration using ``reservations-out-of-pool`` corresponds to: .. code-block:: json @@ -5527,7 +5527,7 @@ The ``out-of-pool`` value from the deprecated ``reservation-mode`` corresponds t } } -And the ``all`` value from the deprecated ``reservation-mode`` corresponds to: +And the ``in-subnet`` configuration using ``reservations-in-subnet`` corresponds to: .. code-block:: json @@ -5539,7 +5539,7 @@ And the ``all`` value from the deprecated ``reservation-mode`` corresponds to: } } -To activate both ``global`` and ``all``, the following combination can be used: +To activate both ``global`` and ``in-subnet``, the following combination can be used: .. code-block:: json diff --git a/doc/sphinx/arm/dhcp6-srv.rst b/doc/sphinx/arm/dhcp6-srv.rst index 1c41ab563c..87e1becbf1 100644 --- a/doc/sphinx/arm/dhcp6-srv.rst +++ b/doc/sphinx/arm/dhcp6-srv.rst @@ -4614,60 +4614,60 @@ instead. Some of those checks may be unnecessary in certain deployments, and not performing them may improve performance. The Kea server provides the -``reservation-mode`` configuration parameter to select the types of +``reservations-global``, ``reservations-in-subnet`` and +``reservations-out-of-pool`` configuration parameters to select the types of reservations allowed for a particular subnet. Each reservation type has different constraints for the checks to be performed by the server when -allocating or renewing a lease for the client. Allowed values are: - -- ``all`` - enables both in-pool and out-of-pool host reservation - types. This setting is the default value, and is the safest and most - flexible. However, as all checks are conducted, it is also the slowest. - It does not check against global reservations. - -- ``out-of-pool`` - allows only out-of-pool host reservations. With - this setting in place, the server assumes that all host - reservations are for addresses that do not belong to the dynamic - pool. Therefore, it can skip the reservation checks when dealing with - in-pool addresses, thus improving performance. Do not use this mode - if any reservations use in-pool addresses. Caution is advised - when using this setting; Kea does not sanity-check the reservations - against ``reservation-mode`` and misconfiguration may cause problems. - -- ``global`` - allows only global host reservations. With this setting - in place, the server searches for reservations for a client only - among the defined global reservations. If an address is specified, - the server skips the reservation checks carried out in - other modes, thus improving performance. Caution is advised when - using this setting; Kea does not sanity-check the reservations when - ``global`` is set, and misconfiguration may cause problems. - -- ``disabled`` - host reservation support is disabled. As there are no - reservations, the server skips all checks. Any reservations - defined are completely ignored. As checks are skipped, the - server may operate faster in this mode. - -Since Kea 1.9.1, the ``reservation-mode`` parameter is replaced by the -``reservations-global``, ``reservations-in-subnet`` and -``reservations-out-of-pool`` flags. -The flags can be activated independently and can produce various combinations, -some of them being unsupported by the deprecated ``reservation-mode``. - -The ``reservation-mode`` parameter can be specified at: - -- global level: ``.Dhcp6["reservation-mode"]`` (lowest priority: gets overridden +allocating or renewing a lease for the client. + +Configuration flags are: + +- ``reservations-in-subnet`` - enables in-pool host reservation types. This + setting is the default value, and is the safest and most flexible. However, + as all checks are conducted, it is also the slowest. It does not check + against global reservations. + +- ``reservations-out-of-pool`` - allows only out-of-pool host reservations. + With this setting in place, the server assumes that all host reservations are + for addresses that do not belong to the dynamic pool. Therefore, it can skip + the reservation checks when dealing with in-pool addresses, thus improving + performance. Do not use this mode if any reservations use in-pool addresses. + Caution is advised when using this setting; Kea does not sanity-check the + reservations against ``reservations-out-of-pool`` and misconfiguration may + cause problems. + +- ``reservations-global`` - allows global host reservations. With this setting + in place, the server searches for reservations for a client among the defined + global reservations. If an address is specified, the server skips the + reservation checks carried out in other modes, thus improving performance. + Caution is advised when using this setting; Kea does not sanity-check the + reservations when ``reservations-global`` is set, and misconfiguration may + cause problems. + +Note: disabling all flags disables host reservation support. As there are no + reservations, the server skips all checks. Any reservations defined are + completely ignored. As checks are skipped, the server may operate faster in + this mode. + +Since Kea 1.9.1 the ``reservations-global``, ``reservations-in-subnet`` and +``reservations-out-of-pool`` flags are suported. + +The ``reservations-global``, ``reservations-in-subnet`` and +``reservations-out-of-pool`` parameters can be specified at: + +- global level: ``.Dhcp6["reservations-global"]`` (lowest priority: gets overridden by all others) -- subnet level: ``.Dhcp6.subnet6[]["reservation-mode"]`` (low priority) +- subnet level: ``.Dhcp6.subnet6[]["reservations-in-subnet"]`` (low priority) -- shared-network level: ``.Dhcp6["shared-networks"][]["reservation-mode"]`` +- shared-network level: ``.Dhcp6["shared-networks"][]["reservations-out-of-pool"]`` (high priority) - shared-network subnet-level: - ``.Dhcp6["shared-networks"][].subnet6[]["reservation-mode"]`` (highest + ``.Dhcp6["shared-networks"][].subnet6[]["reservations-out-of-pool"]`` (highest priority: overrides all others) -To decide which ``"reservation-mode"`` to choose, the -following decision diagram may be useful: +To decide which flags to use, the following decision diagram may be useful: :: @@ -4720,7 +4720,7 @@ following decision diagram may be useful: | | | | | yes| no| | | | | V - +----------------+ +--> "all" + +----------------+ +--> "in-subnet" An example configuration that disables reservations looks as follows: @@ -4736,7 +4736,8 @@ An example configuration that disables reservations looks as follows: "pool": "2001:db8:1::-2001:db8:1::100" } ], - "reservation-mode": "disabled", + "reservations-global": false, + "reservations-in-subnet": false, "subnet": "2001:db8:1::/64" } ] @@ -4749,7 +4750,7 @@ An example configuration using global reservations is shown below: { "Dhcp6": { - "reservation-mode": "global", + "reservations-global": true, "reservations": [ { "duid": "00:03:00:01:11:22:33:44:55:66", @@ -4791,7 +4792,7 @@ The meaning of the reservation flags are: the respective reservations from inside the dynamic pools (if any) can be dynamically assigned to any client. -The ``disabled`` value from the deprecated ``reservation-mode`` corresponds to: +The ``disabled`` configuration corresponds to: .. code-block:: json @@ -4802,7 +4803,7 @@ The ``disabled`` value from the deprecated ``reservation-mode`` corresponds to: } } -The ``global`` value from the deprecated ``reservation-mode`` corresponds to: +The ``global``configuration using ``reservations-global`` corresponds to: .. code-block:: json @@ -4813,7 +4814,7 @@ The ``global`` value from the deprecated ``reservation-mode`` corresponds to: } } -The ``out-of-pool`` value from the deprecated ``reservation-mode`` corresponds to: +The ``out-of-pool`` configuration using ``reservations-out-of-pool`` corresponds to: .. code-block:: json @@ -4825,7 +4826,7 @@ The ``out-of-pool`` value from the deprecated ``reservation-mode`` corresponds t } } -And the ``all`` value from the deprecated ``reservation-mode`` corresponds to: +And the ``in-subnet`` configuration using ``reservations-in-subnet`` corresponds to: .. code-block:: json @@ -4837,7 +4838,7 @@ And the ``all`` value from the deprecated ``reservation-mode`` corresponds to: } } -To activate both ``global`` and ``all``, the following combination can be used: +To activate both ``global`` and ``in-subnet``, the following combination can be used: .. code-block:: json diff --git a/doc/sphinx/arm/hooks-subnet-cmds.rst b/doc/sphinx/arm/hooks-subnet-cmds.rst index 383a48af19..b09dc35ad7 100644 --- a/doc/sphinx/arm/hooks-subnet-cmds.rst +++ b/doc/sphinx/arm/hooks-subnet-cmds.rst @@ -1031,10 +1031,6 @@ An example response could look as follows: "ip-address": "0.0.0.0" }, "renew-timer": 60, - # "reservation-mode": "all", - # It is replaced by the "reservations-global", - # "reservations-in-subnet", and "reservations-out-of-pool" - # parameters. # Specify if the server should look up global reservations. "reservations-global": false, # Specify if the server should look up in-subnet reservations. diff --git a/src/bin/dhcp4/dhcp4_lexer.ll b/src/bin/dhcp4/dhcp4_lexer.ll index f3a722cba1..c0eaa45984 100644 --- a/src/bin/dhcp4/dhcp4_lexer.ll +++ b/src/bin/dhcp4/dhcp4_lexer.ll @@ -1125,62 +1125,6 @@ ControlCharacterFill [^"\\]|\\["\\/bfnrtu] } } -\"reservation-mode\" { - switch(driver.ctx_) { - case isc::dhcp::Parser4Context::DHCP4: - case isc::dhcp::Parser4Context::SUBNET4: - case isc::dhcp::Parser4Context::SHARED_NETWORK: - return isc::dhcp::Dhcp4Parser::make_RESERVATION_MODE(driver.loc_); - default: - return isc::dhcp::Dhcp4Parser::make_STRING("reservation-mode", driver.loc_); - } -} - -\"disabled\" { - switch(driver.ctx_) { - case isc::dhcp::Parser4Context::RESERVATION_MODE: - return isc::dhcp::Dhcp4Parser::make_DISABLED(driver.loc_); - default: - return isc::dhcp::Dhcp4Parser::make_STRING("disabled", driver.loc_); - } -} - -\"off\" { - switch(driver.ctx_) { - case isc::dhcp::Parser4Context::RESERVATION_MODE: - return isc::dhcp::Dhcp4Parser::make_DISABLED(driver.loc_); - default: - return isc::dhcp::Dhcp4Parser::make_STRING("off", driver.loc_); - } -} - -\"out-of-pool\" { - switch(driver.ctx_) { - case isc::dhcp::Parser4Context::RESERVATION_MODE: - return isc::dhcp::Dhcp4Parser::make_OUT_OF_POOL(driver.loc_); - default: - return isc::dhcp::Dhcp4Parser::make_STRING("out-of-pool", driver.loc_); - } -} - -\"global\" { - switch(driver.ctx_) { - case isc::dhcp::Parser4Context::RESERVATION_MODE: - return isc::dhcp::Dhcp4Parser::make_GLOBAL(driver.loc_); - default: - return isc::dhcp::Dhcp4Parser::make_STRING("global", driver.loc_); - } -} - -\"all\" { - switch(driver.ctx_) { - case isc::dhcp::Parser4Context::RESERVATION_MODE: - return isc::dhcp::Dhcp4Parser::make_ALL(driver.loc_); - default: - return isc::dhcp::Dhcp4Parser::make_STRING("all", driver.loc_); - } -} - \"reservations-global\" { switch(driver.ctx_) { case isc::dhcp::Parser4Context::DHCP4: diff --git a/src/bin/dhcp4/dhcp4_parser.yy b/src/bin/dhcp4/dhcp4_parser.yy index 9cad59405c..a0816348ce 100644 --- a/src/bin/dhcp4/dhcp4_parser.yy +++ b/src/bin/dhcp4/dhcp4_parser.yy @@ -175,11 +175,6 @@ using namespace std; SUBNET "subnet" INTERFACE "interface" ID "id" - RESERVATION_MODE "reservation-mode" - DISABLED "disabled" - OUT_OF_POOL "out-of-pool" - GLOBAL "global" - ALL "all" RESERVATIONS_GLOBAL "reservations-global" RESERVATIONS_IN_SUBNET "reservations-in-subnet" RESERVATIONS_OUT_OF_POOL "reservations-out-of-pool" @@ -299,7 +294,6 @@ using namespace std; %type outbound_interface_value %type db_type %type on_fail_mode -%type hr_mode %type ncr_protocol_value %type ddns_replace_client_name_value %type ddns_conflict_resolution_mode_value @@ -534,7 +528,6 @@ global_param: valid_lifetime | reservations | config_control | server_tag - | reservation_mode | reservations_global | reservations_in_subnet | reservations_out_of_pool @@ -1599,7 +1592,6 @@ subnet4_param: valid_lifetime | client_class | require_client_classes | reservations - | reservation_mode | reservations_global | reservations_in_subnet | reservations_out_of_pool @@ -1720,20 +1712,6 @@ reservations_out_of_pool: RESERVATIONS_OUT_OF_POOL COLON BOOLEAN { ctx.stack_.back()->set("reservations-out-of-pool", b); }; -reservation_mode: RESERVATION_MODE { - ctx.unique("reservation-mode", ctx.loc2pos(@1)); - ctx.enter(ctx.RESERVATION_MODE); -} COLON hr_mode { - ctx.stack_.back()->set("reservation-mode", $4); - ctx.leave(); -}; - -hr_mode: DISABLED { $$ = ElementPtr(new StringElement("disabled", ctx.loc2pos(@1))); } - | OUT_OF_POOL { $$ = ElementPtr(new StringElement("out-of-pool", ctx.loc2pos(@1))); } - | GLOBAL { $$ = ElementPtr(new StringElement("global", ctx.loc2pos(@1))); } - | ALL { $$ = ElementPtr(new StringElement("all", ctx.loc2pos(@1))); } - ; - id: ID COLON INTEGER { ctx.unique("id", ctx.loc2pos(@1)); ElementPtr id(new IntElement($3, ctx.loc2pos(@3))); @@ -1793,7 +1771,6 @@ shared_network_param: name | server_hostname | boot_file_name | relay - | reservation_mode | reservations_global | reservations_in_subnet | reservations_out_of_pool diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index 02741cf0a0..c2e34c50f0 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -352,10 +352,6 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) { // default values and will insert derived values as well. mutable_cfg = boost::const_pointer_cast(config_set); - // Move from reservation mode to new reservations flags. - // @todo add warning - BaseNetworkParser::moveReservationMode(mutable_cfg); - // Set all default values if not specified by the user. SimpleParser4::setAllDefaults(mutable_cfg); @@ -627,7 +623,6 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) { (config_pair.first == "server-hostname") || (config_pair.first == "boot-file-name") || (config_pair.first == "server-tag") || - (config_pair.first == "reservation-mode") || (config_pair.first == "reservations-global") || (config_pair.first == "reservations-in-subnet") || (config_pair.first == "reservations-out-of-pool") || diff --git a/src/bin/dhcp4/parser_context.cc b/src/bin/dhcp4/parser_context.cc index 3974ce659d..52bfe2be88 100644 --- a/src/bin/dhcp4/parser_context.cc +++ b/src/bin/dhcp4/parser_context.cc @@ -175,8 +175,6 @@ Parser4Context::contextName() { return ("hooks-libraries"); case SUBNET4: return ("subnet4"); - case RESERVATION_MODE: - return ("reservation-mode"); case OPTION_DEF: return ("option-def"); case OPTION_DATA: diff --git a/src/bin/dhcp4/parser_context.h b/src/bin/dhcp4/parser_context.h index 404e586e1e..070b731517 100644 --- a/src/bin/dhcp4/parser_context.h +++ b/src/bin/dhcp4/parser_context.h @@ -273,9 +273,6 @@ public: /// Used while parsing shared-networks structures. SHARED_NETWORK, - /// Used while parsing Dhcp4/reservation-mode. - RESERVATION_MODE, - /// Used while parsing Dhcp4/option-def structures. OPTION_DEF, diff --git a/src/bin/dhcp4/tests/parser_unittest.cc b/src/bin/dhcp4/tests/parser_unittest.cc index ec32d122cc..9d801374db 100644 --- a/src/bin/dhcp4/tests/parser_unittest.cc +++ b/src/bin/dhcp4/tests/parser_unittest.cc @@ -789,8 +789,7 @@ TEST(ParserTest, mapEntries) { loadFile(sample_dir + "reservations.json", sample_json); loadFile(sample_dir + "all-keys-netconf.json", sample_json); KeywordSet sample_keys = { - "hosts-database", - "reservation-mode" + "hosts-database" }; // Recursively extract keywords. static void (*extract)(ConstElementPtr, KeywordSet&) = diff --git a/src/bin/dhcp6/dhcp6_lexer.ll b/src/bin/dhcp6/dhcp6_lexer.ll index db827af2a4..8ff6736571 100644 --- a/src/bin/dhcp6/dhcp6_lexer.ll +++ b/src/bin/dhcp6/dhcp6_lexer.ll @@ -1403,62 +1403,6 @@ ControlCharacterFill [^"\\]|\\["\\/bfnrtu] } } -\"reservation-mode\" { - switch(driver.ctx_) { - case isc::dhcp::Parser6Context::DHCP6: - case isc::dhcp::Parser6Context::SUBNET6: - case isc::dhcp::Parser6Context::SHARED_NETWORK: - return isc::dhcp::Dhcp6Parser::make_RESERVATION_MODE(driver.loc_); - default: - return isc::dhcp::Dhcp6Parser::make_STRING("reservation-mode", driver.loc_); - } -} - -\"disabled\" { - switch(driver.ctx_) { - case isc::dhcp::Parser6Context::RESERVATION_MODE: - return isc::dhcp::Dhcp6Parser::make_DISABLED(driver.loc_); - default: - return isc::dhcp::Dhcp6Parser::make_STRING("disabled", driver.loc_); - } -} - -\"off\" { - switch(driver.ctx_) { - case isc::dhcp::Parser6Context::RESERVATION_MODE: - return isc::dhcp::Dhcp6Parser::make_DISABLED(driver.loc_); - default: - return isc::dhcp::Dhcp6Parser::make_STRING("off", driver.loc_); - } -} - -\"out-of-pool\" { - switch(driver.ctx_) { - case isc::dhcp::Parser6Context::RESERVATION_MODE: - return isc::dhcp::Dhcp6Parser::make_OUT_OF_POOL(driver.loc_); - default: - return isc::dhcp::Dhcp6Parser::make_STRING("out-of-pool", driver.loc_); - } -} - -\"global\" { - switch(driver.ctx_) { - case isc::dhcp::Parser6Context::RESERVATION_MODE: - return isc::dhcp::Dhcp6Parser::make_GLOBAL(driver.loc_); - default: - return isc::dhcp::Dhcp6Parser::make_STRING("global", driver.loc_); - } -} - -\"all\" { - switch(driver.ctx_) { - case isc::dhcp::Parser6Context::RESERVATION_MODE: - return isc::dhcp::Dhcp6Parser::make_ALL(driver.loc_); - default: - return isc::dhcp::Dhcp6Parser::make_STRING("all", driver.loc_); - } -} - \"reservations-global\" { switch(driver.ctx_) { case isc::dhcp::Parser6Context::DHCP6: diff --git a/src/bin/dhcp6/dhcp6_parser.yy b/src/bin/dhcp6/dhcp6_parser.yy index bdf9d5aeec..e4ccde453e 100644 --- a/src/bin/dhcp6/dhcp6_parser.yy +++ b/src/bin/dhcp6/dhcp6_parser.yy @@ -166,11 +166,6 @@ using namespace std; INTERFACE_ID "interface-id" ID "id" RAPID_COMMIT "rapid-commit" - RESERVATION_MODE "reservation-mode" - DISABLED "disabled" - OUT_OF_POOL "out-of-pool" - GLOBAL "global" - ALL "all" RESERVATIONS_GLOBAL "reservations-global" RESERVATIONS_IN_SUBNET "reservations-in-subnet" RESERVATIONS_OUT_OF_POOL "reservations-out-of-pool" @@ -300,7 +295,6 @@ using namespace std; %type map_value %type db_type %type on_fail_mode -%type hr_mode %type duid_type %type ncr_protocol_value %type ddns_replace_client_name_value @@ -538,7 +532,6 @@ global_param: data_directory | reservations | config_control | server_tag - | reservation_mode | reservations_global | reservations_in_subnet | reservations_out_of_pool @@ -1615,7 +1608,6 @@ subnet6_param: preferred_lifetime | client_class | require_client_classes | reservations - | reservation_mode | reservations_global | reservations_in_subnet | reservations_out_of_pool @@ -1710,20 +1702,6 @@ reservations_out_of_pool: RESERVATIONS_OUT_OF_POOL COLON BOOLEAN { ctx.stack_.back()->set("reservations-out-of-pool", b); }; -reservation_mode: RESERVATION_MODE { - ctx.unique("reservation-mode", ctx.loc2pos(@1)); - ctx.enter(ctx.RESERVATION_MODE); -} COLON hr_mode { - ctx.stack_.back()->set("reservation-mode", $4); - ctx.leave(); -}; - -hr_mode: DISABLED { $$ = ElementPtr(new StringElement("disabled", ctx.loc2pos(@1))); } - | OUT_OF_POOL { $$ = ElementPtr(new StringElement("out-of-pool", ctx.loc2pos(@1))); } - | GLOBAL { $$ = ElementPtr(new StringElement("global", ctx.loc2pos(@1))); } - | ALL { $$ = ElementPtr(new StringElement("all", ctx.loc2pos(@1))); } - ; - id: ID COLON INTEGER { ctx.unique("id", ctx.loc2pos(@1)); ElementPtr id(new IntElement($3, ctx.loc2pos(@3))); @@ -1785,7 +1763,6 @@ shared_network_param: name | rebind_timer | option_data_list | relay - | reservation_mode | reservations_global | reservations_in_subnet | reservations_out_of_pool diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc index cd7fa99e5d..671d69a802 100644 --- a/src/bin/dhcp6/json_config_parser.cc +++ b/src/bin/dhcp6/json_config_parser.cc @@ -454,10 +454,6 @@ processDhcp6Config(isc::data::ConstElementPtr config_set) { // default values and will insert derived values as well. mutable_cfg = boost::const_pointer_cast(config_set); - // Move from reservation mode to new reservations flags. - // @todo add warning - BaseNetworkParser::moveReservationMode(mutable_cfg); - // Set all default values if not specified by the user. SimpleParser6::setAllDefaults(mutable_cfg); @@ -760,7 +756,6 @@ processDhcp6Config(isc::data::ConstElementPtr config_set) { (config_pair.first == "decline-probation-period") || (config_pair.first == "dhcp4o6-port") || (config_pair.first == "server-tag") || - (config_pair.first == "reservation-mode") || (config_pair.first == "reservations-global") || (config_pair.first == "reservations-in-subnet") || (config_pair.first == "reservations-out-of-pool") || diff --git a/src/bin/dhcp6/parser_context.cc b/src/bin/dhcp6/parser_context.cc index b2c9c072f5..649e1e37c0 100644 --- a/src/bin/dhcp6/parser_context.cc +++ b/src/bin/dhcp6/parser_context.cc @@ -172,8 +172,6 @@ Parser6Context::contextName() { return ("hooks-libraries"); case SUBNET6: return ("subnet6"); - case RESERVATION_MODE: - return ("reservation-mode"); case OPTION_DEF: return ("option-def"); case OPTION_DATA: diff --git a/src/bin/dhcp6/parser_context.h b/src/bin/dhcp6/parser_context.h index ff6e9d9635..8d20453a65 100644 --- a/src/bin/dhcp6/parser_context.h +++ b/src/bin/dhcp6/parser_context.h @@ -273,9 +273,6 @@ public: /// Used while parsing shared-networks structures. SHARED_NETWORK, - /// Used while parsing Dhcp6/reservation-mode. - RESERVATION_MODE, - /// Used while parsing Dhcp6/option-def structures. OPTION_DEF, diff --git a/src/bin/dhcp6/tests/parser_unittest.cc b/src/bin/dhcp6/tests/parser_unittest.cc index a0a110be6a..1ba44e1236 100644 --- a/src/bin/dhcp6/tests/parser_unittest.cc +++ b/src/bin/dhcp6/tests/parser_unittest.cc @@ -780,8 +780,7 @@ TEST(ParserTest, mapEntries) { loadFile(sample_dir + "reservations.json", sample_json); loadFile(sample_dir + "all-keys-netconf.json", sample_json); KeywordSet sample_keys = { - "hosts-database", - "reservation-mode" + "hosts-database" }; // Recursively extract keywords. static void (*extract)(ConstElementPtr, KeywordSet&) = diff --git a/src/lib/dhcpsrv/cfg_globals.cc b/src/lib/dhcpsrv/cfg_globals.cc index c5f2346443..7c0201bf7f 100644 --- a/src/lib/dhcpsrv/cfg_globals.cc +++ b/src/lib/dhcpsrv/cfg_globals.cc @@ -24,7 +24,6 @@ CfgGlobals::nameToIndex = { { "dhcp4o6-port", DHCP4O6_PORT }, { "comment", COMMENT }, { "server-tag", SERVER_TAG }, - { "reservation-mode", RESERVATION_MODE }, { "reservations-global", RESERVATIONS_GLOBAL }, { "reservations-in-subnet", RESERVATIONS_IN_SUBNET }, { "reservations-out-of-pool", RESERVATIONS_OUT_OF_POOL }, diff --git a/src/lib/dhcpsrv/cfg_globals.h b/src/lib/dhcpsrv/cfg_globals.h index 06e3cde10d..bb28d52189 100644 --- a/src/lib/dhcpsrv/cfg_globals.h +++ b/src/lib/dhcpsrv/cfg_globals.h @@ -47,7 +47,6 @@ public: DHCP4O6_PORT, COMMENT, SERVER_TAG, - RESERVATION_MODE, RESERVATIONS_GLOBAL, RESERVATIONS_IN_SUBNET, RESERVATIONS_OUT_OF_POOL, diff --git a/src/lib/dhcpsrv/parsers/base_network_parser.cc b/src/lib/dhcpsrv/parsers/base_network_parser.cc index 6f0ab84efc..8d73b7aed9 100644 --- a/src/lib/dhcpsrv/parsers/base_network_parser.cc +++ b/src/lib/dhcpsrv/parsers/base_network_parser.cc @@ -17,77 +17,6 @@ using namespace isc::util; namespace isc { namespace dhcp { -void -BaseNetworkParser::moveReservationMode(ElementPtr config) { - if (!config->contains("reservation-mode")) { - return; - } - if (config->contains("reservations-global") || - config->contains("reservations-in-subnet") || - config->contains("reservations-out-of-pool")) { - isc_throw(DhcpConfigError, "invalid use of both 'reservation-mode'" - " and one of 'reservations-global', 'reservations-in-subnet'" - " or 'reservations-out-of-pool' parameters"); - } - std::string hr_mode = getString(config, "reservation-mode"); - if ((hr_mode == "disabled") || (hr_mode == "off")) { - config->set("reservations-global", Element::create(false)); - config->set("reservations-in-subnet", Element::create(false)); - } else if (hr_mode == "out-of-pool") { - config->set("reservations-global", Element::create(false)); - config->set("reservations-in-subnet", Element::create(true)); - config->set("reservations-out-of-pool", Element::create(true)); - } else if (hr_mode == "global") { - config->set("reservations-global", Element::create(true)); - config->set("reservations-in-subnet", Element::create(false)); - } else if (hr_mode == "all") { - config->set("reservations-global", Element::create(false)); - config->set("reservations-in-subnet", Element::create(true)); - config->set("reservations-out-of-pool", Element::create(false)); - } else { - isc_throw(DhcpConfigError, "invalid reservation-mode parameter: '" - << hr_mode << "' (" - << getPosition("reservation-mode", config) << ")"); - } - config->remove("reservation-mode"); -} - -void -BaseNetworkParser::moveReservationMode(CfgGlobalsPtr config) { - if (!config->get(CfgGlobals::RESERVATION_MODE)) { - return; - } - if (config->get(CfgGlobals::RESERVATIONS_GLOBAL) || - config->get(CfgGlobals::RESERVATIONS_IN_SUBNET) || - config->get(CfgGlobals::RESERVATIONS_OUT_OF_POOL)) { - isc_throw(DhcpConfigError, "invalid use of both 'reservation-mode'" - " and one of 'reservations-global', 'reservations-in-subnet'" - " or 'reservations-out-of-pool' parameters"); - } - std::string hr_mode = config->get(CfgGlobals::RESERVATION_MODE)->stringValue(); - if ((hr_mode == "disabled") || (hr_mode == "off")) { - config->set(CfgGlobals::RESERVATIONS_GLOBAL, Element::create(false)); - config->set(CfgGlobals::RESERVATIONS_IN_SUBNET, Element::create(false)); - } else if (hr_mode == "out-of-pool") { - config->set(CfgGlobals::RESERVATIONS_GLOBAL, Element::create(false)); - config->set(CfgGlobals::RESERVATIONS_IN_SUBNET, Element::create(true)); - config->set(CfgGlobals::RESERVATIONS_OUT_OF_POOL, Element::create(true)); - } else if (hr_mode == "global") { - config->set(CfgGlobals::RESERVATIONS_GLOBAL, Element::create(true)); - config->set(CfgGlobals::RESERVATIONS_IN_SUBNET, Element::create(false)); - } else if (hr_mode == "all") { - config->set(CfgGlobals::RESERVATIONS_GLOBAL, Element::create(false)); - config->set(CfgGlobals::RESERVATIONS_IN_SUBNET, Element::create(true)); - config->set("reservations-out-of-pool", Element::create(false)); - } else { - isc_throw(DhcpConfigError, "invalid reservation-mode parameter: '" - << hr_mode << "' (" - << config->get(CfgGlobals::RESERVATION_MODE)->getPosition() - << ")"); - } - config->set(CfgGlobals::RESERVATION_MODE, ConstElementPtr()); -} - void BaseNetworkParser::parseCommon(const ConstElementPtr& network_data, NetworkPtr& network) { diff --git a/src/lib/dhcpsrv/parsers/base_network_parser.h b/src/lib/dhcpsrv/parsers/base_network_parser.h index f0714c5de4..fe903d36a6 100644 --- a/src/lib/dhcpsrv/parsers/base_network_parser.h +++ b/src/lib/dhcpsrv/parsers/base_network_parser.h @@ -18,24 +18,6 @@ namespace dhcp { /// @brief Common configuration parser for shared networks /// and subnets. class BaseNetworkParser : public data::SimpleParser { -public: - - /// @brief Moves deprecated reservation-mode parameter to - /// new reservations flags. - /// - /// @param config [in/out] configuration to alter. - /// @throw DhcpConfigError on error e.g. when both reservation-mode - /// and a flag are specified. - static void moveReservationMode(isc::data::ElementPtr config); - - /// @brief Moves deprecated reservation-mode parameter to - /// new reservations flags. - /// - /// @param config [in/out] global parameters to alter. - /// @throw DhcpConfigError on error e.g. when both reservation-mode - /// and a flag are specified. - static void moveReservationMode(CfgGlobalsPtr config); - protected: /// @brief Parses common parameters diff --git a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc index 724d2381cb..76b7c7f661 100644 --- a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc +++ b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc @@ -740,11 +740,8 @@ Subnet4ConfigParser::initSubnet(data::ConstElementPtr params, subnet_id); subnet_ = subnet4; - // Move from reservation mode to new reservations flags. ElementPtr mutable_params; mutable_params = boost::const_pointer_cast(params); - // @todo add warning - BaseNetworkParser::moveReservationMode(mutable_params); // Parse parameters common to all Network derivations. NetworkPtr network = boost::dynamic_pointer_cast(subnet4); @@ -1280,11 +1277,8 @@ Subnet6ConfigParser::initSubnet(data::ConstElementPtr params, subnet_id); subnet_ = subnet6; - // Move from reservation mode to new reservations flags. ElementPtr mutable_params; mutable_params = boost::const_pointer_cast(params); - // @todo add warning - BaseNetworkParser::moveReservationMode(mutable_params); // Parse parameters common to all Network derivations. NetworkPtr network = boost::dynamic_pointer_cast(subnet_); diff --git a/src/lib/dhcpsrv/parsers/shared_network_parser.cc b/src/lib/dhcpsrv/parsers/shared_network_parser.cc index 3cf689c6d6..95e444339d 100644 --- a/src/lib/dhcpsrv/parsers/shared_network_parser.cc +++ b/src/lib/dhcpsrv/parsers/shared_network_parser.cc @@ -45,10 +45,8 @@ SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data, std::string name = getString(shared_network_data, "name"); shared_network.reset(new SharedNetwork4(name)); - // Move from reservation mode to new reservations flags. ElementPtr mutable_params; mutable_params = boost::const_pointer_cast(shared_network_data); - BaseNetworkParser::moveReservationMode(mutable_params); // Parse parameters common to all Network derivations. NetworkPtr network = boost::dynamic_pointer_cast(shared_network); @@ -253,10 +251,8 @@ SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data, std::string name = getString(shared_network_data, "name"); shared_network.reset(new SharedNetwork6(name)); - // Move from reservation mode to new reservations flags. ElementPtr mutable_params; mutable_params = boost::const_pointer_cast(shared_network_data); - BaseNetworkParser::moveReservationMode(mutable_params); // Parse parameters common to all Network derivations. NetworkPtr network = boost::dynamic_pointer_cast(shared_network); diff --git a/src/lib/dhcpsrv/parsers/simple_parser4.cc b/src/lib/dhcpsrv/parsers/simple_parser4.cc index 6c979bea33..abc4d96fa3 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser4.cc +++ b/src/lib/dhcpsrv/parsers/simple_parser4.cc @@ -69,7 +69,6 @@ const SimpleKeywords SimpleParser4::GLOBAL4_PARAMETERS = { { "reservations", Element::list }, { "config-control", Element::map }, { "server-tag", Element::string }, - { "reservation-mode", Element::string }, { "reservations-global", Element::boolean }, { "reservations-in-subnet", Element::boolean }, { "reservations-out-of-pool", Element::boolean }, @@ -225,7 +224,6 @@ const SimpleKeywords SimpleParser4::SUBNET4_PARAMETERS = { { "client-class", Element::string }, { "require-client-classes", Element::list }, { "reservations", Element::list }, - { "reservation-mode", Element::string }, { "reservations-global", Element::boolean }, { "reservations-in-subnet", Element::boolean }, { "reservations-out-of-pool", Element::boolean }, @@ -267,8 +265,8 @@ const SimpleKeywords SimpleParser4::SUBNET4_PARAMETERS = { /// Note: When updating this array, please also update SHARED_SUBNET4_DEFAULTS /// below. In most cases, those two should be kept in sync, except cases /// where a parameter can be derived from shared-networks, but is not -/// defined on global level. Currently there are two such parameters: -/// interface and reservation-mode +/// defined on global level. Currently there in only one such parameter: +/// interface. const SimpleDefaults SimpleParser4::SUBNET4_DEFAULTS = { { "interface", Element::string, "" }, { "client-class", Element::string, "" }, @@ -280,9 +278,9 @@ const SimpleDefaults SimpleParser4::SUBNET4_DEFAULTS = { /// @brief This table defines default values for each IPv4 subnet that is /// part of a shared network /// -/// This is mostly the same as @ref SUBNET4_DEFAULTS, except two parameters +/// This is mostly the same as @ref SUBNET4_DEFAULTS, except one parameter /// that can be derived from shared-network, but cannot from global scope. -/// Those are: interface and reservation-mode. +/// This is: interface. const SimpleDefaults SimpleParser4::SHARED_SUBNET4_DEFAULTS = { { "4o6-interface", Element::string, "" }, { "4o6-interface-id", Element::string, "" }, @@ -355,7 +353,6 @@ const SimpleKeywords SimpleParser4::SHARED_NETWORK4_PARAMETERS = { { "server-hostname", Element::string }, { "boot-file-name", Element::string }, { "relay", Element::map }, - { "reservation-mode", Element::string }, { "reservations-global", Element::boolean }, { "reservations-in-subnet", Element::boolean }, { "reservations-out-of-pool", Element::boolean }, diff --git a/src/lib/dhcpsrv/parsers/simple_parser6.cc b/src/lib/dhcpsrv/parsers/simple_parser6.cc index f31c5d53c8..fd2eca8dee 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser6.cc +++ b/src/lib/dhcpsrv/parsers/simple_parser6.cc @@ -69,7 +69,6 @@ const SimpleKeywords SimpleParser6::GLOBAL6_PARAMETERS = { { "reservations", Element::list }, { "config-control", Element::map }, { "server-tag", Element::string }, - { "reservation-mode", Element::string }, { "reservations-global", Element::boolean }, { "reservations-in-subnet", Element::boolean }, { "reservations-out-of-pool", Element::boolean }, @@ -225,7 +224,6 @@ const SimpleKeywords SimpleParser6::SUBNET6_PARAMETERS = { { "client-class", Element::string }, { "require-client-classes", Element::list }, { "reservations", Element::list }, - { "reservation-mode", Element::string }, { "reservations-global", Element::boolean }, { "reservations-in-subnet", Element::boolean }, { "reservations-out-of-pool", Element::boolean }, @@ -362,7 +360,6 @@ const SimpleKeywords SimpleParser6::SHARED_NETWORK6_PARAMETERS = { { "rebind-timer", Element::integer }, { "option-data", Element::list }, { "relay", Element::map }, - { "reservation-mode", Element::string }, { "reservations-global", Element::boolean }, { "reservations-in-subnet", Element::boolean }, { "reservations-out-of-pool", Element::boolean }, diff --git a/src/lib/dhcpsrv/srv_config.cc b/src/lib/dhcpsrv/srv_config.cc index 3979dc467b..0227f64b4b 100644 --- a/src/lib/dhcpsrv/srv_config.cc +++ b/src/lib/dhcpsrv/srv_config.cc @@ -246,22 +246,12 @@ SrvConfig::merge6(SrvConfig& other) { void SrvConfig::mergeGlobals(SrvConfig& other) { auto config_set = getConfiguredGlobals(); - // If the deprecated reservation-mode is found in database, overwrite other - // reservation flags so there is no conflict when merging to new flags. - if (other.getConfiguredGlobal(CfgGlobals::RESERVATION_MODE)) { - config_set->set(CfgGlobals::RESERVATIONS_GLOBAL, ConstElementPtr()); - config_set->set(CfgGlobals::RESERVATIONS_IN_SUBNET, ConstElementPtr()); - config_set->set(CfgGlobals::RESERVATIONS_OUT_OF_POOL, ConstElementPtr()); - } // Iterate over the "other" globals, adding/overwriting them into // this config's list of globals. for (auto const& other_global : other.getConfiguredGlobals()->valuesMap()) { addConfiguredGlobal(other_global.first, other_global.second); } - // Merge the reservation-mode to new reservation flags. - BaseNetworkParser::moveReservationMode(config_set); - // A handful of values are stored as members in SrvConfig. So we'll // iterate over the merged globals, setting appropriate members. for (auto const& merged_global : getConfiguredGlobals()->valuesMap()) { diff --git a/src/lib/dhcpsrv/tests/network_unittest.cc b/src/lib/dhcpsrv/tests/network_unittest.cc index 036513ff2e..341afa57a7 100644 --- a/src/lib/dhcpsrv/tests/network_unittest.cc +++ b/src/lib/dhcpsrv/tests/network_unittest.cc @@ -644,155 +644,6 @@ TEST_F(NetworkTest, getSiaddrNeverFail) { EXPECT_NO_THROW(net4_child->getSiaddr()); } -/// @brief Test fixture class for testing @c moveReservationMode. -class NetworkReservationTest : public ::testing::Test { -public: - - /// @brief Move test error case. - /// - /// Error cases of @ref BaseNetworkParser::moveReservationMode. - /// - /// @param config String with the config to test. - /// @param expected String with the expected error message. - void TestError(const std::string& config, const std::string& expected) { - ElementPtr cfg; - ASSERT_NO_THROW(cfg = Element::fromJSON(config)) - << "bad config, test broken"; - - ElementPtr copy = isc::data::copy(cfg); - - EXPECT_THROW_MSG(BaseNetworkParser::moveReservationMode(cfg), - DhcpConfigError, expected); - - ASSERT_TRUE(copy->equals(*cfg)); - } - - /// @brief Move test case. - /// - /// Test cases of @ref BaseNetworkParser::moveReservationMode. - /// - /// @param config String with the config to test. - /// @param expected String with the config after move. - void TestMove(const std::string& config, const std::string& expected) { - ElementPtr cfg; - ASSERT_NO_THROW(cfg = Element::fromJSON(config)) - << "bad config, test broken"; - - EXPECT_NO_THROW(BaseNetworkParser::moveReservationMode(cfg)); - - EXPECT_EQ(expected, cfg->str()); - } -}; - -/// @brief Test @ref BaseNetworkParser::moveReservationMode error cases. -TEST_F(NetworkReservationTest, errors) { - // Conflicts. - std::string config = "{\n" - "\"reservation-mode\": \"all\",\n" - "\"reservations-global\": true\n" - "}"; - std::string expected = "invalid use of both 'reservation-mode'" - " and one of 'reservations-global', 'reservations-in-subnet'" - " or 'reservations-out-of-pool' parameters"; - TestError(config, expected); - - config = "{\n" - "\"reservation-mode\": \"all\",\n" - "\"reservations-in-subnet\": true\n" - "}"; - TestError(config, expected); - - config = "{\n" - "\"reservation-mode\": \"all\",\n" - "\"reservations-out-of-pool\": false\n" - "}"; - TestError(config, expected); - - // Unknown mode. - config = "{\n" - "\"reservation-mode\": \"foo\"\n" - "}"; - expected = "invalid reservation-mode parameter: 'foo' (:2:21)"; - TestError(config, expected); -} - -/// @brief Test @ref BaseNetworkParser::moveReservationMode. -TEST_F(NetworkReservationTest, move) { - // No-ops. - std::string config = "{\n" - "}"; - std::string expected = "{ " - " }"; - TestMove(config, expected); - - config = "{\n" - "\"reservations-global\": true\n" - "}"; - expected = "{" - " \"reservations-global\": true" - " }"; - TestMove(config, expected); - - // Disabled. - config = "{\n" - "\"reservation-mode\": \"disabled\"\n" - "}"; - expected = "{" - " \"reservations-global\": false," - " \"reservations-in-subnet\": false" - " }"; - TestMove(config, expected); - - config = "{\n" - "\"reservation-mode\": \"off\"\n" - "}"; - TestMove(config, expected); - - // Out-of-pool. - config = "{\n" - "\"reservation-mode\": \"out-of-pool\"\n" - "}"; - expected = "{" - " \"reservations-global\": false," - " \"reservations-in-subnet\": true," - " \"reservations-out-of-pool\": true" - " }"; - TestMove(config, expected); - - // Global. - config = "{\n" - "\"reservation-mode\": \"global\"\n" - "}"; - expected = "{" - " \"reservations-global\": true," - " \"reservations-in-subnet\": false" - " }"; - TestMove(config, expected); - - // All. - config = "{\n" - "\"reservation-mode\": \"all\"\n" - "}"; - expected = "{" - " \"reservations-global\": false," - " \"reservations-in-subnet\": true," - " \"reservations-out-of-pool\": false" - " }"; - TestMove(config, expected); - - config = "{\n" - "\"foobar\": 1234,\n" - "\"reservation-mode\": \"all\"\n" - "}"; - expected = "{" - " \"foobar\": 1234," - " \"reservations-global\": false," - " \"reservations-in-subnet\": true," - " \"reservations-out-of-pool\": false" - " }"; - TestMove(config, expected); -} - // This test verifies that the inheritance is supported for triplets. // Note that triplets have no comparison operator. TEST_F(NetworkTest, inheritanceTriplet) { -- 2.47.2