From: Tomek Mrugalski Date: Mon, 30 Jul 2018 17:02:47 +0000 (+0200) Subject: [5682] Added two missing log messages X-Git-Tag: ha_phase2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Ftrac5682;p=thirdparty%2Fkea.git [5682] Added two missing log messages --- diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc index 1a09a5b2a1..c5f81a4796 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc @@ -3523,6 +3523,8 @@ TEST_F(LeaseCmdsTest, Lease6WipeNoLeasesAll) { testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp); } +// Checks that an attempt to update a lease (set incorrect subnet-id) +// will fail. TEST_F(LeaseCmdsTest, brokenUpdate) { // Initialize lease manager (false = v4, false = don't add leases) diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.mes b/src/lib/dhcpsrv/dhcpsrv_messages.mes index 4b4661444b..199381e6cc 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.mes +++ b/src/lib/dhcpsrv/dhcpsrv_messages.mes @@ -431,10 +431,23 @@ 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. +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_FIXED The lease %1 with subnet-id %2 failed subnet-id checks, but was correced to subnet-id %3. +% DHCPSRV_LEASE_SANITY_FIXED The lease %1 with subnet-id %2 failed subnet-id checks, but was corrected to subnet-id %3. +This informational message is printed when a lease was loaded, but had +incorrect subnet-id value. The lease-checks parameter was set to a value +that told Kea to try to correct the problem. There is a matching subnet, +so Kea updated subnet-id and loaded the lease successfully. % DHCPSRV_LEASE_SANITY_FAIL_DISCARD The lease %1 with subnet-id %2 failed subnet-id checks 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 +with matching subnet-id or the address of the lease does not belong to the +subnet. % DHCPSRV_MEMFILE_ADD_ADDR4 adding IPv4 lease with address %1 A debug message issued when the server is about to add an IPv4 lease diff --git a/src/lib/dhcpsrv/sanity_checker.cc b/src/lib/dhcpsrv/sanity_checker.cc index 478acbf6ac..1de927c875 100644 --- a/src/lib/dhcpsrv/sanity_checker.cc +++ b/src/lib/dhcpsrv/sanity_checker.cc @@ -78,9 +78,11 @@ void SanityChecker::checkLeaseInternal(LeasePtrType& lease, const CfgConsistency LOG_INFO(dhcpsrv_logger, DHCPSRV_LEASE_SANITY_FIXED) .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_); } - - // If not, return the lease as is. } break; @@ -89,12 +91,14 @@ void SanityChecker::checkLeaseInternal(LeasePtrType& lease, const CfgConsistency // If there is a better subnet, use it. if (id != 0) { - LOG_INFO(dhcpsrv_logger, DHCPSRV_LEASE_SANITY_FAIL_DISCARD) - .arg(lease->addr_.toText()).arg(lease->subnet_id_); + LOG_INFO(dhcpsrv_logger, DHCPSRV_LEASE_SANITY_FIXED) + .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_); lease.reset(); }