Commit c5d28bf7 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[5029] Allocation engine allows for multiple leases w/ the same HW addr.

parent bacfbf15
...@@ -2149,13 +2149,21 @@ void findClientLease(const AllocEngine::ClientContext4& ctx, Lease4Ptr& client_l ...@@ -2149,13 +2149,21 @@ void findClientLease(const AllocEngine::ClientContext4& ctx, Lease4Ptr& client_l
// If no lease found using the client identifier, try the lookup using // If no lease found using the client identifier, try the lookup using
// the HW address. // the HW address.
if (!client_lease && ctx.hwaddr_) { if (!client_lease && ctx.hwaddr_) {
client_lease = lease_mgr.getLease4(*ctx.hwaddr_, ctx.subnet_->getID());
// This lookup may return the lease which has conflicting client // There may be cases when there is a lease for the same MAC address
// identifier and thus is considered to belong to someone else. // (even within the same subnet). Such situation may occur for PXE
// If this is the case, we need to toss the result and force the // boot clients using the same MAC address but different client
// Allocation Engine to allocate another lease. // identifiers.
if (client_lease && !client_lease->belongsToClient(ctx.hwaddr_, ctx.clientid_)) { Lease4Collection client_leases = lease_mgr.getLease4(*ctx.hwaddr_);
client_lease.reset(); for (Lease4Collection::const_iterator client_lease_it = client_leases.begin();
client_lease_it != client_leases.end(); ++client_lease_it) {
Lease4Ptr existing_lease = *client_lease_it;
if ((existing_lease->subnet_id_ == ctx.subnet_->getID()) &&
existing_lease->belongsToClient(ctx.hwaddr_, ctx.clientid_)) {
// Found the lease of this client, so return it.
client_lease = existing_lease;
break;
}
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment