5 #include <sandesh/sandesh_types.h>
6 #include <sandesh/sandesh.h>
16 #include <services/services_types.h>
24 server_(new BFD::Server(agent->event_manager(), &communicator_)),
25 client_(new BFD::Client(&communicator_)), handler_(agent, msg_, io) {
40 boost::asio::io_context &io) {
69 if (source_ip.is_unspecified()) {
71 destination_ip.to_string(),
72 source_ip.to_string(), service->
interface()->id(),
81 tbb::mutex::scoped_lock lock(
mutex_);
86 if (source_ip.is_v4() &&
91 uint32_t tx_interval = service->
service()->
delay() * 1000000 +
108 boost::posix_time::microseconds(tx_interval);
110 boost::posix_time::microseconds(rx_interval);
118 destination_ip.to_string(),
119 source_ip.to_string(), service->
interface()->id(),
120 tx_interval, rx_interval, multiplier);
129 Sessions::iterator it =
sessions_.find(skey);
133 destination_ip.to_string(),
134 source_ip.to_string(), service->
interface()->id(),
138 std::string str(
"BFD delete session ");
139 str +=
" interface-id: " + service->
interface()->id();
140 str +=
" source-ip: " + source_ip.to_string();
141 str +=
" destination-ip: " + destination_ip.to_string();
143 LOG(ERROR,
"Duplicate request: " << str);
164 tbb::mutex::scoped_lock lock(
mutex_);
166 Sessions::iterator it =
sessions_.find(key);
170 it->second->OnRead(data);
173 std::string str(
"BFD session ");
174 if (data.find(
"success") != std::string::npos) {
177 if (data.find(
"failure") != std::string::npos) {
180 if (it->second->service()) {
181 str +=
" service-health-check: " + it->second->service()->name();
183 str +=
" service: null";
185 if (it->second->interface()) {
186 str +=
" interface: " + it->second->interface()->name();
187 if (it->second->interface()->vrf()) {
188 str +=
" vrf: " + it->second->interface()->vrf()->GetName();
193 str +=
" interface: null";
195 if (!it->second->destination_ip().is_unspecified()) {
196 str +=
" destination-ip: " + it->second->destination_ip().to_string();
198 str +=
" destination-ip: null";
200 LOG(WARN,
"SYS_NOTICE " << str);
205 boost::asio::const_buffer packet,
206 const boost::asio::ip::udp::endpoint &local_endpoint,
207 const boost::asio::ip::udp::endpoint &remote_endpoint,
210 boost::system::error_code ec) {
214 packet, local_endpoint, remote_endpoint,
222 const boost::asio::ip::udp::endpoint &local_endpoint,
223 const boost::asio::ip::udp::endpoint &remote_endpoint,
225 const boost::asio::mutable_buffer &packet,
int pktSize) {
227 session_index.
if_index, packet, pktSize);
233 std::string data = up ?
"success" :
"failure";
234 bfd_proto_->NotifyHealthCheckInstanceService(key.
index.
if_index,
240 if (msg->is_bfd_keepalive) {
bool Enqueue(boost::shared_ptr< PktInfo > msg)
void SetBounded(bool bounded)
InterfaceRef interface() const
void NotifyHealthCheckInstanceService(uint32_t interface, IpAddress address, std::string &data)
ProtoWorkQueue work_queue_
static Agent * GetInstance()
virtual void NotifyStateChange(const BFD::SessionKey &key, const bool &up)
void IncrementKaEnqueueCount()
TimeInterval desiredMinTxInterval
bool ProcessBfdKeepAlive(boost::shared_ptr< PktInfo > msg)
HealthCheckService * service() const
void ProcessStats(PktStatsType::Type type)
IpAddress destination_ip() const
boost::asio::ip::address IpAddress
bool IsEqual(const BfdSessionsKey &rhs) const
static const uint32_t kMultiplier
bool BfdHealthCheckSessionControl(HealthCheckTable::HealthCheckServiceAction action, HealthCheckInstanceService *service)
TimeInterval requiredMinRxInterval
boost::asio::ip::address remote_address
virtual bool Enqueue(boost::shared_ptr< PktInfo > msg)
void IncrementReceiveDropCount()
void HandleReceiveSafe(boost::asio::const_buffer pkt, const boost::asio::ip::udp::endpoint &local_endpoint, const boost::asio::ip::udp::endpoint &remote_endpoint, const BFD::SessionIndex &session_index, uint8_t pkt_len, boost::system::error_code ec)
void SetSize(size_t size)
PktHandler * pkt_handler() const
AgentParam * params() const
boost::asio::io_context & get_io_service() const
boost::asio::ip::address_v4 Ip4Address
virtual void HandleReceive(const boost::asio::const_buffer &recv_buffer, const boost::asio::ip::udp::endpoint &local_endpoint, const boost::asio::ip::udp::endpoint &remote_endpoint, const SessionIndex &session_index, std::size_t bytes_transferred, const boost::system::error_code &error)
HealthCheckTable * health_check_table() const
uint32_t services_queue_limit()
BfdCommunicator & bfd_communicator()
IpAddress update_source_ip()
static const uint32_t kMinTxInterval
uint32_t max_retries() const
void DeleteSession(const SessionKey &key)
void SendPacket(const boost::asio::ip::udp::endpoint &local_endpoint, const boost::asio::ip::udp::endpoint &remote_endpoint, uint32_t interface_id, const boost::asio::mutable_buffer &packet, int packet_length)
#define LOG(_Level, _Msg)
void AddSession(const SessionKey &key, const SessionConfig &config)
#define BFD_TRACE(obj,...)
uint64_t delay_usecs() const
static const uint32_t kMinRxInterval
bool IsLess(const BfdSessionsKey &rhs) const
bool is_multi_hop() const
void RegisterHealthCheckCallback(HealthCheckServiceCallback fn, HealthCheckService::HealthCheckType type)
BfdProto(Agent *agent, boost::asio::io_context &io)
int detectionTimeMultiplier
ProtoHandler * AllocProtoHandler(boost::shared_ptr< PktInfo > info, boost::asio::io_context &io)
virtual void SendPacket(const boost::asio::ip::udp::endpoint &local_endpoint, const boost::asio::ip::udp::endpoint &remote_endpoint, const BFD::SessionIndex &session_index, const boost::asio::mutable_buffer &packet, int pktSize)
uint64_t timeout_usecs() const