mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 13:37:55 +00:00
[#1405] checking out of pool reservations should be done only if in subnet is true
This commit is contained in:
parent
8665346286
commit
2cc17075ff
@ -621,7 +621,7 @@ AllocEngine::findReservation(ClientContext6& ctx) {
|
|||||||
(network->getAllSubnets()->size() > ctx.host_identifiers_.size());
|
(network->getAllSubnets()->size() > ctx.host_identifiers_.size());
|
||||||
|
|
||||||
if (use_single_query) {
|
if (use_single_query) {
|
||||||
for (auto id_pair : ctx.host_identifiers_) {
|
for (const auto id_pair : ctx.host_identifiers_) {
|
||||||
ConstHostCollection hosts = HostMgr::instance().getAll(id_pair.first,
|
ConstHostCollection hosts = HostMgr::instance().getAll(id_pair.first,
|
||||||
&id_pair.second[0],
|
&id_pair.second[0],
|
||||||
id_pair.second.size());
|
id_pair.second.size());
|
||||||
@ -645,7 +645,7 @@ AllocEngine::findReservation(ClientContext6& ctx) {
|
|||||||
subnet->getReservationsInSubnet()) {
|
subnet->getReservationsInSubnet()) {
|
||||||
// Iterate over configured identifiers in the order of preference
|
// Iterate over configured identifiers in the order of preference
|
||||||
// and try to use each of them to search for the reservations.
|
// and try to use each of them to search for the reservations.
|
||||||
for (auto id_pair : ctx.host_identifiers_) {
|
for (const auto id_pair : ctx.host_identifiers_) {
|
||||||
if (use_single_query) {
|
if (use_single_query) {
|
||||||
if (host_map.count(subnet->getID()) > 0) {
|
if (host_map.count(subnet->getID()) > 0) {
|
||||||
ctx.hosts_[subnet->getID()] = host_map[subnet->getID()];
|
ctx.hosts_[subnet->getID()] = host_map[subnet->getID()];
|
||||||
@ -931,8 +931,8 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) {
|
|||||||
// The out-of-pool flag indicates that no client should be assigned reservations
|
// The out-of-pool flag indicates that no client should be assigned reservations
|
||||||
// from within the dynamic pool, and for that reason we only look at reservations that
|
// from within the dynamic pool, and for that reason we only look at reservations that
|
||||||
// are outside the pools, hence the inPool check.
|
// are outside the pools, hence the inPool check.
|
||||||
if ((in_subnet && !out_of_pool) ||
|
if (in_subnet && (!out_of_pool ||
|
||||||
(out_of_pool && (!ctx.subnet_->inPool(ctx.currentIA().type_, hint)))) {
|
!ctx.subnet_->inPool(ctx.currentIA().type_, hint))) {
|
||||||
hosts = getIPv6Resrv(subnet->getID(), hint);
|
hosts = getIPv6Resrv(subnet->getID(), hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -969,8 +969,8 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) {
|
|||||||
// The out-of-pool flag indicates that no client should be assigned reservations
|
// The out-of-pool flag indicates that no client should be assigned reservations
|
||||||
// from within the dynamic pool, and for that reason we only look at reservations that
|
// from within the dynamic pool, and for that reason we only look at reservations that
|
||||||
// are outside the pools, hence the inPool check.
|
// are outside the pools, hence the inPool check.
|
||||||
if ((in_subnet && !out_of_pool) ||
|
if (in_subnet && (!out_of_pool ||
|
||||||
(out_of_pool && (!ctx.subnet_->inPool(ctx.currentIA().type_, hint)))) {
|
!ctx.subnet_->inPool(ctx.currentIA().type_, hint))) {
|
||||||
hosts = getIPv6Resrv(subnet->getID(), hint);
|
hosts = getIPv6Resrv(subnet->getID(), hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1277,8 +1277,8 @@ AllocEngine::allocateReservedLeases6(ClientContext6& ctx,
|
|||||||
// The out-of-pool flag indicates that no client should be assigned reservations
|
// The out-of-pool flag indicates that no client should be assigned reservations
|
||||||
// from within the dynamic pool, and for that reason we only look at reservations that
|
// from within the dynamic pool, and for that reason we only look at reservations that
|
||||||
// are outside the pools, hence the inPool check.
|
// are outside the pools, hence the inPool check.
|
||||||
if ((in_subnet && !out_of_pool) ||
|
if (in_subnet && (!out_of_pool ||
|
||||||
(out_of_pool && (!subnet->inPool(ctx.currentIA().type_, addr)))) {
|
!subnet->inPool(ctx.currentIA().type_, addr))) {
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1480,8 +1480,8 @@ AllocEngine::removeNonmatchingReservedLeases6(ClientContext6& ctx,
|
|||||||
}
|
}
|
||||||
// If host reservation is disabled (so there are no reserved leases)
|
// If host reservation is disabled (so there are no reserved leases)
|
||||||
// use the simplified version.
|
// use the simplified version.
|
||||||
if (!ctx.subnet_->getReservationsGlobal() &&
|
if (!ctx.subnet_->getReservationsInSubnet() &&
|
||||||
!ctx.subnet_->getReservationsInSubnet()) {
|
!ctx.subnet_->getReservationsGlobal()) {
|
||||||
removeNonmatchingReservedNoHostLeases6(ctx, existing_leases);
|
removeNonmatchingReservedNoHostLeases6(ctx, existing_leases);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2974,8 +2974,8 @@ addressReserved(const IOAddress& address, const AllocEngine::ClientContext4& ctx
|
|||||||
// The out-of-pool flag indicates that no client should be assigned reservations
|
// The out-of-pool flag indicates that no client should be assigned reservations
|
||||||
// from within the dynamic pool, and for that reason we only look at reservations that
|
// from within the dynamic pool, and for that reason we only look at reservations that
|
||||||
// are outside the pools, hence the inPool check.
|
// are outside the pools, hence the inPool check.
|
||||||
if ((in_subnet && !out_of_pool) ||
|
if (in_subnet && (!out_of_pool ||
|
||||||
(out_of_pool && (!ctx.subnet_->inPool(Lease::TYPE_V4, address)))) {
|
!ctx.subnet_->inPool(Lease::TYPE_V4, address))) {
|
||||||
// The global parameter ip-reservations-unique controls whether it is allowed
|
// The global parameter ip-reservations-unique controls whether it is allowed
|
||||||
// to specify multiple reservations for the same IP address or delegated prefix
|
// to specify multiple reservations for the same IP address or delegated prefix
|
||||||
// or IP reservations must be unique. Some host backends do not support the
|
// or IP reservations must be unique. Some host backends do not support the
|
||||||
@ -2997,7 +2997,7 @@ addressReserved(const IOAddress& address, const AllocEngine::ClientContext4& ctx
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto host : hosts) {
|
for (auto host : hosts) {
|
||||||
for (auto id : ctx.host_identifiers_) {
|
for (const auto id : ctx.host_identifiers_) {
|
||||||
// If we find the matching host we know that this address is reserved
|
// If we find the matching host we know that this address is reserved
|
||||||
// for us and we can return immediately.
|
// for us and we can return immediately.
|
||||||
if (id.first == host->getIdentifierType() &&
|
if (id.first == host->getIdentifierType() &&
|
||||||
@ -3061,8 +3061,8 @@ hasAddressReservation(AllocEngine::ClientContext4& ctx) {
|
|||||||
if (host != ctx.hosts_.end()) {
|
if (host != ctx.hosts_.end()) {
|
||||||
auto reservation = host->second->getIPv4Reservation();
|
auto reservation = host->second->getIPv4Reservation();
|
||||||
if (!reservation.isV4Zero() &&
|
if (!reservation.isV4Zero() &&
|
||||||
((in_subnet && !out_of_pool) ||
|
in_subnet && (!out_of_pool ||
|
||||||
(out_of_pool && !subnet->inPool(Lease::TYPE_V4, reservation)))) {
|
!subnet->inPool(Lease::TYPE_V4, reservation))) {
|
||||||
ctx.subnet_ = subnet;
|
ctx.subnet_ = subnet;
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
@ -3362,12 +3362,10 @@ AllocEngine::findReservation(ClientContext4& ctx) {
|
|||||||
(network->getAllSubnets()->size() > ctx.host_identifiers_.size());
|
(network->getAllSubnets()->size() > ctx.host_identifiers_.size());
|
||||||
|
|
||||||
if (use_single_query) {
|
if (use_single_query) {
|
||||||
for (auto id_pair = ctx.host_identifiers_.begin();
|
for (const auto id_pair : ctx.host_identifiers_) {
|
||||||
id_pair != ctx.host_identifiers_.end();
|
ConstHostCollection hosts = HostMgr::instance().getAll(id_pair.first,
|
||||||
++id_pair) {
|
&id_pair.second[0],
|
||||||
ConstHostCollection hosts = HostMgr::instance().getAll(id_pair->first,
|
id_pair.second.size());
|
||||||
&id_pair->second[0],
|
|
||||||
id_pair->second.size());
|
|
||||||
// Store the hosts in the temporary map, because some hosts may
|
// Store the hosts in the temporary map, because some hosts may
|
||||||
// belong to subnets outside of the shared network. We'll need
|
// belong to subnets outside of the shared network. We'll need
|
||||||
// to eliminate them.
|
// to eliminate them.
|
||||||
@ -3388,7 +3386,7 @@ AllocEngine::findReservation(ClientContext4& ctx) {
|
|||||||
subnet->getReservationsInSubnet()) {
|
subnet->getReservationsInSubnet()) {
|
||||||
// Iterate over configured identifiers in the order of preference
|
// Iterate over configured identifiers in the order of preference
|
||||||
// and try to use each of them to search for the reservations.
|
// and try to use each of them to search for the reservations.
|
||||||
BOOST_FOREACH(const IdentifierPair& id_pair, ctx.host_identifiers_) {
|
for (const IdentifierPair& id_pair : ctx.host_identifiers_) {
|
||||||
if (use_single_query) {
|
if (use_single_query) {
|
||||||
if (host_map.count(subnet->getID()) > 0) {
|
if (host_map.count(subnet->getID()) > 0) {
|
||||||
ctx.hosts_[subnet->getID()] = host_map[subnet->getID()];
|
ctx.hosts_[subnet->getID()] = host_map[subnet->getID()];
|
||||||
@ -3420,7 +3418,7 @@ AllocEngine::findReservation(ClientContext4& ctx) {
|
|||||||
ConstHostPtr
|
ConstHostPtr
|
||||||
AllocEngine::findGlobalReservation(ClientContext4& ctx) {
|
AllocEngine::findGlobalReservation(ClientContext4& ctx) {
|
||||||
ConstHostPtr host;
|
ConstHostPtr host;
|
||||||
BOOST_FOREACH(const IdentifierPair& id_pair, ctx.host_identifiers_) {
|
for (const IdentifierPair& id_pair : ctx.host_identifiers_) {
|
||||||
// Attempt to find a host using a specified identifier.
|
// Attempt to find a host using a specified identifier.
|
||||||
host = HostMgr::instance().get4(SUBNET_ID_GLOBAL, id_pair.first,
|
host = HostMgr::instance().get4(SUBNET_ID_GLOBAL, id_pair.first,
|
||||||
&id_pair.second[0], id_pair.second.size());
|
&id_pair.second[0], id_pair.second.size());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user