From f06b3ffde9bbe8429d2997794f1c0ffc68d42c0f Mon Sep 17 00:00:00 2001 From: Razvan Becheriu Date: Mon, 16 Nov 2020 16:00:18 +0200 Subject: [PATCH] [#1405] ignore out of pool if in subnet is disabled --- doc/sphinx/arm/dhcp4-srv.rst | 8 ++--- doc/sphinx/arm/dhcp6-srv.rst | 8 ++--- src/bin/admin/tests/mysql_tests.sh.in | 32 +++++++++---------- src/bin/dhcp4/dhcp4_srv.cc | 3 +- src/bin/dhcp4/json_config_parser.cc | 3 +- src/bin/dhcp4/tests/config_parser_unittest.cc | 6 ++-- src/bin/dhcp4/tests/dora_unittest.cc | 1 - src/bin/dhcp4/tests/host_unittest.cc | 4 --- src/bin/dhcp6/json_config_parser.cc | 3 +- src/bin/dhcp6/tests/config_parser_unittest.cc | 7 ++-- src/bin/dhcp6/tests/host_unittest.cc | 6 +--- .../mysql_cb/tests/mysql_cb_dhcp4_unittest.cc | 2 -- .../mysql_cb/tests/mysql_cb_dhcp6_unittest.cc | 2 -- src/lib/dhcpsrv/alloc_engine.cc | 22 +++++-------- .../dhcpsrv/parsers/base_network_parser.cc | 2 -- src/lib/dhcpsrv/parsers/dhcp_parsers.cc | 6 ++-- src/lib/dhcpsrv/tests/network_unittest.cc | 6 ++-- src/share/api/network4-get.json | 1 - src/share/api/network6-get.json | 1 - .../scripts/mysql/upgrade_9.4_to_9.5.sh.in | 24 +++++--------- 20 files changed, 54 insertions(+), 93 deletions(-) diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index 1fcd8c0fa5..889907c655 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -4662,7 +4662,6 @@ The correspondence of old values are: "reservations-global": false, "reservations-in-subnet": false, - "reservations-out-of-pool": false, ... } @@ -4735,19 +4734,20 @@ configuration, as ``out-of-pool`` are also ``in-subnet``. "Dhcp4": { "reservations-global": true, - // "reservations-in-subnet": false, <-config error + // "reservations-in-subnet": false, "reservations-out-of-pool": true, ... } -For this reason, the ``in-subnet`` can be omitted when ``out-of-pool`` is set. +For this reason, the ``in-subnet`` can not be omitted when ``out-of-pool`` is set. :: "Dhcp4": { "reservations-global": true, + "reservations-in-subnet": true, "reservations-out-of-pool": true, ... } @@ -4765,7 +4765,6 @@ An example configuration that disables reservations looks as follows: "subnet": "192.0.2.0/24", "reservations-global": false, "reservations-in-subnet": false, - "reservations-out-of-pool": false, ... } ] @@ -4780,7 +4779,6 @@ An example configuration using global reservations is shown below: "reservations-global": true, "reservations-in-subnet": false, - "reservations-out-of-pool": false, "reservations": [ { "hw-address": "01:bb:cc:dd:ee:ff", diff --git a/doc/sphinx/arm/dhcp6-srv.rst b/doc/sphinx/arm/dhcp6-srv.rst index 285478912f..30492c2dd4 100644 --- a/doc/sphinx/arm/dhcp6-srv.rst +++ b/doc/sphinx/arm/dhcp6-srv.rst @@ -4107,7 +4107,6 @@ The correspondence of old values are: "reservations-global": false, "reservations-in-subnet": false, - "reservations-out-of-pool": false, ... } @@ -4180,19 +4179,20 @@ configuration, as ``out-of-pool`` are also ``in-subnet``. "Dhcp6": { "reservations-global": true, - // "reservations-in-subnet": false, <-config error + // "reservations-in-subnet": false, "reservations-out-of-pool": true, ... } -For this reason, the ``in-subnet`` can be omitted when ``out-of-pool`` is set. +For this reason, the ``in-subnet`` can not be omitted when ``out-of-pool`` is set. :: "Dhcp6": { "reservations-global": true, + "reservations-in-subnet": true, "reservations-out-of-pool": true, ... } @@ -4210,7 +4210,6 @@ An example configuration that disables reservations looks as follows: "subnet": "2001:db8:1::/64", "reservations-global": false, "reservations-in-subnet": false, - "reservations-out-of-pool": false, ... } ] @@ -4225,7 +4224,6 @@ An example configuration using global reservations is shown below: "reservations-global": true, "reservations-in-subnet": false, - "reservations-out-of-pool": false, "reservations": [ { "duid": "00:03:00:01:11:22:33:44:55:66", diff --git a/src/bin/admin/tests/mysql_tests.sh.in b/src/bin/admin/tests/mysql_tests.sh.in index daa965532a..98ce622c79 100644 --- a/src/bin/admin/tests/mysql_tests.sh.in +++ b/src/bin/admin/tests/mysql_tests.sh.in @@ -1468,64 +1468,64 @@ mysql_reservation_mode_upgrade_test() { # Upgrade to schema 9.5. mysql_upgrade_schema_to_version 9.5 - # Test DISABLED (0) -> false, false, false - qry="select count(id) from dhcp4_shared_network where reservations_global = false and reservations_in_subnet = false and reservations_out_of_pool = false and name = 'test0';" + # Test DISABLED (0) -> false, false, null + qry="select count(id) from dhcp4_shared_network where reservations_global = false and reservations_in_subnet = false and reservations_out_of_pool is null and name = 'test0';" run_statement "#4_shared_disabled" "$qry" 1 # Test OUT_OF_POOL (1) -> false, true, true qry="select count(id) from dhcp4_shared_network where reservations_global = false and reservations_in_subnet = true and reservations_out_of_pool = true and name = 'test1';" run_statement "#4_shared_out_of_pool" "$qry" 1 - # Test GLOBAL (2) -> true, false, false - qry="select count(id) from dhcp4_shared_network where reservations_global = true and reservations_in_subnet = false and reservations_out_of_pool = false and name = 'test2';" + # Test GLOBAL (2) -> true, false, null + qry="select count(id) from dhcp4_shared_network where reservations_global = true and reservations_in_subnet = false and reservations_out_of_pool is null and name = 'test2';" run_statement "#4_shared_global" "$qry" 1 # Test ALL (3) -> false, true, false qry="select count(id) from dhcp4_shared_network where reservations_global = false and reservations_in_subnet = true and reservations_out_of_pool = false and name = 'test3';" run_statement "#4_shared_all" "$qry" 1 - # Test DISABLED (0) -> false, false, false - qry="select count(subnet_id) from dhcp4_subnet where reservations_global = false and reservations_in_subnet = false and reservations_out_of_pool = false and subnet_prefix = '192.0.0.0/24'" + # Test DISABLED (0) -> false, false, null + qry="select count(subnet_id) from dhcp4_subnet where reservations_global = false and reservations_in_subnet = false and reservations_out_of_pool is null and subnet_prefix = '192.0.0.0/24'" run_statement "#4_subnet_disabled" "$qry" 1 # Test OUT_OF_POOL (1) -> false, true, true qry="select count(subnet_id) from dhcp4_subnet where reservations_global = false and reservations_in_subnet = true and reservations_out_of_pool = true and subnet_prefix = '192.0.1.0/24'" run_statement "#4_subnet_out_of_pool" "$qry" 1 - # Test GLOBAL (2) -> true, false, false - qry="select count(subnet_id) from dhcp4_subnet where reservations_global = true and reservations_in_subnet = false and reservations_out_of_pool = false and subnet_prefix = '192.0.2.0/24'" + # Test GLOBAL (2) -> true, false, null + qry="select count(subnet_id) from dhcp4_subnet where reservations_global = true and reservations_in_subnet = false and reservations_out_of_pool is null and subnet_prefix = '192.0.2.0/24'" run_statement "#4_subnet_global" "$qry" 1 # Test ALL (3) -> false, true, false qry="select count(subnet_id) from dhcp4_subnet where reservations_global = false and reservations_in_subnet = true and reservations_out_of_pool = false and subnet_prefix = '192.0.3.0/24'" run_statement "#4_subnet_all" "$qry" 1 - # Test DISABLED (0) -> false, false, false - qry="select count(id) from dhcp6_shared_network where reservations_global = false and reservations_in_subnet = false and reservations_out_of_pool = false and name = 'test0';" + # Test DISABLED (0) -> false, false, null + qry="select count(id) from dhcp6_shared_network where reservations_global = false and reservations_in_subnet = false and reservations_out_of_pool is null and name = 'test0';" run_statement "#6_shared_disabled" "$qry" 1 # Test OUT_OF_POOL (1) -> false, true, true qry="select count(id) from dhcp6_shared_network where reservations_global = false and reservations_in_subnet = true and reservations_out_of_pool = true and name = 'test1';" run_statement "#6_shared_out_of_pool" "$qry" 1 - # Test GLOBAL (2) -> true, false, false - qry="select count(id) from dhcp6_shared_network where reservations_global = true and reservations_in_subnet = false and reservations_out_of_pool = false and name = 'test2';" + # Test GLOBAL (2) -> true, false, null + qry="select count(id) from dhcp6_shared_network where reservations_global = true and reservations_in_subnet = false and reservations_out_of_pool is null and name = 'test2';" run_statement "#6_shared_global" "$qry" 1 # Test ALL (3) -> false, true, false qry="select count(id) from dhcp6_shared_network where reservations_global = false and reservations_in_subnet = true and reservations_out_of_pool = false and name = 'test3';" run_statement "#6_shared_all" "$qry" 1 - # Test DISABLED (0) -> false, false, false - qry="select count(subnet_id) from dhcp6_subnet where reservations_global = false and reservations_in_subnet = false and reservations_out_of_pool = false and subnet_prefix = '2001:db8::/64'" + # Test DISABLED (0) -> false, false, null + qry="select count(subnet_id) from dhcp6_subnet where reservations_global = false and reservations_in_subnet = false and reservations_out_of_pool is null and subnet_prefix = '2001:db8::/64'" run_statement "#6_subnet_disabled" "$qry" 1 # Test OUT_OF_POOL (1) -> false, true, true qry="select count(subnet_id) from dhcp6_subnet where reservations_global = false and reservations_in_subnet = true and reservations_out_of_pool = true and subnet_prefix = '2001:db8:1::/64'" run_statement "#6_subnet_out_of_pool" "$qry" 1 - # Test GLOBAL (2) -> true, false, false - qry="select count(subnet_id) from dhcp6_subnet where reservations_global = true and reservations_in_subnet = false and reservations_out_of_pool = false and subnet_prefix = '2001:db8:2::/64'" + # Test GLOBAL (2) -> true, false, null + qry="select count(subnet_id) from dhcp6_subnet where reservations_global = true and reservations_in_subnet = false and reservations_out_of_pool is null and subnet_prefix = '2001:db8:2::/64'" run_statement "#6_subnet_global" "$qry" 1 # Test ALL (3) -> false, true, false diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 56d64fe477..e1868877d6 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -181,8 +181,7 @@ Dhcpv4Exchange::Dhcpv4Exchange(const AllocEnginePtr& alloc_engine, // Find static reservations if not disabled for our subnet. if (subnet->getReservationsGlobal() || - subnet->getReservationsInSubnet() || - subnet->getReservationsOutOfPool()) { + subnet->getReservationsInSubnet()) { // Before we can check for static reservations, we need to prepare a set // of identifiers to be used for this. setHostIdentifiers(); diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index d46cb63523..1d65cb00f2 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -375,7 +375,8 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set, // Move from reservation mode to new reservations flags. if (BaseNetworkParser::moveReservationMode(mutable_cfg)) { - LOG_WARN(dhcp4_logger, DHCP4_DEPRECATED_RESERVATION_MODE); + // @todo enable warning + // LOG_WARN(dhcp4_logger, DHCP4_DEPRECATED_RESERVATION_MODE); } // Set all default values if not specified by the user. diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc index 79239c5178..f12aa45ae7 100644 --- a/src/bin/dhcp4/tests/config_parser_unittest.cc +++ b/src/bin/dhcp4/tests/config_parser_unittest.cc @@ -5316,15 +5316,13 @@ TEST_F(Dhcp4ParserTest, hostReservationPerSubnet) { " \"pools\": [ { \"pool\": \"192.0.3.0/24\" } ]," " \"subnet\": \"192.0.3.0/24\", " " \"reservations-global\": false," - " \"reservations-in-subnet\": false," - " \"reservations-out-of-pool\": false" + " \"reservations-in-subnet\": false" " }," " {" " \"pools\": [ { \"pool\": \"192.0.4.0/24\" } ]," " \"subnet\": \"192.0.4.0/24\", " " \"reservations-global\": true," - " \"reservations-in-subnet\": false," - " \"reservations-out-of-pool\": false" + " \"reservations-in-subnet\": false" " }," " {" " \"pools\": [ { \"pool\": \"192.0.5.0/24\" } ]," diff --git a/src/bin/dhcp4/tests/dora_unittest.cc b/src/bin/dhcp4/tests/dora_unittest.cc index b380032ed5..3ea2529a98 100644 --- a/src/bin/dhcp4/tests/dora_unittest.cc +++ b/src/bin/dhcp4/tests/dora_unittest.cc @@ -481,7 +481,6 @@ const char* DORA_CONFIGS[] = { " \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ]," " \"reservations-global\": false," " \"reservations-in-subnet\": false," - " \"reservations-out-of-pool\": false," " \"reservations\": [ " " {" " \"hw-address\": \"aa:bb:cc:dd:ee:ff\"," diff --git a/src/bin/dhcp4/tests/host_unittest.cc b/src/bin/dhcp4/tests/host_unittest.cc index 55d8c6e579..6502f68fa2 100644 --- a/src/bin/dhcp4/tests/host_unittest.cc +++ b/src/bin/dhcp4/tests/host_unittest.cc @@ -69,7 +69,6 @@ const char* CONFIGS[] = { " \"subnet\": \"10.0.0.0/24\",\n" " \"reservations-global\": true,\n" " \"reservations-in-subnet\": false,\n" - " \"reservations-out-of-pool\": false,\n" " \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ]\n" "} ]\n" "}\n" @@ -107,7 +106,6 @@ const char* CONFIGS[] = { " \"interface\": \"eth1\",\n" " \"reservations-global\": true,\n" " \"reservations-in-subnet\": false,\n" - " \"reservations-out-of-pool\": false,\n" " \"reservations\": [ \n" " {\n" " \"hw-address\": \"aa:bb:cc:dd:ee:ff\",\n" @@ -194,7 +192,6 @@ const char* CONFIGS[] = { "],\n" "\"reservations-global\": true,\n" "\"reservations-in-subnet\": false,\n" - "\"reservations-out-of-pool\": false,\n" "\"valid-lifetime\": 600,\n" "\"reservations\": [ \n" "{\n" @@ -247,7 +244,6 @@ const char* CONFIGS[] = { "],\n" "\"reservations-global\": true,\n" "\"reservations-in-subnet\": false,\n" - "\"reservations-out-of-pool\": false,\n" "\"valid-lifetime\": 600,\n" "\"reservations\": [ \n" "{\n" diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc index 18f5eda151..50d7718140 100644 --- a/src/bin/dhcp6/json_config_parser.cc +++ b/src/bin/dhcp6/json_config_parser.cc @@ -476,7 +476,8 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set, // Move from reservation mode to new reservations flags. if (BaseNetworkParser::moveReservationMode(mutable_cfg)) { - LOG_WARN(dhcp6_logger, DHCP6_DEPRECATED_RESERVATION_MODE); + // @todo enable warning + // LOG_WARN(dhcp6_logger, DHCP6_DEPRECATED_RESERVATION_MODE); } // Set all default values if not specified by the user. diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc index bfe1fc2ab9..538e5a2be5 100644 --- a/src/bin/dhcp6/tests/config_parser_unittest.cc +++ b/src/bin/dhcp6/tests/config_parser_unittest.cc @@ -5686,15 +5686,13 @@ TEST_F(Dhcp6ParserTest, hostReservationPerSubnet) { " \"pools\": [ { \"pool\": \"2001:db8:3::/64\" } ]," " \"subnet\": \"2001:db8:3::/48\", " " \"reservations-global\": false," - " \"reservations-in-subnet\": false," - " \"reservations-out-of-pool\": false" + " \"reservations-in-subnet\": false" " }," " {" " \"pools\": [ { \"pool\": \"2001:db8:4::/64\" } ]," " \"subnet\": \"2001:db8:4::/48\", " " \"reservations-global\": true," - " \"reservations-in-subnet\": false," - " \"reservations-out-of-pool\": false" + " \"reservations-in-subnet\": false" " }," " {" " \"pools\": [ { \"pool\": \"2001:db8:5::/64\" } ]," @@ -6773,7 +6771,6 @@ TEST_F(Dhcp6ParserTest, sharedNetworksDerive) { " \"rapid-commit\": true,\n" " \"reservations-global\": false,\n" " \"reservations-in-subnet\": false,\n" - " \"reservations-out-of-pool\": false,\n" " \"subnet6\": [\n" " { \n" " \"subnet\": \"2001:db1::/48\",\n" diff --git a/src/bin/dhcp6/tests/host_unittest.cc b/src/bin/dhcp6/tests/host_unittest.cc index 43b5a9b411..c60a05fb83 100644 --- a/src/bin/dhcp6/tests/host_unittest.cc +++ b/src/bin/dhcp6/tests/host_unittest.cc @@ -356,8 +356,7 @@ const char* CONFIGS[] = { " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ], \n" " \"interface\" : \"eth0\", \n" " \"reservations-global\": true, \n" - " \"reservations-in-subnet\": false, \n" - " \"reservations-out-of-pool\": false \n" + " \"reservations-in-subnet\": false \n" " }," " { \n" " \"id\": 2, \n" @@ -402,7 +401,6 @@ const char* CONFIGS[] = { " \"interface\" : \"eth0\", \n" " \"reservations-global\": true, \n" " \"reservations-in-subnet\": false, \n" - " \"reservations-out-of-pool\": false, \n" " \"pd-pools\": [ \n" " { \n" " \"prefix\": \"3000::\", \n" @@ -446,7 +444,6 @@ const char* CONFIGS[] = { "],\n" "\"reservations-global\": true,\n" "\"reservations-in-subnet\": false,\n" - "\"reservations-out-of-pool\": false,\n" "\"valid-lifetime\": 4000,\n" "\"reservations\": [ \n" "{\n" @@ -500,7 +497,6 @@ const char* CONFIGS[] = { "],\n" "\"reservations-global\": true,\n" "\"reservations-in-subnet\": false,\n" - "\"reservations-out-of-pool\": false,\n" "\"valid-lifetime\": 4000,\n" "\"reservations\": [ \n" "{\n" diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc index 4a2feb7cbf..43da6cef8c 100644 --- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc +++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc @@ -163,7 +163,6 @@ public: subnet->requireClientClass("required-class2"); subnet->setReservationsGlobal(false); subnet->setReservationsInSubnet(false); - subnet->setReservationsOutOfPool(false); subnet->setSname("server-hostname"); subnet->setContext(user_context); subnet->setValid(555555); @@ -264,7 +263,6 @@ public: shared_network->requireClientClass("required-class2"); shared_network->setReservationsGlobal(false); shared_network->setReservationsInSubnet(false); - shared_network->setReservationsOutOfPool(false); shared_network->setContext(user_context); shared_network->setValid(5555); shared_network->setCalculateTeeTimes(true); diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc index 4c34d4f4df..1ce871302b 100644 --- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc +++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc @@ -159,7 +159,6 @@ public: subnet->requireClientClass("required-class2"); subnet->setReservationsGlobal(false); subnet->setReservationsInSubnet(false); - subnet->setReservationsOutOfPool(false); subnet->setContext(user_context); subnet->setValid(555555); subnet->setPreferred(4444444); @@ -311,7 +310,6 @@ public: shared_network->requireClientClass("required-class2"); shared_network->setReservationsGlobal(false); shared_network->setReservationsInSubnet(false); - shared_network->setReservationsOutOfPool(false); shared_network->setContext(user_context); shared_network->setValid(5555); shared_network->setPreferred(4444); diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index c769a9dc3a..f869a3d4b9 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -535,8 +535,7 @@ isAllocated(const asiolink::IOAddress& prefix, const uint8_t prefix_len) const { ConstHostPtr AllocEngine::ClientContext6::currentHost() const { Subnet6Ptr subnet = host_subnet_ ? host_subnet_ : subnet_; - if (subnet && (subnet->getReservationsInSubnet() || - subnet->getReservationsOutOfPool())) { + if (subnet && subnet->getReservationsInSubnet()) { auto host = hosts_.find(subnet->getID()); if (host != hosts_.cend()) { return (host->second); @@ -604,8 +603,7 @@ AllocEngine::findReservation(ClientContext6& ctx) { ctx.hosts_[SUBNET_ID_GLOBAL] = ghost; // If we had only to fetch global reservations it is done. - if (!subnet->getReservationsInSubnet() && - !subnet->getReservationsOutOfPool()) { + if (!subnet->getReservationsInSubnet()) { return; } } @@ -644,7 +642,7 @@ AllocEngine::findReservation(ClientContext6& ctx) { // Only makes sense to get reservations if the client has access // to the class and host reservations are enabled for this subnet. if (subnet->clientSupported(ctx.query_->getClasses()) && - (subnet->getReservationsInSubnet() || subnet->getReservationsOutOfPool())) { + subnet->getReservationsInSubnet()) { // Iterate over configured identifiers in the order of preference // and try to use each of them to search for the reservations. for (auto id_pair : ctx.host_identifiers_) { @@ -1483,8 +1481,7 @@ AllocEngine::removeNonmatchingReservedLeases6(ClientContext6& ctx, // If host reservation is disabled (so there are no reserved leases) // use the simplified version. if (!ctx.subnet_->getReservationsGlobal() && - !ctx.subnet_->getReservationsInSubnet() && - !ctx.subnet_->getReservationsOutOfPool()) { + !ctx.subnet_->getReservationsInSubnet()) { removeNonmatchingReservedNoHostLeases6(ctx, existing_leases); return; } @@ -3046,8 +3043,7 @@ hasAddressReservation(AllocEngine::ClientContext4& ctx) { !(host->second->getIPv4Reservation().isV4Zero())); // if we want global + other modes we would need to // return only if true, else continue - if (!subnet->getReservationsInSubnet() && - !subnet->getReservationsOutOfPool()) { + if (!subnet->getReservationsInSubnet()) { return (found); } else { if (found) { @@ -3243,8 +3239,7 @@ AllocEngine::ClientContext4::ClientContext4(const Subnet4Ptr& subnet, ConstHostPtr AllocEngine::ClientContext4::currentHost() const { - if (subnet_ && (subnet_->getReservationsInSubnet() || - subnet_->getReservationsOutOfPool())) { + if (subnet_ && subnet_->getReservationsInSubnet()) { auto host = hosts_.find(subnet_->getID()); if (host != hosts_.cend()) { return (host->second); @@ -3349,8 +3344,7 @@ AllocEngine::findReservation(ClientContext4& ctx) { ctx.hosts_[SUBNET_ID_GLOBAL] = ghost; // If we had only to fetch global reservations it is done. - if (!subnet->getReservationsInSubnet() && - !subnet->getReservationsOutOfPool()) { + if (!subnet->getReservationsInSubnet()) { return; } } @@ -3391,7 +3385,7 @@ AllocEngine::findReservation(ClientContext4& ctx) { // Only makes sense to get reservations if the client has access // to the class. if (subnet->clientSupported(ctx.query_->getClasses()) && - (subnet->getReservationsInSubnet() || subnet->getReservationsOutOfPool())) { + subnet->getReservationsInSubnet()) { // Iterate over configured identifiers in the order of preference // and try to use each of them to search for the reservations. BOOST_FOREACH(const IdentifierPair& id_pair, ctx.host_identifiers_) { diff --git a/src/lib/dhcpsrv/parsers/base_network_parser.cc b/src/lib/dhcpsrv/parsers/base_network_parser.cc index baad63e898..da165eaddb 100644 --- a/src/lib/dhcpsrv/parsers/base_network_parser.cc +++ b/src/lib/dhcpsrv/parsers/base_network_parser.cc @@ -32,7 +32,6 @@ BaseNetworkParser::moveReservationMode(ElementPtr config) { if ((hr_mode == "disabled") || (hr_mode == "off")) { config->set("reservations-global", Element::create(false)); config->set("reservations-in-subnet", Element::create(false)); - config->set("reservations-out-of-pool", 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)); @@ -40,7 +39,6 @@ BaseNetworkParser::moveReservationMode(ElementPtr config) { } else if (hr_mode == "global") { config->set("reservations-global", Element::create(true)); config->set("reservations-in-subnet", Element::create(false)); - config->set("reservations-out-of-pool", Element::create(false)); } else if (hr_mode == "all") { config->set("reservations-global", Element::create(false)); config->set("reservations-in-subnet", Element::create(true)); diff --git a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc index 96976378b2..94467deadf 100644 --- a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc +++ b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc @@ -747,7 +747,8 @@ Subnet4ConfigParser::initSubnet(data::ConstElementPtr params, ElementPtr mutable_params; mutable_params = boost::const_pointer_cast(params); if (BaseNetworkParser::moveReservationMode(mutable_params)) { - LOG_WARN(dhcpsrv_logger, DHCPSRV_DEPRECATED_RESERVATION_MODE); + // @todo enable warning + // LOG_WARN(dhcpsrv_logger, DHCPSRV_DEPRECATED_RESERVATION_MODE); } // Parse parameters common to all Network derivations. @@ -1245,7 +1246,8 @@ Subnet6ConfigParser::initSubnet(data::ConstElementPtr params, ElementPtr mutable_params; mutable_params = boost::const_pointer_cast(params); if (BaseNetworkParser::moveReservationMode(mutable_params)) { - LOG_WARN(dhcpsrv_logger, DHCPSRV_DEPRECATED_RESERVATION_MODE); + // @todo enable warning + // LOG_WARN(dhcpsrv_logger, DHCPSRV_DEPRECATED_RESERVATION_MODE); } // Parse parameters common to all Network derivations. diff --git a/src/lib/dhcpsrv/tests/network_unittest.cc b/src/lib/dhcpsrv/tests/network_unittest.cc index 7a3d89beff..ce8d4cf37e 100644 --- a/src/lib/dhcpsrv/tests/network_unittest.cc +++ b/src/lib/dhcpsrv/tests/network_unittest.cc @@ -685,8 +685,7 @@ TEST_F(NetworkReservationTest, move) { "}"; expected = "{" " \"reservations-global\": false," - " \"reservations-in-subnet\": false," - " \"reservations-out-of-pool\": false" + " \"reservations-in-subnet\": false" " }"; TestMove(config, expected); @@ -712,8 +711,7 @@ TEST_F(NetworkReservationTest, move) { "}"; expected = "{" " \"reservations-global\": true," - " \"reservations-in-subnet\": false," - " \"reservations-out-of-pool\": false" + " \"reservations-in-subnet\": false" " }"; TestMove(config, expected); diff --git a/src/share/api/network4-get.json b/src/share/api/network4-get.json index 97548b941d..670317048e 100644 --- a/src/share/api/network4-get.json +++ b/src/share/api/network4-get.json @@ -33,7 +33,6 @@ " \"ip-address\": \"0.0.0.0\"", " },", " \"renew-timer\": 60,", - " \"reservation-mode\": \"all\",", " \"subnet4\": [", " {", " \"subnet\": \"192.0.2.0/24\",", diff --git a/src/share/api/network6-get.json b/src/share/api/network6-get.json index 87a2045cbe..c24f0b519b 100644 --- a/src/share/api/network6-get.json +++ b/src/share/api/network6-get.json @@ -33,7 +33,6 @@ " \"ip-address\": \"0.0.0.0\"", " },", " \"renew-timer\": 60,", - " \"reservation-mode\": \"all\",", " \"subnet4\": [", " {", " \"subnet\": \"192.0.2.0/24\",", diff --git a/src/share/database/scripts/mysql/upgrade_9.4_to_9.5.sh.in b/src/share/database/scripts/mysql/upgrade_9.4_to_9.5.sh.in index da58d017ca..03c1c5588c 100644 --- a/src/share/database/scripts/mysql/upgrade_9.4_to_9.5.sh.in +++ b/src/share/database/scripts/mysql/upgrade_9.4_to_9.5.sh.in @@ -49,8 +49,7 @@ SET @disable_audit = 1; # 3 is ALL UPDATE dhcp4_subnet SET reservations_global = FALSE, - reservations_in_subnet = FALSE, - reservations_out_of_pool = FALSE + reservations_in_subnet = FALSE WHERE reservation_mode = 0; UPDATE dhcp4_subnet @@ -61,8 +60,7 @@ UPDATE dhcp4_subnet UPDATE dhcp4_subnet SET reservations_global = TRUE, - reservations_in_subnet = FALSE, - reservations_out_of_pool = FALSE + reservations_in_subnet = FALSE WHERE reservation_mode = 2; UPDATE dhcp4_subnet @@ -73,8 +71,7 @@ UPDATE dhcp4_subnet UPDATE dhcp4_shared_network SET reservations_global = FALSE, - reservations_in_subnet = FALSE, - reservations_out_of_pool = FALSE + reservations_in_subnet = FALSE WHERE reservation_mode = 0; UPDATE dhcp4_shared_network @@ -85,8 +82,7 @@ UPDATE dhcp4_shared_network UPDATE dhcp4_shared_network SET reservations_global = TRUE, - reservations_in_subnet = FALSE, - reservations_out_of_pool = FALSE + reservations_in_subnet = FALSE WHERE reservation_mode = 2; UPDATE dhcp4_shared_network @@ -97,8 +93,7 @@ UPDATE dhcp4_shared_network UPDATE dhcp6_subnet SET reservations_global = FALSE, - reservations_in_subnet = FALSE, - reservations_out_of_pool = FALSE + reservations_in_subnet = FALSE WHERE reservation_mode = 0; UPDATE dhcp6_subnet @@ -109,8 +104,7 @@ UPDATE dhcp6_subnet UPDATE dhcp6_subnet SET reservations_global = TRUE, - reservations_in_subnet = FALSE, - reservations_out_of_pool = FALSE + reservations_in_subnet = FALSE WHERE reservation_mode = 2; UPDATE dhcp6_subnet @@ -121,8 +115,7 @@ UPDATE dhcp6_subnet UPDATE dhcp6_shared_network SET reservations_global = FALSE, - reservations_in_subnet = FALSE, - reservations_out_of_pool = FALSE + reservations_in_subnet = FALSE WHERE reservation_mode = 0; UPDATE dhcp6_shared_network @@ -133,8 +126,7 @@ UPDATE dhcp6_shared_network UPDATE dhcp6_shared_network SET reservations_global = TRUE, - reservations_in_subnet = FALSE, - reservations_out_of_pool = FALSE + reservations_in_subnet = FALSE WHERE reservation_mode = 2; UPDATE dhcp6_shared_network