]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3268] Post rebase updates
authorFrancis Dupont <fdupont@isc.org>
Wed, 6 Nov 2024 09:48:47 +0000 (10:48 +0100)
committerFrancis Dupont <fdupont@isc.org>
Wed, 6 Nov 2024 09:48:47 +0000 (10:48 +0100)
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/dhcp4_srv.h
src/bin/dhcp4/tests/config_parser_unittest.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.h
src/bin/dhcp6/tests/config_parser_unittest.cc

index c1520352a09d276068569680078c2e0b25f28182..d63e03243bd8e0c8dd76486195e4d42f91b32e53 100644 (file)
@@ -2907,8 +2907,9 @@ Dhcpv4Srv::createNameChangeRequests(const Lease4Ptr& lease,
 }
 
 bool
-Dhcpv4Srv::assignZero(Subnet4Ptr& subnet, const ClientClasses& client_classes) {
-    Subnet4Ptr current_subnet = subnet;
+Dhcpv4Srv::assignZero(ConstSubnet4Ptr& subnet,
+                      const ClientClasses& client_classes) {
+    ConstSubnet4Ptr current_subnet = subnet;
     // Try subnets.
     while (current_subnet) {
         const ConstCfgOptionPtr& co = current_subnet->getCfgOption();
@@ -2948,7 +2949,7 @@ Dhcpv4Srv::assignLease(Dhcpv4Exchange& ex) {
     AllocEngine::ClientContext4Ptr ctx = ex.getContext();
 
     // Subnet should have been already selected when the context was created.
-    Subnet4Ptr subnet = ctx->subnet_;
+    ConstSubnet4Ptr subnet = ctx->subnet_;
 
     // "Fake" allocation is processing of DISCOVER message. We pretend to do an
     // allocation, but we do not put the lease in the database. That is ok,
index 2ec2c7da6511309060ebfe7cdf4dfe7c8612d213..950a613f814237c08afb9fb31b7f267114de621b 100644 (file)
@@ -743,7 +743,8 @@ protected:
     /// the option is found in another subnet of the shared network.
     /// @param client_classes Client classes.
     /// @return true if an IPv6-Only Preferred option was found, false otherwise.
-    bool assignZero(Subnet4Ptr& subnet, const ClientClasses& client_classes);
+    bool assignZero(ConstSubnet4Ptr& subnet,
+                    const ClientClasses& client_classes);
 
     /// @brief Assigns a lease and appends corresponding options
     ///
index da99452fcfb489f1e9d9d10c8e0078cb5aefdf24..f7f8563556daf62e02db8cb71b62d284e3cf0313 100644 (file)
@@ -2077,8 +2077,8 @@ TEST_F(Dhcp4ParserTest, subnetInterface) {
     // returned value should be 0 (configuration success)
     checkResult(status, 0);
 
-    Subnet4Ptr subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets4()->
-        selectSubnet(IOAddress("192.0.2.200"), classify_);
+    ConstSubnet4Ptr subnet = CfgMgr::instance().getStagingCfg()->
+        getCfgSubnets4()->selectSubnet(IOAddress("192.0.2.200"), classify_);
     ASSERT_TRUE(subnet);
     EXPECT_EQ(valid_iface_, subnet->getIface().get());
 }
@@ -2110,8 +2110,8 @@ TEST_F(Dhcp4ParserTest, subnetInterfaceBogus) {
     checkResult(status, 1);
     EXPECT_TRUE(errorContainsPosition(status, "<string>"));
 
-    Subnet4Ptr subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets4()->
-        selectSubnet(IOAddress("192.0.2.200"), classify_);
+    ConstSubnet4Ptr subnet = CfgMgr::instance().getStagingCfg()->
+        getCfgSubnets4()->selectSubnet(IOAddress("192.0.2.200"), classify_);
     EXPECT_FALSE(subnet);
 }
 
@@ -7760,7 +7760,7 @@ TEST_F(Dhcp4ParserTest, storeExtendedInfoNoGlobal) {
     mutable_subnet1->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
         return (CfgMgr::instance().getStagingCfg()->getConfiguredGlobals());
     });
-    EXPECT_TRUE(subnet->getStoreExtendedInfo());
+    EXPECT_TRUE(subnet1->getStoreExtendedInfo());
 
     // Second subnet should use its own value.
     ConstSubnet4Ptr subnet2 = cfg->selectSubnet(IOAddress("192.0.3.1"));
@@ -7770,7 +7770,7 @@ TEST_F(Dhcp4ParserTest, storeExtendedInfoNoGlobal) {
     mutable_subnet2->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
         return (CfgMgr::instance().getStagingCfg()->getConfiguredGlobals());
     });
-    EXPECT_FALSE(subnet->getStoreExtendedInfo());
+    EXPECT_FALSE(subnet2->getStoreExtendedInfo());
 }
 
 // This test checks that the global store-extended-info parameter is used
@@ -8168,8 +8168,8 @@ TEST_F(Dhcp4ParserTest, deprecatedRequireClientClassesCheck) {
     auto cclasses = net_class_list.begin();
     EXPECT_EQ(*cclasses, "one");
 
-    Subnet4Ptr subnet = CfgMgr::instance().getStagingCfg()->
-                            getCfgSubnets4()->selectSubnet(IOAddress("192.0.2.0"));
+    ConstSubnet4Ptr subnet = CfgMgr::instance().getStagingCfg()->
+        getCfgSubnets4()->selectSubnet(IOAddress("192.0.2.0"));
     ASSERT_TRUE(subnet);
 
     auto& sub_class_list = subnet->getAdditionalClasses();
index fa8722ceaa260300fb851d942ce976908f197fae..346ed3f085db43f277b19e9940b9b97259a294ac 100644 (file)
@@ -2546,7 +2546,7 @@ Dhcpv6Srv::getPDExclude(const AllocEngine::ClientContext6& ctx,
     }
 
     // Search the pool the address is from.
-    const Subnet6Ptr& subnet = ctx.subnet_;
+    const ConstSubnet6Ptr& subnet = ctx.subnet_;
     Pool6Ptr pool = boost::dynamic_pointer_cast<Pool6>(
         subnet->getPool(Lease::TYPE_PD, lease->addr_));
     if (pool) {
index 6d4072a33a027c439394cb5f54b17aa00d0aa179..8d921ea51cd4987730d3575a4e0d2500baf3a798 100644 (file)
@@ -1065,7 +1065,7 @@ protected:
     //
     void checkDynamicSubnetChange(const Pkt6Ptr& question, Pkt6Ptr& answer,
                                   AllocEngine::ClientContext6& ctx,
-                                  const Subnet6Ptr orig_subnet);
+                                  const ConstSubnet6Ptr orig_subnet);
 
     /// @brief Return the PD exclude option to include.
     ///
index a2ecf7692c8294cf823fdd86d8791aaf933f7560..c9b087320ea6503f0cca734c52f461bd37014c23 100644 (file)
@@ -1237,7 +1237,7 @@ TEST_F(Dhcp6ParserTest, unspecifiedRenewTimer) {
     // returned value should be 0 (success)
     checkResult(status, 0);
 
-    Subnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->
+    ConstSubnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->
         getCfgSubnets6()->selectSubnet(IOAddress("2001:db8::1"));
     ASSERT_TRUE(subnet);
 
@@ -1272,7 +1272,7 @@ TEST_F(Dhcp6ParserTest, unspecifiedRebindTimer) {
     // returned value should be 0 (success)
     checkResult(status, 0);
 
-    Subnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->
+    ConstSubnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->
         getCfgSubnets6()->selectSubnet(IOAddress("2001:db8::1"));
     ASSERT_TRUE(subnet);
     EXPECT_FALSE(subnet->getT1().unspecified());
@@ -3844,7 +3844,7 @@ TEST_F(Dhcp6ParserTest, optionDataInSingleSubnet) {
     EXPECT_NO_THROW(x = Dhcpv6SrvTest::configure(srv_, json));
     checkResult(x, 0);
 
-    Subnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->
+    ConstSubnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->
         getCfgSubnets6()->selectSubnet(IOAddress("2001:db8:1::5"), classify_);
     ASSERT_TRUE(subnet);
     OptionContainerPtr options = subnet->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
@@ -4074,8 +4074,8 @@ TEST_F(Dhcp6ParserTest, optionDataSinglePool) {
     EXPECT_NO_THROW(x = Dhcpv6SrvTest::configure(srv_, json));
     checkResult(x, 0);
 
-    Subnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->
-        selectSubnet(IOAddress("2001:db8:1::5"), classify_);
+    ConstSubnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->
+        getCfgSubnets6()->selectSubnet(IOAddress("2001:db8:1::5"), classify_);
     ASSERT_TRUE(subnet);
 
     PoolPtr pool = subnet->getPool(Lease::TYPE_NA, IOAddress("2001:db8:1::10"), false);
@@ -6235,27 +6235,30 @@ TEST_F(Dhcp6ParserTest, hostReservationGlobal) {
     // Let's check if the parsed subnets have correct HR modes.
 
     // Subnet 1
-    ConstSubnet6Ptr subnet;
-    subnet = subnets->selectSubnet(IOAddress("2001:db8:1::1"));
-    ASSERT_TRUE(subnet);
+    ConstSubnet6Ptr subnet1;
+    subnet1 = subnets->selectSubnet(IOAddress("2001:db8:1::1"));
+    ASSERT_TRUE(subnet1);
     // Reset the fetch global function to staging (vs current) config.
-    subnet->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
+    Subnet6Ptr mutable_subnet1 = boost::const_pointer_cast<Subnet6>(subnet1);
+    mutable_subnet1->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
         return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
     });
-    EXPECT_FALSE(subnet->getReservationsGlobal());
-    EXPECT_TRUE(subnet->getReservationsInSubnet());
-    EXPECT_FALSE(subnet->getReservationsOutOfPool());
+    EXPECT_FALSE(subnet1->getReservationsGlobal());
+    EXPECT_TRUE(subnet1->getReservationsInSubnet());
+    EXPECT_FALSE(subnet1->getReservationsOutOfPool());
 
     // Subnet 2
-    subnet = subnets->selectSubnet(IOAddress("2001:db8:2::1"));
-    ASSERT_TRUE(subnet);
+    ConstSubnet6Ptr subnet2;
+    subnet2 = subnets->selectSubnet(IOAddress("2001:db8:2::1"));
+    ASSERT_TRUE(subnet2);
     // Reset the fetch global function to staging (vs current) config.
-    subnet->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
+    Subnet6Ptr mutable_subnet2 = boost::const_pointer_cast<Subnet6>(subnet2);
+    mutable_subnet2->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
         return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
     });
-    EXPECT_FALSE(subnet->getReservationsGlobal());
-    EXPECT_TRUE(subnet->getReservationsInSubnet());
-    EXPECT_TRUE(subnet->getReservationsOutOfPool());
+    EXPECT_FALSE(subnet2->getReservationsGlobal());
+    EXPECT_TRUE(subnet2->getReservationsInSubnet());
+    EXPECT_TRUE(subnet2->getReservationsOutOfPool());
 }
 
 /// Check that the decline-probation-period has a default value when not
@@ -8586,22 +8589,24 @@ TEST_F(Dhcp6ParserTest, storeExtendedInfoNoGlobal) {
 
     // First subnet should use global default.
     CfgSubnets6Ptr cfg = CfgMgr::instance().getStagingCfg()->getCfgSubnets6();
-    Subnet6Ptr subnet = cfg->selectSubnet(IOAddress("2001:db8:1::"));
-    ASSERT_TRUE(subnet);
+    ConstSubnet6Ptr subnet1 = cfg->selectSubnet(IOAddress("2001:db8:1::"));
+    ASSERT_TRUE(subnet1);
     // Reset the fetch global function to staging (vs current) config.
-    subnet->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
+    Subnet6Ptr mutable_subnet1 = boost::const_pointer_cast<Subnet6>(subnet1);
+    mutable_subnet1->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
         return (CfgMgr::instance().getStagingCfg()->getConfiguredGlobals());
     });
-    EXPECT_FALSE(subnet->getStoreExtendedInfo());
+    EXPECT_FALSE(subnet1->getStoreExtendedInfo());
 
     // Second subnet should use its own value.
-    subnet = cfg->selectSubnet(IOAddress("2001:db8:2::"));
-    ASSERT_TRUE(subnet);
+    ConstSubnet6Ptr subnet2 = cfg->selectSubnet(IOAddress("2001:db8:2::"));
+    ASSERT_TRUE(subnet2);
     // Reset the fetch global function to staging (vs current) config.
-    subnet->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
+    Subnet6Ptr mutable_subnet2 = boost::const_pointer_cast<Subnet6>(subnet2);
+    mutable_subnet2->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
         return (CfgMgr::instance().getStagingCfg()->getConfiguredGlobals());
     });
-    EXPECT_TRUE(subnet->getStoreExtendedInfo());
+    EXPECT_TRUE(subnet2->getStoreExtendedInfo());
 }
 
 // This test checks that the global store-extended-info parameter is used
@@ -8657,54 +8662,6 @@ TEST_F(Dhcp6ParserTest, storeExtendedInfoGlobal) {
     EXPECT_TRUE(subnet2->getStoreExtendedInfo());
 }
 
-// Verifies the value of store-extended-info for subnets when there
-// is no global value defined.
-TEST_F(Dhcp6ParserTest, storeExtendedInfoNoGlobal) {
-    const string config = "{ " + genIfaceConfig() + ","
-        "\"preferred-lifetime\": 3000,"
-        "\"rebind-timer\": 2000, "
-        "\"renew-timer\": 1000, "
-        "\"subnet6\": [ "
-        "{ "
-        "    \"id\": 1, "
-        "    \"pools\": [ { \"pool\": \"2001:db8:1::1 - 2001:db8:1::ffff\" } ],"
-        "    \"subnet\": \"2001:db8:1::/64\""
-        "},"
-        "{"
-        "    \"id\": 2, "
-        "    \"pools\": [ { \"pool\": \"2001:db8:2::1 - 2001:db8:2::ffff\" } ],"
-        "    \"subnet\": \"2001:db8:2::/64\","
-        "    \"store-extended-info\": true"
-        "} ],"
-        "\"valid-lifetime\": 4000 }";
-
-    ConstElementPtr json = parseJSON(config);
-    ConstElementPtr status;
-    EXPECT_NO_THROW(status = Dhcpv6SrvTest::configure(srv_, json));
-    checkResult(status, 0);
-
-    // First subnet should use global default.
-    CfgSubnets6Ptr cfg = CfgMgr::instance().getStagingCfg()->getCfgSubnets6();
-    ConstSubnet6Ptr subnet1 = cfg->selectSubnet(IOAddress("2001:db8:1::"));
-    ASSERT_TRUE(subnet1);
-    // Reset the fetch global function to staging (vs current) config.
-    Subnet6Ptr mutable_subnet1 = boost::const_pointer_cast<Subnet6>(subnet1);
-    mutable_subnet1->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
-        return (CfgMgr::instance().getStagingCfg()->getConfiguredGlobals());
-    });
-    EXPECT_FALSE(subnet1->getStoreExtendedInfo());
-
-    // Second subnet should use its own value.
-    ConstSubnet6Ptr subnet2 = cfg->selectSubnet(IOAddress("2001:db8:2::"));
-    ASSERT_TRUE(subnet2);
-    // Reset the fetch global function to staging (vs current) config.
-    Subnet6Ptr mutable_subnet2 = boost::const_pointer_cast<Subnet6>(subnet2);
-    mutable_subnet2->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
-        return (CfgMgr::instance().getStagingCfg()->getConfiguredGlobals());
-    });
-    EXPECT_TRUE(subnet2->getStoreExtendedInfo());
-}
-
 /// This test checks that the statistic-default-sample-count and age
 /// global parameters are committed to the stats manager as expected.
 TEST_F(Dhcp6ParserTest, statsDefaultLimits) {
@@ -9197,8 +9154,8 @@ TEST_F(Dhcp6ParserTest, deprecatedRequireClientClassesCheck) {
     auto cclasses = net_class_list.begin();
     EXPECT_EQ(*cclasses, "one");
 
-    Subnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->
-                            getCfgSubnets6()->selectSubnet(IOAddress("2001:db8::"));
+    ConstSubnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->
+        getCfgSubnets6()->selectSubnet(IOAddress("2001:db8::"));
     ASSERT_TRUE(subnet);
 
     auto& sub_class_list = subnet->getAdditionalClasses();