Commit 75ce722c authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

Merge branch 'master' of ssh://git.kea.isc.org/git/kea

# Conflicts:
#	ChangeLog
parents e39edaed d9b05db8
1401. [bug] tomek
1402. [bug] tomek
Fixed a crash that was caused by hook library registering
new hook points. This fixes unit-tests with forensic
logging, but the problem was generic and could cause
other libraries to segfault during unloading or reconfiguration.
(Trac 5577, git 2f9d1aa95c16e12fabc50d581b966f20b6d8a950)
1400. [func] tmark
1401. [bug] tmark
Corrected an issue which caused kea-dhcp4 and kea-dhcp6 servers
to unload their hooks libraries upon receipt of the first client
message following a dynamic reconfigure.
(Trac #5564, git 5111f569bd251c2a98a2e6d958e8f6b640a1802d)
1400. [func] tmark
A new hooks library, Stat Cmds, has been added to the open source
distribution. This library provides commands for fetching lease
allocation statistics using lease backend as the source for
......
......@@ -459,6 +459,9 @@ Dhcpv4Srv::Dhcpv4Srv(uint16_t port, const bool use_bcast,
}
Dhcpv4Srv::~Dhcpv4Srv() {
// Discard any cached packets or parked packets
discardPackets();
try {
stopD2();
} catch(const std::exception& ex) {
......@@ -3588,5 +3591,13 @@ int Dhcpv4Srv::getHookIndexLease4Decline() {
return (Hooks.hook_index_lease4_decline_);
}
void Dhcpv4Srv::discardPackets() {
// Clear any packets held by the callhout handle store and
// all parked packets
isc::dhcp::Pkt4Ptr pkt4ptr_empty;
isc::dhcp::getCalloutHandle(pkt4ptr_empty);
HooksManager::clearParkingLots();
}
} // namespace dhcp
} // namespace isc
......@@ -329,6 +329,10 @@ public:
virtual void d2ClientErrorHandler(const dhcp_ddns::
NameChangeSender::Result result,
dhcp_ddns::NameChangeRequestPtr& ncr);
/// @brief Discard all in-progress packets
void discardPackets();
protected:
/// @name Functions filtering and sanity-checking received messages.
......
......@@ -8,6 +8,7 @@
#include <cc/command_interpreter.h>
#include <dhcp4/dhcp4_log.h>
#include <dhcp4/dhcp4_srv.h>
#include <dhcp/libdhcp++.h>
#include <dhcp/option_definition.h>
#include <dhcpsrv/cfg_option.h>
......@@ -272,7 +273,7 @@ void configureCommandChannel() {
}
isc::data::ConstElementPtr
configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set,
configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
bool check_only) {
if (!config_set) {
ConstElementPtr answer = isc::config::createAnswer(1,
......@@ -290,6 +291,7 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set,
// Remove any existing timers.
if (!check_only) {
TimerMgr::instance()->unregisterTimers();
server.discardPackets();
}
// Revert any runtime option definitions configured so far and not committed.
......
......@@ -218,6 +218,7 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port)
}
Dhcpv6Srv::~Dhcpv6Srv() {
discardPackets();
try {
stopD2();
} catch(const std::exception& ex) {
......@@ -3761,6 +3762,12 @@ Dhcpv6Srv::requestedInORO(const Pkt6Ptr& query, const uint16_t code) const {
return (false);
}
void Dhcpv6Srv::discardPackets() {
// Dump all of our current packets, anything that is mid-stream
isc::dhcp::Pkt6Ptr pkt6ptr_empty;
isc::dhcp::getCalloutHandle(pkt6ptr_empty);
HooksManager::clearParkingLots();
}
};
};
......@@ -174,6 +174,11 @@ public:
NameChangeSender::Result result,
dhcp_ddns::NameChangeRequestPtr& ncr);
/// @brief Discards cached and parked packets
/// Clears the call_handle store and packet parking lots
/// of all packets. Called during reconfigure and shutdown.
void discardPackets();
protected:
/// @brief Compare received server id with our server id
......
......@@ -13,6 +13,7 @@
#include <dhcp/libdhcp++.h>
#include <dhcp6/json_config_parser.h>
#include <dhcp6/dhcp6_log.h>
#include <dhcp6/dhcp6_srv.h>
#include <dhcp/iface_mgr.h>
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/cfgmgr.h>
......@@ -369,7 +370,7 @@ void configureCommandChannel() {
}
isc::data::ConstElementPtr
configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set,
configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
bool check_only) {
if (!config_set) {
......@@ -388,6 +389,7 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set,
// Remove any existing timers.
if (!check_only) {
TimerMgr::instance()->unregisterTimers();
server.discardPackets();
}
// Revert any runtime option definitions configured so far and not committed.
......
......@@ -310,6 +310,15 @@ public:
getHooksManager().referenceInternal(hook_name, parked_object);
}
/// @brief Clears any parking packets.
///
/// This method should be called during reconfiguration to ensure there
/// are no dangling pointers that could possibly prevent the library
/// from being unloaded.
static void clearParkingLots() {
getHooksManager().clearParkingLotsInternal();
}
private:
/// @brief Constructor
......@@ -367,6 +376,13 @@ private:
getParkingLotPtr(hook_name)->reference(parked_object);
}
/// @brief Clears all pointers stored in parking lots.
///
/// See @ref clearParkingLots for explanation.
void clearParkingLotsInternal() {
ServerHooks::getServerHooks().getParkingLotsPtr()->clear();
}
//@{
/// The following methods correspond to similarly-named static methods,
/// but actually do the work on the singleton instance of the HooksManager.
......
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