]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5403] Send prefix with 0 lifetime for old client's leases.
authorMarcin Siodelski <marcin@isc.org>
Tue, 7 Nov 2017 14:09:42 +0000 (15:09 +0100)
committerMarcin Siodelski <marcin@isc.org>
Tue, 7 Nov 2017 14:09:42 +0000 (15:09 +0100)
src/bin/dhcp6/dhcp6_srv.cc

index a0aa2cb111b9edc2d12956970cf91cf15d006240..a382f2514f0ad39d760b85a103194dd21cb44154 100644 (file)
@@ -2010,12 +2010,27 @@ Dhcpv6Srv::extendIA_PD(const Pkt6Ptr& query,
                     hints.end());
     }
 
-    /// @todo: Maybe we should iterate over ctx.old_leases_, i.e. the leases
-    /// that used to be valid, but they are not anymore.
+    /// For the leases that we just retired, send the prefixes with 0 lifetimes.
+    for (Lease6Collection::const_iterator l = ctx.currentIA().old_leases_.begin();
+                                          l != ctx.currentIA().old_leases_.end(); ++l) {
+
+        // Send a prefix with zero lifetimes only when this lease belonged to
+        // this client. Do not send it when we're reusing an old lease that belonged
+        // to someone else.
+        if (equalValues(query->getClientId(), (*l)->duid_)) {
+            Option6IAPrefixPtr prefix(new Option6IAPrefix(D6O_IAPREFIX, (*l)->addr_,
+                                                          (*l)->prefixlen_, 0, 0));
+            ia_rsp->addOption(prefix);
+        }
+
+        // Now remove this prefix from the hints list.
+        AllocEngine::ResourceType hint_type((*l)->addr_, (*l)->prefixlen_);
+        hints.erase(std::remove(hints.begin(), hints.end(), hint_type), hints.end());
+    }
 
     // For all the leases the client had requested, but we didn't assign, put them with
     // zero lifetimes
-    // Finally, if there are any addresses requested that we haven't dealt with
+    // Finally, if there are any prefixes requested that we haven't dealt with
     // already, inform the client that he can't have them.
     for (AllocEngine::HintContainer::const_iterator prefix = hints.begin();
          prefix != hints.end(); ++prefix) {