From: Marcin Siodelski Date: Tue, 7 Nov 2017 14:09:42 +0000 (+0100) Subject: [5403] Send prefix with 0 lifetime for old client's leases. X-Git-Tag: trac5452_base~9^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=936e372821acf0786cbb113c44a311be5d1897ab;p=thirdparty%2Fkea.git [5403] Send prefix with 0 lifetime for old client's leases. --- diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index a0aa2cb111..a382f2514f 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -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) {