diff options
author | Thomas Markwalder <tmark@isc.org> | 2019-05-01 20:05:55 +0200 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2019-05-01 20:05:55 +0200 |
commit | abfa55b90714997f1c5beafd938a84ed41cf6f65 (patch) | |
tree | 745f31bb94566588279ec7733662d50027691f85 | |
parent | [#360,!305] ChangeLog updated. (diff) | |
download | kea-abfa55b90714997f1c5beafd938a84ed41cf6f65.tar.xz kea-abfa55b90714997f1c5beafd938a84ed41cf6f65.zip |
[#591,!#313] kea-dhcp6 skips sanity checks for prefix leases
src/lib/dhcpsrv/sanity_checker.*
SanityChecker::checkLease(Lease6Ptr& lease, bool current) - now
simply returns if lease type is TYPE_PD.
src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc
TEST_F(LeaseFileLoaderTest, sanityChecker6PD) - new test to
verify PD leases are not sanity checked
ChangeLog - added proposed entry
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/lib/dhcpsrv/sanity_checker.cc | 7 | ||||
-rw-r--r-- | src/lib/dhcpsrv/sanity_checker.h | 7 | ||||
-rw-r--r-- | src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc | 28 |
4 files changed, 40 insertions, 9 deletions
@@ -1,3 +1,10 @@ +15xx. [bug] tmark + kea-dhcp6 now properly skips sanity checking prefix + leases. Prior to this it was incorrectly subjecting + them to sanity checks during memfile lease file reloads + and then flagging the leases as incorrect. + (Gitlab #591,!#313, git TBD) + 1567. [bug] marcin Kea HTTP client now always includes Host header in all HTTP requests. The Host header is required in all HTTP/1.1 requests. This corrects diff --git a/src/lib/dhcpsrv/sanity_checker.cc b/src/lib/dhcpsrv/sanity_checker.cc index 1de927c875..6e512d09ed 100644 --- a/src/lib/dhcpsrv/sanity_checker.cc +++ b/src/lib/dhcpsrv/sanity_checker.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2019 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 @@ -26,6 +26,11 @@ void SanityChecker::checkLease(Lease4Ptr& lease, bool current) { } void SanityChecker::checkLease(Lease6Ptr& lease, bool current) { + // We only check IA_NAs currently. + if (lease->type_ != Lease::TYPE_NA) { + return; + } + SrvConfigPtr cfg; if (current) { cfg = CfgMgr::instance().getCurrentCfg(); diff --git a/src/lib/dhcpsrv/sanity_checker.h b/src/lib/dhcpsrv/sanity_checker.h index c181fd44c5..ad0ee24473 100644 --- a/src/lib/dhcpsrv/sanity_checker.h +++ b/src/lib/dhcpsrv/sanity_checker.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2019 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 @@ -32,11 +32,12 @@ class SanityChecker { /// config void checkLease(Lease4Ptr& lease, bool current = true); - /// @brief Sanity checks and possibly corrects an IPv4 lease + /// @brief Sanity checks and possibly corrects an IPv6 lease /// /// Depending on the sanity-checks/lease-checks parameter value (see /// @ref CfgConsistency for details), this code may print a warning, - /// correct subnet-id or discard the lease. + /// correct subnet-id or discard the lease. Note that if the lease + /// type is TYPE_PD, it simply returns. /// /// @param lease Lease to be sanity-checked /// @param current specify whether to use current (true) or staging(false) diff --git a/src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc b/src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc index ad2569847f..b8754cfa4a 100644 --- a/src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc +++ b/src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2019 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 @@ -235,7 +235,7 @@ public: } } - /// @brief Checks if IPv4 lease loaded from file is sanity checked. + /// @brief Checks if IPv6 lease loaded from file is sanity checked. /// /// This method writes a simple lease file with one lease in it, /// then sets sanity checks to tested level, then tries to load @@ -249,10 +249,13 @@ public: /// @param sanity level of sanity checks /// @param exp_present is the lease expected to be loaded (true = yes) /// @param exp_id expected subnet-id of the loaded lease + /// @param prefix_len length of the prefix if the lease created should be + /// a PD lease. Defaults to 0. void sanityChecks6(std::string lease, SubnetID lease_id, std::string subnet_txt, SubnetID subnet_id, CfgConsistency::LeaseSanity sanity, - bool exp_present, SubnetID exp_id) { + bool exp_present, SubnetID exp_id, + unsigned int prefix_len=0) { // Create the subnet and add it to configuration. if (!subnet_txt.empty()) { @@ -263,8 +266,9 @@ public: std::stringstream file_content; file_content << v6_hdr_ << lease << ",dd:de:ba:0d:1b:2e," - << "300,300," << static_cast<int>(lease_id) - << ",150,0,8,0,0,0,,,1,\n"; + << "300,300," << static_cast<int>(lease_id) << ",150," + << static_cast<int>(prefix_len > 0 ? Lease::TYPE_PD : Lease::TYPE_NA) + << ",8," << prefix_len << ",0,0,,,1,\n"; ASSERT_NO_THROW(CfgMgr::instance().getStagingCfg()->getConsistency() ->setLeaseSanityCheck(sanity)); @@ -820,4 +824,18 @@ TEST_F(LeaseFileLoaderTest, sanityChecker6Del) { sanityChecks6("2001::1", 1, "2001::/16", 2, CfgConsistency::LEASE_CHECK_DEL, false, 1); } +// This test checks to make sure PD leases are not sanity checked, +// and thus not discarded. +TEST_F(LeaseFileLoaderTest, sanityChecker6PD) { + int prefix_len = 64; + + // We check a prefix lease whose subnet-id does not exist and + // is clearly outside the only known subnet. + sanityChecks6("2001:1::", 2, // create prefix lease in subnet 2 + "3001::/64", 1, // create subnet 1 + CfgConsistency::LEASE_CHECK_DEL, + true, 2, // lease should still exist with subnet id of 2 + prefix_len); +} + } // end of anonymous namespace |