From: Andrei Pavel Date: Wed, 6 Jul 2022 19:33:37 +0000 (+0300) Subject: [#2448] make NEXT_STEP_DROP in dhcpX_srv_configured lead to DHCPX_CONFIG_LOAD_FAIL X-Git-Tag: Kea-2.2.0~74 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7879c8d56edf9ca3b0428bbb1cb84c5d5749d481;p=thirdparty%2Fkea.git [#2448] make NEXT_STEP_DROP in dhcpX_srv_configured lead to DHCPX_CONFIG_LOAD_FAIL --- diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 196b03a809..431c13026f 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -914,7 +914,6 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) { try { Dhcp4to6Ipc::instance().open(); } catch (const std::exception& ex) { - std::ostringstream err; err << "error starting DHCPv4-over-DHCPv6 IPC " " after server reconfiguration: " << ex.what(); return (isc::config::createAnswer(1, err.str())); @@ -1013,8 +1012,16 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) { HooksManager::callCallouts(Hooks.hooks_index_dhcp4_srv_configured_, *callout_handle); - // Ignore status code as none of them would have an effect on further - // operation. + // If next step is DROP, report a configuration error. + if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) { + string error; + try { + callout_handle->getArgument("error", error); + } catch (NoSuchArgument const& ex) { + error = "unknown error"; + } + return (isc::config::createAnswer(CONTROL_RESULT_ERROR, error)); + } } // Apply multi threading settings. diff --git a/src/bin/dhcp4/dhcp4_hooks.dox b/src/bin/dhcp4/dhcp4_hooks.dox index b88f76b986..47a490b347 100644 --- a/src/bin/dhcp4/dhcp4_hooks.dox +++ b/src/bin/dhcp4/dhcp4_hooks.dox @@ -63,8 +63,11 @@ to the end of this list. provides access to the DHCP service state of the server and allows for enabling and disabling the DHCP service from the hooks libraries. - - Next step status: Status codes returned by the callouts installed on - this hook point are ignored. + - Next step status: If any callout sets the status to DROP, the server + will interrupt the reconfiguration process. The hook callout is expected to + have completed the cause of the interruption under the "error" handle argument + with a std::string which is then logged. Finally, this leads to the + termination of kea-dhcp4. @subsection dhcpv4HooksCb4Update cb4_updated - @b Arguments: diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index 40d27c971b..316937ebad 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -919,7 +919,6 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) { } } catch (const std::exception& ex) { - std::ostringstream err; err << "unable to configure server identifier: " << ex.what(); return (isc::config::createAnswer(1, err.str())); } @@ -937,7 +936,6 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) { try { Dhcp6to4Ipc::instance().open(); } catch (const std::exception& ex) { - std::ostringstream err; err << "error starting DHCPv4-over-DHCPv6 IPC " " after server reconfiguration: " << ex.what(); return (isc::config::createAnswer(1, err.str())); @@ -1035,8 +1033,16 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) { HooksManager::callCallouts(Hooks.hooks_index_dhcp6_srv_configured_, *callout_handle); - // Ignore status code as none of them would have an effect on further - // operation. + // If next step is DROP, report a configuration error. + if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) { + string error; + try { + callout_handle->getArgument("error", error); + } catch (NoSuchArgument const& ex) { + error = "unknown error"; + } + return (isc::config::createAnswer(CONTROL_RESULT_ERROR, error)); + } } // Apply multi threading settings. diff --git a/src/bin/dhcp6/dhcp6_hooks.dox b/src/bin/dhcp6/dhcp6_hooks.dox index a7afd1ae7e..4c5af6ff8b 100644 --- a/src/bin/dhcp6/dhcp6_hooks.dox +++ b/src/bin/dhcp6/dhcp6_hooks.dox @@ -63,8 +63,12 @@ to the end of this list. provides access to the DHCP service state of the server and allows for enabling and disabling the DHCP service from the hooks libraries. - - Next step status: Status codes returned by the callouts installed on - this hook point are ignored. + + - Next step status: If any callout sets the status to DROP, the server + will interrupt the reconfiguration process. The hook callout is expected to + have completed the cause of the interruption under the "error" handle argument + with a std::string which is then logged. Finally, this leads to the + termination of kea-dhcp6. @subsection dhcpv6HooksCb6Update cb6_updated - @b Arguments: