This is the corresponding change to the previous v4 change.
ctx.subnet_ = subnet = original_subnet;
+ // subnets_tried tracks the ids of the subnets for which the allocation engine
+ // has made an attempt to allocate a lease. The first value of the pair is a
+ // subnet id. The second value in the pair is a pool capacity provided the
+ // client belongs to certain classes. The value of 0 indicates that no pool
+ // had any addresses available for that client. Other value indicates that
+ // a number of attempts were made but no leases could be assigned because
+ // the leases were either reserved to other clients or there were handed
+ // out to other clients. Based on this information we will be able to
+ // produce a meaningful log message to an operator.
+ std::list<std::pair<uint32_t, uint64_t> > subnets_tried;
+
for (; subnet; subnet = subnet->getNextSubnet(original_subnet)) {
if (!subnet->clientSupported(ctx.query_->getClasses())) {
uint64_t possible_attempts =
subnet->getPoolCapacity(ctx.currentIA().type_,
ctx.query_->getClasses());
+ uint64_t max_attempts = (attempts_ > 0 ? attempts_ : possible_attempts);
// Try next subnet if there is no chance to get something
if (possible_attempts == 0) {
+ max_attempts = 0;
+ }
+
+ // Remember an id of the current subnet and how many leases are potentially
+ // available for this client.
+ subnets_tried.push_back(std::make_pair(subnet->getID(), max_attempts));
+ if (max_attempts == 0) {
continue;
}
- uint64_t max_attempts = (attempts_ > 0 ? attempts_ : possible_attempts);
+
bool in_subnet = subnet->getReservationsInSubnet();
bool out_of_pool = subnet->getReservationsOutOfPool();
}
}
- // Unable to allocate an address, return an empty lease.
- LOG_WARN(alloc_engine_logger, ALLOC_ENGINE_V6_ALLOC_FAIL)
- .arg(ctx.query_->getLabel())
- .arg(total_attempts);
+ if (network) {
+ // The client is in the shared network. Let's log the high level message
+ // indicating which shared network the client belongs to.
+ LOG_WARN(alloc_engine_logger, ALLOC_ENGINE_V6_ALLOC_FAIL_SHARED_NETWORK)
+ .arg(ctx.query_->getLabel())
+ .arg(network->getName());
+
+ // The allocation engine could have tried several subnets in this shared
+ // network. We want to log which subnets it tried to use.
+ for (auto subnet_tried : subnets_tried) {
+ // If the allocation engine tried allocate any leases in this subnet
+ // we want to indicate that the failure was related to a problem with
+ // allocations rather than with access to the pools. Otherwise, we
+ // want to log that there were zero attempts to allocate a lease,
+ // which is likely because the pools were guarded by the client
+ // classes that the client did not belong to.
+ if (subnet_tried.second > 0) {
+ LOG_WARN(alloc_engine_logger, ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET_TRIED)
+ .arg(ctx.query_->getLabel())
+ .arg(subnet_tried.first);
+ } else {
+ LOG_WARN(alloc_engine_logger, ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET_POOLS_UNAVAIL)
+ .arg(ctx.query_->getLabel())
+ .arg(subnet_tried.first);
+ }
+ }
+
+ } else {
+ // The client is not connected to a shared network. It is connected
+ // to a subnet. Let's log the ID of that subnet.
+ LOG_WARN(alloc_engine_logger, ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET)
+ .arg(ctx.query_->getLabel())
+ .arg(ctx.subnet_->getID());
+ }
+ if (total_attempts == 0) {
+ // In this case, it seems that none of the pools in the subnets could
+ // be used for that client, both in case the client is connected to
+ // a shared network or to a single subnet. Apparently, the client was
+ // rejected to use the pools because of the client classes' mismatch.
+ LOG_WARN(alloc_engine_logger, ALLOC_ENGINE_V6_ALLOC_FAIL_NO_POOLS)
+ .arg(ctx.query_->getLabel());
+ } else {
+ // This is an old log message which provides a number of attempts
+ // made by the allocation engine to allocate a lease. The only case
+ // when we don't want to log this message is when the number of
+ // attempts is zero (condition above), because it would look silly.
+ LOG_WARN(alloc_engine_logger, ALLOC_ENGINE_V6_ALLOC_FAIL)
+ .arg(ctx.query_->getLabel())
+ .arg(total_attempts);
+ }
// We failed to allocate anything. Let's return empty collection.
return (Lease6Collection());
extern const isc::log::MessageID ALLOC_ENGINE_V4_REUSE_EXPIRED_LEASE_DATA = "ALLOC_ENGINE_V4_REUSE_EXPIRED_LEASE_DATA";
extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_ERROR = "ALLOC_ENGINE_V6_ALLOC_ERROR";
extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_FAIL = "ALLOC_ENGINE_V6_ALLOC_FAIL";
+extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_FAIL_NO_POOLS = "ALLOC_ENGINE_V6_ALLOC_FAIL_NO_POOLS";
+extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_FAIL_SHARED_NETWORK = "ALLOC_ENGINE_V6_ALLOC_FAIL_SHARED_NETWORK";
+extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET = "ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET";
+extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET_POOLS_UNAVAIL = "ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET_POOLS_UNAVAIL";
+extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET_TRIED = "ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET_TRIED";
extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_HR_LEASE_EXISTS = "ALLOC_ENGINE_V6_ALLOC_HR_LEASE_EXISTS";
extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_LEASES_HR = "ALLOC_ENGINE_V6_ALLOC_LEASES_HR";
extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_LEASES_NO_HR = "ALLOC_ENGINE_V6_ALLOC_LEASES_NO_HR";
"ALLOC_ENGINE_V4_REQUEST_USE_HR", "client %1 hasn't requested specific address, using reserved address %2",
"ALLOC_ENGINE_V4_REUSE_EXPIRED_LEASE_DATA", "%1: reusing expired lease, updated lease information: %2",
"ALLOC_ENGINE_V6_ALLOC_ERROR", "%1: error during attempt to allocate an IPv6 address: %2",
- "ALLOC_ENGINE_V6_ALLOC_FAIL", "%1: failed to allocate an IPv6 address after %2 attempt(s)",
+ "ALLOC_ENGINE_V6_ALLOC_FAIL", "%1: failed to allocate an IPv6 lease after %2 attempt(s)",
+ "ALLOC_ENGINE_V6_ALLOC_FAIL_NO_POOLS", "%1: no pools were available for the lease allocation",
+ "ALLOC_ENGINE_V6_ALLOC_FAIL_SHARED_NETWORK", "%1: failed to allocate an IPv6 lease in the shared network %2",
+ "ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET", "%1: failed to allocate an IPv6 lease in the subnet with id %2",
+ "ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET_POOLS_UNAVAIL", "%1: no suitable pools found in the subnet with id %2",
+ "ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET_TRIED", "%1: no available leases found in the subnet with id %2",
"ALLOC_ENGINE_V6_ALLOC_HR_LEASE_EXISTS", "%1: lease type %2 for reserved address/prefix %3 already exists",
"ALLOC_ENGINE_V6_ALLOC_LEASES_HR", "leases and static reservations found for client %1",
"ALLOC_ENGINE_V6_ALLOC_LEASES_NO_HR", "no reservations found but leases exist for client %1",
extern const isc::log::MessageID ALLOC_ENGINE_V4_REUSE_EXPIRED_LEASE_DATA;
extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_ERROR;
extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_FAIL;
+extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_FAIL_NO_POOLS;
+extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_FAIL_SHARED_NETWORK;
+extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET;
+extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET_POOLS_UNAVAIL;
+extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET_TRIED;
extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_HR_LEASE_EXISTS;
extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_LEASES_HR;
extern const isc::log::MessageID ALLOC_ENGINE_V6_ALLOC_LEASES_NO_HR;
-# Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2015-2021 Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
number of clients you are trying to service and should be expanded.
Alternatively, if the you know that the number of concurrently active
clients is less than the addresses you have available, you may want to
-consider reducing the lease lifetime. In this way, addresses allocated
+consider reducing the lease lifetime. This way, addresses allocated
to clients that are no longer active on the network will become available
sooner.
return a message to the client refusing a lease. The first argument
includes the client identification information.
-% ALLOC_ENGINE_V6_ALLOC_FAIL %1: failed to allocate an IPv6 address after %2 attempt(s)
-The DHCP allocation engine gave up trying to allocate an IPv6 address
-after the specified number of attempts. This probably means that the
-address pool from which the allocation is being attempted is either
-empty, or very nearly empty. As a result, the client will have been
-refused a lease. The first argument includes the client identification
-information.
-
-This message may indicate that your address pool is too small for the
-number of clients you are trying to service and should be expanded.
-Alternatively, if the you know that the number of concurrently active
-clients is less than the addresses you have available, you may want to
-consider reducing the lease lifetime. In this way, addresses allocated
-to clients that are no longer active on the network will become available
+% ALLOC_ENGINE_V6_ALLOC_FAIL %1: failed to allocate an IPv6 lease after %2 attempt(s)
+This is an old warning message issued when the allocation engine fails to allocate a
+lease for a client. This message includes a number of lease allocation attempts
+that the engine made before giving up. If the number of attempts is 0 because the
+engine was unable to use any of the pools for the particular client, this message
+is not logged. Even though, several more detailed logs precede this message, it was
+left for backward compatibility.
+
+This message may indicate that your pool is too small for the number of clients
+you are trying to service and should be expanded. Alternatively, if the you know
+that the number of concurrently active clients is less than the leases you have
+available, you may want to consider reducing the lease lifetime. This way, leases
+allocated to clients that are no longer active on the network will become available
sooner.
+% ALLOC_ENGINE_V6_ALLOC_FAIL_NO_POOLS %1: no pools were available for the lease allocation
+This warning message is issued when the allocation engine fails to
+allocate a lease because it could not use any configured pools for the
+particular client. It is also possible that all of the subnets from
+which the allocation engine attempted to assign an address lack address
+pools. In this case, it should be considered misconfiguration if an
+operator expects that some clients should be assigned dynamic addresses.
+A subnet may lack any pools only when all clients should be assigned
+reserved leases.
+
+Suppose the subnets connected to a shared network or a single subnet to
+which the client belongs have pools configured. In that case, this
+message is an indication that none of the pools could be used for the
+client because the client does not belong to appropriate client classes.
+
+% ALLOC_ENGINE_V6_ALLOC_FAIL_SHARED_NETWORK %1: failed to allocate an IPv6 lease in the shared network %2
+This warning message is issued when the allocation engine fails to allocate
+a lease for a client connected to a shared network. The first argument
+includes the client identification information. The second argument specifies
+the shared network name. The shared network should contain at least one subnet,
+but typically it aggregates multiple subnets. This log message indicates that
+the allocation engine could not find and allocate any suitable lease in any of
+the subnets within the shared network.
+
+Further log messages print the subnets in this shared network from which the
+allocation engine attempted to assign a lease. The allocation engine does not
+use the subnets in the shared network, which are unavailable to the DHCP client
+due to non-matching client classes. Such subnets are not included in the log
+messages following this message. In the extreme case, the allocation engine
+may use none of the subnets in the shared network for the lease allocation.
+It is the case when the address pools are available to certain client classes,
+but the requesting client does not belong to them. A suitable log message
+informing about the occurrence of this situation is issued after this log
+message.
+
+% ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET %1: failed to allocate an IPv6 lease in the subnet with id %2
+This warning message is issued when the allocation engine fails to allocate
+a lease for a client connected to a subnet that does not belong to a shared
+network. The first argument includes the client identification information.
+The second argument specifies the subnet identifier.
+
+There are many reasons for failing lease allocations. One of them may be the
+pools exhaustion or existing reservations for the free leases. However, in
+some cases, the allocation engine may fail to find a suitable pool for the
+client when the pools are only available to certain client classes, but the
+requesting client does not belong to them. Further log messages provide more
+information to distinguish between these different cases.
+
+% ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET_POOLS_UNAVAIL %1: no suitable pools found in the subnet with id %2
+This warning message is issued when the allocation engine fails to allocate
+a lease for a client connected to a shared network. The engine tried to
+allocate leases from different subnets belonging to this shared network,
+but the pools in some of the subnets were apparently guarded by client classes
+that the client did not belong to. All such subnets are logged with this
+message. The log message includes the client identification information
+and a subnet identifier.
+
+% ALLOC_ENGINE_V6_ALLOC_FAIL_SUBNET_TRIED %1: no available leases found in the subnet with id %2
+This warning message is issued when the allocation engine fails to allocate
+a lease for a client connected to a shared network. The engine tried to
+allocate addresses from different subnets belonging to this shared network
+and having a matching client class. This message is logged for each such
+subnet. It is not logged for the subnets from which the engine did not try
+to assign a lease because of the non-matching client classes. The log
+message includes the client identification information and a subnet
+identifier.
+
% ALLOC_ENGINE_V6_ALLOC_HR_LEASE_EXISTS %1: lease type %2 for reserved address/prefix %3 already exists
This debug message is issued when the allocation engine determines that
the lease for the IPv6 address or prefix has already been allocated