]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2448] make NEXT_STEP_DROP in dhcpX_srv_configured lead to DHCPX_CONFIG_LOAD_FAIL
authorAndrei Pavel <andrei@isc.org>
Wed, 6 Jul 2022 19:33:37 +0000 (22:33 +0300)
committerAndrei Pavel <andrei@isc.org>
Thu, 7 Jul 2022 11:48:20 +0000 (11:48 +0000)
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/dhcp4_hooks.dox
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6_hooks.dox

index 196b03a80940d609dfba1101fe08fbc980f016c3..431c13026fe3e24cf91f1fa7f84bc442eeaa7d62 100644 (file)
@@ -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.
index b88f76b986b25d4197397b0bc2cb1b093b0d348a..47a490b347485bbf95562a2447031e2eb992535e 100644 (file)
@@ -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.
 
- - <b>Next step status</b>: Status codes returned by the callouts installed on
-   this hook point are ignored.
+ - <b>Next step status</b>: 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:
index 40d27c971be0a7141fdae2e1b406f4f8974a52a2..316937ebad4ff8b55fcf63a4a23c1e380f5b200b 100644 (file)
@@ -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.
index a7afd1ae7e80d96784613c1a7d5c7a1fc75a09a9..4c5af6ff8bc410ef7cab88b91199b4350d56d88d 100644 (file)
@@ -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.
 
- - <b>Next step status</b>: Status codes returned by the callouts installed on
-   this hook point are ignored.
+
+ - <b>Next step status</b>: 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: