]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1124] Reversed order for v6 also
authorThomas Markwalder <tmark@isc.org>
Tue, 3 Mar 2020 16:04:00 +0000 (11:04 -0500)
committerThomas Markwalder <tmark@isc.org>
Wed, 4 Mar 2020 19:54:50 +0000 (14:54 -0500)
modified:
    alloc_engine.cc

src/lib/dhcpsrv/alloc_engine.cc

index fe806faae11444cd4d7e4e1d837cfa04b57797af..352fe8fc41743447f32822bbd78cae7ee64be385 100644 (file)
@@ -1031,17 +1031,6 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) {
                                                          ctx.query_->getClasses(),
                                                          ctx.duid_,
                                                          hint);
-
-            /// In-pool reservations: Check if this address is reserved for someone
-            /// else. There is no need to check for whom it is reserved, because if
-            /// it has been reserved for us we would have already allocated a lease.
-            if (hr_mode == Network::HR_ALL &&
-                HostMgr::instance().get6(subnet->getID(), candidate)) {
-
-                // Don't allocate.
-                continue;
-            }
-
             // The first step is to find out prefix length. It is 128 for
             // non-PD leases.
             uint8_t prefix_len = 128;
@@ -1055,9 +1044,21 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) {
                 }
             }
 
+            // Look for an existing lease for the candidate.
             Lease6Ptr existing = LeaseMgrFactory::instance().getLease6(ctx.currentIA().type_,
                                                                        candidate);
+
             if (!existing) {
+                /// In-pool reservations: Check if this address is reserved for someone
+                /// else. There is no need to check for whom it is reserved, because if
+                /// it has been reserved for us we would have already allocated a lease.
+                if (hr_mode == Network::HR_ALL &&
+                    HostMgr::instance().get6(subnet->getID(), candidate)) {
+
+                    // Don't allocate.
+                    continue;
+                }
+
 
                 // there's no existing lease for selected candidate, so it is
                 // free. Let's allocate it.
@@ -1083,6 +1084,13 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) {
                 // allocation attempts.
             } else {
                 if (existing->expired()) {
+                    // Make sure it's not reserved.
+                    if (hr_mode == Network::HR_ALL &&
+                        HostMgr::instance().get6(subnet->getID(), candidate)) {
+                        // Don't allocate.
+                        continue;
+                    }
+
                     // Copy an existing, expired lease so as it can be returned
                     // to the caller.
                     Lease6Ptr old_lease(new Lease6(*existing));