ctrl_dhcp6_srv.cc 21.3 KB
Newer Older
1
// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
Tomek Mrugalski's avatar
Tomek Mrugalski committed
2
//
3 4 5
// 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
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
Tomek Mrugalski's avatar
Tomek Mrugalski committed
6 7 8

#include <config.h>
#include <cc/data.h>
9
#include <config/command_mgr.h>
10
#include <dhcp/libdhcp++.h>
11
#include <dhcpsrv/cfgmgr.h>
12
#include <dhcpsrv/cfg_db_access.h>
Tomek Mrugalski's avatar
Tomek Mrugalski committed
13
#include <dhcp6/ctrl_dhcp6_srv.h>
14
#include <dhcp6/dhcp6to4_ipc.h>
Tomek Mrugalski's avatar
Tomek Mrugalski committed
15 16
#include <dhcp6/dhcp6_log.h>
#include <dhcp6/json_config_parser.h>
17 18
#include <hooks/hooks_manager.h>
#include <stats/stats_mgr.h>
Francis Dupont's avatar
Francis Dupont committed
19
#include <cfgrpt/config_report.h>
Tomek Mrugalski's avatar
Tomek Mrugalski committed
20

21
using namespace isc::config;
Tomek Mrugalski's avatar
Tomek Mrugalski committed
22 23
using namespace isc::data;
using namespace isc::hooks;
24
using namespace isc::stats;
Tomek Mrugalski's avatar
Tomek Mrugalski committed
25 26
using namespace std;

27 28 29 30 31 32 33
namespace {

// Name of the file holding server identifier.
static const char* SERVER_DUID_FILE = "kea-dhcp6-serverid";

}

Tomek Mrugalski's avatar
Tomek Mrugalski committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
namespace isc {
namespace dhcp {

ControlledDhcpv6Srv* ControlledDhcpv6Srv::server_ = NULL;

ConstElementPtr
ControlledDhcpv6Srv::commandShutdownHandler(const string&, ConstElementPtr) {
    if (ControlledDhcpv6Srv::server_) {
        ControlledDhcpv6Srv::server_->shutdown();
    } else {
        LOG_WARN(dhcp6_logger, DHCP6_NOT_RUNNING);
        ConstElementPtr answer = isc::config::createAnswer(1, "Shutdown failure.");
        return (answer);
    }
    ConstElementPtr answer = isc::config::createAnswer(0, "Shutting down.");
    return (answer);
}

ConstElementPtr
ControlledDhcpv6Srv::commandLibReloadHandler(const string&, ConstElementPtr) {
54 55
    /// @todo delete any stored CalloutHandles referring to the old libraries
    /// Get list of currently loaded libraries and reload them.
56
    HookLibsCollection loaded = HooksManager::getLibraryInfo();
Tomek Mrugalski's avatar
Tomek Mrugalski committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70
    bool status = HooksManager::loadLibraries(loaded);
    if (!status) {
        LOG_ERROR(dhcp6_logger, DHCP6_HOOKS_LIBS_RELOAD_FAIL);
        ConstElementPtr answer = isc::config::createAnswer(1,
                                 "Failed to reload hooks libraries.");
        return (answer);
    }
    ConstElementPtr answer = isc::config::createAnswer(0,
                             "Hooks libraries successfully reloaded.");
    return (answer);
}

ConstElementPtr
ControlledDhcpv6Srv::commandConfigReloadHandler(const string&, ConstElementPtr args) {
71
    // Use set-config as it handles logging and server config
72
    return (commandSetConfigHandler("set-config", args));
Tomek Mrugalski's avatar
Tomek Mrugalski committed
73 74
}

75
ConstElementPtr
76
ControlledDhcpv6Srv::commandConfigGetHandler(const string&,
77 78 79 80 81 82
                                             ConstElementPtr /*args*/) {
    ConstElementPtr config = CfgMgr::instance().getCurrentCfg()->toElement();

    return (createAnswer(0, config));
}

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
ConstElementPtr
ControlledDhcpv6Srv::commandConfigWriteHandler(const string&, ConstElementPtr args) {
    string filename;

    if (args) {
        if (args->getType() != Element::map) {
            return (createAnswer(CONTROL_RESULT_ERROR, "Argument must be a map"));
        }
        ConstElementPtr filename_param = args->get("filename");
        if (filename_param) {
            if (filename_param->getType() != Element::string) {
                return (createAnswer(CONTROL_RESULT_ERROR,
                                     "passed parameter 'filename' is not a string"));
            }
            filename = filename_param->stringValue();
        }
    }

    if (filename.empty()) {
        // filename parameter was not specified, so let's use whatever we remember
        // from the command-line
        filename = getConfigFile();
        if (filename.empty()) {
            return (createAnswer(CONTROL_RESULT_ERROR, "Unable to determine filename."
                                 "Please specify filename explicitly."));
        }
    }

    // Now do the sanity checks on the filename
    if (filename.find("..") != string::npos) {
        // Trying to escape the directory with .. nope.
        return (createAnswer(CONTROL_RESULT_ERROR,
                             "Using '..' in filename is not allowed."));
    }

    if (filename.find("\\") != string::npos) {
        // Trying to inject escapes (possibly to inject quotes and something
        // nasty afterward)
        return (createAnswer(CONTROL_RESULT_ERROR,
                             "Using \\ in filename is not allowed."));
    }

    if (filename[0] == '/') {
        // Absolute paths are not allowed.
        return (createAnswer(CONTROL_RESULT_ERROR,
                             "Absolute path in filename is not allowed."));
    }

    // Ok, it's time to write the file.
    size_t size = 0;
    try {
        size = writeConfigFile(filename);
    } catch (const isc::Exception& ex) {
        return (createAnswer(CONTROL_RESULT_ERROR, string("Error during write-config:")
                             + ex.what()));
    }
    if (size == 0) {
        return (createAnswer(CONTROL_RESULT_ERROR, "Error writing configuration to "
                             + filename));
    }

    // Ok, it's time to return the successful response.
    ElementPtr params = Element::createMap();
    params->set("size", Element::create(static_cast<long long>(size)));
    params->set("filename", Element::create(filename));

    return (createAnswer(CONTROL_RESULT_SUCCESS, "Configuration written to "
                         + filename + " successful", params));
}

153 154 155 156 157 158 159 160 161
ConstElementPtr
ControlledDhcpv6Srv::commandSetConfigHandler(const string&,
                                             ConstElementPtr args) {
    const int status_code = 1; // 1 indicates an error
    ConstElementPtr dhcp6;
    string message;

    // Command arguments are expected to be:
    // { "Dhcp6": { ... }, "Logging": { ... } }
162 163
    // The Logging component is technically optional. If it's not supplied
    // logging will revert to default logging.
164 165 166 167 168 169 170 171 172 173
    if (!args) {
        message = "Missing mandatory 'arguments' parameter.";
    } else {
        dhcp6 = args->get("Dhcp6");
        if (!dhcp6) {
            message = "Missing mandatory 'Dhcp6' parameter.";
        } else if (dhcp6->getType() != Element::map) {
            message = "'Dhcp6' parameter expected to be a map.";
        }
    }
Tomek Mrugalski's avatar
Tomek Mrugalski committed
174

175 176 177 178 179 180
    if (!message.empty()) {
        // Something is amiss with arguments, return a failure response.
        ConstElementPtr result = isc::config::createAnswer(status_code,
                                                           message);
        return (result);
    }
181

182 183 184 185 186
    // We are starting the configuration process so we should remove any
    // staging configuration that has been created during previous
    // configuration attempts.
    CfgMgr::instance().rollback();

187
    // Logging is a sibling element and must be parsed explicitly.
188
    // The call to configureLogger parses the given Logging element if
189
    // not null, into the staging config.  Note this does not alter the
190
    // current loggers, they remain in effect until we apply the
191 192
    // logging config below.  If no logging is supplied logging will
    // revert to default logging.
193 194 195
    Daemon::configureLogger(args->get("Logging"),
                            CfgMgr::instance().getStagingCfg());

196
    // Now we configure the server proper.
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
    ConstElementPtr result = processConfig(dhcp6);

    // If the configuration parsed successfully, apply the new logger
    // configuration and the commit the new configuration.  We apply
    // the logging first in case there's a configuration failure.
    int rcode = 0;
    isc::config::parseAnswer(rcode, result);
    if (rcode == 0) {
        CfgMgr::instance().getStagingCfg()->applyLoggingCfg();

        // Use new configuration.
        CfgMgr::instance().commit();
    }

    return (result);
Tomek Mrugalski's avatar
Tomek Mrugalski committed
212 213
}

214

Francis Dupont's avatar
Francis Dupont committed
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
ConstElementPtr
ControlledDhcpv6Srv::commandVersionGetHandler(const string&, ConstElementPtr) {
    ElementPtr extended = Element::create(Dhcpv6Srv::getVersion(true));
    ElementPtr arguments = Element::createMap();
    arguments->set("extended", extended);
    ConstElementPtr answer = isc::config::createAnswer(0,
                                Dhcpv6Srv::getVersion(false),
                                arguments);
    return (answer);
}

ConstElementPtr
ControlledDhcpv6Srv::commandBuildReportHandler(const string&, ConstElementPtr) {
    ConstElementPtr answer =
        isc::config::createAnswer(0, isc::detail::getConfigReport());
    return (answer);
}

233
ConstElementPtr
234
ControlledDhcpv6Srv::commandLeasesReclaimHandler(const string&,
Francis Dupont's avatar
Francis Dupont committed
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
                                                 ConstElementPtr args) {
    int status_code = 1;
    string message;

    // args must be { "remove": <bool> }
    if (!args) {
        message = "Missing mandatory 'remove' parameter.";
    } else {
        ConstElementPtr remove_name = args->get("remove");
        if (!remove_name) {
            message = "Missing mandatory 'remove' parameter.";
        } else if (remove_name->getType() != Element::boolean) {
            message = "'remove' parameter expected to be a boolean.";
        } else {
            bool remove_lease = remove_name->boolValue();
            server_->alloc_engine_->reclaimExpiredLeases6(0, 0, remove_lease);
            status_code = 0;
            message = "Reclamation of expired leases is complete.";
        }
    }
    ConstElementPtr answer = isc::config::createAnswer(status_code, message);
256 257 258
    return (answer);
}

Tomek Mrugalski's avatar
Tomek Mrugalski committed
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
isc::data::ConstElementPtr
ControlledDhcpv6Srv::processCommand(const std::string& command,
                                    isc::data::ConstElementPtr args) {
    LOG_DEBUG(dhcp6_logger, DBG_DHCP6_COMMAND, DHCP6_COMMAND_RECEIVED)
              .arg(command).arg(args->str());

    ControlledDhcpv6Srv* srv = ControlledDhcpv6Srv::getInstance();

    if (!srv) {
        ConstElementPtr no_srv = isc::config::createAnswer(1,
          "Server object not initialized, can't process command '" +
          command + "'.");
        return (no_srv);
    }

    try {
        if (command == "shutdown") {
            return (srv->commandShutdownHandler(command, args));

        } else if (command == "libreload") {
            return (srv->commandLibReloadHandler(command, args));

        } else if (command == "config-reload") {
            return (srv->commandConfigReloadHandler(command, args));
Francis Dupont's avatar
Francis Dupont committed
283

284 285 286
        } else if (command == "set-config") {
            return (srv->commandSetConfigHandler(command, args));

287 288
        } else if (command == "config-get") {
            return (srv->commandConfigGetHandler(command, args));
289

Francis Dupont's avatar
Francis Dupont committed
290 291 292 293 294 295
        } else if (command == "version-get") {
            return (srv->commandVersionGetHandler(command, args));

        } else if (command == "build-report") {
            return (srv->commandBuildReportHandler(command, args));

Francis Dupont's avatar
Francis Dupont committed
296 297
        } else if (command == "leases-reclaim") {
            return (srv->commandLeasesReclaimHandler(command, args));
298 299 300 301

        } else if (command == "config-write") {
            return (srv->commandConfigWriteHandler(command, args));

Tomek Mrugalski's avatar
Tomek Mrugalski committed
302 303 304 305 306 307 308 309 310 311 312 313 314
        }

        return (isc::config::createAnswer(1, "Unrecognized command:"
                                          + command));

    } catch (const Exception& ex) {
        return (isc::config::createAnswer(1, "Error while processing command '"
                                          + command + "':" + ex.what()));
    }
}

isc::data::ConstElementPtr
ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) {
Tomek Mrugalski's avatar
Tomek Mrugalski committed
315 316 317 318

    LOG_DEBUG(dhcp6_logger, DBG_DHCP6_COMMAND, DHCP6_CONFIG_RECEIVED)
              .arg(config->str());

Tomek Mrugalski's avatar
Tomek Mrugalski committed
319 320 321 322 323 324 325 326
    ControlledDhcpv6Srv* srv = ControlledDhcpv6Srv::getInstance();

    if (!srv) {
        ConstElementPtr no_srv = isc::config::createAnswer(1,
          "Server object not initialized, can't process config.");
        return (no_srv);
    }

327 328 329 330 331 332 333 334 335 336 337
    // We're going to modify the timers configuration. This is not allowed
    // when the thread is running.
    try {
        TimerMgr::instance()->stopThread();
    } catch (const std::exception& ex) {
        std::ostringstream err;
        err << "Unable to stop worker thread running timers: "
            << ex.what() << ".";
        return (isc::config::createAnswer(1, err.str()));
    }

Tomek Mrugalski's avatar
Tomek Mrugalski committed
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
    ConstElementPtr answer = configureDhcp6Server(*srv, config);

    // Check that configuration was successful. If not, do not reopen sockets
    // and don't bother with DDNS stuff.
    try {
        int rcode = 0;
        isc::config::parseAnswer(rcode, answer);
        if (rcode != 0) {
            return (answer);
        }
    } catch (const std::exception& ex) {
        return (isc::config::createAnswer(1, "Failed to process configuration:"
                                          + string(ex.what())));
    }

353 354 355 356 357 358 359 360 361 362 363
    // Re-open lease and host database with new parameters.
    try {
        CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
        cfg_db->setAppendedParameters("universe=6");
        cfg_db->createManagers();

    } catch (const std::exception& ex) {
        return (isc::config::createAnswer(1, "Unable to open database: "
                                          + std::string(ex.what())));
    }

364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
    // Regenerate server identifier if needed.
    try {
        const std::string duid_file = CfgMgr::instance().getDataDir() + "/" +
            std::string(SERVER_DUID_FILE);
        DuidPtr duid = CfgMgr::instance().getStagingCfg()->getCfgDUID()->create(duid_file);
        server_->serverid_.reset(new Option(Option::V6, D6O_SERVERID, duid->getDuid()));
        if (duid) {
            LOG_INFO(dhcp6_logger, DHCP6_USING_SERVERID)
                .arg(duid->toText())
                .arg(duid_file);
        }

    } catch (const std::exception& ex) {
        std::ostringstream err;
        err << "unable to configure server identifier: " << ex.what();
        return (isc::config::createAnswer(1, err.str()));
    }

Tomek Mrugalski's avatar
Tomek Mrugalski committed
382 383 384 385 386 387 388
    // Server will start DDNS communications if its enabled.
    try {
        srv->startD2();
    } catch (const std::exception& ex) {
        std::ostringstream err;
        err << "error starting DHCP_DDNS client "
                " after server reconfiguration: " << ex.what();
389 390 391 392 393
        return (isc::config::createAnswer(1, err.str()));
    }

    // Setup DHCPv4-over-DHCPv6 IPC
    try {
394
        Dhcp6to4Ipc::instance().open();
395 396 397 398
    } catch (const std::exception& ex) {
        std::ostringstream err;
        err << "error starting DHCPv4-over-DHCPv6 IPC "
               " after server reconfiguration: " << ex.what();
Tomek Mrugalski's avatar
Tomek Mrugalski committed
399 400 401 402
        return (isc::config::createAnswer(1, err.str()));
    }

    // Configuration may change active interfaces. Therefore, we have to reopen
403 404 405 406 407 408
    // sockets according to new configuration. It is possible that this
    // operation will fail for some interfaces but the openSockets function
    // guards against exceptions and invokes a callback function to
    // log warnings. Since we allow that this fails for some interfaces there
    // is no need to rollback configuration if socket fails to open on any
    // of the interfaces.
409
    CfgMgr::instance().getStagingCfg()->getCfgIface()->openSockets(AF_INET6, srv->getPort());
Tomek Mrugalski's avatar
Tomek Mrugalski committed
410

411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
    // Install the timers for handling leases reclamation.
    try {
        CfgMgr::instance().getStagingCfg()->getCfgExpiration()->
            setupTimers(&ControlledDhcpv6Srv::reclaimExpiredLeases,
                        &ControlledDhcpv6Srv::deleteExpiredReclaimedLeases,
                        server_);

    } catch (const std::exception& ex) {
        std::ostringstream err;
        err << "unable to setup timers for periodically running the"
            " reclamation of the expired leases: "
            << ex.what() << ".";
        return (isc::config::createAnswer(1, err.str()));
    }

    // Start worker thread if there are any timers installed.
    if (TimerMgr::instance()->timersCount() > 0) {
        try {
            TimerMgr::instance()->startThread();
        } catch (const std::exception& ex) {
            std::ostringstream err;
            err << "Unable to start worker thread running timers: "
                << ex.what() << ".";
            return (isc::config::createAnswer(1, err.str()));
        }
    }

438 439 440 441
    // Finally, we can commit runtime option definitions in libdhcp++. This is
    // exception free.
    LibDHCP::commitRuntimeOptionDefs();

Tomek Mrugalski's avatar
Tomek Mrugalski committed
442 443 444 445
    return (answer);
}

ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t port)
446
    : Dhcpv6Srv(port), io_service_(), timer_mgr_(TimerMgr::instance()) {
Tomek Mrugalski's avatar
Tomek Mrugalski committed
447 448 449 450 451
    if (server_) {
        isc_throw(InvalidOperation,
                  "There is another Dhcpv6Srv instance already.");
    }
    server_ = this; // remember this instance for use in callback
452

453 454
    // These are the commands always supported by the DHCPv6 server.
    // Please keep the list in alphabetic order.
Francis Dupont's avatar
Francis Dupont committed
455 456 457
    CommandMgr::instance().registerCommand("build-report",
        boost::bind(&ControlledDhcpv6Srv::commandBuildReportHandler, this, _1, _2));

458 459 460 461 462 463 464 465 466 467
    CommandMgr::instance().registerCommand("config-get",
        boost::bind(&ControlledDhcpv6Srv::commandConfigGetHandler, this, _1, _2));

    /// @todo: register config-reload (see CtrlDhcpv6Srv::commandConfigReloadHandler)

    CommandMgr::instance().registerCommand("config-write",
        boost::bind(&ControlledDhcpv6Srv::commandConfigWriteHandler, this, _1, _2));

    CommandMgr::instance().registerCommand("leases-reclaim",
        boost::bind(&ControlledDhcpv6Srv::commandLeasesReclaimHandler, this, _1, _2));
468

469 470
    CommandMgr::instance().registerCommand("libreload",
        boost::bind(&ControlledDhcpv6Srv::commandLibReloadHandler, this, _1, _2));
471

472 473 474
    CommandMgr::instance().registerCommand("set-config",
        boost::bind(&ControlledDhcpv6Srv::commandSetConfigHandler, this, _1, _2));

475 476
    CommandMgr::instance().registerCommand("shutdown",
        boost::bind(&ControlledDhcpv6Srv::commandShutdownHandler, this, _1, _2));
477

Francis Dupont's avatar
Francis Dupont committed
478 479 480
    CommandMgr::instance().registerCommand("version-get",
        boost::bind(&ControlledDhcpv6Srv::commandVersionGetHandler, this, _1, _2));

481 482 483 484 485 486 487
    // Register statistic related commands
    CommandMgr::instance().registerCommand("statistic-get",
        boost::bind(&StatsMgr::statisticGetHandler, _1, _2));

    CommandMgr::instance().registerCommand("statistic-get-all",
        boost::bind(&StatsMgr::statisticGetAllHandler, _1, _2));

488 489 490
    CommandMgr::instance().registerCommand("statistic-reset",
        boost::bind(&StatsMgr::statisticResetHandler, _1, _2));

491 492 493
    CommandMgr::instance().registerCommand("statistic-reset-all",
        boost::bind(&StatsMgr::statisticResetAllHandler, _1, _2));

494 495 496
    CommandMgr::instance().registerCommand("statistic-remove",
        boost::bind(&StatsMgr::statisticRemoveHandler, _1, _2));

497 498
    CommandMgr::instance().registerCommand("statistic-remove-all",
        boost::bind(&StatsMgr::statisticRemoveAllHandler, _1, _2));
Tomek Mrugalski's avatar
Tomek Mrugalski committed
499 500 501 502 503 504 505 506
}

void ControlledDhcpv6Srv::shutdown() {
    io_service_.stop(); // Stop ASIO transmissions
    Dhcpv6Srv::shutdown(); // Initiate DHCPv6 shutdown procedure.
}

ControlledDhcpv6Srv::~ControlledDhcpv6Srv() {
507 508 509
    try {
        cleanup();

510 511
        // Stop worker thread running timers, if it is running. Then
        // unregister any timers.
512
        timer_mgr_->stopThread();
513
        timer_mgr_->unregisterTimers();
514 515 516 517

        // Close the command socket (if it exists).
        CommandMgr::instance().closeCommandSocket();

518
        // Deregister any registered commands (please keep in alphabetic order)
Francis Dupont's avatar
Francis Dupont committed
519
        CommandMgr::instance().deregisterCommand("build-report");
520 521
        CommandMgr::instance().deregisterCommand("config-get");
        CommandMgr::instance().deregisterCommand("config-write");
522
        CommandMgr::instance().deregisterCommand("leases-reclaim");
Francis Dupont's avatar
Francis Dupont committed
523
        CommandMgr::instance().deregisterCommand("libreload");
524 525
        CommandMgr::instance().deregisterCommand("set-config");
        CommandMgr::instance().deregisterCommand("shutdown");
526 527
        CommandMgr::instance().deregisterCommand("statistic-get");
        CommandMgr::instance().deregisterCommand("statistic-get-all");
528
        CommandMgr::instance().deregisterCommand("statistic-remove");
529
        CommandMgr::instance().deregisterCommand("statistic-remove-all");
530 531
        CommandMgr::instance().deregisterCommand("statistic-reset");
        CommandMgr::instance().deregisterCommand("statistic-reset-all");
Francis Dupont's avatar
Francis Dupont committed
532
        CommandMgr::instance().deregisterCommand("version-get");
533 534 535 536 537 538

    } catch (...) {
        // Don't want to throw exceptions from the destructor. The server
        // is shutting down anyway.
        ;
    }
539

Tomek Mrugalski's avatar
Tomek Mrugalski committed
540 541 542 543 544 545 546 547 548 549 550 551
    server_ = NULL; // forget this instance. There should be no callback anymore
                    // at this stage anyway.
}

void ControlledDhcpv6Srv::sessionReader(void) {
    // Process one asio event. If there are more events, iface_mgr will call
    // this callback more than once.
    if (server_) {
        server_->io_service_.run_one();
    }
}

552 553 554
void
ControlledDhcpv6Srv::reclaimExpiredLeases(const size_t max_leases,
                                          const uint16_t timeout,
555 556
                                          const bool remove_lease,
                                          const uint16_t max_unwarned_cycles) {
557
    server_->alloc_engine_->reclaimExpiredLeases6(max_leases, timeout,
558 559
                                                  remove_lease,
                                                  max_unwarned_cycles);
560 561 562 563 564 565 566 567 568 569 570 571
    // We're using the ONE_SHOT timer so there is a need to re-schedule it.
    TimerMgr::instance()->setup(CfgExpiration::RECLAIM_EXPIRED_TIMER_NAME);
}

void
ControlledDhcpv6Srv::deleteExpiredReclaimedLeases(const uint32_t secs) {
    server_->alloc_engine_->deleteExpiredReclaimedLeases6(secs);
    // We're using the ONE_SHOT timer so there is a need to re-schedule it.
    TimerMgr::instance()->setup(CfgExpiration::FLUSH_RECLAIMED_TIMER_NAME);
}


Tomek Mrugalski's avatar
Tomek Mrugalski committed
572 573
}; // end of isc::dhcp namespace
}; // end of isc namespace