Skip to content

Commit

Permalink
Merge remote-tracking branch 'isc-kea/master' into cassandra_improvem…
Browse files Browse the repository at this point in the history
…ents
  • Loading branch information
Razvan Becheriu committed Mar 13, 2018
2 parents c3e4fe2 + 4eb1198 commit 33e4b4f
Show file tree
Hide file tree
Showing 71 changed files with 7,803 additions and 6,323 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "premium"]
path = premium
url = ssh://fdupont@repo.isc.org/proj/git/prod/kea-premium.git
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ We have received the following contributions:
2018-01: Various changes (github 54)
2018-02: Support for Google benchmark added (github 36)
2018-02: exit-wait-time param added to perfdhcp (github 55)
2018-03: Cassandra: host delete, fixed DHCPv4 fields, user contexts,
Postgres: hwaddress source, type storage (github 70)

- Patrik Lundin
2016-07: Replace test by expr for < in configure.ac
Expand Down
29 changes: 29 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
1374. [func] razvan
Cassandra backend improvements: get all IPv4 leases, delete
hosts, ability to store fixed DHCPv4 fields (next-server,
server-hostname, boot-file-name) and user contexts in host
reservations. Also, the ability to store MAC address details
in DHCPv6 leases on PostgreSQL has been improved.
(Github #70, git 8cd0c1ae416be88baf69c2243e83a429d6d5c965)
(Trac #5506, git 8cd0c1ae416be88baf69c2243e83a429d6d5c965)
(Trac #5507, git 8cd0c1ae416be88baf69c2243e83a429d6d5c965)
(Trac #5508, git 8cd0c1ae416be88baf69c2243e83a429d6d5c965)
(Trac #4530, git 8cd0c1ae416be88baf69c2243e83a429d6d5c965)

1373. [func] tmark
When encountering errors unpacking vendor specific options,
both kea-dhcp4 and kea-dhcp6 will now log the error, skip
unpacking any remaining options, and then attempt to process
the packet as is. Prior to this the servers would log the issue
and then drop the packet.
(Trac #5551, git 59ef33ee17672c55cee4ec86ff59737b361a3c21)

1372. [func] tmark
kea-dhp4 and kea-dhcp6 can now be configured to attempt to
reconnect to Postgresql backends if connectivity is lost.
(Trac #5477, git 8e62a058382b2245d418cfbf829776934c638e5e)

1371. [func] marcin
Implemented leases parsing from JSON in libkea-dhcpsrv.
(Trac #5466, git 84c2a2084b0fb7c086fc6b9502f7ff58b708174e)

1370. [func] marcin
Implemented new hook points "dhcp4_srv_configured" and
"leases4_committed" in the DHCPv4 server. The latter supports
Expand Down
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1623,9 +1623,9 @@ if test "$CQL_CPPFLAGS" != "" ; then
cat >> config.report << END

Cassandra CQL:
CQL_VERSION: ${CQL_VERSION}
CQL_CPPFLAGS: ${CQL_CPPFLAGS}
CQL_LIBS: ${CQL_LIBS}
CQL_VERSION: ${CQL_VERSION}
CQL_CPPFLAGS: ${CQL_CPPFLAGS}
CQL_LIBS: ${CQL_LIBS}
END
else
cat >> config.report << END
Expand Down
1 change: 1 addition & 0 deletions premium
Submodule premium added at cc1c11
78 changes: 76 additions & 2 deletions src/bin/dhcp4/ctrl_dhcp4_srv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,7 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) {
try {
CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
cfg_db->setAppendedParameters("universe=4");
cfg_db->createManagers();

cfg_db->createManagers(boost::bind(&ControlledDhcpv4Srv::dbLostCallback, srv, _1));
} catch (const std::exception& ex) {
err << "Unable to open database: " << ex.what();
return (isc::config::createAnswer(1, err.str()));
Expand Down Expand Up @@ -840,5 +839,80 @@ ControlledDhcpv4Srv::deleteExpiredReclaimedLeases(const uint32_t secs) {
TimerMgr::instance()->setup(CfgExpiration::FLUSH_RECLAIMED_TIMER_NAME);
}

void
ControlledDhcpv4Srv::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
bool reopened = false;

// Re-open lease and host database with new parameters.
try {
CfgDbAccessPtr cfg_db = CfgMgr::instance().getCurrentCfg()->getCfgDbAccess();
cfg_db->createManagers(boost::bind(&ControlledDhcpv4Srv::dbLostCallback, this, _1));
reopened = true;
} catch (const std::exception& ex) {
LOG_ERROR(dhcp4_logger, DHCP4_DB_RECONNECT_ATTEMPT_FAILED).arg(ex.what());
}

if (reopened) {
// Cancel the timer.
if (TimerMgr::instance()->isTimerRegistered("Dhcp4DbReconnectTimer")) {
TimerMgr::instance()->cancel("Dhcp4DbReconnectTimer");
}

// Set network state to service enabled
network_state_.enableService();

// Toss the reconnect control, we're done with it
db_reconnect_ctl.reset();
} else {
if (!db_reconnect_ctl->checkRetries()) {
LOG_ERROR(dhcp4_logger, DHCP4_DB_RECONNECT_RETRIES_EXHAUSTED)
.arg(db_reconnect_ctl->maxRetries());
shutdown();
return;
}

LOG_INFO(dhcp4_logger, DHCP4_DB_RECONNECT_ATTEMPT_SCHEDULE)
.arg(db_reconnect_ctl->maxRetries() - db_reconnect_ctl->retriesLeft() + 1)
.arg(db_reconnect_ctl->maxRetries())
.arg(db_reconnect_ctl->retryInterval());

if (!TimerMgr::instance()->isTimerRegistered("Dhcp4DbReconnectTimer")) {
TimerMgr::instance()->registerTimer("Dhcp4DbReconnectTimer",
boost::bind(&ControlledDhcpv4Srv::dbReconnect, this,
db_reconnect_ctl),
db_reconnect_ctl->retryInterval() * 1000,
asiolink::IntervalTimer::ONE_SHOT);
}

TimerMgr::instance()->setup("Dhcp4DbReconnectTimer");
}
}

bool
ControlledDhcpv4Srv::dbLostCallback(ReconnectCtlPtr db_reconnect_ctl) {
// Disable service until we recover
network_state_.disableService();

if (!db_reconnect_ctl) {
// This shouldn't never happen
LOG_ERROR(dhcp4_logger, DHCP4_DB_RECONNECT_NO_DB_CTL);
return (false);
}

// If reconnect isn't enabled, log it and return false
if (!db_reconnect_ctl->retriesLeft() ||
!db_reconnect_ctl->retryInterval()) {
LOG_INFO(dhcp4_logger, DHCP4_DB_RECONNECT_DISABLED)
.arg(db_reconnect_ctl->retriesLeft())
.arg(db_reconnect_ctl->retryInterval());
return(false);
}

// Invoke reconnect method
dbReconnect(db_reconnect_ctl);

return(true);
}

}; // end of isc::dhcp namespace
}; // end of isc namespace
43 changes: 42 additions & 1 deletion src/bin/dhcp4/ctrl_dhcp4_srv.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2018 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
Expand All @@ -11,6 +11,7 @@
#include <asiolink/asiolink.h>
#include <cc/data.h>
#include <cc/command_interpreter.h>
#include <dhcpsrv/database_connection.h>
#include <dhcpsrv/timer_mgr.h>
#include <dhcp4/dhcp4_srv.h>

Expand Down Expand Up @@ -317,6 +318,46 @@ class ControlledDhcpv4Srv : public isc::dhcp::Dhcpv4Srv {
/// deleted.
void deleteExpiredReclaimedLeases(const uint32_t secs);

/// @brief Attempts to reconnect the server to the DB backend managers
///
/// This is a self-rescheduling function that attempts to reconnect to the
/// server's DB backends after connectivity to one or more have been
/// lost. Upon entry it will attempt to reconnect via @ref CfgDdbAccess::
/// createManagers. If this is succesful, DHCP servicing is re-enabled and
/// server returns to normal operation.
///
/// If reconnection fails and the maximum number of retries has not been
/// exhausted, it will schedule a call to itself to occur at the
/// configured retry interval. DHCP service remains disabled.
///
/// If the maximum number of retries has been exhausted an error is logged
/// and the server shuts down.
///
/// @param db_reconnect_ctl pointer to the ReconnectCtl containing the
/// configured reconnect parameters
///
void dbReconnect(ReconnectCtlPtr db_reconnect_ctl);

/// @brief Callback DB backends should invoke upon loss of connectivity
///
/// This function is invoked by DB backends when they detect a loss of
/// connectivity. The parameter, db_reconnect_ctl, conveys the configured
/// maximum number of reconnect retries as well as the interval to wait
/// between retry attempts.
///
/// If either value is zero, reconnect is presumed to be disabled and
/// the function will returns false. This instructs the DB backend
/// layer (the caller) to treat the connectivity loss as fatal.
///
/// Otherwise, the function saves db_reconnect_ctl and invokes
/// dbReconnect to initiate the reconnect process.
///
/// @param db_reconnect_ctl pointer to the ReconnectCtl containing the
/// configured reconnect parameters
///
/// @return false if reconnect is not configured, true otherwise
bool dbLostCallback(ReconnectCtlPtr db_reconnect_ctl);

/// @brief Static pointer to the sole instance of the DHCP server.
///
/// This is required for config and command handlers to gain access to
Expand Down
Loading

0 comments on commit 33e4b4f

Please sign in to comment.