Kea 3.1.3
ping_check_mgr.cc
Go to the documentation of this file.
1// Copyright (C) 2023-2025 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <ping_check_mgr.h>
10#include <ping_check_log.h>
11#include <dhcpsrv/cfgmgr.h>
12#include <hooks/hooks_manager.h>
15
16using namespace isc;
17using namespace isc::asiolink;
18using namespace isc::dhcp;
19using namespace isc::data;
20using namespace isc::hooks;
21using namespace isc::util;
22using namespace std;
23using namespace std::chrono;
24
25namespace ph = std::placeholders;
26
27namespace isc {
28namespace ping_check {
29
33 channel_(),
35 mutex_(new mutex()),
36 suspended_(false) {
37}
38
39PingCheckMgr::PingCheckMgr(uint32_t num_threads,
40 uint32_t min_echos,
41 uint32_t reply_timeout)
44 channel_(),
46 mutex_(new mutex()),
47 suspended_(false) {
49 config->setMinPingRequests(min_echos);
50 config->setReplyTimeout(reply_timeout);
51 config->setPingChannelThreads(num_threads);
52 config_cache_->setGlobalConfig(config);
53}
54
58
59void
61 if (!params) {
62 isc_throw(dhcp::DhcpConfigError, "params must not be null");
63 return;
64 }
65
66 if (params->getType() != Element::map) {
67 isc_throw(dhcp::DhcpConfigError, "params must be an Element::map");
68 return;
69 }
70
72 config->parse(params);
73 config_cache_->setGlobalConfig(config);
74}
75
76void
78 // Iterate over subnets and cache configurations for each.
79 ConfigCachePtr local_cache(new ConfigCache());
80 local_cache->setGlobalConfig(config_cache_->getGlobalConfig());
81 auto const& subnets = server_config->getCfgSubnets4()->getAll();
82 for (auto const& subnet : (*subnets)) {
83 auto user_context = subnet->getContext();
84 local_cache->parseAndCacheConfig(subnet->getID(), user_context);
85 }
86
87 // No errors above, replace the existing cache.
88 config_cache_ = local_cache;
89}
90
93 return (config_cache_->getGlobalConfig());
94}
95
98 if (!lease) {
99 // This really shouldn't happen.
100 isc_throw(InvalidOperation, "PingCheckConfig::getScopedConfig() - lease cannot be empty");
101 }
102
103 auto subnet_id = lease->subnet_id_;
104
105 // If the cache is stale, update it. We do this to catch subnets that have been updated
106 // via subnet_cmds.
107 auto server_config = CfgMgr::instance().getCurrentCfg();
108 auto const& subnet = server_config->getCfgSubnets4()->getBySubnetId(subnet_id);
109 if (!subnet) {
110 // This really shouldn't happen.
111 isc_throw(InvalidOperation, "PingCheckMgr::getScopedConfig() - "
112 "no subnet for id: " << subnet_id
113 << ", for lease address: " << lease->addr_);
114 }
115
116 // If cache is stale flush it and we'll lazy init subnets as we see them.
117 if (subnet->getModificationTime() > config_cache_->getLastFlushTime()) {
118 config_cache_->flush();
119 }
120
121 // If we don't find an entry for this subnet then we haven't seen it
122 // before so parse and cache it. If the subnet doesn't specify ping-check
123 // we cache an empty entry.
125 if (!config_cache_->findConfig(subnet_id, config)) {
126 auto user_context = subnet->getContext();
127 try {
128 config = config_cache_->parseAndCacheConfig(subnet_id, user_context);
129 } catch (const std::exception& ex) {
130 // We emit and error and then cache an empty entry. This causes us
131 // to log the error once and then default to global settings afterward.
132 // This avoids us relentlessly logging and failing. Remember this
133 // is happening because a subnet was updated with an invalid context via
134 // subnet-cmd.
136 .arg(subnet_id)
137 .arg(ex.what());
138 config_cache_->cacheConfig(subnet_id, config);
139 }
140 }
141
142 // Return subnet's ping-check config if it specified one, otherwise
143 // return the global config.
144 return (config ? config : config_cache_->getGlobalConfig());
145}
146
147void
149 const PingCheckConfigPtr& config) {
150 if (checkSuspended()) {
151 // Server should not be submitting requests.
152 isc_throw(InvalidOperation, "PingCheckMgr::startPing() - DHCP service is suspended!");
153 }
154
155 if (!channel_ || !channel_->isOpen()) {
156 isc_throw(InvalidOperation, "PingCheckMgr::startPing() - channel isn't open");
157 }
158
161 .arg(lease->addr_)
162 .arg(query->getLabel());
163
164 // Adds a context to the store
165 store_->addContext(lease, query, config->getMinPingRequests(),
166 config->getReplyTimeout(), parking_lot);
167
168 // Posts a call to channel's startSend() and startRead(). This will kick-start perpetual
169 // write and read cycles if they are not already running.
170 if (channel_) {
171 channel_->startSend();
172 channel_->startRead();
173 }
174}
175
176void
178 startPing(lease, query, parking_lot, getGlobalConfig());
179}
180
183 if (!checkSuspended()) {
184 return (store_->getNextToSend());
185 }
186
187 return (PingContextPtr());
188}
189
190void
192 // Transition to sending.
193 // Must not call @ref PingCheckMgr::checkSuspended() or
194 // it will cause a deadlock.
195 context->setState(PingContext::SENDING);
196 store_->updateContext(context);
197}
198
199void
200PingCheckMgr::sendCompleted(const ICMPMsgPtr& echo, bool send_failed) {
201 if (checkSuspended()) {
202 return;
203 }
204
205 try {
206 if (!echo) {
207 isc_throw(BadValue, "PingCheckMgr::sendCompleted() - echo is empty");
208 }
209
210 if (echo->getType() != ICMPMsg::ECHO_REQUEST) {
211 isc_throw(BadValue, "PingCheckMgr::sendCompleted() - message type: "
212 << echo->getType() << " is not an ECHO_REQUEST");
213 }
214
215 // Update the context associated with this ECHO_REQUEST.
216 PingContextPtr context = store_->getContextByAddress(echo->getDestination());
217 if (!context) {
218 isc_throw(Unexpected, "PingCheckMgr::sendCompleted() "
219 " no context found for: " << echo->getDestination());
220 }
221
222 if (send_failed) {
223 // Recoverable error occurred which means we can't get to the target's
224 // network (interface down?). Treat this the same as TARGET UNREACHABLE.
225 finishFree(context);
226 } else {
227 // Transition the context to WAITING_FOR_REPLY.
228 context->beginWaitingForReply();
229 store_->updateContext(context);
230 }
231
232 // Update the expiration timer if necessary.
234 } catch (const std::exception& ex) {
236 .arg(ex.what());
237 }
238}
239
240void
242 if (checkSuspended()) {
243 return;
244 }
245
246 try {
247 if (!reply) {
248 isc_throw(BadValue, "PingCheckMgr::replyReceived() - echo is empty");
249 }
250
251 switch (reply->getType()) {
253 handleEchoReply(reply);
254 break;
256 // Extract embedded ECHO REQUEST
258 break;
259 default:
260 // Ignore anything else.
261 return;
262 }
263
265 } catch (const std::exception& ex) {
267 .arg(ex.what());
268 }
269}
270
271void
273 // Update the context associated with this ECHO_REQUEST.
274 PingContextPtr context = store_->getContextByAddress(echo_reply->getSource());
275 if (!context) {
278 .arg(echo_reply->getSource())
279 .arg(echo_reply->getId())
280 .arg(echo_reply->getSequence());
281 return;
282 }
283
286 .arg(echo_reply->getSource())
287 .arg(echo_reply->getId())
288 .arg(echo_reply->getSequence());
289
290 context->setState(PingContext::TARGET_IN_USE);
291 store_->updateContext(context);
292
293 // If parking is employed, unpark the query from the parking lot,
294 // and set the offer_address_in_use argument in the callout handle
295 // to true, indicating to the server that the lease should be declined
296 // and the DHCPOFFER discarded.
297 auto parking_lot = context->getParkingLot();
298 if (parking_lot) {
299 auto query = context->getQuery();
300 auto callout_handle = query->getCalloutHandle();
301 callout_handle->setArgument("offer_address_in_use", true);
302 parking_lot->unpark(query);
303 }
304
305 // Remove the context from the store.
306 store_->deleteContext(context);
307}
308
309void
311 // Unpack the embedded ECHO REQUEST.
312 ICMPMsgPtr embedded_echo;
313 auto payload = unreachable->getPayload();
314 embedded_echo = ICMPMsg::unpack(payload.data(), payload.size());
315
316 // Fetch the context associated with the ECHO_REQUEST.
317 PingContextPtr context = store_->getContextByAddress(embedded_echo->getDestination());
318 if (!context) {
321 .arg(embedded_echo->getDestination())
322 .arg(embedded_echo->getId())
323 .arg(embedded_echo->getSequence());
324 return;
325 }
326
329 .arg(embedded_echo->getDestination())
330 .arg(embedded_echo->getId())
331 .arg(embedded_echo->getSequence());
332
333 // Render the address usable.
334 finishFree(context);
335}
336
337void
339 context->setState(PingContext::TARGET_FREE);
340 store_->updateContext(context);
341
344 .arg(context->getTarget())
345 .arg(context->getQuery()->getLabel());
346
347 // If parking is employed, unpark the query from the parking lot,
348 // and set the offer_address_in_use argument in the callout handle
349 // to false, indicating to the server that the lease is available
350 // and the DHCPOFFER should be sent to the client.
351 auto parking_lot = context->getParkingLot();
352 if (parking_lot) {
353 auto query = context->getQuery();
354 auto callout_handle = query->getCalloutHandle();
355 callout_handle->setArgument("offer_address_in_use", false);
356 parking_lot->unpark(context->getQuery());
357 }
358
359 // Remove the context from the store.
360 store_->deleteContext(context);
361}
362
363void
366 if (io_service_) {
367 // As this is a callback that may be invoked by a channel
368 // thread we post a call to stopService() rather than call
369 // it directly.
370 io_service_->post([&]() { stopService(true); });
371 }
372}
373
374size_t
375PingCheckMgr::processExpiredSince(const TimeStamp& since /* = PingContext::now() */) {
376 auto expired_pings = store_->getExpiredSince(since);
377 size_t more_pings = 0;
378 for (auto const& context : *(expired_pings)) {
381 .arg(context->getTarget())
382 .arg(context->getEchosSent())
383 .arg(context->getMinEchos())
384 .arg(context->getReplyTimeout());
385
386 if (context->getEchosSent() < context->getMinEchos()) {
387 doNextEcho(context);
388 ++more_pings;
389 } else {
390 finishFree(context);
391 }
392 }
393
394 return (more_pings);
395}
396
397void
399 // Position to do another ping by re-entering WAITING_TO_SEND
402 .arg(context->getTarget())
403 .arg(context->getEchosSent() + 1)
404 .arg(context->getMinEchos());
405
406 context->beginWaitingToSend();
407 store_->updateContext(context);
408}
409
415
416void
425
426void
428 // Find the context that expires soonest.
429 PingContextPtr context = store_->getExpiresNext();
430 if (context) {
431 // if the context's expiry is sooner than current expiry
432 // reschedule expiration timer
434 (context->getNextExpiry() < next_expiry_)) {
435 auto now = PingContext::now();
436 auto timeout = duration_cast<milliseconds>(context->getNextExpiry() - now);
438 timeout = (timeout > milliseconds(2) ? timeout : milliseconds(2));
439 next_expiry_ = now + timeout;
441 shared_from_this()),
442 timeout.count(), IntervalTimer::ONE_SHOT);
443 }
444 } else {
445 // Nothing waiting to expire. Cancel the timer.
447 }
448}
449
450void
455
456void
463
464void
468 return;
469 }
470
471 // Process everything that has expired since current time.
472 auto more_pings = processExpiredSince();
473
474 // Update the expiration timer.
477
478 // In the event there was nothing left to process when timed out,
479 // poke the channel to make sure things are moving.
480 if (more_pings && channel_) {
481 channel_->startSend();
482 channel_->startRead();
483 }
484}
485
488 Lease4Ptr& old_lease,
489 ConstHostPtr host,
490 const PingCheckConfigPtr& config) {
491 // If ping-check is disabled or the channel isn't open,
492 // drop the query from parking and release the offer to the client.
493 if (!config->getEnablePingCheck() || !channel_ || !channel_->isOpen()) {
495 }
496
497 // If we're already running check on this address then drop the
498 // query from parking and discard the offer.
499 if (store_->getContextByAddress(lease->addr_)) {
502 .arg(lease->addr_)
503 .arg(query->getLabel());
505 }
506
507 // Reserved addresses are never checked.
508 if (host && (host->getIPv4Reservation() == lease->addr_)) {
510 }
511
512 // If there's a previous lease that belongs to this client and it either
513 // active or was touched by the client less than ping-cltt-secs ago then
514 // no check is needed. Drop the query from parking and release the
515 // offer to the client,
516 if (old_lease && (old_lease->addr_ == lease->addr_)) {
517 if (old_lease->belongsToClient(lease->hwaddr_, lease->client_id_)) {
518 if (!old_lease->expired() ||
519 ((time(0) - old_lease->cltt_) < config->getPingClttSecs())) {
521 }
522 }
523 }
524
525 // Leave it parked and do the ping check.
527}
528
529void
531 network_state_ = network_state;
532 io_service_->post([&]() { start(); });
533}
534
535bool
540
541bool
543 if (!network_state_ || network_state_->isServiceEnabled()) {
544 suspended_ = false;
545 } else {
546 if (!suspended_) {
547 suspended_ = true;
548
549 // Flush the context store, dropping parked queries.
550 flush(false);
551 }
552 }
553
554 return (suspended_);
555}
556
557void
558PingCheckMgr::stopService(bool finish_free) {
559 // Pause the thread pool while we flush the store.
560 pause();
561
562 // Flush the context store. If finish_free is true
563 // the flush will treat the remaining context lease
564 // addresses as free to use and unpark them. This
565 // will cause the server to send out the associated
566 // OFFERs. If it's false we just drop them from
567 // the parking lot.
568 flush(finish_free);
569
570 // Stop the thread pool, destroy the channel and the like.
571 stop();
572}
573
574void
576 if (MultiThreadingMgr::instance().isTestMode()) {
577 return;
578 }
579 if (!MultiThreadingMgr::instance().getMode()) {
581 return;
582 }
583
584 // We must be in multi-threading mode.
585 // Add critical section callbacks.
587 std::bind(&PingCheckMgr::checkPermissions, this),
588 std::bind(&PingCheckMgr::pause, this),
589 std::bind(&PingCheckMgr::resume, this));
590
591 // Punt if we're already started.
592 if (thread_pool_ && thread_pool_->isStopped()) {
593 isc_throw(InvalidOperation, "PingCheckMgr already started!");
594 }
595
596 try {
597 auto config = config_cache_->getGlobalConfig();
598 auto use_threads = (config->getPingChannelThreads() ? config->getPingChannelThreads()
599 : MultiThreadingMgr::instance().getThreadPoolSize());
600 thread_pool_.reset(new IoServiceThreadPool(IOServicePtr(), use_threads, true));
601 IOServicePtr pool_ios = thread_pool_->getIOService();
602 channel_ = createChannel(pool_ios);
603 channel_->open();
604 expiration_timer_.reset(new IntervalTimer(pool_ios));
605 thread_pool_->run();
607 .arg(use_threads);
608 } catch (const std::exception& ex) {
609 channel_.reset();
610 thread_pool_.reset();
611 isc_throw(Unexpected, "PingCheckMgr::start failed:" << ex.what());
612 }
613}
614
615void
617 try {
618 auto config = config_cache_->getGlobalConfig();
620 channel_->open();
623 } catch (const std::exception& ex) {
624 channel_.reset();
625 isc_throw(Unexpected, "PingCheckMgr::startSingleThreaded() failed:" << ex.what());
626 }
627}
628
631 return (PingChannelPtr(new PingChannel(io_service,
632 std::bind(&PingCheckMgr::nextToSend,
633 this),
635 this, ph::_1),
637 this, ph::_1, ph::_2),
639 this, ph::_1),
641 this))));
642}
643
644void
646 // Since this function is used as CS callback all exceptions must be
647 // suppressed, unlikely though they may be.
648 try {
649 if (thread_pool_) {
650 thread_pool_->checkPausePermissions();
651 }
652 } catch (const isc::MultiThreadingInvalidOperation& ex) {
654 .arg(ex.what());
655 // The exception needs to be propagated to the caller of the
656 // @ref MultiThreadingCriticalSection constructor.
657 throw;
658 } catch (const std::exception& ex) {
660 .arg(ex.what());
661 }
662}
663
664void
666 if (!MultiThreadingMgr::instance().getMode()) {
667 return;
668 }
669
670 // Since this function is used as CS callback all exceptions must be
671 // suppressed, unlikely though they may be.
672 try {
673 // Cancel the expiration timer.
675
676 // Pause the thread pool.
677 if (thread_pool_) {
678 thread_pool_->pause();
679 }
680 } catch (const std::exception& ex) {
682 .arg(ex.what());
683 }
684}
685
686void
688 if (!MultiThreadingMgr::instance().getMode()) {
689 return;
690 }
691
692 // Since this function is used as CS callback all exceptions must be
693 // suppressed, unlikely though they may be.
694 try {
695 if (thread_pool_) {
696 thread_pool_->run();
697 }
698
699 // Restore the expiration timer.
701 } catch (const std::exception& ex) {
703 .arg(ex.what());
704 }
705}
706
707void
710
711 // Cancel the expiration timer.
713
714 if (channel_) {
715 channel_->close();
716 }
717
718 if (thread_pool_) {
719 // Remove critical section callbacks.
721
722 // Stop the thread pool.
723 thread_pool_->stop();
724
725 thread_pool_->getIOService()->stopAndPoll();
726
727 // Ditch the thread_pool
728 thread_pool_.reset();
729 }
730 // Ditch the timer. It must be destroyed before the thread pool because in
731 // MT it holds a reference to the pool's IOService.
732 expiration_timer_.reset();
733
734 // Get rid of the channel.
735 channel_.reset();
736
737 if (io_service_) {
738 io_service_->stopAndPoll();
739 }
740
742}
743
744bool
746 // In ST mode, running is an open channel.
747 if (!MultiThreadingMgr::instance().getMode()) {
748 return (channel_ && channel_->isOpen());
749 }
750
751 if (thread_pool_) {
752 return (thread_pool_->isRunning());
753 }
754
755 return (false);
756}
757
758bool
760 // In ST mode, stopped equates to no channel.
761 if (!MultiThreadingMgr::instance().getMode()) {
762 return (!channel_);
763 }
764
765 if (thread_pool_) {
766 return (thread_pool_->isStopped());
767 }
768
769 return (true);
770}
771
772bool
774 if (thread_pool_) {
775 return (thread_pool_->isPaused());
776 }
777
778 return (false);
779}
780
781void
782PingCheckMgr::flush(bool finish_free /* = false */) {
783 if (!store_) {
784 return;
785 }
786
787 // Fetch them all.
788 auto contexts = store_->getAll();
789 for (auto const& context : *contexts) {
790 if (finish_free) {
791 finishFree(context);
792 } else {
793 auto parking_lot = context->getParkingLot();
794 if (parking_lot) {
795 parking_lot->drop(context->getQuery());
796 }
797 }
798 }
799
800 store_->clear();
801}
802
803} // end of namespace ping_check
804} // end of namespace isc
CalloutNextStep
Specifies allowed next steps.
@ map
Definition data.h:147
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown if a function is called in a prohibited way.
Exception thrown when a worker thread is trying to stop or pause the respective thread pool (which wo...
A generic exception that is thrown when an unexpected error condition occurs.
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition cfgmgr.cc:29
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Definition cfgmgr.cc:116
To be removed. Please use ConfigError instead.
@ NEXT_STEP_PARK
park the packet
@ NEXT_STEP_CONTINUE
continue normally
@ NEXT_STEP_DROP
drop the packet
ConfigCache stores ping check config per subnet.
static ICMPMsgPtr unpack(const uint8_t *wire_data, size_t length)
Unpacks an ICMP message from the given wire_data.
Definition icmp_msg.cc:30
Provides thread-safe ICMP ECHO REQUEST/ECHO REPLY service.
Houses the Ping check configuration parameters for a single scope (e.g.
virtual void channelShutdown()
Callback passed to PingChannel to invoke when it shuts down.
virtual void expirationTimedOut()
Callback passed to expiration timer to invoke on timeout.
virtual void updateContextToSend(PingContextPtr context)
Callback passed to PingChannel to update a context to SENDING state just before sending.
asiolink::IntervalTimerPtr expiration_timer_
Timer which tracks the next expiration event.
bool isRunning()
Indicates if the thread pool is running.
void checkPermissions()
Check if the current thread can perform thread pool state transition.
void configure(data::ConstElementPtr params)
Configure the PingCheckMgr.
asiolink::IoServiceThreadPoolPtr thread_pool_
Thread pool used when running multi-threaded.
void cancelExpirationTimerInternal()
Cancels the expiration timer.
TimeStamp next_expiry_
TimeStamp of the next expiration event.
virtual void setNextExpirationInternal()
Updates the expiration timer.
void stopService(bool finish_free=false)
Shuts down the manager's channel, flushes the store.
void resume()
Resume PingChannel operations.
void startService(dhcp::NetworkStatePtr network_state)
Performs a deferred start by posting an invocation of start() to the given IOService.
const PingCheckConfigPtr getScopedConfig(dhcp::Lease4Ptr &lease)
Fetches the current, scoped configuration parameters.
bool isStopped()
Indicates if the thread pool is stopped.
virtual PingChannelPtr createChannel(asiolink::IOServicePtr io_service)
Creates a ping channel instance.
const PingCheckConfigPtr getGlobalConfig() const
Fetches the current, global configuration parameters.
TimeStamp getNextExpiry()
Fetches the time at which expiration timer will next expire.
void handleTargetUnreachable(const ICMPMsgPtr &unreachable)
Process an UNREACHABLE message.
void startPing(dhcp::Lease4Ptr &lease, dhcp::Pkt4Ptr &query, hooks::ParkingLotHandlePtr &parking_lot, const PingCheckConfigPtr &config)
Initiates a ping check for a given lease and its associated DHCPDISCOVER packet.
void finishFree(const PingContextPtr &context)
Processes a context whose address has been deemed free to use.
const boost::scoped_ptr< std::mutex > mutex_
The mutex used to protect internal state.
virtual size_t processExpiredSince(const TimeStamp &since=PingContext::now())
Performs expiration processing for contexts whose WAITING_FOR_REPLY states expired prior to a given p...
bool checkSuspendedInternal()
Checks if operations are currently suspended due to NetworkState.
void pause()
Pause PingChannel operations.
virtual ~PingCheckMgr()
Destructor.
bool checkSuspended()
Checks if operations are currently suspended due to NetworkState.
void flush(bool finish_free=false)
Flushes the ping context store.
PingChannelPtr channel_
Channel that conducts ICMP messaging.
bool suspended_
Indicates whether or not operations have been suspended.
void cancelExpirationTimer()
Cancels the expiration timer (thread safe).
void start()
Start PingChannel operations.
void updateSubnetConfig(dhcp::SrvConfigPtr server_config)
Update the cache of subnet ping check configurations.
virtual void replyReceived(const ICMPMsgPtr &reply)
Callback passed to PingChannel to invoke when an ICMP reply has been received.
PingContextStorePtr store_
In-memory store of PingContexts.
virtual hooks::CalloutHandle::CalloutNextStep shouldPing(dhcp::Lease4Ptr &lease, dhcp::Pkt4Ptr &query, dhcp::Lease4Ptr &old_lease, dhcp::ConstHostPtr host, const PingCheckConfigPtr &config)
Determines whether or not a lease should be ping checked.
virtual PingContextPtr nextToSend()
Callback passed to PingChannel to use to retrieve the next context with address to check.
void startSingleThreaded()
Start single-threaded PingChannel operations.
void stop()
Stop PingChannel operations.
ConfigCachePtr config_cache_
Warehouses parsed global and subnet configuration.
isc::asiolink::IOServicePtr io_service_
The hook I/O service.
dhcp::NetworkStatePtr network_state_
Tracks whether or not the server is processing DHCP packets.
void handleEchoReply(const ICMPMsgPtr &echo_reply)
Process an ECHO REPLY message.
virtual void setNextExpiration()
Updates the expiration timer (thread safe).
void doNextEcho(const PingContextPtr &context)
Position a context to do another ping test.
virtual void sendCompleted(const ICMPMsgPtr &echo, bool send_failed)
Callback passed to PingChannel to invoke when an ECHO REQUEST send has completed.
bool isPaused()
Indicates if the thread pool is paused.
Maintains an in-memory store of PingContexts.
static const TimeStamp & EMPTY_TIME()
Fetches an empty timestamp.
static TimeStamp now()
Fetches the current timestamp (UTC/milliseconds precision)
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
void removeCriticalSectionCallbacks(const std::string &name)
Removes the set of callbacks associated with a given name from the list of CriticalSection callbacks.
void addCriticalSectionCallbacks(const std::string &name, const CSCallbackSet::Callback &check_cb, const CSCallbackSet::Callback &entry_cb, const CSCallbackSet::Callback &exit_cb)
Adds a set of callbacks to the list of CriticalSection callbacks.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition macros.h:32
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Definition macros.h:20
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
Definition macros.h:14
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition pkt4.h:556
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
boost::shared_ptr< NetworkState > NetworkStatePtr
Pointer to the NetworkState object.
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition host.h:840
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition lease.h:315
boost::shared_ptr< ParkingLotHandle > ParkingLotHandlePtr
Pointer to the parking lot handle.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
const int DBGLVL_TRACE_DETAIL
Trace detailed operations.
boost::shared_ptr< PingCheckConfig > PingCheckConfigPtr
Defines a shared pointer to a PingCheckConfig.
boost::shared_ptr< ICMPMsg > ICMPMsgPtr
Shared pointer type for ICMPMsg.
Definition icmp_msg.h:26
isc::log::Logger ping_check_logger("ping-check-hooks")
std::chrono::time_point< std::chrono::system_clock > TimeStamp
Specifies the type for time stamps.
boost::shared_ptr< ConfigCache > ConfigCachePtr
Defines a shared pointer to a ConfigCache.
boost::shared_ptr< PingContext > PingContextPtr
Defines a shared pointer to a PingContext.
boost::shared_ptr< PingChannel > PingChannelPtr
Defines a smart pointer to PingChannel.
Defines the logger used by the top-level component of kea-lfc.
const isc::log::MessageID PING_CHECK_MGR_STARTED
const isc::log::MessageID PING_CHECK_MGR_NEXT_ECHO_SCHEDULED
const isc::log::MessageID PING_CHECK_MGR_STARTED_SINGLE_THREADED
const isc::log::MessageID PING_CHECK_DUPLICATE_CHECK
const isc::log::MessageID PING_CHECK_MGR_CHANNEL_DOWN
const isc::log::MessageID PING_CHECK_MGR_RECEIVED_UNREACHABLE_MSG
const isc::log::MessageID PING_CHECK_MGR_RECEIVED_ECHO_REPLY
const isc::log::MessageID PING_CHECK_MGR_RECEIVED_UNEXPECTED_ECHO_REPLY
const isc::log::MessageID PING_CHECK_RESUME_FAILED
const isc::log::MessageID PING_CHECK_MGR_STOPPING
const isc::log::MessageID PING_CHECK_MGR_REPLY_RECEIVED_ERROR
const isc::log::MessageID PING_CHECK_MGR_SEND_COMPLETED_ERROR
const isc::log::MessageID PING_CHECK_MGR_SUBNET_CONFIG_FAILED
const isc::log::MessageID PING_CHECK_MGR_LEASE_FREE_TO_USE
const isc::log::MessageID PING_CHECK_MGR_STOPPED
const isc::log::MessageID PING_CHECK_MGR_REPLY_TIMEOUT_EXPIRED
const isc::log::MessageID PING_CHECK_PAUSE_FAILED
const isc::log::MessageID PING_CHECK_MGR_START_PING_CHECK
const isc::log::MessageID PING_CHECK_MGR_RECEIVED_UNEXPECTED_UNREACHABLE_MSG
const isc::log::MessageID PING_CHECK_PAUSE_PERMISSIONS_FAILED
const isc::log::MessageID PING_CHECK_PAUSE_ILLEGAL
RAII lock object to protect the code in the same scope with a mutex.