mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 13:37:55 +00:00
[5458] Removed deleted_leases from ClientContext6.
Also, declined lease is treated as new lease when calling leases6_committed hook.
This commit is contained in:
@@ -785,25 +785,7 @@ Dhcpv6Srv::processPacket(Pkt6Ptr& query, Pkt6Ptr& rsp) {
|
||||
callout_handle->setArgument("leases6", new_leases);
|
||||
|
||||
Lease6CollectionPtr deleted_leases(new Lease6Collection());
|
||||
// Do global list first
|
||||
for (auto old_lease : ctx.deleted_leases_) {
|
||||
if (ctx.new_leases_.empty()) {
|
||||
deleted_leases->push_back(old_lease);
|
||||
continue;
|
||||
}
|
||||
bool in_new = false;
|
||||
for (auto const new_lease : ctx.new_leases_) {
|
||||
if ((new_lease->addr_ == old_lease->addr_) &&
|
||||
(new_lease->prefixlen_ == old_lease->prefixlen_)) {
|
||||
in_new = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (in_new) {
|
||||
continue;
|
||||
}
|
||||
deleted_leases->push_back(old_lease);
|
||||
}
|
||||
|
||||
// Do per IA lists
|
||||
for (auto const iac : ctx.ias_) {
|
||||
if (!iac.old_leases_.empty()) {
|
||||
@@ -820,10 +802,9 @@ Dhcpv6Srv::processPacket(Pkt6Ptr& query, Pkt6Ptr& rsp) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (in_new) {
|
||||
continue;
|
||||
if (!in_new) {
|
||||
deleted_leases->push_back(old_lease);
|
||||
}
|
||||
deleted_leases->push_back(old_lease);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2343,7 +2324,7 @@ Dhcpv6Srv::releaseLeases(const Pkt6Ptr& release, Pkt6Ptr& reply,
|
||||
|
||||
// Store the old lease.
|
||||
if (old_lease) {
|
||||
ctx.deleted_leases_.push_back(old_lease);
|
||||
ctx.currentIA().old_leases_.push_back(old_lease);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2981,7 +2962,7 @@ Dhcpv6Srv::declineLeases(const Pkt6Ptr& decline, Pkt6Ptr& reply,
|
||||
case D6O_IA_NA: {
|
||||
OptionPtr answer_opt = declineIA(decline, ctx.duid_, general_status,
|
||||
boost::dynamic_pointer_cast<Option6IA>(opt->second),
|
||||
ctx.deleted_leases_);
|
||||
ctx.new_leases_);
|
||||
if (answer_opt) {
|
||||
|
||||
// We have an answer, let's use it.
|
||||
@@ -3007,7 +2988,7 @@ Dhcpv6Srv::declineLeases(const Pkt6Ptr& decline, Pkt6Ptr& reply,
|
||||
OptionPtr
|
||||
Dhcpv6Srv::declineIA(const Pkt6Ptr& decline, const DuidPtr& duid,
|
||||
int& general_status, boost::shared_ptr<Option6IA> ia,
|
||||
Lease6Collection& old_leases) {
|
||||
Lease6Collection& new_leases) {
|
||||
|
||||
LOG_DEBUG(lease6_logger, DBG_DHCP6_DETAIL, DHCP6_DECLINE_PROCESS_IA)
|
||||
.arg(decline->getLabel())
|
||||
@@ -3113,8 +3094,9 @@ Dhcpv6Srv::declineIA(const Pkt6Ptr& decline, const DuidPtr& duid,
|
||||
// declineLease returns false only when hook callouts set the next
|
||||
// step status to drop. We just propagate the bad news here.
|
||||
return (OptionPtr());
|
||||
|
||||
} else {
|
||||
old_leases.push_back(lease);
|
||||
new_leases.push_back(lease);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -759,11 +759,11 @@ protected:
|
||||
/// @param duid client's duid (used to verify if the client owns the lease)
|
||||
/// @param general_status [out] status in top-level message (may be updated)
|
||||
/// @param ia specific IA_NA option to process.
|
||||
/// @param old_leases a collection of leases being declined.
|
||||
/// @param new_leases a collection of leases being declined.
|
||||
/// @return IA_NA option with response (to be included in Reply message)
|
||||
OptionPtr
|
||||
declineIA(const Pkt6Ptr& decline, const DuidPtr& duid, int& general_status,
|
||||
boost::shared_ptr<Option6IA> ia, Lease6Collection& old_leases);
|
||||
boost::shared_ptr<Option6IA> ia, Lease6Collection& new_leases);
|
||||
|
||||
/// @brief Declines specific IPv6 lease.
|
||||
///
|
||||
|
@@ -3486,14 +3486,14 @@ TEST_F(HooksDhcpv6SrvTest, leases6CommittedDecline) {
|
||||
sort(expected_argument_names.begin(), expected_argument_names.end());
|
||||
EXPECT_TRUE(callback_argument_names_ == expected_argument_names);
|
||||
|
||||
// No new allocations.
|
||||
ASSERT_TRUE(callback_new_leases6_);
|
||||
ASSERT_TRUE(callback_new_leases6_->empty());
|
||||
// No deleted leases.
|
||||
ASSERT_TRUE(callback_deleted_leases6_);
|
||||
ASSERT_TRUE(callback_deleted_leases6_->empty());
|
||||
|
||||
// Declined lease should be returned.
|
||||
ASSERT_TRUE(callback_deleted_leases6_);
|
||||
EXPECT_EQ(1, callback_deleted_leases6_->size());
|
||||
Lease6Ptr lease = callback_deleted_leases6_->at(0);
|
||||
ASSERT_TRUE(callback_new_leases6_);
|
||||
EXPECT_EQ(1, callback_new_leases6_->size());
|
||||
Lease6Ptr lease = callback_new_leases6_->at(0);
|
||||
ASSERT_TRUE(lease);
|
||||
EXPECT_EQ("2001:db8:1::28", lease->addr_.toText());
|
||||
|
||||
|
@@ -444,7 +444,7 @@ AllocEngine::ClientContext6::ClientContext6(const Subnet6Ptr& subnet,
|
||||
duid_(duid), hwaddr_(), host_identifiers_(), hosts_(),
|
||||
fwd_dns_update_(fwd_dns), rev_dns_update_(rev_dns), hostname_(hostname),
|
||||
callout_handle_(callout_handle), allocated_resources_(), new_leases_(),
|
||||
deleted_leases_(), ias_() {
|
||||
ias_() {
|
||||
|
||||
// Initialize host identifiers.
|
||||
if (duid) {
|
||||
|
@@ -380,9 +380,6 @@ public:
|
||||
/// @brief A collection of newly allocated leases.
|
||||
Lease6Collection new_leases_;
|
||||
|
||||
/// @brief A collection of old leases that the client had before.
|
||||
Lease6Collection deleted_leases_;
|
||||
|
||||
//@}
|
||||
|
||||
/// @brief Parameters pertaining to individual IAs.
|
||||
|
Reference in New Issue
Block a user