]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3144] addressed review comments
authorRazvan Becheriu <razvan@isc.org>
Thu, 14 May 2026 12:09:57 +0000 (15:09 +0300)
committerRazvan Becheriu <razvan@isc.org>
Mon, 18 May 2026 11:22:02 +0000 (14:22 +0300)
13 files changed:
doc/sphinx/api-files.txt
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/shell/tests/dhcp4_basic_auth_tests.sh.in
src/bin/shell/tests/dhcp6_basic_auth_tests.sh.in
src/bin/shell/tests/shell_dhcp4_process_tests.sh.in
src/bin/shell/tests/shell_dhcp6_process_tests.sh.in
src/bin/shell/tests/tls_dhcp4_process_tests.sh.in
src/bin/shell/tests/tls_dhcp6_process_tests.sh.in
src/lib/dhcp/iface_mgr.cc
src/lib/dhcp/iface_mgr.h
src/lib/dhcp/iface_mgr_bsd.cc
src/lib/dhcp/iface_mgr_linux.cc

index 4841b800591b466d6009deb6f249b96e4183d4d6..4f4c01c4a3ed4153ddcfc39dbe343d83af6d9284 100644 (file)
@@ -43,9 +43,9 @@ src/share/api/ha-reset.json
 src/share/api/ha-scopes.json
 src/share/api/ha-sync.json
 src/share/api/ha-sync-complete-notify.json
+src/share/api/interface-add.json
 src/share/api/interface-list.json
 src/share/api/interface-redetect.json
-src/share/api/interface-add.json
 src/share/api/kea-lfc-start.json
 src/share/api/lease4-add.json
 src/share/api/lease4-del.json
index 4509c978984dfa8d6954afd45bea52ae2dd93dab..f8d28460183050c4d42f1d9b59c173891ce78225 100644 (file)
@@ -737,7 +737,6 @@ ControlledDhcpv4Srv::commandInterfaceAddHandler(const std::string&,
     // stop thread pool (if running)
     MultiThreadingCriticalSection cs;
     string message;
-    bool error = false;
     ConstElementPtr ifaces_config;
     if (!args) {
         message = "Missing mandatory 'arguments' parameter.";
@@ -765,6 +764,7 @@ ControlledDhcpv4Srv::commandInterfaceAddHandler(const std::string&,
     if (!ifaces_config->size()) {
         return (isc::config::createAnswer(CONTROL_RESULT_SUCCESS, "Configuration successful."));
     }
+    bool error = false;
     try {
         ElementPtr mutable_cfg = boost::const_pointer_cast<Element>(args);
         CfgIfacePtr running_cfg_iface = CfgMgr::instance().getCurrentCfg()->getCfgIface();
@@ -1660,15 +1660,15 @@ ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t server_port /*= DHCP4_SERVER_P
     CommandMgr::instance().registerCommand("dhcp-disable",
         std::bind(&ControlledDhcpv4Srv::commandDhcpDisableHandler, this, ph::_1, ph::_2));
 
+    CommandMgr::instance().registerCommand("interface-add",
+        std::bind(&ControlledDhcpv4Srv::commandInterfaceAddHandler, this, ph::_1, ph::_2));
+
     CommandMgr::instance().registerCommand("interface-list",
         std::bind(&ControlledDhcpv4Srv::commandInterfaceListHandler, this, ph::_1, ph::_2));
 
     CommandMgr::instance().registerCommand("interface-redetect",
         std::bind(&ControlledDhcpv4Srv::commandInterfaceRedetectHandler, this, ph::_1, ph::_2));
 
-    CommandMgr::instance().registerCommand("interface-add",
-        std::bind(&ControlledDhcpv4Srv::commandInterfaceAddHandler, this, ph::_1, ph::_2));
-
     CommandMgr::instance().registerCommand("kea-lfc-start",
         std::bind(&ControlledDhcpv4Srv::commandLfcStartHandler, this, ph::_1, ph::_2));
 
@@ -1765,9 +1765,9 @@ ControlledDhcpv4Srv::~ControlledDhcpv4Srv() {
         CommandMgr::instance().deregisterCommand("config-write");
         CommandMgr::instance().deregisterCommand("dhcp-disable");
         CommandMgr::instance().deregisterCommand("dhcp-enable");
+        CommandMgr::instance().deregisterCommand("interface-add");
         CommandMgr::instance().deregisterCommand("interface-list");
         CommandMgr::instance().deregisterCommand("interface-redetect");
-        CommandMgr::instance().deregisterCommand("interface-add");
         CommandMgr::instance().deregisterCommand("kea-lfc-start");
         CommandMgr::instance().deregisterCommand("leases-reclaim");
         CommandMgr::instance().deregisterCommand("subnet4-select-test");
index 73a12ba146a10e13ce6b0a42877343c9eeae7b6e..74af883564f100d7a0fbe14a3ad6fff6d1982356 100644 (file)
@@ -740,7 +740,6 @@ ControlledDhcpv6Srv::commandInterfaceAddHandler(const std::string&,
     // stop thread pool (if running)
     MultiThreadingCriticalSection cs;
     string message;
-    bool error = false;
     ConstElementPtr ifaces_config;
     if (!args) {
         message = "Missing mandatory 'arguments' parameter.";
@@ -768,6 +767,7 @@ ControlledDhcpv6Srv::commandInterfaceAddHandler(const std::string&,
     if (!ifaces_config->size()) {
         return (isc::config::createAnswer(CONTROL_RESULT_SUCCESS, "Configuration successful."));
     }
+    bool error = false;
     try {
         ElementPtr mutable_cfg = boost::const_pointer_cast<Element>(args);
         CfgIfacePtr running_cfg_iface = CfgMgr::instance().getCurrentCfg()->getCfgIface();
@@ -1450,15 +1450,15 @@ ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t server_port /*= DHCP6_SERVER_P
     CommandMgr::instance().registerCommand("dhcp-disable",
         std::bind(&ControlledDhcpv6Srv::commandDhcpDisableHandler, this, ph::_1, ph::_2));
 
+    CommandMgr::instance().registerCommand("interface-add",
+        std::bind(&ControlledDhcpv6Srv::commandInterfaceAddHandler, this, ph::_1, ph::_2));
+
     CommandMgr::instance().registerCommand("interface-list",
         std::bind(&ControlledDhcpv6Srv::commandInterfaceListHandler, this, ph::_1, ph::_2));
 
     CommandMgr::instance().registerCommand("interface-redetect",
         std::bind(&ControlledDhcpv6Srv::commandInterfaceRedetectHandler, this, ph::_1, ph::_2));
 
-    CommandMgr::instance().registerCommand("interface-add",
-        std::bind(&ControlledDhcpv6Srv::commandInterfaceAddHandler, this, ph::_1, ph::_2));
-
     CommandMgr::instance().registerCommand("kea-lfc-start",
         std::bind(&ControlledDhcpv6Srv::commandLfcStartHandler, this, ph::_1, ph::_2));
 
@@ -1552,9 +1552,9 @@ ControlledDhcpv6Srv::~ControlledDhcpv6Srv() {
         CommandMgr::instance().deregisterCommand("config-write");
         CommandMgr::instance().deregisterCommand("dhcp-disable");
         CommandMgr::instance().deregisterCommand("dhcp-enable");
+        CommandMgr::instance().deregisterCommand("interface-add");
         CommandMgr::instance().deregisterCommand("interface-list");
         CommandMgr::instance().deregisterCommand("interface-redetect");
-        CommandMgr::instance().deregisterCommand("interface-add");
         CommandMgr::instance().deregisterCommand("kea-lfc-start");
         CommandMgr::instance().deregisterCommand("leases-reclaim");
         CommandMgr::instance().deregisterCommand("subnet6-select-test");
index 6b56adab54a9b24340313d48f5aee3d9db7e5254..e9f43d4cc2fa393a5bc96b58de3bb80a4ab2eb5e 100755 (executable)
@@ -229,7 +229,7 @@ shell_command_test "shell.bad-auth" \
     "Failed to run: HTTP Error 401: Unauthorized"
 shell_command_test "shell.authorized" \
     "--auth-user pet --auth-password meow" "list-commands" "" \
-    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-list\", \"interface-redetect\", \"interface-add\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-add\", \"interface-list\", \"interface-redetect\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 shell_command_test "shell.bad-auth-password-file" \
     "--auth-user foo --auth-password-file foobar" "list-commands" "fail" \
     "Failed to run: [Errno 2] No such file or directory: 'foobar'"
@@ -238,7 +238,7 @@ shell_command_test "shell.bad-auth-password-file-content" \
     "Failed to run: HTTP Error 401: Unauthorized"
 shell_command_test "shell.good-auth-password-file-content" \
     "--auth-user pet --auth-password-file ${tmpfile_path}/auth_password_file" "list-commands" "" \
-    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-list\", \"interface-redetect\", \"interface-add\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-add\", \"interface-list\", \"interface-redetect\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 shell_command_test "shell.flag-precedence" \
     "--auth-user pet --auth-password meow --auth-password-file ${tmpfile_path}/auth_bad_password_file" "list-commands" "fail" \
     "Failed to run: HTTP Error 401: Unauthorized"
index 7cee3fab14fa33625b5dd958f6826e61c38b2e33..ebcee9fd8504686e6d4563d0d21f9e71f40d13fc 100755 (executable)
@@ -234,7 +234,7 @@ shell_command_test "shell.bad-auth" \
     "Failed to run: HTTP Error 401: Unauthorized"
 shell_command_test "shell.authorized" \
     "--auth-user pet --auth-password meow" "list-commands" "" \
-    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-list\", \"interface-redetect\", \"interface-add\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-add\", \"interface-list\", \"interface-redetect\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 shell_command_test "shell.bad-auth-password-file" \
     "--auth-user foo --auth-password-file foobar" "list-commands" "fail" \
     "Failed to run: [Errno 2] No such file or directory: 'foobar'"
@@ -243,7 +243,7 @@ shell_command_test "shell.bad-auth-password-file-content" \
     "Failed to run: HTTP Error 401: Unauthorized"
 shell_command_test "shell.good-auth-password-file-content" \
     "--auth-user pet --auth-password-file ${tmpfile_path}/auth_password_file" "list-commands" "" \
-    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-list\", \"interface-redetect\", \"interface-add\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-add\", \"interface-list\", \"interface-redetect\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 shell_command_test "shell.flag-precedence" \
     "--auth-user pet --auth-password meow --auth-password-file ${tmpfile_path}/auth_bad_password_file" "list-commands" "fail" \
     "Failed to run: HTTP Error 401: Unauthorized"
index 4b40deeb643957ba15c3c49febd7a0f5aa6fd152..4b07c77b6bcf4e4be1e07dfc23c3f2fe954f6ba4 100755 (executable)
@@ -195,7 +195,7 @@ shell_command_test() {
 }
 
 shell_command_test "shell.list-commands" "list-commands" \
-    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-list\", \"interface-redetect\", \"interface-add\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]" ""
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-add\", \"interface-list\", \"interface-redetect\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]" ""
 shell_command_test "shell.bogus" "give-me-a-beer" \
 "[ { \"result\": 2, \"text\": \"'give-me-a-beer' command not supported.\" } ]" ""
 shell_command_test "shell.empty-config-test" "config-test" \
index 70b9760bdb593f46ae16896597ff44f6e2806647..2e33fb40b42361032e5c012cf987d1574ac16cd0 100755 (executable)
@@ -200,7 +200,7 @@ shell_command_test() {
 }
 
 shell_command_test "shell.list-commands" "list-commands" \
-    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-list\", \"interface-redetect\", \"interface-add\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]" ""
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-add\", \"interface-list\", \"interface-redetect\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]" ""
 shell_command_test "shell.bogus" "give-me-a-beer" \
 "[ { \"result\": 2, \"text\": \"'give-me-a-beer' command not supported.\" } ]" ""
 shell_command_test "shell.empty-config-test" "config-test" \
index f51ae351048991b42500c4e8efdb1045432fc91d..1637620b6ece5459e9484131315e8baf12606412 100755 (executable)
@@ -306,10 +306,10 @@ list_commands_test() {
 }
 
 list_commands_test "NoTLS" "${CONFIG_NONE}" "" \
-"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-list\", \"interface-redetect\", \"interface-add\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-add\", \"interface-list\", \"interface-redetect\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 list_commands_test "Encrypted" "${CONFIG_NOCR}" \
 "--ca ${TEST_CA_DIR}/kea-ca.crt" \
-"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-list\", \"interface-redetect\", \"interface-add\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-add\", \"interface-list\", \"interface-redetect\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 list_commands_test "Authenticated" "${CONFIG}" \
 "--ca ${TEST_CA_DIR}/kea-ca.crt --cert ${TEST_CA_DIR}/kea-client.crt --key ${TEST_CA_DIR}/kea-client.key" \
-"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-list\", \"interface-redetect\", \"interface-add\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-add\", \"interface-list\", \"interface-redetect\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
index 0196bad6c3ecf790a5f2589c9f388cbd172a0061..53fefc8b12db6403a50ab2611973c854c5b5a0e9 100755 (executable)
@@ -321,10 +321,10 @@ list_commands_test() {
 }
 
 list_commands_test "NoTLS" "${CONFIG_NONE}" "" \
-"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-list\", \"interface-redetect\", \"interface-add\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-add\", \"interface-list\", \"interface-redetect\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 list_commands_test "Encrypted" "${CONFIG_NOCR}" \
 "--ca ${TEST_CA_DIR}/kea-ca.crt" \
-"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-list\", \"interface-redetect\", \"interface-add\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-add\", \"interface-list\", \"interface-redetect\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 list_commands_test "Authenticated" "${CONFIG}" \
 "--ca ${TEST_CA_DIR}/kea-ca.crt --cert ${TEST_CA_DIR}/kea-client.crt --key ${TEST_CA_DIR}/kea-client.key" \
-"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-list\", \"interface-redetect\", \"interface-add\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"interface-add\", \"interface-list\", \"interface-redetect\", \"kea-lfc-start\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
index e3932ce523f4922adff9d3293bd9987cf133d08e..5e882f28e828663ec7872f05d7f930538ddd7f0c 100644 (file)
@@ -321,19 +321,21 @@ void IfaceMgr::closeSockets() {
     }
 }
 
-void IfaceMgr::stopDHCPReceiver() {
+void IfaceMgr::stopDHCPReceiver(bool clear_queue) {
     if (isDHCPReceiverRunning()) {
         dhcp_receiver_->stop();
     }
 
     dhcp_receiver_.reset();
 
-    if (getPacketQueue4()) {
-        getPacketQueue4()->clear();
-    }
+    if (clear_queue) {
+        if (getPacketQueue4()) {
+            getPacketQueue4()->clear();
+        }
 
-    if (getPacketQueue6()) {
-        getPacketQueue6()->clear();
+        if (getPacketQueue6()) {
+            getPacketQueue6()->clear();
+        }
     }
 }
 
index bea1f871b88148d77f8a459a0f35f25dc620f654..0b9dfa6dee4f8345d826cfd085fb0aa23f61c8ec 100644 (file)
@@ -1478,8 +1478,11 @@ public:
     /// @brief Stops the DHCP packet receiver.
     ///
     /// If the thread exists, it is stopped, deleted, and
-    /// the packet queue is flushed.
-    void stopDHCPReceiver();
+    /// the packet queue is flushed only if clear_queue is true.
+    ///
+    /// @param clear_queue The flag which indicates that the
+    /// packet queue should be cleared.
+    void stopDHCPReceiver(bool clear_queue = true);
 
     /// @brief Returns true if there is a receiver exists and its
     /// thread is currently running.
index bf4e2f32145c272bd845179b5357edd02b8461be..e0c4eba240a125d2e1cdd72af1c6dd5c10f0e6f9 100644 (file)
@@ -31,6 +31,17 @@ namespace dhcp {
 /// This is a BSD specific interface detection method.
 void
 IfaceMgr::detectIfaces(bool update_only) {
+    IfaceMgr* mgr_p = 0;
+    if (isDHCPReceiverRunning()) {
+        mgr_p = this;
+        stopDHCPReceiver(false);
+    }
+    std::unique_ptr<void, void(*)(void*)> p(static_cast<void*>(mgr_p), [](void* m) {
+        if (m) {
+            IfaceMgr* mgr = reinterpret_cast<IfaceMgr*>(m);
+            mgr->startDHCPReceiver(mgr->getFamily());
+        }
+    });
     if (detect_callback_) {
         if (!detect_callback_(update_only)) {
             return;
index c03bad7250b9852d9f1e6f9f2a192a7c96b995de..af1473898d73c387b80e831fd3d8b733ae38d530 100644 (file)
@@ -413,6 +413,17 @@ namespace dhcp {
 /// Uses the socket-based netlink protocol to retrieve the list of interfaces
 /// from the Linux kernel.
 void IfaceMgr::detectIfaces(bool update_only) {
+    IfaceMgr* mgr_p = 0;
+    if (isDHCPReceiverRunning()) {
+        mgr_p = this;
+        stopDHCPReceiver(false);
+    }
+    std::unique_ptr<void, void(*)(void*)> p(static_cast<void*>(mgr_p), [](void* m) {
+        if (m) {
+            IfaceMgr* mgr = reinterpret_cast<IfaceMgr*>(m);
+            mgr->startDHCPReceiver(mgr->getFamily());
+        }
+    });
     if (detect_callback_) {
         if (!detect_callback_(update_only)) {
             return;