Kea 3.1.1
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
181bool
183 if (checkSuspended()) {
184 return (false);
185 }
186
187 PingContextPtr context = store_->getNextToSend();
188 if (!context) {
189 return (false);
190 }
191
192 next = context->getTarget();
193 // Transition to sending.
194 context->setState(PingContext::SENDING);
195 store_->updateContext(context);
196
197 return (true);
198}
199
200void
201PingCheckMgr::sendCompleted(const ICMPMsgPtr& echo, bool send_failed) {
202 if (checkSuspended()) {
203 return;
204 }
205
206 try {
207 if (!echo) {
208 isc_throw(BadValue, "PingCheckMgr::sendCompleted() - echo is empty");
209 }
210
211 if (echo->getType() != ICMPMsg::ECHO_REQUEST) {
212 isc_throw(BadValue, "PingCheckMgr::sendCompleted() - message type: "
213 << echo->getType() << " is not an ECHO_REQUEST");
214 }
215
216 // Update the context associated with this ECHO_REQUEST.
217 PingContextPtr context = store_->getContextByAddress(echo->getDestination());
218 if (!context) {
219 isc_throw(Unexpected, "PingCheckMgr::sendCompleted() "
220 " no context found for: " << echo->getDestination());
221 }
222
223 if (send_failed) {
224 // Recoverable error occurred which means we can't get to the target's
225 // network (interface down?). Treat this the same as TARGET UNREACHABLE.
226 finishFree(context);
227 } else {
228 // Transition the context to WAITING_FOR_REPLY.
229 context->beginWaitingForReply();
230 store_->updateContext(context);
231 }
232
233 // Update the expiration timer if necessary.
235 } catch (const std::exception& ex) {
237 .arg(ex.what());
238 }
239}
240
241void
243 if (checkSuspended()) {
244 return;
245 }
246
247 try {
248 if (!reply) {
249 isc_throw(BadValue, "PingCheckMgr::replyReceived() - echo is empty");
250 }
251
252 switch (reply->getType()) {
254 handleEchoReply(reply);
255 break;
257 // Extract embedded ECHO REQUEST
259 break;
260 default:
261 // Ignore anything else.
262 return;
263 }
264
266 } catch (const std::exception& ex) {
268 .arg(ex.what());
269 }
270}
271
272void
274 // Update the context associated with this ECHO_REQUEST.
275 PingContextPtr context = store_->getContextByAddress(echo_reply->getSource());
276 if (!context) {
279 .arg(echo_reply->getSource())
280 .arg(echo_reply->getId())
281 .arg(echo_reply->getSequence());
282 return;
283 }
284
287 .arg(echo_reply->getSource())
288 .arg(echo_reply->getId())
289 .arg(echo_reply->getSequence());
290
291 context->setState(PingContext::TARGET_IN_USE);
292 store_->updateContext(context);
293
294 // If parking is employed, unpark the query from the parking lot,
295 // and set the offer_address_in_use argument in the callout handle
296 // to true, indicating to the server that the lease should be declined
297 // and the DHCPOFFER discarded.
298 auto parking_lot = context->getParkingLot();
299 if (parking_lot) {
300 auto query = context->getQuery();
301 auto callout_handle = query->getCalloutHandle();
302 callout_handle->setArgument("offer_address_in_use", true);
303 parking_lot->unpark(query);
304 }
305
306 // Remove the context from the store.
307 store_->deleteContext(context);
308}
309
310void
312 // Unpack the embedded ECHO REQUEST.
313 ICMPMsgPtr embedded_echo;
314 auto payload = unreachable->getPayload();
315 embedded_echo = ICMPMsg::unpack(payload.data(), payload.size());
316
317 // Fetch the context associated with the ECHO_REQUEST.
318 PingContextPtr context = store_->getContextByAddress(embedded_echo->getDestination());
319 if (!context) {
322 .arg(embedded_echo->getDestination())
323 .arg(embedded_echo->getId())
324 .arg(embedded_echo->getSequence());
325 return;
326 }
327
330 .arg(embedded_echo->getDestination())
331 .arg(embedded_echo->getId())
332 .arg(embedded_echo->getSequence());
333
334 // Render the address usable.
335 finishFree(context);
336}
337
338void
340 context->setState(PingContext::TARGET_FREE);
341 store_->updateContext(context);
342
345 .arg(context->getTarget())
346 .arg(context->getQuery()->getLabel());
347
348 // If parking is employed, unpark the query from the parking lot,
349 // and set the offer_address_in_use argument in the callout handle
350 // to false, indicating to the server that the lease is available
351 // and the DHCPOFFER should be sent to the client.
352 auto parking_lot = context->getParkingLot();
353 if (parking_lot) {
354 auto query = context->getQuery();
355 auto callout_handle = query->getCalloutHandle();
356 callout_handle->setArgument("offer_address_in_use", false);
357 parking_lot->unpark(context->getQuery());
358 }
359
360 // Remove the context from the store.
361 store_->deleteContext(context);
362}
363
364void
367 if (io_service_) {
368 // As this is a callback that may be invoked by a channel
369 // thread we post a call to stopService() rather than call
370 // it directly.
371 io_service_->post([&]() { stopService(true); });
372 }
373}
374
375size_t
376PingCheckMgr::processExpiredSince(const TimeStamp& since /* = PingContext::now() */) {
377 auto expired_pings = store_->getExpiredSince(since);
378 size_t more_pings = 0;
379 for (auto const& context : *(expired_pings)) {
382 .arg(context->getTarget())
383 .arg(context->getEchosSent())
384 .arg(context->getMinEchos())
385 .arg(context->getReplyTimeout());
386
387 if (context->getEchosSent() < context->getMinEchos()) {
388 doNextEcho(context);
389 ++more_pings;
390 } else {
391 finishFree(context);
392 }
393 }
394
395 return (more_pings);
396}
397
398void
400 // Position to do another ping by re-entering WAITING_TO_SEND
403 .arg(context->getTarget())
404 .arg(context->getEchosSent() + 1)
405 .arg(context->getMinEchos());
406
407 context->beginWaitingToSend();
408 store_->updateContext(context);
409}
410
416
417void
426
427void
429 // Find the context that expires soonest.
430 PingContextPtr context = store_->getExpiresNext();
431 if (context) {
432 // if the context's expiry is sooner than current expiry
433 // reschedule expiration timer
435 (context->getNextExpiry() < next_expiry_)) {
436 auto now = PingContext::now();
437 auto timeout = duration_cast<milliseconds>(context->getNextExpiry() - now);
439 timeout = (timeout > milliseconds(2) ? timeout : milliseconds(2));
440 next_expiry_ = now + timeout;
442 shared_from_this()),
443 timeout.count(), IntervalTimer::ONE_SHOT);
444 }
445 } else {
446 // Nothing waiting to expire. Cancel the timer.
448 }
449}
450
451void
456
457void
464
465void
469 return;
470 }
471
472 // Process everything that has expired since current time.
473 auto more_pings = processExpiredSince();
474
475 // Update the expiration timer.
478
479 // In the event there was nothing left to process when timed out,
480 // poke the channel to make sure things are moving.
481 if (more_pings && channel_) {
482 channel_->startSend();
483 channel_->startRead();
484 }
485}
486
489 Lease4Ptr& old_lease,
490 ConstHostPtr host,
491 const PingCheckConfigPtr& config) {
492 // If ping-check is disabled or the channel isn't open,
493 // drop the query from parking and release the offer to the client.
494 if (!config->getEnablePingCheck() || !channel_ || !channel_->isOpen()) {
496 }
497
498 // If we're already running check on this address then drop the
499 // query from parking and discard the offer.
500 if (store_->getContextByAddress(lease->addr_)) {
503 .arg(lease->addr_)
504 .arg(query->getLabel());
506 }
507
508 // Reserved addresses are never checked.
509 if (host && (host->getIPv4Reservation() == lease->addr_)) {
511 }
512
513 // If there's a previous lease that belongs to this client and it either
514 // active or was touched by the client less than ping-cltt-secs ago then
515 // no check is needed. Drop the query from parking and release the
516 // offer to the client,
517 if (old_lease && (old_lease->addr_ == lease->addr_)) {
518 if (old_lease->belongsToClient(lease->hwaddr_, lease->client_id_)) {
519 if (!old_lease->expired() ||
520 ((time(0) - old_lease->cltt_) < config->getPingClttSecs())) {
522 }
523 }
524 }
525
526 // Leave it parked and do the ping check.
528}
529
530void
532 network_state_ = network_state;
533 io_service_->post([&]() { start(); });
534}
535
536bool
541
542bool
544 if (!network_state_ || network_state_->isServiceEnabled()) {
545 suspended_ = false;
546 } else {
547 if (!suspended_) {
548 suspended_ = true;
549
550 // Flush the context store, dropping parked queries.
551 flush(false);
552 }
553 }
554
555 return (suspended_);
556}
557
558void
559PingCheckMgr::stopService(bool finish_free) {
560 // Pause the thread pool while we flush the store.
561 pause();
562
563 // Flush the context store. If finish_free is true
564 // the flush will treat the remaining context lease
565 // addresses as free to use and unpark them. This
566 // will cause the server to send out the associated
567 // OFFERs. If it's false we just drop them from
568 // the parking lot.
569 flush(finish_free);
570
571 // Stop the thread pool, destroy the channel and the like.
572 stop();
573}
574
575void
577 if (MultiThreadingMgr::instance().isTestMode()) {
578 return;
579 }
580 if (!MultiThreadingMgr::instance().getMode()) {
582 return;
583 }
584
585 // We must be in multi-threading mode.
586 // Add critical section callbacks.
588 std::bind(&PingCheckMgr::checkPermissions, this),
589 std::bind(&PingCheckMgr::pause, this),
590 std::bind(&PingCheckMgr::resume, this));
591
592 // Punt if we're already started.
593 if (thread_pool_ && thread_pool_->isStopped()) {
594 isc_throw(InvalidOperation, "PingCheckMgr already started!");
595 }
596
597 try {
598 auto config = config_cache_->getGlobalConfig();
599 auto use_threads = (config->getPingChannelThreads() ? config->getPingChannelThreads()
600 : MultiThreadingMgr::instance().getThreadPoolSize());
601 thread_pool_.reset(new IoServiceThreadPool(IOServicePtr(), use_threads, true));
602 IOServicePtr pool_ios = thread_pool_->getIOService();
603 channel_ = createChannel(pool_ios);
604 channel_->open();
605 expiration_timer_.reset(new IntervalTimer(pool_ios));
606 thread_pool_->run();
608 .arg(use_threads);
609 } catch (const std::exception& ex) {
610 channel_.reset();
611 thread_pool_.reset();
612 isc_throw(Unexpected, "PingCheckMgr::start failed:" << ex.what());
613 }
614}
615
616void
618 try {
619 auto config = config_cache_->getGlobalConfig();
621 channel_->open();
624 } catch (const std::exception& ex) {
625 channel_.reset();
626 isc_throw(Unexpected, "PingCheckMgr::startSingleThreaded() failed:" << ex.what());
627 }
628}
629
632 return (PingChannelPtr(new PingChannel(io_service,
633 std::bind(&PingCheckMgr::nextToSend,
634 this, ph::_1),
636 this, ph::_1, ph::_2),
638 this, ph::_1),
640 this))));
641}
642
643void
645 // Since this function is used as CS callback all exceptions must be
646 // suppressed, unlikely though they may be.
647 try {
648 if (thread_pool_) {
649 thread_pool_->checkPausePermissions();
650 }
651 } catch (const isc::MultiThreadingInvalidOperation& ex) {
653 .arg(ex.what());
654 // The exception needs to be propagated to the caller of the
655 // @ref MultiThreadingCriticalSection constructor.
656 throw;
657 } catch (const std::exception& ex) {
659 .arg(ex.what());
660 }
661}
662
663void
665 if (!MultiThreadingMgr::instance().getMode()) {
666 return;
667 }
668
669 // Since this function is used as CS callback all exceptions must be
670 // suppressed, unlikely though they may be.
671 try {
672 // Cancel the expiration timer.
674
675 // Pause the thread pool.
676 if (thread_pool_) {
677 thread_pool_->pause();
678 }
679 } catch (const std::exception& ex) {
681 .arg(ex.what());
682 }
683}
684
685void
687 if (!MultiThreadingMgr::instance().getMode()) {
688 return;
689 }
690
691 // Since this function is used as CS callback all exceptions must be
692 // suppressed, unlikely though they may be.
693 try {
694 if (thread_pool_) {
695 thread_pool_->run();
696 }
697
698 // Restore the expiration timer.
700 } catch (const std::exception& ex) {
702 .arg(ex.what());
703 }
704}
705
706void
709
710 // Cancel the expiration timer.
712
713 if (channel_) {
714 channel_->close();
715 }
716
717 if (thread_pool_) {
718 // Remove critical section callbacks.
720
721 // Stop the thread pool.
722 thread_pool_->stop();
723
724 thread_pool_->getIOService()->stopAndPoll();
725
726 // Ditch the thread_pool
727 thread_pool_.reset();
728 }
729 // Ditch the timer. It must be destroyed before the thread pool because in
730 // MT it holds a reference to the pool's IOService.
731 expiration_timer_.reset();
732
733 // Get rid of the channel.
734 channel_.reset();
735
736 if (io_service_) {
737 io_service_->stopAndPoll();
738 }
739
741}
742
743bool
745 // In ST mode, running is an open channel.
746 if (!MultiThreadingMgr::instance().getMode()) {
747 return (channel_ && channel_->isOpen());
748 }
749
750 if (thread_pool_) {
751 return (thread_pool_->isRunning());
752 }
753
754 return (false);
755}
756
757bool
759 // In ST mode, stopped equates to no channel.
760 if (!MultiThreadingMgr::instance().getMode()) {
761 return (!channel_);
762 }
763
764 if (thread_pool_) {
765 return (thread_pool_->isStopped());
766 }
767
768 return (true);
769}
770
771bool
773 if (thread_pool_) {
774 return (thread_pool_->isPaused());
775 }
776
777 return (false);
778}
779
780void
781PingCheckMgr::flush(bool finish_free /* = false */) {
782 if (!store_) {
783 return;
784 }
785
786 // Fetch them all.
787 auto contexts = store_->getAll();
788 for (auto const& context : *contexts) {
789 if (finish_free) {
790 finishFree(context);
791 } else {
792 auto parking_lot = context->getParkingLot();
793 if (parking_lot) {
794 parking_lot->drop(context->getQuery());
795 }
796 }
797 }
798
799 store_->clear();
800}
801
802} // end of namespace ping_check
803} // 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.
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 bool nextToSend(asiolink::IOAddress &next)
Callback passed to PingChannel to use to retrieve the next address to check.
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.
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.