Commit 5b9b5e26 authored by Thomas Markwalder's avatar Thomas Markwalder

[5564] Servers dump cached and parked packets on reconfig and shutdown

src/bin/dhcp4/dhcp4_srv.*
    - dumpPackets() - new function that frees all cached and parked packets
    - Dhcpv4Srv::~Dhcpv4Srv() - added call to dumpPackets() for cleanliness

src/bin/dhcp4/json_config_parser.cc
    configureDhcp4Server() - added a call Dhcpv4Srv::dumpPackets()

src/bin/dhcp6/dhcp6_srv.*
    - dumpPackets() - new function that frees all cached and parked packets
    - Dhcpv6Srv::~Dhcpv6Srv() - added call to dumpPackets() for cleanliness

src/bin/dhcp6/json_config_parser.cc
    configureDhcp6Server() - added a call Dhcpv6Srv::dumpPackets()

src/lib/hooks/hooks_manager.h
    - clearParkingLots() - new convenience function for clearing
     all parking lots
    - clearParkingLotsInternal() - private impl of the above
parent a8b6b26e
......@@ -459,6 +459,9 @@ Dhcpv4Srv::Dhcpv4Srv(uint16_t port, const bool use_bcast,
}
Dhcpv4Srv::~Dhcpv4Srv() {
// Discard any cached packets or parked packets
dumpPackets();
try {
stopD2();
} catch(const std::exception& ex) {
......@@ -3586,5 +3589,13 @@ int Dhcpv4Srv::getHookIndexLease4Decline() {
return (Hooks.hook_index_lease4_decline_);
}
void Dhcpv4Srv::dumpPackets() {
// 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 dumpPackets();
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.dumpPackets();
}
// Revert any runtime option definitions configured so far and not committed.
......
......@@ -218,6 +218,7 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port)
}
Dhcpv6Srv::~Dhcpv6Srv() {
dumpPackets();
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::dumpPackets() {
// Dump all of our current packets, anything that is mid-stream
isc::dhcp::Pkt6Ptr pkt6ptr_empty;
isc::dhcp::getCalloutHandle(pkt6ptr_empty);
ServerHooks::getServerHooks().getParkingLotsPtr()->clear();
}
};
};
......@@ -174,6 +174,11 @@ public:
NameChangeSender::Result result,
dhcp_ddns::NameChangeRequestPtr& ncr);
/// @brief Dumps cached and parked packets
/// Clears the call_handle store and packet parking lots
/// of all packets. Called during reconfigure and shutdown.
void dumpPackets();
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.dumpPackets();
}
// Revert any runtime option definitions configured so far and not committed.
......
......@@ -310,6 +310,10 @@ public:
getHooksManager().referenceInternal(hook_name, parked_object);
}
static void clearParkingLots() {
getHooksManager().clearParkingLotsInternal();
}
private:
/// @brief Constructor
......@@ -367,6 +371,10 @@ private:
getParkingLotPtr(hook_name)->reference(parked_object);
}
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