#include <config.h>
+#include <database/db_exceptions.h>
#include <dhcp/dhcp6.h>
#include <dhcp/pkt4.h>
#include <dhcp/pkt6.h>
#include <vector>
using namespace isc::asiolink;
+using namespace isc::db;
using namespace isc::dhcp;
using namespace isc::dhcp_ddns;
using namespace isc::hooks;
// the mode in which non-unique reservations are allowed the backends which
// don't support it are not used and we can safely call getAll6.
if (CfgMgr::instance().getCurrentCfg()->getCfgDbAccess()->getIPReservationsUnique()) {
- auto host = HostMgr::instance().get6(subnet_id, address);
- if (host) {
- reserved.push_back(host);
+ try {
+ // Reservations are unique. It is safe to call get6 to get the unique host.
+ auto host = HostMgr::instance().get6(subnet_id, address);
+ if (host) {
+ reserved.push_back(host);
+ }
+ } catch (const MultipleRecords& ex) {
+ LOG_WARN(dhcpsrv_logger, DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_DETECTED)
+ .arg(address)
+ .arg(subnet_id)
+ .arg(ex.what());
+ throw;
}
} else {
auto hosts = HostMgr::instance().getAll6(subnet_id, address);
// don't support it are not used and we can safely call getAll4.
ConstHostCollection hosts;
if (CfgMgr::instance().getCurrentCfg()->getCfgDbAccess()->getIPReservationsUnique()) {
- // Reservations are unique. It is safe to call get4 to get the unique host.
- ConstHostPtr host = HostMgr::instance().get4(ctx.subnet_->getID(), address);
- if (host) {
- hosts.push_back(host);
+ try {
+ // Reservations are unique. It is safe to call get4 to get the unique host.
+ ConstHostPtr host = HostMgr::instance().get4(ctx.subnet_->getID(), address);
+ if (host) {
+ hosts.push_back(host);
+ }
+ } catch (const MultipleRecords& ex) {
+ LOG_WARN(dhcpsrv_logger, DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_DETECTED)
+ .arg(address)
+ .arg(ctx.subnet_->getID())
+ .arg(ex.what());
+ throw;
}
} else {
// Reservations can be non-unique. Need to get all reservations for that address.
extern const isc::log::MessageID DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_PREFIX_LEASES_DONE = "DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_PREFIX_LEASES_DONE";
extern const isc::log::MessageID DHCPSRV_CFGMGR_IPV4_RESERVATIONS_NON_UNIQUE_IGNORED = "DHCPSRV_CFGMGR_IPV4_RESERVATIONS_NON_UNIQUE_IGNORED";
extern const isc::log::MessageID DHCPSRV_CFGMGR_IPV6_RESERVATIONS_NON_UNIQUE_IGNORED = "DHCPSRV_CFGMGR_IPV6_RESERVATIONS_NON_UNIQUE_IGNORED";
+extern const isc::log::MessageID DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_DETECTED = "DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_DETECTED";
extern const isc::log::MessageID DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_POSSIBLE = "DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_POSSIBLE";
extern const isc::log::MessageID DHCPSRV_CFGMGR_NEW_SUBNET4 = "DHCPSRV_CFGMGR_NEW_SUBNET4";
extern const isc::log::MessageID DHCPSRV_CFGMGR_NEW_SUBNET6 = "DHCPSRV_CFGMGR_NEW_SUBNET6";
"DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_PREFIX_LEASES_DONE", "populated %1 free prefix leases for the FLQ allocator in subnet %2 completed in %3",
"DHCPSRV_CFGMGR_IPV4_RESERVATIONS_NON_UNIQUE_IGNORED", "ignoring \"ip-reservations-unique\" setting because at least one of the host database backends does not support non-unique IP reservations in a subnet",
"DHCPSRV_CFGMGR_IPV6_RESERVATIONS_NON_UNIQUE_IGNORED", "ignoring \"ip-reservations-unique\" setting because at least one of the host database backends does not support non unique IP reservations in a subnet",
+ "DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_DETECTED", "the \"ip-reservations-unique\" flag is set to false and multiple reservations for the IP address: %1 in subnet: %2 are not allowed causing error: %3",
"DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_POSSIBLE", "setting \"ip-reservations-unique\" from false to true poses a risk that some host backends may still contain multiple reservations for the same IP address",
"DHCPSRV_CFGMGR_NEW_SUBNET4", "a new subnet has been added to configuration: %1",
"DHCPSRV_CFGMGR_NEW_SUBNET6", "a new subnet has been added to configuration: %1",
extern const isc::log::MessageID DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_PREFIX_LEASES_DONE;
extern const isc::log::MessageID DHCPSRV_CFGMGR_IPV4_RESERVATIONS_NON_UNIQUE_IGNORED;
extern const isc::log::MessageID DHCPSRV_CFGMGR_IPV6_RESERVATIONS_NON_UNIQUE_IGNORED;
+extern const isc::log::MessageID DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_DETECTED;
extern const isc::log::MessageID DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_POSSIBLE;
extern const isc::log::MessageID DHCPSRV_CFGMGR_NEW_SUBNET4;
extern const isc::log::MessageID DHCPSRV_CFGMGR_NEW_SUBNET6;
causing problems with lease allocation for certain addresses. Please ensure
that all such duplicates are removed.
+% DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_DETECTED the "ip-reservations-unique" flag is set to false and multiple reservations for the IP address: %1 in subnet: %2 are not allowed causing error: %3
+This warning message is issued when the DHCP server is configured to not allow
+multiple reservations for the same IP address. However, the host database
+backends contains multiple reservations for the IP addresses which logged as
+the first argument, in the subnet logged as second argument, causing problems
+with lease allocation logged as third argument.
+
% DHCPSRV_CFGMGR_NEW_SUBNET4 a new subnet has been added to configuration: %1
This is an informational message reporting that the configuration has
been extended to include the specified IPv4 subnet.