2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[#2799] call setMode only on config-set

This commit is contained in:
Razvan Becheriu
2023-03-21 13:47:29 +02:00
parent 9b86464f43
commit afd47676ee
31 changed files with 180 additions and 151 deletions

View File

@@ -18,6 +18,7 @@
#include <dhcp/libdhcp++.h>
#include <dhcp/option_definition.h>
#include <dhcpsrv/cb_ctl_dhcp4.h>
#include <dhcpsrv/cfg_multi_threading.h>
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/config_backend_dhcp4_mgr.h>
@@ -411,19 +412,25 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) {
parser.parse(*srv_config, multi_threading);
}
bool multi_threading_enabled = true;
uint32_t thread_count = 0;
uint32_t queue_size = 0;
CfgMultiThreading::extract(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading(),
multi_threading_enabled, thread_count, queue_size);
/// depends on "multi-threading" being enabled, so it must come after.
ConstElementPtr queue_control = mutable_cfg->get("dhcp-queue-control");
if (queue_control) {
parameter_name = "dhcp-queue-control";
DHCPQueueControlParser parser;
srv_config->setDHCPQueueControl(parser.parse(queue_control));
srv_config->setDHCPQueueControl(parser.parse(queue_control, multi_threading_enabled));
}
/// depends on "multi-threading" being enabled, so it must come after.
ConstElementPtr reservations_lookup_first = mutable_cfg->get("reservations-lookup-first");
if (reservations_lookup_first) {
parameter_name = "reservations-lookup-first";
if (MultiThreadingMgr::instance().getMode()) {
if (multi_threading_enabled) {
LOG_WARN(dhcp4_logger, DHCP4_RESERVATIONS_LOOKUP_FIRST_ENABLED);
}
srv_config->setReservationsLookupFirst(reservations_lookup_first->boolValue());
@@ -469,7 +476,8 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) {
HooksLibrariesParser hooks_parser;
HooksConfig& libraries = srv_config->getHooksConfig();
hooks_parser.parse(libraries, hooks_libraries);
libraries.verifyLibraries(hooks_libraries->getPosition());
libraries.verifyLibraries(hooks_libraries->getPosition(),
multi_threading_enabled);
}
// D2 client configuration.
@@ -903,7 +911,12 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
static_cast<void>(HooksManager::unloadLibraries());
const HooksConfig& libraries =
CfgMgr::instance().getStagingCfg()->getHooksConfig();
libraries.loadLibraries();
bool multi_threading_enabled = true;
uint32_t thread_count = 0;
uint32_t queue_size = 0;
CfgMultiThreading::extract(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading(),
multi_threading_enabled, thread_count, queue_size);
libraries.loadLibraries(multi_threading_enabled);
} catch (const isc::Exception& ex) {
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(ex.what());
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, ex.what());