Kea: isc::ping_check::PingCheckMgr Class Reference

| Kea 3.2.0-git

isc::ping_check::PingCheckMgr Class Reference

Ping Check Manager. More...

`#include <ping_check_mgr.h>`

Inheritance diagram for isc::ping_check::PingCheckMgr:
[legend]

## Public Member Functions
| PingCheckMgr ()
| Constructor.
| PingCheckMgr (uint32_t num_threads, uint32_t min_echos=1, uint32_t reply_timeout=100)
| Constructor.
virtual | ~PingCheckMgr ()
| Destructor.
void | cancelExpirationTimer ()
| Cancels the expiration timer (thread safe).
void | cancelExpirationTimerInternal ()
| Cancels the expiration timer.
virtual void | channelShutdown ()
| Callback passed to PingChannel to invoke when it shuts down.
void | checkPermissions ()
| Check if the current thread can perform thread pool state transition.
bool | checkSuspended ()
| Checks if operations are currently suspended due to NetworkState.
bool | checkSuspendedInternal ()
| Checks if operations are currently suspended due to NetworkState.
void | configure (data::ConstElementPtr params)
| Configure the PingCheckMgr.
virtual PingChannelPtr | createChannel (asiolink::IOServicePtr io_service)
| Creates a ping channel instance.
void | doNextEcho (const PingContextPtr &context)
| Position a context to do another ping test.
virtual void | expirationTimedOut ()
| Callback passed to expiration timer to invoke on timeout.
void | finishFree (const PingContextPtr &context)
| Processes a context whose address has been deemed free to use.
void | flush (bool finish_free=false)
| Flushes the ping context store.
const PingCheckConfigPtr | getGlobalConfig () const
| Fetches the current, global configuration parameters.
isc::asiolink::IOServicePtr | getIOService ()
| Get the hook I/O service.
TimeStamp | getNextExpiry ()
| Fetches the time at which expiration timer will next expire.
const PingCheckConfigPtr | getScopedConfig (dhcp::Lease4Ptr &lease)
| Fetches the current, scoped configuration parameters.
void | handleEchoReply (const ICMPMsgPtr &echo_reply)
| Process an ECHO REPLY message.
void | handleTargetUnreachable (const ICMPMsgPtr &unreachable)
| Process an UNREACHABLE message.
bool | isPaused ()
| Indicates if the thread pool is paused.
bool | isRunning ()
| Indicates if the thread pool is running.
bool | isStopped ()
| Indicates if the thread pool is stopped.
virtual PingContextPtr | nextToSend ()
| Callback passed to PingChannel to use to retrieve the next context with address to check.
void | pause ()
| Pause PingChannel operations.
virtual size_t | processExpiredSince (const TimeStamp &since=PingContext::now())
| Performs expiration processing for contexts whose WAITING_FOR_REPLY states expired prior to a given point in time.
virtual void | replyReceived (const ICMPMsgPtr &reply)
| Callback passed to PingChannel to invoke when an ICMP reply has been received.
void | resume ()
| Resume PingChannel operations.
virtual void | sendCompleted (const ICMPMsgPtr &echo, bool send_failed)
| Callback passed to PingChannel to invoke when an ECHO REQUEST send has completed.
void | setIOService (isc::asiolink::IOServicePtr io_service)
| Set the hook I/O service.
virtual void | setNextExpiration ()
| Updates the expiration timer (thread safe).
virtual void | setNextExpirationInternal ()
| Updates the expiration timer.
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 | start ()
| Start PingChannel operations.
void | startPing (dhcp::Lease4Ptr &lease, dhcp::Pkt4Ptr &query, hooks::ParkingLotHandlePtr &parking_lot)
| Initiates a ping check for a given lease and its associated DHCPDISCOVER packet.
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 | startService (dhcp::NetworkStatePtr network_state)
| Performs a deferred start by posting an invocation of `start()` to the given IOService.
void | startSingleThreaded ()
| Start single-threaded PingChannel operations.
void | stop ()
| Stop PingChannel operations.
void | stopService (bool finish_free=false)
| Shuts down the manager's channel, flushes the store.
virtual void | updateContextToSend (PingContextPtr context)
| Callback passed to PingChannel to update a context to SENDING state just before sending.
void | updateSubnetConfig (dhcp::SrvConfigPtr server_config)
| Update the cache of subnet ping check configurations.

## Protected Attributes
PingChannelPtr | channel_
| Channel that conducts ICMP messaging.
ConfigCachePtr | config_cache_
| Warehouses parsed global and subnet configuration.
asiolink::IntervalTimerPtr | expiration_timer_
| Timer which tracks the next expiration event.
isc::asiolink::IOServicePtr | io_service_
| The hook I/O service.
const boost::scoped_ptr< std::mutex > | mutex_
| The mutex used to protect internal state.
dhcp::NetworkStatePtr | network_state_
| Tracks whether or not the server is processing DHCP packets.
TimeStamp | next_expiry_
| TimeStamp of the next expiration event.
PingContextStorePtr | store_
| In-memory store of PingContexts.
bool | suspended_
| Indicates whether or not operations have been suspended.
asiolink::IoServiceThreadPoolPtr | thread_pool_
| Thread pool used when running multi-threaded.

## Detailed Description

Ping Check Manager.

PinCheckMgr carries out the higher order management of requests for ping checks from the server. It is a singleton, instantiated when the library is loaded. It is responsible for:

1. Parsing and applying configuration.
2. Maintaining in-memory store of current ping requests (PingContextStore).
3. Creating and managing the PingChannel through which individual ICMP ECHO/REPLY cycles are conducted.
4. When in multi-threaded mode, it creates an IOServiceThread and synchronizes its state with Kea core MT.

Definition at line 47 of file ping_check_mgr.h.

## Constructor & Destructor Documentation

## ◆ PingCheckMgr() [1/2]

isc::ping_check::PingCheckMgr::PingCheckMgr | ( |  | ) |
| explicit

Constructor.

Definition at line 32 of file ping_check_mgr.cc.

References channel_, config_cache_, io_service_, mutex_, store_, suspended_, and thread_pool_.

## ◆ PingCheckMgr() [2/2]

isc::ping_check::PingCheckMgr::PingCheckMgr | ( | uint32_t | num_threads,
|  | uint32_t | min_echos = 1,
|  | uint32_t | reply_timeout = 100 )

Constructor.

This constructor is used in testing. It permits setting some basic behavior parameters directly, rather than requiring calls to `configure()`.

Parameters

  num_threads | number of threads to use in the thread pool (0 means follow core thread pool size).
  min_echos | minimum number of ECHO REQUESTs sent without replies received required to declare an address free to offer. Defaults to 1, must be greater than zero.
  reply_timeout | maximum number of milliseconds to wait for an ECHO REPLY after an ECHO REQUEST has been sent. Defaults to 100.

Definition at line 41 of file ping_check_mgr.cc.

References channel_, config_cache_, io_service_, mutex_, store_, suspended_, and thread_pool_.

## ◆ ~PingCheckMgr()

isc::ping_check::PingCheckMgr::~PingCheckMgr | ( |  | ) |
| virtual

Destructor.

Definition at line 57 of file ping_check_mgr.cc.

References stop().

Here is the call graph for this function:

## Member Function Documentation

## ◆ cancelExpirationTimer()

void isc::ping_check::PingCheckMgr::cancelExpirationTimer | ( |  | ) |

Cancels the expiration timer (thread safe).

Definition at line 457 of file ping_check_mgr.cc.

References cancelExpirationTimerInternal(), and mutex_.

Referenced by pause(), and stop().

Here is the call graph for this function:

## ◆ cancelExpirationTimerInternal()

void isc::ping_check::PingCheckMgr::cancelExpirationTimerInternal | ( |  | ) |

Cancels the expiration timer.

Definition at line 463 of file ping_check_mgr.cc.

References isc::ping_check::PingContext::EMPTY_TIME(), expiration_timer_, and next_expiry_.

Referenced by cancelExpirationTimer(), and setNextExpirationInternal().

Here is the call graph for this function:

## ◆ channelShutdown()

void isc::ping_check::PingCheckMgr::channelShutdown | ( |  | ) |
| virtual

Callback passed to PingChannel to invoke when it shuts down.

Logs the shutdown and then posts a call to `stopService()` to the main IOService.

Definition at line 370 of file ping_check_mgr.cc.

References io_service_, LOG_ERROR, isc::ping_check::ping_check_logger, PING_CHECK_MGR_CHANNEL_DOWN, and stopService().

Referenced by createChannel().

Here is the call graph for this function:

## ◆ checkPermissions()

void isc::ping_check::PingCheckMgr::checkPermissions | ( |  | ) |

Check if the current thread can perform thread pool state transition.

Exceptions

  MultiThreadingInvalidOperation | if the state transition is done on any of the worker threads.

Definition at line 655 of file ping_check_mgr.cc.

References LOG_ERROR, isc::ping_check::ping_check_logger, PING_CHECK_PAUSE_ILLEGAL, PING_CHECK_PAUSE_PERMISSIONS_FAILED, thread_pool_, and isc::Exception::what().

Referenced by start().

Here is the call graph for this function:

## ◆ checkSuspended()

bool isc::ping_check::PingCheckMgr::checkSuspended | ( |  | ) |

Checks if operations are currently suspended due to NetworkState.

Thread-safe wrapper around checkSuspendedInternal().

Returns
  True if operations are suspended, false otherwise.

Definition at line 546 of file ping_check_mgr.cc.

References checkSuspendedInternal(), and mutex_.

Referenced by nextToSend(), replyReceived(), sendCompleted(), and startPing().

Here is the call graph for this function:

## ◆ checkSuspendedInternal()

bool isc::ping_check::PingCheckMgr::checkSuspendedInternal | ( |  | ) |

Checks if operations are currently suspended due to NetworkState.

If DHCP service is enabled, operations are not suspended and the function returns false. Otherwise operations, if not already suspended, are suspended by flushing the PingContext store and the function returns true. The queries for flushed contexts are dropped from parking and thus their offers discarded.

Returns
  True if operations are suspended, false otherwise.

Definition at line 552 of file ping_check_mgr.cc.

References flush(), network_state_, and suspended_.

Referenced by checkSuspended(), expirationTimedOut(), and setNextExpiration().

Here is the call graph for this function:

## ◆ configure()

void isc::ping_check::PingCheckMgr::configure | ( | data::ConstElementPtr | params | ) |

Configure the PingCheckMgr.

Parameters

  params | map containing the hook library parameters.

Exceptions

  BadValue | and similar exceptions on error.

Definition at line 62 of file ping_check_mgr.cc.

References config_cache_, isc_throw, and Element::map.

## ◆ createChannel()

PingChannelPtr isc::ping_check::PingCheckMgr::createChannel | ( | asiolink::IOServicePtr | io_service | ) |
| virtual

Creates a ping channel instance.

Parameters

  io_service | IOService that will drive the channel.

Returns
  pointer to the newly created channel.

Definition at line 640 of file ping_check_mgr.cc.

References channelShutdown(), nextToSend(), replyReceived(), sendCompleted(), and updateContextToSend().

Referenced by start(), and startSingleThreaded().

Here is the call graph for this function:

## ◆ doNextEcho()

void isc::ping_check::PingCheckMgr::doNextEcho | ( | const PingContextPtr & | context | ) |

Position a context to do another ping test.

1. Moves the context to WAITING_SEND_STATE
2. Updates the context in the store

Parameters

  context | context to process.

Definition at line 404 of file ping_check_mgr.cc.

References isc::log::DBGLVL_TRACE_DETAIL, LOG_DEBUG, isc::ping_check::ping_check_logger, PING_CHECK_MGR_NEXT_ECHO_SCHEDULED, and store_.

Referenced by processExpiredSince().

## ◆ expirationTimedOut()

void isc::ping_check::PingCheckMgr::expirationTimedOut | ( |  | ) |
| virtual

Callback passed to expiration timer to invoke on timeout.

Definition at line 471 of file ping_check_mgr.cc.

References channel_, checkSuspendedInternal(), isc::ping_check::PingContext::EMPTY_TIME(), mutex_, next_expiry_, processExpiredSince(), and setNextExpirationInternal().

Referenced by setNextExpirationInternal().

Here is the call graph for this function:

## ◆ finishFree()

void isc::ping_check::PingCheckMgr::finishFree | ( | const PingContextPtr & | context | ) |

Processes a context whose address has been deemed free to use.

1. Moves the context to TARGET_FREE state
2. Updates the context in the store
3. Unparks the query which will release the DHCPOFFER to the client
4. Invokes the target free callback (do we still need this?)
5. Deletes the store from the context

Parameters

  context | context to process.

Definition at line 344 of file ping_check_mgr.cc.

References isc::log::DBGLVL_TRACE_BASIC, LOG_DEBUG, isc::ping_check::ping_check_logger, PING_CHECK_MGR_LEASE_FREE_TO_USE, store_, and isc::ping_check::PingContext::TARGET_FREE.

Referenced by flush(), handleTargetUnreachable(), processExpiredSince(), and sendCompleted().

## ◆ flush()

void isc::ping_check::PingCheckMgr::flush | ( | bool | finish_free = false | ) |

Flushes the ping context store.

This function iterates over the contexts in the store and then either invokes finishFree() or drops their queries from parking depending upon finish_free parameter. It assumes the operations have ceased (i.e. thread pool is not running).

Parameters

  finish_free | if true finishFree() will be invoke on all remaining contexts in the store, otherwise their queries are simply dropped from the parking lot.

Definition at line 796 of file ping_check_mgr.cc.

References finishFree(), and store_.

Referenced by checkSuspendedInternal(), and stopService().

Here is the call graph for this function:

## ◆ getGlobalConfig()

const PingCheckConfigPtr isc::ping_check::PingCheckMgr::getGlobalConfig | ( |  | ) | const

Fetches the current, global configuration parameters.

Returns
  PingCheckConfig reference containing the current configuration.

Definition at line 94 of file ping_check_mgr.cc.

References config_cache_.

Referenced by startPing().

## ◆ getIOService()

isc::asiolink::IOServicePtr isc::ping_check::PingCheckMgr::getIOService | ( |  | ) |
| inline

Get the hook I/O service.

Returns
  the hook I/O service.

Definition at line 396 of file ping_check_mgr.h.

References io_service_.

## ◆ getNextExpiry()

TimeStamp isc::ping_check::PingCheckMgr::getNextExpiry | ( |  | ) |

Fetches the time at which expiration timer will next expire.

Returns
  TimeStamp containing the next expiration time.

Definition at line 417 of file ping_check_mgr.cc.

References mutex_, and next_expiry_.

## ◆ getScopedConfig()

const PingCheckConfigPtr isc::ping_check::PingCheckMgr::getScopedConfig | ( | dhcp::Lease4Ptr & | lease | ) |

Fetches the current, scoped configuration parameters.

Parameters

  lease | lease for which the parameters are desired.

Returns
  PingCheckConfig reference containing the current configuration.

Definition at line 99 of file ping_check_mgr.cc.

References config_cache_, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc_throw, LOG_ERROR, isc::ping_check::ping_check_logger, and PING_CHECK_MGR_SUBNET_CONFIG_FAILED.

Here is the call graph for this function:

## ◆ handleEchoReply()

void isc::ping_check::PingCheckMgr::handleEchoReply | ( | const ICMPMsgPtr & | echo_reply | ) |

Process an ECHO REPLY message.

Parameters

  echo_reply | ICMP ECHO REPLY message to process.

Definition at line 278 of file ping_check_mgr.cc.

References isc::log::DBGLVL_TRACE_BASIC, isc::log::DBGLVL_TRACE_DETAIL, LOG_DEBUG, isc::ping_check::ping_check_logger, PING_CHECK_MGR_RECEIVED_ECHO_REPLY, PING_CHECK_MGR_RECEIVED_UNEXPECTED_ECHO_REPLY, store_, and isc::ping_check::PingContext::TARGET_IN_USE.

Referenced by replyReceived().

## ◆ handleTargetUnreachable()

void isc::ping_check::PingCheckMgr::handleTargetUnreachable | ( | const ICMPMsgPtr & | unreachable | ) |

Process an UNREACHABLE message.

Parameters

  unreachable | ICMP UNREACHABLE message to process.

Definition at line 316 of file ping_check_mgr.cc.

References isc::log::DBGLVL_TRACE_DETAIL, finishFree(), LOG_DEBUG, isc::ping_check::ping_check_logger, PING_CHECK_MGR_RECEIVED_UNEXPECTED_UNREACHABLE_MSG, PING_CHECK_MGR_RECEIVED_UNREACHABLE_MSG, store_, and isc::ping_check::ICMPMsg::unpack().

Referenced by replyReceived().

Here is the call graph for this function:

## ◆ isPaused()

bool isc::ping_check::PingCheckMgr::isPaused | ( |  | ) |

Indicates if the thread pool is paused.

Returns
  True if the thread pool exists and it is in the PAUSED state, false otherwise. Always returns false in single-threaded mode.

Definition at line 787 of file ping_check_mgr.cc.

References thread_pool_.

## ◆ isRunning()

bool isc::ping_check::PingCheckMgr::isRunning | ( |  | ) |

Indicates if the thread pool is running.

Returns
  True if the thread pool exists and it is in the RUNNING state in multi-threaded mode, true if the channel exists and is open in single-threaded mode, false otherwise.

Definition at line 759 of file ping_check_mgr.cc.

References channel_, isc::util::MultiThreadingMgr::instance(), and thread_pool_.

Here is the call graph for this function:

## ◆ isStopped()

bool isc::ping_check::PingCheckMgr::isStopped | ( |  | ) |

Indicates if the thread pool is stopped.

Returns
  True if the thread pool does not exist or it is in the STOPPED state in multi-threaded mode, true if the channel does not exist in single-threaded mode, false otherwise.

Definition at line 773 of file ping_check_mgr.cc.

References channel_, isc::util::MultiThreadingMgr::instance(), and thread_pool_.

Here is the call graph for this function:

## ◆ nextToSend()

PingContextPtr isc::ping_check::PingCheckMgr::nextToSend | ( |  | ) |
| virtual

Callback passed to PingChannel to use to retrieve the next context with address to check.

Fetches the context which has been in the WAITING_TO_SEND state the longest and returns it.

Returns
  The context selected to send, or null if none available.

Definition at line 184 of file ping_check_mgr.cc.

References checkSuspended(), and store_.

Referenced by createChannel().

Here is the call graph for this function:

## ◆ pause()

void isc::ping_check::PingCheckMgr::pause | ( |  | ) |

Pause PingChannel operations.

In multi-threaded mode this pauses the thread pool threads, in single-threaded mode it does nothing.

Definition at line 675 of file ping_check_mgr.cc.

References cancelExpirationTimer(), isc::util::MultiThreadingMgr::instance(), LOG_ERROR, isc::ping_check::ping_check_logger, PING_CHECK_PAUSE_FAILED, and thread_pool_.

Referenced by start(), and stopService().

Here is the call graph for this function:

## ◆ processExpiredSince()

size_t isc::ping_check::PingCheckMgr::processExpiredSince | ( | const TimeStamp & | since = PingContext::now() | ) |
| virtual

Performs expiration processing for contexts whose WAITING_FOR_REPLY states expired prior to a given point in time.

expired_pings = store_->getExpiredSince(since) for context : expired_pings { unpark context->getQuery() store_->deleteContext(context) }

Parameters

  since | point in time to select against. Defaults to current time.

Returns
  number of contexts scheduled for another ping, zero if none.

Definition at line 381 of file ping_check_mgr.cc.

References isc::log::DBGLVL_TRACE_DETAIL, doNextEcho(), finishFree(), LOG_DEBUG, isc::ping_check::ping_check_logger, PING_CHECK_MGR_REPLY_TIMEOUT_EXPIRED, and store_.

Referenced by expirationTimedOut().

Here is the call graph for this function:

## ◆ replyReceived()

void isc::ping_check::PingCheckMgr::replyReceived | ( | const ICMPMsgPtr & | reply | ) |
| virtual

Callback passed to PingChannel to invoke when an ICMP reply has been received.

If the reply type is an ECHO REQUEST, it is passed to handleEchoRequest(), if it is an UNREACHABLE message it is passed to handleTargetUnreachable(), any other message type is dropped on the floor and the function returns. Upon handler completion, it calls setNextExpiration() to update the expiration timer.

Parameters

  reply | ICMP message that was received.

Definition at line 245 of file ping_check_mgr.cc.

References checkSuspended(), isc::ping_check::ICMPMsg::ECHO_REPLY, handleEchoReply(), handleTargetUnreachable(), isc_throw, LOG_ERROR, mutex_, isc::ping_check::ping_check_logger, PING_CHECK_MGR_REPLY_RECEIVED_ERROR, setNextExpirationInternal(), and isc::ping_check::ICMPMsg::TARGET_UNREACHABLE.

Referenced by createChannel().

Here is the call graph for this function:

## ◆ resume()

void isc::ping_check::PingCheckMgr::resume | ( |  | ) |

Resume PingChannel operations.

In multi-threaded mode this resumes the thread pool threads, in single-threaded mode it does nothing.

Definition at line 697 of file ping_check_mgr.cc.

References isc::util::MultiThreadingMgr::instance(), LOG_ERROR, isc::ping_check::ping_check_logger, PING_CHECK_RESUME_FAILED, setNextExpiration(), and thread_pool_.

Referenced by start().

Here is the call graph for this function:

## ◆ sendCompleted()

void isc::ping_check::PingCheckMgr::sendCompleted | ( | const ICMPMsgPtr & | echo,
|  | bool | send_failed )
| virtual

Callback passed to PingChannel to invoke when an ECHO REQUEST send has completed.

If the send completed successfully we'll transition the context to WAITING_FOR_REPLY, update the context in the store, and the update next expiration.

If the send failed, this implies that a recoverable error occurred, such as a interface being down and thus, there is currently no way to send the ping to the target network. We'll treat this the same as an ICMP TARGET_UNREACHABLE and release the OFFER by calling `finishFree()`.

Parameters

  echo | ICMP echo message that as sent.
  send_failed | True if the send completed with a non-fatal error, false otherwise.

Definition at line 202 of file ping_check_mgr.cc.

References checkSuspended(), isc::ping_check::ICMPMsg::ECHO_REQUEST, finishFree(), isc_throw, LOG_ERROR, mutex_, isc::ping_check::ping_check_logger, PING_CHECK_MGR_SEND_COMPLETED_ERROR, setNextExpirationInternal(), and store_.

Referenced by createChannel().

Here is the call graph for this function:

## ◆ setIOService()

void isc::ping_check::PingCheckMgr::setIOService | ( | isc::asiolink::IOServicePtr | io_service | ) |
| inline

Set the hook I/O service.

Parameters

  io_service | the hook I/O service.

Definition at line 403 of file ping_check_mgr.h.

References io_service_.

## ◆ setNextExpiration()

void isc::ping_check::PingCheckMgr::setNextExpiration | ( |  | ) |
| virtual

Updates the expiration timer (thread safe).

PingContextPtr next = pings->getExpiresNext() if next reschedule expiration timer for next->getNextExpiry(); else cancel expiration timer

Definition at line 423 of file ping_check_mgr.cc.

References checkSuspendedInternal(), mutex_, and setNextExpirationInternal().

Referenced by resume().

Here is the call graph for this function:

## ◆ setNextExpirationInternal()

void isc::ping_check::PingCheckMgr::setNextExpirationInternal | ( |  | ) |
| virtual

Updates the expiration timer.

PingContextPtr next = pings->getExpiresNext() if next reschedule expiration timer for next->getNextExpiry(); else cancel expiration timer

Todo
  For now we'll impose a 2 ms minimum to avoid thrashing the timer.

Definition at line 433 of file ping_check_mgr.cc.

References cancelExpirationTimerInternal(), isc::ping_check::PingContext::EMPTY_TIME(), expiration_timer_, expirationTimedOut(), next_expiry_, isc::ping_check::PingContext::now(), isc::asiolink::IntervalTimer::ONE_SHOT, and store_.

Referenced by expirationTimedOut(), replyReceived(), sendCompleted(), and setNextExpiration().

Here is the call graph for this function:

## ◆ shouldPing()

CalloutHandle::CalloutNextStep isc::ping_check::PingCheckMgr::shouldPing | ( | dhcp::Lease4Ptr & | lease,
|  | dhcp::Pkt4Ptr & | query,
|  | dhcp::Lease4Ptr & | old_lease,
|  | dhcp::ConstHostPtr | host,
|  | const PingCheckConfigPtr & | config )
| virtual

Determines whether or not a lease should be ping checked.

Employs the following logic to determine if a ping-check should be conducted:

If there's a previous lease that belongs to this client and it was touched by the client less than ping-cltt-secs ago, then send the offer to the client without ping checking.

Otherwise a ping-check is called for, leave the query parked.

Parameters

  lease | prospective lease to check.
  query | DHCPDISCOVER associated with the lease.
  old_lease | pre-existing lease for this client (if one).
  host | host reservation associated with lease (if one)
  config | configuration parameters to employ.

Returns
  CalloutNextStep indicating what should happen next:
  - status == PARK - ping check it
  - status == CONTINUE - check not needed, release DHCPOFFER to client
  - status == DROP - duplicate check, drop the duplicate DHCPOFFER

Definition at line 493 of file ping_check_mgr.cc.

References isc::stats::StatsMgr::addValue(), channel_, isc::log::DBGLVL_TRACE_BASIC, isc::stats::StatsMgr::instance(), LOG_DEBUG, isc::hooks::CalloutHandle::NEXT_STEP_CONTINUE, isc::hooks::CalloutHandle::NEXT_STEP_DROP, isc::hooks::CalloutHandle::NEXT_STEP_PARK, PING_CHECK_DUPLICATE_CHECK, isc::ping_check::ping_check_logger, and store_.

Here is the call graph for this function:

## ◆ start()

void isc::ping_check::PingCheckMgr::start | ( |  | ) |

Start PingChannel operations.

Will start multi-threaded if core MT is enabled, or calls `startSingleThreaded()` if core MT is disabled. Creates a thread pool with its own IOService, uses that IOService when creating the channel.

Definition at line 585 of file ping_check_mgr.cc.

References isc::util::MultiThreadingMgr::addCriticalSectionCallbacks(), channel_, checkPermissions(), config_cache_, createChannel(), expiration_timer_, isc::util::MultiThreadingMgr::instance(), isc_throw, LOG_INFO, pause(), isc::ping_check::ping_check_logger, PING_CHECK_MGR_STARTED, resume(), startSingleThreaded(), and thread_pool_.

Referenced by startService().

Here is the call graph for this function:

## ◆ startPing() [1/2]

void isc::ping_check::PingCheckMgr::startPing | ( | dhcp::Lease4Ptr & | lease,
|  | dhcp::Pkt4Ptr & | query,
|  | hooks::ParkingLotHandlePtr & | parking_lot )

Initiates a ping check for a given lease and its associated DHCPDISCOVER packet.

Convenience method used in unit tests which uses global configuration parameters only.

Parameters

  lease | lease whose address needs to be ping checked.
  query | parked DHCPDISCOVER associated with the lease.
  parking_lot | parking lot in which query is parked. If empty, parking is assumed to not be employed.

Definition at line 179 of file ping_check_mgr.cc.

References getGlobalConfig(), and startPing().

Here is the call graph for this function:

## ◆ startPing() [2/2]

void isc::ping_check::PingCheckMgr::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.

Adds a context to the store and posts a call to `PingChannel::startSend()`.

Parameters

  lease | lease whose address needs to be ping checked.
  query | parked DHCPDISCOVER associated with the lease.
  parking_lot | parking lot in which query is parked. If empty, parking is assumed to not be employed.
  config | configuration parameters to employ.

Definition at line 150 of file ping_check_mgr.cc.

References channel_, checkSuspended(), isc::log::DBGLVL_TRACE_BASIC, isc_throw, LOG_DEBUG, isc::ping_check::ping_check_logger, PING_CHECK_MGR_START_PING_CHECK, and store_.

Referenced by startPing().

Here is the call graph for this function:

## ◆ startService()

void isc::ping_check::PingCheckMgr::startService | ( | dhcp::NetworkStatePtr | network_state | ) |

Performs a deferred start by posting an invocation of `start()` to the given IOService.

Parameters

  network_state | pointer to server's networks state object.

Definition at line 540 of file ping_check_mgr.cc.

References io_service_, network_state_, and start().

Here is the call graph for this function:

## ◆ startSingleThreaded()

void isc::ping_check::PingCheckMgr::startSingleThreaded | ( |  | ) |

Start single-threaded PingChannel operations.

Does not create a thread pool. Uses main thread's IOService when creating the channel.

Definition at line 626 of file ping_check_mgr.cc.

References channel_, config_cache_, createChannel(), expiration_timer_, io_service_, isc_throw, LOG_INFO, isc::ping_check::ping_check_logger, and PING_CHECK_MGR_STARTED_SINGLE_THREADED.

Referenced by start().

Here is the call graph for this function:

## ◆ stop()

void isc::ping_check::PingCheckMgr::stop | ( |  | ) |

Stop PingChannel operations.

Definition at line 718 of file ping_check_mgr.cc.

References cancelExpirationTimer(), channel_, isc::log::DBGLVL_TRACE_BASIC, expiration_timer_, isc::util::MultiThreadingMgr::instance(), io_service_, LOG_DEBUG, LOG_INFO, isc::ping_check::ping_check_logger, PING_CHECK_MGR_STOPPED, PING_CHECK_MGR_STOPPING, isc::util::MultiThreadingMgr::removeCriticalSectionCallbacks(), and thread_pool_.

Referenced by ~PingCheckMgr(), and stopService().

Here is the call graph for this function:

## ◆ stopService()

void isc::ping_check::PingCheckMgr::stopService | ( | bool | finish_free = false | ) |

Shuts down the manager's channel, flushes the store.

This function gracefully winds down operation:

1. Pauses the thread pool.
2. Flushes the context store, either finishing all contexts as free or just dropping them from parking, depending on finish_free parameter.
3. Stop the thread pool, shutdown the channel.

Parameters

  finish_free | if true finishFree() will be invoke on all remaining contexts in the store, otherwise their queries are simply dropped from the parking lot.

Definition at line 568 of file ping_check_mgr.cc.

References flush(), pause(), and stop().

Referenced by channelShutdown().

Here is the call graph for this function:

## ◆ updateContextToSend()

void isc::ping_check::PingCheckMgr::updateContextToSend | ( | PingContextPtr | context | ) |
| virtual

Callback passed to PingChannel to update a context to SENDING state just before sending.

This is invoked inside the channel mutex. Must not call PingCheckMgr::checkSuspended() or it will cause a deadlock.

Parameters

  context | The context to update.

Definition at line 193 of file ping_check_mgr.cc.

References isc::ping_check::PingContext::SENDING, and store_.

Referenced by createChannel().

## ◆ updateSubnetConfig()

void isc::ping_check::PingCheckMgr::updateSubnetConfig | ( | dhcp::SrvConfigPtr | server_config | ) |

Update the cache of subnet ping check configurations.

Iterates over the subnets in the given server configuration, and caches their ping-check configuration.

Parameters

  server_config | Server configuration containing the configured subnets to process.

Definition at line 79 of file ping_check_mgr.cc.

References config_cache_.

## Member Data Documentation

## ◆ channel_

PingChannelPtr isc::ping_check::PingCheckMgr::channel_
| protected

Channel that conducts ICMP messaging.

Definition at line 419 of file ping_check_mgr.h.

Referenced by PingCheckMgr(), PingCheckMgr(), expirationTimedOut(), isRunning(), isStopped(), shouldPing(), start(), startPing(), startSingleThreaded(), and stop().

## ◆ config_cache_

ConfigCachePtr isc::ping_check::PingCheckMgr::config_cache_
| protected

Warehouses parsed global and subnet configuration.

Definition at line 422 of file ping_check_mgr.h.

Referenced by PingCheckMgr(), PingCheckMgr(), configure(), getGlobalConfig(), getScopedConfig(), start(), startSingleThreaded(), and updateSubnetConfig().

## ◆ expiration_timer_

asiolink::IntervalTimerPtr isc::ping_check::PingCheckMgr::expiration_timer_
| protected

Timer which tracks the next expiration event.

Definition at line 431 of file ping_check_mgr.h.

Referenced by cancelExpirationTimerInternal(), setNextExpirationInternal(), start(), startSingleThreaded(), and stop().

## ◆ io_service_

isc::asiolink::IOServicePtr isc::ping_check::PingCheckMgr::io_service_
| protected

The hook I/O service.

Definition at line 410 of file ping_check_mgr.h.

Referenced by PingCheckMgr(), PingCheckMgr(), channelShutdown(), getIOService(), setIOService(), startService(), startSingleThreaded(), and stop().

## ◆ mutex_

const boost::scoped_ptr<std::mutex> isc::ping_check::PingCheckMgr::mutex_
| protected

The mutex used to protect internal state.

Definition at line 434 of file ping_check_mgr.h.

Referenced by PingCheckMgr(), PingCheckMgr(), cancelExpirationTimer(), checkSuspended(), expirationTimedOut(), getNextExpiry(), replyReceived(), sendCompleted(), and setNextExpiration().

## ◆ network_state_

dhcp::NetworkStatePtr isc::ping_check::PingCheckMgr::network_state_
| protected

Tracks whether or not the server is processing DHCP packets.

Definition at line 425 of file ping_check_mgr.h.

Referenced by checkSuspendedInternal(), and startService().

## ◆ next_expiry_

TimeStamp isc::ping_check::PingCheckMgr::next_expiry_
| protected

TimeStamp of the next expiration event.

Definition at line 428 of file ping_check_mgr.h.

Referenced by cancelExpirationTimerInternal(), expirationTimedOut(), getNextExpiry(), and setNextExpirationInternal().

## ◆ store_

PingContextStorePtr isc::ping_check::PingCheckMgr::store_
| protected

In-memory store of PingContexts.

Definition at line 416 of file ping_check_mgr.h.

Referenced by PingCheckMgr(), PingCheckMgr(), doNextEcho(), finishFree(), flush(), handleEchoReply(), handleTargetUnreachable(), nextToSend(), processExpiredSince(), sendCompleted(), setNextExpirationInternal(), shouldPing(), startPing(), and updateContextToSend().

## ◆ suspended_

bool isc::ping_check::PingCheckMgr::suspended_
| protected

Indicates whether or not operations have been suspended.

Definition at line 437 of file ping_check_mgr.h.

Referenced by PingCheckMgr(), PingCheckMgr(), and checkSuspendedInternal().

## ◆ thread_pool_

asiolink::IoServiceThreadPoolPtr isc::ping_check::PingCheckMgr::thread_pool_
| protected

Thread pool used when running multi-threaded.

Definition at line 413 of file ping_check_mgr.h.

Referenced by PingCheckMgr(), PingCheckMgr(), checkPermissions(), isPaused(), isRunning(), isStopped(), pause(), resume(), start(), and stop().

The documentation for this class was generated from the following files:

- ping_check_mgr.h
- ping_check_mgr.cc