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

void watch_all_sbfd_echo_sessions(bool)

Registers this class to receive change updates on all sBFD echo sessions created by EosSdk.

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

This controls notifications on:

void watch_sbfd_echo_session(sbfd_echo_session_key_t const &, bool)

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

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

virtual void on_sbfd_echo_session_status(sbfd_echo_session_key_t const &, bfd_session_status_t)

Handler called when the status of a sBFD echo 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_sbfd_echo_session_set(sbfd_echo_session_key_t const &)

Handler called when a sBFD echo session is created.

virtual void on_sbfd_echo_session_del(sbfd_echo_session_key_t const &)

Handler called when a sBFD echo session is deleted.

virtual void on_sbfd_echo_session_rtt(sbfd_echo_session_key_t const &, sbfd_echo_session_rtt_stats_t const &)

Handler called periodically for sBFD echo sessions where RTT statistics have been enabled with sbfd_echo_rtt_enabled_set.

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 sbfd_echo_session_iter_t
#include <bfd.h>

An iterator that yields an sbfd_echo_session_key_t for each configured sBFD echo session

Private Functions

sbfd_echo_session_iter_t(sbfd_echo_session_iter_impl * const)

Friends

friend class sbfd_echo_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.

virtual sbfd_echo_session_iter_t sbfd_echo_session_iter() const = 0

sBFD echo sessions.

Only a single EosSdk application can use the sbfd_echo_* APIs, if a second application attempts to use them, it will result in a panic / exception. Returns an iterator over all sBFD echo sessions configured through EosSdk on the system.

virtual bool sbfd_echo_session_exists(sbfd_echo_session_key_t const &) const = 0

Return true if the sBFD echo session is configured.

virtual void sbfd_echo_session_set(sbfd_echo_session_key_t const &) = 0

Create a sBFD echo session.

virtual void sbfd_echo_session_del(sbfd_echo_session_key_t const &) = 0

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

virtual void sbfd_echo_default_interval_set(sbfd_interval_t const &) = 0

Set sBFD echo session default interval value. It will be applied to all sBFD echo session.

virtual sbfd_interval_t sbfd_echo_default_interval() const = 0

Get global sBFD echo session interval configuration.

virtual void sbfd_echo_interval_set(sbfd_echo_session_key_t const &, sbfd_interval_t const &) = 0

Set sBFD echo session interval value per session

virtual sbfd_interval_t sbfd_echo_interval(sbfd_echo_session_key_t const &) const = 0

Get sBFD echo session interval configuration.

virtual void sbfd_echo_interval_reset(sbfd_echo_session_key_t const &) = 0

Reset sBFD echo session interval configuration on a session back to value configured by sbfd_echo_default_interval_set(). If sbfd_echo_default_interval_set() has not been explicitly called to configure a default interval, the interval will be reset to tx=300ms and mult=3.

virtual void sbfd_echo_rtt_enabled_set(sbfd_echo_session_key_t const &, bool) = 0

Request RTT measurements for the sBFD probe packets.

RTTs will be reported via the on_sbfd_echo_session_rtt at intervals configured by

router bfd session stats snapshot interval ((dangerous <1-9>)|<10-3600 seconds>)

virtual bool sbfd_echo_rtt_enabled(sbfd_echo_session_key_t const &) const = 0

Is sBFD RTT measurements enabled?

virtual bfd_session_status_t sbfd_echo_session_status(sbfd_echo_session_key_t const &) const = 0

Return the BFD status given a sBFD echo 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_LAGRFC7130 -
  • BFD_SESSION_TYPE_MICRORFC7130 -
  • BFD_SESSION_TYPE_MULTIHOP -
  • BFD_SESSION_TYPE_SBFD_INITIATOR -
  • BFD_SESSION_TYPE_SBFD_REFLECTOR -
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)
bfd_session_key_t(ip_addr_t ip_addr, std::string vrf, bfd_session_type_t type, intf_id_t intf, ip_addr_t src_ip_addr)
bfd_session_key_t(ip_addr_t ip_addr, std::string vrf, bfd_session_type_t type, uint64_t tunnel_id)
bfd_session_key_t(ip_addr_t ip_addr, std::string vrf, bfd_session_type_t type, intf_id_t intf, ip_addr_t src_ip_addr, uint64_t tunnel_id)
bfd_session_key_t(const bfd_session_key_t & other)
bfd_session_key_t & operator=(bfd_session_key_t const & other)
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.

ip_addr_t src_ip_addr() const

Getter for ‘src_ip_addr’: Src IP address associated with the BFD session.

uint64_t tunnel_id() const

Getter for ‘tunnel_id’: Tunnel Id 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.

void mix_me(hash_mix & h) const

The hash mix function for type bfd_session_key_t.

std::string to_string() const

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

Private Members

std::shared_ptr< bfd_session_key_impl_t > pimpl

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)
bfd_interval_t(const bfd_interval_t & other)
bfd_interval_t & operator=(bfd_interval_t const & other)
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.

void mix_me(hash_mix & h) const

The hash mix function for type bfd_interval_t.

std::string to_string() const

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

Private Members

std::shared_ptr< bfd_interval_impl_t > pimpl

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_t(const bfd_session_t & other)
bfd_session_t & operator=(bfd_session_t const & other)
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.

void mix_me(hash_mix & h) const

The hash mix function for type bfd_session_t.

std::string to_string() const

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

Private Members

std::shared_ptr< bfd_session_impl_t > pimpl

Friends

friend std::ostream & operator<<

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

class sbfd_echo_session_key_t
#include <bfd.h>

sBFD echo session key class. Used to identify a sBFD echo session on a switch.

Public Functions

sbfd_echo_session_key_t()
sbfd_echo_session_key_t(ip_addr_t nexthop, intf_id_t nexthop_intf, std::forward_list< mpls_label_t > const & labels, uint8_t ip_dscp, uint8_t mpls_exp)
sbfd_echo_session_key_t(ip_addr_t nexthop, intf_id_t nexthop_intf, std::forward_list< mpls_label_t > const & labels)

ip_dscp & mpls_exp defaults to CS6 and 6 respectively.

sbfd_echo_session_key_t(const sbfd_echo_session_key_t & other)
sbfd_echo_session_key_t & operator=(sbfd_echo_session_key_t const & other)
ip_addr_t nexthop() const

Getter for ‘nexthop’: nexthop IP address to send the probes to. If the nexthop is an IPv4 address, the probes will be IPv4 packets, if the nexthop is an IPv6 packet, the probes will be IPv6 packets.

intf_id_t nexthop_intf() const

Getter for ‘nexthop_intf’: local interface to send probes on.

std::forward_list< mpls_label_t > const & labels() const

Getter for ‘labels’: MPLS labels to impose on the probes.

The first element in iteration order is the outermost label, the last element in iteration order is the innermost label. When using std::forward_list< eos::mpls_label_t >::push_front to build the label stack, the first element pushed will be the innermost label, also known as bottom of stack.

uint8_t ip_dscp() const

Getter for ‘ip_dscp’: IPv4/IPv6 DSCP value of the probe.

uint8_t mpls_exp() const

Getter for ‘mpls_exp’: MPLS exp value of the probe.

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

The hash function for type sbfd_echo_session_key_t.

void mix_me(hash_mix & h) const

The hash mix function for type sbfd_echo_session_key_t.

std::string to_string() const

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

Private Members

std::shared_ptr< sbfd_echo_session_key_impl_t > pimpl

Friends

friend std::ostream & operator<<

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

class sbfd_interval_t
#include <bfd.h>

sBFD echo interval configuration class. Used to specify sBFD echo timer interval.

Public Functions

sbfd_interval_t()
sbfd_interval_t(uint16_t tx, uint8_t mult)
sbfd_interval_t(const sbfd_interval_t & other)
sbfd_interval_t & operator=(sbfd_interval_t const & other)
uint16_t tx() const

Getter for ‘tx’: desired minimum tx interval, in milliseconds.

uint8_t mult() const

Getter for ‘mult’: detection multiplier.

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

The hash function for type sbfd_interval_t.

void mix_me(hash_mix & h) const

The hash mix function for type sbfd_interval_t.

std::string to_string() const

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

Private Members

std::shared_ptr< sbfd_interval_impl_t > pimpl

Friends

friend std::ostream & operator<<

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

class sbfd_echo_session_rtt_stats_t
#include <bfd.h>

sBFD RTT statistics class. Used to report RTT statistics.

Public Functions

sbfd_echo_session_rtt_stats_t(uint32_t last_rtt, uint32_t min_rtt, uint32_t avg_rtt, uint32_t max_rtt, uint32_t snapshot_min_rtt, uint32_t snapshot_avg_rtt, uint32_t snapshot_max_rtt)
sbfd_echo_session_rtt_stats_t(const sbfd_echo_session_rtt_stats_t & other)
sbfd_echo_session_rtt_stats_t & operator=(sbfd_echo_session_rtt_stats_t const & other)
uint32_t last_rtt() const

Getter for ‘last_rtt’: RTT of the last received probe, in microseconds.

uint32_t min_rtt() const

Getter for ‘min_rtt’: Minimum RTT for lifetime of session, in microseconds.

uint32_t avg_rtt() const

Getter for ‘avg_rtt’: Average RTT for lifetime of session, in microseconds.

uint32_t max_rtt() const

Getter for ‘max_rtt’: Maximum RTT for lifetime of session, in microseconds.

uint32_t snapshot_min_rtt() const

Getter for ‘snapshot_min_rtt’: Minimum RTT since last RTT report, in microseconds.

uint32_t snapshot_avg_rtt() const

Getter for ‘snapshot_avg_rtt’: Average RTT since last RTT report, in microseconds.

uint32_t snapshot_max_rtt() const

Getter for ‘snapshot_max_rtt’: Maximum RTT since last RTT report, in microseconds.

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

The hash function for type sbfd_echo_session_rtt_stats_t.

void mix_me(hash_mix & h) const

The hash mix function for type sbfd_echo_session_rtt_stats_t.

std::string to_string() const

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

Private Members

std::shared_ptr< sbfd_echo_session_rtt_stats_impl_t > pimpl

Friends

friend std::ostream & operator<<

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