]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3481] Set runtime option defs in CB
authorMarcin Siodelski <marcin@isc.org>
Mon, 15 Jul 2024 13:08:05 +0000 (15:08 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 16 Jul 2024 14:02:32 +0000 (16:02 +0200)
src/lib/dhcpsrv/cfgmgr.cc
src/lib/dhcpsrv/tests/cfgmgr_unittest.cc

index c457fb7bdecfdfdc596a68e6c32c6deca08fadfd..ef156dd22c7c0b886a7ad01e274a787a37e8f91e 100644 (file)
@@ -197,6 +197,7 @@ CfgMgr::mergeIntoCurrentCfg(const uint32_t seq) {
         // First we need to remove statistics.
         getCurrentCfg()->removeStatistics();
         mergeIntoCfg(getCurrentCfg(), seq);
+        LibDHCP::setRuntimeOptionDefs(getCurrentCfg()->getCfgOptionDef()->getContainer());
 
     } catch (...) {
         // Make sure the statistics is updated even if the merge failed.
index 1be8c6845624e615122ddc7e5d2e7f439f8411ef..13ec6a1147862c54cd9d2882c044abaad3fc4cd4 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <exceptions/exceptions.h>
 #include <dhcp/dhcp6.h>
+#include <dhcp/libdhcp++.h>
 #include <dhcp/testutils/iface_mgr_test_config.h>
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/lease_mgr_factory.h>
@@ -1054,6 +1055,13 @@ TEST_F(CfgMgrTest, mergeIntoCurrentCfg) {
     // Those must be two separate instances.
     ASSERT_FALSE(ext_cfg1 == ext_cfg2);
 
+    // Add an option definition.
+    ext_cfg1->getCfgOptionDef()->add(OptionDefinition::create("option-foo",
+                                                              1,
+                                                              "isc",
+                                                              OPT_EMPTY_TYPE,
+                                                              ""));
+
     // Add a subnet which will be merged from first configuration.
     Subnet4Ptr subnet1(new Subnet4(IOAddress("192.1.2.0"), 24, 1, 2, 3, 123));
     ext_cfg1->getCfgSubnets4()->add(subnet1);
@@ -1073,6 +1081,10 @@ TEST_F(CfgMgrTest, mergeIntoCurrentCfg) {
     ASSERT_TRUE(cfg_mgr.getCurrentCfg()->getCfgSubnets4()->getBySubnetId(123));
     ASSERT_FALSE(cfg_mgr.getCurrentCfg()->getCfgSubnets4()->getBySubnetId(124));
 
+    // Ensure that the runtime option definitions have been updated.
+    auto runtime_def = LibDHCP::getRuntimeOptionDef("isc", "option-foo");
+    ASSERT_TRUE(runtime_def);
+
     // Create another configuration instance to check what sequence it would
     // pick. It should pick the first available one.
     SrvConfigPtr ext_cfg3;