mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 22:15:23 +00:00
[4267] Finished merge of trac4266 (run_one server routine)
This commit is contained in:
@@ -449,10 +449,17 @@ This error message is issued when preparing an on-wire format of the packet
|
||||
has failed. The first argument identifies the client and the DHCP transaction.
|
||||
The second argument includes the error string.
|
||||
|
||||
% DHCP4_PACKET_PROCESS_EXCEPTION exception occurred during packet processing: %1
|
||||
This error message indicates that an exception was raised during packet processing
|
||||
that was not caught by other, more specific exception handlers. This packet will
|
||||
be dropped and the server will continue operation.
|
||||
% DHCP4_PACKET_PROCESS_EXCEPTION exception occurred during packet processing
|
||||
This error message indicates that a non-standard exception was raised
|
||||
during packet processing that was not caught by other, more specific
|
||||
exception handlers. This packet will be dropped and the server will
|
||||
continue operation.
|
||||
|
||||
% DHCP4_PACKET_PROCESS_STD_EXCEPTION exception occurred during packet processing: %1
|
||||
This error message indicates that a standard exception was raised
|
||||
during packet processing that was not caught by other, more specific
|
||||
exception handlers. This packet will be dropped and the server will
|
||||
continue operation.
|
||||
|
||||
% DHCP4_PACKET_RECEIVED %1: %2 (type %3) received from %4 to %5 on interface %6
|
||||
A debug message noting that the server has received the specified type of
|
||||
|
@@ -415,10 +415,29 @@ Dhcpv4Srv::sendPacket(const Pkt4Ptr& packet) {
|
||||
bool
|
||||
Dhcpv4Srv::run() {
|
||||
while (!shutdown_) {
|
||||
try {
|
||||
run_one();
|
||||
} catch (const std::exception& e) {
|
||||
// General catch-all exception that are not caught by more specific
|
||||
// catches. This one is for exceptions derived from std::exception.
|
||||
LOG_ERROR(packet4_logger, DHCP4_PACKET_PROCESS_STD_EXCEPTION)
|
||||
.arg(e.what());
|
||||
} catch (...) {
|
||||
// General catch-all exception that are not caught by more specific
|
||||
// catches. This one is for other exceptions, not derived from
|
||||
// std::exception.
|
||||
LOG_ERROR(packet4_logger, DHCP4_PACKET_PROCESS_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
void
|
||||
Dhcpv4Srv::run_one() {
|
||||
// client's message and server's response
|
||||
Pkt4Ptr query;
|
||||
|
||||
try {
|
||||
Pkt4Ptr rsp;
|
||||
|
||||
try {
|
||||
uint32_t timeout = 1000;
|
||||
@@ -444,14 +463,13 @@ Dhcpv4Srv::run() {
|
||||
.arg(timeout);
|
||||
}
|
||||
|
||||
} catch (const SignalInterruptOnSelect&) {
|
||||
} catch (const SignalInterruptOnSelect) {
|
||||
// Packet reception interrupted because a signal has been received.
|
||||
// This is not an error because we might have received a SIGTERM,
|
||||
// SIGINT, SIGHUP or SIGCHILD which are handled by the server. For
|
||||
// signals that are not handled by the server we rely on the default
|
||||
// behavior of the system.
|
||||
LOG_DEBUG(packet4_logger, DBG_DHCP4_DETAIL,
|
||||
DHCP4_BUFFER_WAIT_SIGNAL)
|
||||
LOG_DEBUG(packet4_logger, DBG_DHCP4_DETAIL, DHCP4_BUFFER_WAIT_SIGNAL)
|
||||
.arg(signal_set_->getNext());
|
||||
} catch (const std::exception& e) {
|
||||
// Log all other errors.
|
||||
@@ -481,35 +499,21 @@ Dhcpv4Srv::run() {
|
||||
// with no reception occurred. No need to log anything here because
|
||||
// we have logged right after the call to receivePacket().
|
||||
if (!query) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
processPacket(query);
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
// General catch-all exception that are not caught by more specific
|
||||
// catches. This one is for exceptions derived from std::exception.
|
||||
LOG_ERROR(packet4_logger, DHCP4_PACKET_PROCESS_EXCEPTION)
|
||||
.arg(e.what());
|
||||
} catch (...) {
|
||||
// General catch-all exception that are not caught by more specific
|
||||
// catches. This one is for other exceptions, not derived from
|
||||
// std::exception.
|
||||
LOG_ERROR(packet4_logger, DHCP4_PACKET_PROCESS_EXCEPTION)
|
||||
.arg("an unknown exception not derived from std::exception");
|
||||
}
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
void
|
||||
Dhcpv4Srv::processPacket(Pkt4Ptr& query) {
|
||||
Pkt4Ptr rsp;
|
||||
|
||||
// Log reception of the packet. We need to increase it early, as any
|
||||
// failures in unpacking will cause the packet to be dropped. We
|
||||
// will increase type specific statistoc further down the road.
|
||||
// will increase type specific statistic further down the road.
|
||||
// See processStatsReceived().
|
||||
isc::stats::StatsMgr::instance().addValue("pkt4-received",
|
||||
static_cast<int64_t>(1));
|
||||
@@ -712,9 +716,6 @@ Dhcpv4Srv::processPacket(Pkt4Ptr& query) {
|
||||
// Clear skip flag if it was set in previous callouts
|
||||
callout_handle->setStatus(CalloutHandle::NEXT_STEP_CONTINUE);
|
||||
|
||||
// Also pass the corresponding query packet as argument
|
||||
callout_handle->setArgument("query4", query);
|
||||
|
||||
// Set our response
|
||||
callout_handle->setArgument("response4", rsp);
|
||||
|
||||
|
@@ -208,13 +208,18 @@ public:
|
||||
|
||||
/// @brief Main server processing loop.
|
||||
///
|
||||
/// Main server processing loop. Receives incoming packets, and calls
|
||||
/// processPacket for each of them.
|
||||
/// Main server processing loop. Call the processing one routine
|
||||
/// until shut down.
|
||||
///
|
||||
/// @return true, if being shut down gracefully, fail if experienced
|
||||
/// critical error.
|
||||
/// @return true, if being shut down gracefully, never fail.
|
||||
bool run();
|
||||
|
||||
/// @brief Main server processing one.
|
||||
///
|
||||
/// Main server processing one. Receives one incoming packet, calls
|
||||
/// the processing packet routing,
|
||||
void run_one();
|
||||
|
||||
/// @brief Process a single incoming DHCPv4 packet.
|
||||
///
|
||||
/// It verifies correctness of the passed packet, call per-type processXXX
|
||||
|
@@ -417,16 +417,23 @@ because packets of this type must be sent to multicast. The first argument
|
||||
specifies the client and transaction identification information, the
|
||||
second argument specifies packet type.
|
||||
|
||||
% DHCP6_PACKET_PROCESS_EXCEPTION exception occurred during packet processing: %1
|
||||
This error message indicates that an exception was raised during packet processing
|
||||
that was not caught by other, more specific exception handlers. This packet will
|
||||
be dropped and the server will continue operation.
|
||||
% DHCP6_PACKET_PROCESS_EXCEPTION exception occurred during packet processing
|
||||
This error message indicates that a non-standard exception was raised
|
||||
during packet processing that was not caught by other, more specific
|
||||
exception handlers. This packet will be dropped and the server will
|
||||
continue operation.
|
||||
|
||||
% DHCP6_PACKET_PROCESS_FAIL processing of %1 message received from %2 failed: %3
|
||||
This is a general catch-all message indicating that the processing of the
|
||||
specified packet type from the indicated address failed. The reason is given in the
|
||||
message. The server will not send a response but will instead ignore the packet.
|
||||
|
||||
% DHCP6_PACKET_PROCESS_STD_EXCEPTION exception occurred during packet processing: %1
|
||||
This error message indicates that a standard exception was raised
|
||||
during packet processing that was not caught by other, more specific
|
||||
exception handlers. This packet will be dropped and the server will
|
||||
continue operation.
|
||||
|
||||
% DHCP6_PACKET_RECEIVED %1: %2 (type %3) received from %4 to %5 on interface %6
|
||||
A debug message noting that the server has received the specified type of
|
||||
packet on the specified interface. The first argument specifies the
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
|
||||
// Copyright (C) 2011-2016 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
|
||||
@@ -288,12 +288,28 @@ Dhcpv6Srv::createContext(const Pkt6Ptr& pkt) {
|
||||
|
||||
bool Dhcpv6Srv::run() {
|
||||
while (!shutdown_) {
|
||||
try {
|
||||
run_one();
|
||||
} catch (const std::exception& e) {
|
||||
// General catch-all standard exceptions that are not caught by more
|
||||
// specific catches.
|
||||
LOG_ERROR(packet6_logger, DHCP6_PACKET_PROCESS_STD_EXCEPTION)
|
||||
.arg(e.what());
|
||||
} catch (...) {
|
||||
// General catch-all non-standard exception that are not caught
|
||||
// by more specific catches.
|
||||
LOG_ERROR(packet6_logger, DHCP6_PACKET_PROCESS_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
void Dhcpv6Srv::run_one() {
|
||||
// client's message and server's response
|
||||
Pkt6Ptr query;
|
||||
Pkt6Ptr rsp;
|
||||
|
||||
try {
|
||||
|
||||
try {
|
||||
uint32_t timeout = 1000;
|
||||
LOG_DEBUG(packet6_logger, DBG_DHCP6_DETAIL, DHCP6_BUFFER_WAIT).arg(timeout);
|
||||
@@ -357,7 +373,7 @@ bool Dhcpv6Srv::run() {
|
||||
// Timeout may be reached or signal received, which breaks select()
|
||||
// with no packet received
|
||||
if (!query) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
// In order to parse the DHCP options, the server needs to use some
|
||||
@@ -425,7 +441,7 @@ bool Dhcpv6Srv::run() {
|
||||
static_cast<int64_t>(1));
|
||||
StatsMgr::instance().addValue("pkt6-receive-drop",
|
||||
static_cast<int64_t>(1));
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,7 +454,7 @@ bool Dhcpv6Srv::run() {
|
||||
|
||||
// Increase the statistic of dropped packets.
|
||||
StatsMgr::instance().addValue("pkt6-receive-drop", static_cast<int64_t>(1));
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the received query has been sent to unicast or multicast.
|
||||
@@ -448,7 +464,7 @@ bool Dhcpv6Srv::run() {
|
||||
|
||||
// Increase the statistic of dropped packets.
|
||||
StatsMgr::instance().addValue("pkt6-receive-drop", static_cast<int64_t>(1));
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_DEBUG(packet6_logger, DBG_DHCP6_BASIC_DATA, DHCP6_PACKET_RECEIVED)
|
||||
@@ -483,7 +499,7 @@ bool Dhcpv6Srv::run() {
|
||||
if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) {
|
||||
LOG_DEBUG(hooks_logger, DBG_DHCP6_HOOKS, DHCP6_HOOK_PACKET_RCVD_SKIP)
|
||||
.arg(query->getLabel());
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
/// @todo: Add support for DROP status.
|
||||
@@ -636,7 +652,7 @@ bool Dhcpv6Srv::run() {
|
||||
} catch (const std::exception& e) {
|
||||
LOG_ERROR(options6_logger, DHCP6_PACK_FAIL)
|
||||
.arg(e.what());
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -665,7 +681,7 @@ bool Dhcpv6Srv::run() {
|
||||
if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) {
|
||||
LOG_DEBUG(hooks_logger, DBG_DHCP6_HOOKS, DHCP6_HOOK_BUFFER_SEND_SKIP)
|
||||
.arg(rsp->getLabel());
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
/// @todo: Add support for DROP status
|
||||
@@ -687,21 +703,6 @@ bool Dhcpv6Srv::run() {
|
||||
.arg(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
// General catch-all standard exceptions that are not caught by more
|
||||
// specific catches.
|
||||
LOG_ERROR(packet6_logger, DHCP6_PACKET_PROCESS_EXCEPTION)
|
||||
.arg(e.what());
|
||||
} catch (...) {
|
||||
// General catch-all non-standard exception that are not caught
|
||||
// by more specific catches.
|
||||
LOG_ERROR(packet6_logger, DHCP6_PACKET_PROCESS_EXCEPTION)
|
||||
.arg("an unknown exception not derived from std::exception");
|
||||
}
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
std::string
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
|
||||
// Copyright (C) 2011-2016 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
|
||||
@@ -89,14 +89,19 @@ public:
|
||||
|
||||
/// @brief Main server processing loop.
|
||||
///
|
||||
/// Main server processing loop. Receives incoming packets, verifies
|
||||
/// their correctness, generates appropriate answer (if needed) and
|
||||
/// transmits responses.
|
||||
/// Main server processing loop. Call the processing one routine
|
||||
/// until shut down.
|
||||
///
|
||||
/// @return true, if being shut down gracefully, fail if experienced
|
||||
/// critical error.
|
||||
/// @return true, if being shut down gracefully, never fail.
|
||||
bool run();
|
||||
|
||||
/// @brief Main server processing one.
|
||||
///
|
||||
/// Main server processing one. Receives one incoming packet, verifies
|
||||
/// its correctness, generates appropriate answer (if needed) and
|
||||
/// transmits response.
|
||||
void run_one();
|
||||
|
||||
/// @brief Instructs the server to shut down.
|
||||
void shutdown();
|
||||
|
||||
|
Reference in New Issue
Block a user