]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2249] Addressed comments
authorFrancis Dupont <fdupont@isc.org>
Mon, 14 Mar 2022 15:33:42 +0000 (16:33 +0100)
committerRazvan Becheriu <razvan@isc.org>
Mon, 14 Mar 2022 18:22:51 +0000 (20:22 +0200)
doc/examples/kea4/all-keys.json
doc/examples/kea6/all-keys.json
doc/sphinx/arm/classify.rst
src/bin/dhcp4/dhcp4_srv.h
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/tests/classify_unittests.cc
src/bin/dhcp6/tests/fqdn_unittest.cc
src/lib/dhcpsrv/alloc_engine.h
src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc

index 01b38b84648785b86c8aff7defe85042ffbf039b..808358fbd04087c1ec7d00c5457838dffcbe107b 100644 (file)
             "re-detect": true
         },
 
-        // Boolean parameter which controls  whether an early global host
+        // Boolean parameter which controls whether an early global host
         // reservations lookup should be performed. This lookup takes place
         // before subnet selection and when a global reservation is found
         // with some client classes triggers a second phase classification.
index 3c7ce109605fd67deb3aeb2de4244ddc55f57bed..68356bb7b46221e0fdd5de1849ffdd0cd50a5213 100644 (file)
             "re-detect": true
         },
 
-        // Boolean parameter which controls  whether an early global host
+        // Boolean parameter which controls whether an early global host
         // reservations lookup should be performed. This lookup takes place
         // before subnet selection and when a global reservation is found
         // with some client classes triggers a second phase classification.
index ed7357433c2372286cabd14fc2d8a92dfdc07d28..66754247664019a65865a09801bb045d44d85703 100644 (file)
@@ -91,9 +91,9 @@ The classification process is conducted in several steps:
     class. After a subnet is selected, the server determines whether
     there is a reservation for a given client. Therefore, it is not
     possible to use the ``UNKNOWN`` class to select a shared network or
-    a subnet, and for using the ``KNOWN`` class only global reservations
-    can be used and the ``early-global-reservations-lookup`` parameter
-    must be configured to true
+    a subnet. For the ``KNOWN`` class only global reservations only
+    global reservations are used and the ``early-global-reservations-lookup``
+    parameter must be configured to true
 
 10. When the incoming packet belongs to the special class ``DROP``, it is
     dropped and an informational message is logged with the packet
index b8ce076cef1b9e81ab79eddebb0571fa8b58c8e6..f8b16d93fa8579f305d0187f87c0fb10bdd1b474 100644 (file)
@@ -603,7 +603,7 @@ protected:
     /// Returns ACK message, NAK message, or NULL
     ///
     /// @param request a message received from client
-    /// @param context pointer to the client context  where allocated and
+    /// @param context pointer to the client context where allocated and
     /// deleted leases are stored.
     ///
     /// @return ACK or NAK message
index 76c0ba02748201f48bbd01fc5450ef6cdfdf3dba..8918c8142b7fe0490d355102e4372a2e93fb3555 100644 (file)
@@ -453,8 +453,8 @@ Dhcpv6Srv::earlyGHRLookup(const Pkt6Ptr& query,
 
             // Add classes from the global reservations.
             const ClientClasses& classes = global_host->getClientClasses6();
-             for (ClientClasses::const_iterator cclass = classes.cbegin();
-                  cclass != classes.cend(); ++cclass) {
+            for (ClientClasses::const_iterator cclass = classes.cbegin();
+                 cclass != classes.cend(); ++cclass) {
                  query->addClass(*cclass);
              }
 
@@ -550,7 +550,7 @@ Dhcpv6Srv::initContext(const Pkt6Ptr& pkt,
         // time evaluate to false as desired.
         removeDependentEvaluatedClasses(pkt);
         setReservedClientClasses(pkt, ctx);
-        evaluateClasses(pkt,  false);
+        evaluateClasses(pkt, false);
     }
 
     // Set KNOWN builtin class if something was found, UNKNOWN if not.
index 8791a806540ed1442cacf16d038be4681984edcd..ee68acfdea05a42c7ec6aa8902a12cb8b9b21e89 100644 (file)
@@ -2465,7 +2465,7 @@ TEST_F(ClassifyTest, earlyDrop) {
 
     ASSERT_NO_THROW(client2.doSolicit(true));
 
-    // Not matchine so not dropped.
+    // Not matching so not dropped.
     EXPECT_TRUE(client2.getContext().response_);
 }
 
index 1cca731d926b522f6db32273c4199f2038e8b178..683a71cf6275146e06f0d0bfee7d851e9bffadbc 100644 (file)
@@ -455,8 +455,10 @@ public:
 
         AllocEngine::ClientContext6 ctx;
         bool drop = !srv_->earlyGHRLookup(query, ctx);
+        ASSERT_FALSE(drop);
         srv_->initContext(query, ctx, drop);
 
+        ASSERT_FALSE(drop);
         Pkt6Ptr answer = generateMessageWithIds(DHCPV6_ADVERTISE);
 
         ASSERT_NO_THROW(srv_->processClientFqdn(query, answer, ctx));
index ef22751a411926283d92a3b1752ca86be0ab68d7..a2973995ca39c24d02e33399dffb582fe54e6ce5 100644 (file)
@@ -473,10 +473,10 @@ public:
         /// update existing lease.
         bool fake_allocation_;
 
-       /// @brief Indicates if early global reservation is looked for.
-       ///
-       /// This caches the early-global-reservations-lookup value.
-       bool early_global_reservations_lookup_;
+        /// @brief Indicates if early global reservation is looked for.
+        ///
+        /// This caches the early-global-reservations-lookup value.
+        bool early_global_reservations_lookup_;
 
         /// @brief Subnet selected for the client by the server.
         Subnet6Ptr subnet_;
@@ -1004,9 +1004,9 @@ public:
 public:
     /// @brief Determines the preferred and valid v6 lease lifetimes.
     ///
-    /// A candidate triplet for both preferred and valid lifetimes will be 
+    /// A candidate triplet for both preferred and valid lifetimes will be
     /// selected from the first class matched to the query which defines the
-    /// value or from the subnet if none do. Classes are searched in the order 
+    /// value or from the subnet if none do. Classes are searched in the order
     /// they are assigned to the query.
     ///
     /// If the client requested a lifetime IA hint, then the
@@ -1378,10 +1378,10 @@ public:
     /// information to the allocation engine methods is that adding
     /// new information doesn't modify the API of the allocation engine.
     struct ClientContext4 : public boost::noncopyable {
-       /// @brief Indicates if early global reservation is looked for.
-       ///
-       /// This caches the early-global-reservations-lookup value.
-       bool early_global_reservations_lookup_;
+        /// @brief Indicates if early global reservation is looked for.
+        ///
+        /// This caches the early-global-reservations-lookup value.
+        bool early_global_reservations_lookup_;
 
         /// @brief Subnet selected for the client by the server.
         Subnet4Ptr subnet_;
index 36f5b929e5b8b04b7eba55cc4f6eff3c9cab1f92..0b490e87b97fa9e6d1323bdc1b41f744788f1aa8 100644 (file)
@@ -1331,6 +1331,7 @@ TEST_F(SharedNetworkAlloc4Test, discoverSharedNetworkReservations) {
     lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease2));
     ctx.subnet_ = subnet1_;
+    ctx.hosts_.clear();
     AllocEngine::findReservation(ctx);
     lease = engine_.allocateLease4(ctx);
     ASSERT_TRUE(lease);
@@ -1374,6 +1375,7 @@ TEST_F(SharedNetworkAlloc4Test, discoverSharedNetworkReservationsNoColl) {
     lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease2));
     ctx.subnet_ = subnet1_;
+    ctx.hosts_.clear();
     AllocEngine::findReservation(ctx);
     lease = engine_.allocateLease4(ctx);
     ASSERT_TRUE(lease);
@@ -1647,6 +1649,7 @@ TEST_F(SharedNetworkAlloc4Test, requestSharedNetworkReservations) {
     lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease2));
     ctx.subnet_ = subnet1_;
+    ctx.hosts_.clear();
     AllocEngine::findReservation(ctx);
     lease = engine_.allocateLease4(ctx);
     ASSERT_TRUE(lease);
@@ -1693,6 +1696,7 @@ TEST_F(SharedNetworkAlloc4Test, requestSharedNetworkReservationsNoColl) {
     lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease2));
     ctx.subnet_ = subnet1_;
+    ctx.hosts_.clear();
     AllocEngine::findReservation(ctx);
     lease = engine_.allocateLease4(ctx);
     ASSERT_TRUE(lease);
@@ -3066,18 +3070,21 @@ TEST_F(AllocEngine4Test, findReservation) {
     CfgMgr::instance().commit();
 
     // This time the reservation should be returned.
+    ctx.hosts_.clear();
     ASSERT_NO_THROW(engine.findReservation(ctx));
     EXPECT_TRUE(ctx.currentHost());
     EXPECT_EQ(ctx.currentHost()->getIPv4Reservation(), host->getIPv4Reservation());
 
     // It shouldn't be returned when reservations-in-subnet is disabled.
     subnet_->setReservationsInSubnet(false);
+    ctx.hosts_.clear();
     ASSERT_NO_THROW(engine.findReservation(ctx));
     EXPECT_FALSE(ctx.currentHost());
 
     // Check the reservations-in-subnet and reservations-out-of-pool flags.
     subnet_->setReservationsInSubnet(true);
     subnet_->setReservationsOutOfPool(true);
+    ctx.hosts_.clear();
     ASSERT_NO_THROW(engine.findReservation(ctx));
     EXPECT_TRUE(ctx.currentHost());
     EXPECT_EQ(ctx.currentHost()->getIPv4Reservation(), host->getIPv4Reservation());
@@ -3090,6 +3097,7 @@ TEST_F(AllocEngine4Test, findReservation) {
     CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host);
     CfgMgr::instance().commit();
 
+    ctx.hosts_.clear();
     ASSERT_NO_THROW(engine.findReservation(ctx));
     EXPECT_TRUE(ctx.currentHost());
     EXPECT_EQ(ctx.currentHost()->getIPv4Reservation(), host->getIPv4Reservation());
@@ -3097,6 +3105,7 @@ TEST_F(AllocEngine4Test, findReservation) {
     // Remove the subnet. Subnet id is required to find host reservations, so
     // if it is set to NULL, no reservation should be returned
     ctx.subnet_.reset();
+    ctx.hosts_.clear();
     ASSERT_NO_THROW(engine.findReservation(ctx));
     EXPECT_FALSE(ctx.currentHost());
 
@@ -3109,6 +3118,7 @@ TEST_F(AllocEngine4Test, findReservation) {
     CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host);
     CfgMgr::instance().commit();
 
+    ctx.hosts_.clear();
     ASSERT_NO_THROW(engine.findReservation(ctx));
     EXPECT_FALSE(ctx.currentHost());
 }