Commit abfa55b9 authored by Thomas Markwalder's avatar Thomas Markwalder
Browse files

[#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
parent fbef712c
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
......
// 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();
......
// 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)
......
// 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment