-// File created from ../../../src/lib/dhcpsrv/dhcpsrv_messages.mes on Tue Apr 16 2019 17:21
+// File created from ../../../src/lib/dhcpsrv/dhcpsrv_messages.mes on Fri Jun 21 2019 16:14
#include <cstddef>
#include <log/message_types.h>
"DHCPSRV_HOOK_LEASE6_RECOVER_SKIP", "DHCPv6 lease %1 was not recovered from declined state because a callout set the skip status.",
"DHCPSRV_HOOK_LEASE6_SELECT_SKIP", "Lease6 (non-temporary) creation was skipped, because of callout skip flag.",
"DHCPSRV_INVALID_ACCESS", "invalid database access string: %1",
- "DHCPSRV_LEASE_SANITY_FAIL", "The lease %1 with subnet-id %2 failed subnet-id checks.",
- "DHCPSRV_LEASE_SANITY_FAIL_DISCARD", "The lease %1 with subnet-id %2 failed subnet-id checks and was dropped.",
+ "DHCPSRV_LEASE_SANITY_FAIL", "The lease %1 with subnet-id %2 failed subnet-id checks (%3).",
+ "DHCPSRV_LEASE_SANITY_FAIL_DISCARD", "The lease %1 with subnet-id %2 failed subnet-id checks (%3) and was dropped.",
"DHCPSRV_LEASE_SANITY_FIXED", "The lease %1 with subnet-id %2 failed subnet-id checks, but was corrected to subnet-id %3.",
"DHCPSRV_MEMFILE_ADD_ADDR4", "adding IPv4 lease with address %1",
"DHCPSRV_MEMFILE_ADD_ADDR6", "adding IPv6 lease with address %1",
should be of the form 'keyword=value keyword=value...' is included in
the message.
-% DHCPSRV_LEASE_SANITY_FAIL The lease %1 with subnet-id %2 failed subnet-id checks.
+% DHCPSRV_LEASE_SANITY_FAIL The lease %1 with subnet-id %2 failed subnet-id checks (%3).
This warning message is printed when the lease being loaded does not match the
configuration. Due to lease-checks value, the lease will be loaded, but
it will most likely be unused by Kea, as there is no subnet that matches
the IP address associated with the lease.
-% DHCPSRV_LEASE_SANITY_FAIL_DISCARD The lease %1 with subnet-id %2 failed subnet-id checks and was dropped.
+% DHCPSRV_LEASE_SANITY_FAIL_DISCARD The lease %1 with subnet-id %2 failed subnet-id checks (%3) and was dropped.
This warning message is printed when a lease was loaded, but Kea was told
(by setting lease-checks parameter) to discard leases with inconsistent
data. The lease was discarded, because either there is no subnet configured
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/subnet_id.h>
#include <dhcpsrv/dhcpsrv_log.h>
+#include <sstream>
namespace isc {
namespace dhcp {
// of found it, but it wasn't the right subnet.
SubnetID id = findSubnetId(lease, subnets);
+ // Prepare a message in the case the check fails.
+ std::ostringstream msg;
+ if (id != 0) {
+ msg << "the lease should have subnet-id " << id;
+ } else {
+ msg << "the lease IP address did not belong to a configured subnet";
+ }
+
switch (checks->getLeaseSanityCheck()) {
case CfgConsistency::LEASE_CHECK_NONE:
// No checks whatsoever, just return the lease as-is.
if (lease->subnet_id_ != id) {
// Print a warning, but return the lease as is.
LOG_WARN(dhcpsrv_logger, DHCPSRV_LEASE_SANITY_FAIL)
- .arg(lease->addr_.toText()).arg(lease->subnet_id_);
+ .arg(lease->addr_.toText())
+ .arg(lease->subnet_id_)
+ .arg(msg.str());
}
break;
// If there is a better subnet, use it.
if (id != 0) {
LOG_INFO(dhcpsrv_logger, DHCPSRV_LEASE_SANITY_FIXED)
- .arg(lease->addr_.toText()).arg(lease->subnet_id_).arg(id);
+ .arg(lease->addr_.toText())
+ .arg(lease->subnet_id_)
+ .arg(id);
lease->subnet_id_ = id;
} else {
// If not, return the lease as is.
LOG_WARN(dhcpsrv_logger, DHCPSRV_LEASE_SANITY_FAIL)
- .arg(lease->addr_.toText()).arg(lease->subnet_id_);
+ .arg(lease->addr_.toText())
+ .arg(lease->subnet_id_)
+ .arg(msg.str());
}
}
break;
// If there is a better subnet, use it.
if (id != 0) {
LOG_INFO(dhcpsrv_logger, DHCPSRV_LEASE_SANITY_FIXED)
- .arg(lease->addr_.toText()).arg(lease->subnet_id_).arg(id);
+ .arg(lease->addr_.toText())
+ .arg(lease->subnet_id_)
+ .arg(id);
lease->subnet_id_ = id;
break;
} else {
// If not, delete the lease.
LOG_INFO(dhcpsrv_logger, DHCPSRV_LEASE_SANITY_FAIL_DISCARD)
- .arg(lease->addr_.toText()).arg(lease->subnet_id_);
+ .arg(lease->addr_.toText())
+ .arg(lease->subnet_id_)
+ .arg(msg.str());
lease.reset();
}
case CfgConsistency::LEASE_CHECK_DEL:
if (lease->subnet_id_ != id) {
LOG_INFO(dhcpsrv_logger, DHCPSRV_LEASE_SANITY_FAIL_DISCARD)
- .arg(lease->addr_.toText()).arg(lease->subnet_id_);
+ .arg(lease->addr_.toText())
+ .arg(lease->subnet_id_)
+ .arg(msg.str());
lease.reset();
}
break;