bfd

The bfd module manages BFD sessions

Bi-directional Forwarding Detection (BFD) is a low-latency protocol designed to detect faults between two forwarding planes. The protocol itself is independent from media, link and routing protocols. In EOS, BFD is implemented on top of IP encapuslations, conforming to RFC5881.

This module provides APIs to provision BFD. APIs include

  • BFD session creation
  • BFD session getter
  • BFD session deletion
  • BFD global interval timers setter/getter
  • BFD interface timers setter/getter
  • BFD session status getter

An iterator is also provided to iterate through all BFD sessions that are configured via EosSdk in the system.

namespace eos
class bfd_session_handler
#include <bfd.h>

The BFD handler.

This class provides handler APIs to react to a BFD’s session state change.

Public Functions

bfd_session_handler(bfd_session_mgr * mgr)
bfd_session_mgr * get_bfd_session_mgr() const
void watch_all_bfd_sessions(bool)

Registers this class to receive change updates on all BFD sessions.

Expects a boolean signifying whether notifications should be generated for all BFD sessions created by EosSdk or not.

This controls notifications on:

void watch_bfd_session(bfd_session_key_t const &, bool)

Registers this class to receive change updates on the given BFD session.

Expects the session key of the corresponding BFD session and a boolean signifying whether notifications should be propagated to this BFD session or not.

virtual void on_bfd_session_status(bfd_session_key_t const &, bfd_session_status_t)

Handler called when the status of a BFD session status changes.

Possible status are: BFD_SESSION_STATUS_NULL BFD_SESSION_STATUS_DOWN BFD_SESSION_STATUS_INIT BFD_SESSION_STATUS_UP BFD_SESSION_STATUS_ADMIN_DOWN

virtual void on_bfd_session_set(bfd_session_key_t const &)

Handler called when a BFD session is created

virtual void on_bfd_session_del(bfd_session_key_t const &)

Handler called when a BFD session is deleted

class bfd_session_iter_t
#include <bfd.h>

An iterator that yields an bfd_session_key_t for each configured BFD session

Private Functions

bfd_session_iter_t(bfd_session_iter_impl * const)

Friends

friend class bfd_session_iter_impl
class bfd_session_mgr
#include <bfd.h>

A manager of BFD session configurations for EosSdk client

Create one of these via an sdk object prior to starting the agent main loop. When your eos::agent_handler::on_initialized virtual function is called, the manager is valid for use.

Public Functions

virtual ~bfd_session_mgr()
virtual bfd_session_iter_t session_iter() const = 0

Returns an iterator over all BFD sessions configured through EosSdk on the system.

virtual bool exists(bfd_session_key_t const &) const = 0

Return true if the BFD session is configured.

virtual void session_set(bfd_session_key_t const &) = 0

Creates a BFD session. If an existing session has already been created by other client (i.e. BGP, OSPF), no new BFD session will be created. Instead, EsoSdk will be added to the list of clients that will receive BFD session status change notifications.

virtual bfd_session_t session(bfd_session_key_t const &) const = 0

Returns the BFD session with the specified key. Will return an empty bfd_session_t if the BFD session does not exist already.

virtual void session_del(bfd_session_key_t const &) = 0

Remove a BFD session if it exists. It is a no-op if the specified BFD session does not exist.

virtual void default_interval_is(bfd_interval_t const &) = 0

Set BFD default interval value. It will be applied to all interface unless overridden by per-interface interval configuration.

virtual bfd_interval_t default_interval() const = 0

Get global BFD interval configuration.

virtual void interval_is(intf_id_t intf, bfd_interval_t const &) = 0

Set BFD interval on an interface.

virtual bfd_interval_t interval(intf_id_t intf) const = 0

Get BFD interval configuration on an interface.

virtual void interval_reset(intf_id_t intf) = 0

Reset BFD interval configuration on an interface back to value configured by bfd_default_interval_is(). If bfd_default_interval_is() has not been explicitly called to configure a default interval, the interval will be reset to tx=300ms, rx=300ms and mult=3.

virtual bfd_session_status_t session_status(bfd_session_key_t const &) const = 0

Return the BFD status given a BFD session key.

Protected Functions

bfd_session_mgr()

Private Members

bfd_session_mgr

Friends

friend class bfd_session_handler

Type definitions in bfd

namespace eos

Enums

bfd_session_status_t enum

BFD session status.

Values:

  • BFD_SESSION_STATUS_NULL -
  • BFD_SESSION_STATUS_DOWN -
  • BFD_SESSION_STATUS_INIT -
  • BFD_SESSION_STATUS_UP -
  • BFD_SESSION_STATUS_ADMIN_DOWN -
bfd_session_type_t enum

BFD session type.

Values:

  • BFD_SESSION_TYPE_NULL -
  • BFD_SESSION_TYPE_NORMAL -
  • BFD_SESSION_TYPE_MICRO -
  • BFD_SESSION_TYPE_VXLANTUNNEL -
  • BFD_SESSION_TYPE_MICRORFC7130 -
  • BFD_SESSION_TYPE_MULTIHOP -
class bfd_session_key_t
#include <bfd.h>

BFD session key class. Used to identify a BFD session on a switch.

Public Functions

bfd_session_key_t()
bfd_session_key_t(ip_addr_t ip_addr, std::string vrf, bfd_session_type_t type, intf_id_t intf)
ip_addr_t ip_addr() const

Getter for ‘ip_addr’: IP address of the peer.

std::string vrf() const

Getter for ‘vrf’: vrf associated with the BFD session.

bfd_session_type_t type() const

Getter for ‘type’: type associated with the BFD session.

intf_id_t intf() const

Getter for ‘intf’: local interface associated with the BFD session.

bool operator==(bfd_session_key_t const & other) const
bool operator!=(bfd_session_key_t const & other) const
bool operator<(bfd_session_key_t const & other) const
uint32_t hash() const

The hash function for type bfd_session_key_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

ip_addr_t ip_addr_
std::string vrf_
bfd_session_type_t type_
intf_id_t intf_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of bfd_session_key_t to the ostream.

class bfd_interval_t
#include <bfd.h>

BFD interval configuration class. Used to specify BFD timer interval.

Public Functions

bfd_interval_t()
bfd_interval_t(uint16_t tx, uint16_t rx, uint8_t mult)
uint16_t tx() const

Getter for ‘tx’: desired minimum tx interval.

uint16_t rx() const

Getter for ‘rx’: required minimum rx interval.

uint8_t mult() const

Getter for ‘mult’: detection multiplier.

bool operator==(bfd_interval_t const & other) const
bool operator!=(bfd_interval_t const & other) const
uint32_t hash() const

The hash function for type bfd_interval_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

uint16_t tx_
uint16_t rx_
uint8_t mult_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of bfd_interval_t to the ostream.

class bfd_session_t
#include <bfd.h>

This data structure is used to describe a BFD session.

Public Functions

bfd_session_t()
bfd_session_t(bfd_session_key_t peer, bfd_session_status_t status)
bfd_session_key_t peer() const

Getter for ‘peer’: the peer for this BFD session.

bfd_session_status_t status() const

Getter for ‘status’: the status of the BFD session.

bool operator==(bfd_session_t const & other) const
bool operator!=(bfd_session_t const & other) const
bool operator<(bfd_session_t const & other) const
uint32_t hash() const

The hash function for type bfd_session_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

bfd_session_key_t peer_
bfd_session_status_t status_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of bfd_session_t to the ostream.

Table Of Contents

Previous topic

base_mgr

Next topic

class_map