bgp_path

BGP path management module.

Border Gateway Protocol (BGP) is a standardized exterior gateway routing protocol designed to exchange routing and reachability information among autonomous systems (AS). In EOS, BGP follows RFC4271.

This module provides APIs to query BGP paths in the Adj-RIB-In.

An example of the API usage is in examples/BgpPathAgent.cpp.

namespace eos
class bgp_path_iter_t
#include <bgp_path.h>

An iterator that yields an bgp_path_t for each BGP path in Adj-RIB-In.

Private Functions

bgp_path_iter_t(bgp_path_iter_impl * const)

Friends

friend class bgp_path_iter_impl
class bgp_path_handler
#include <bgp_path.h>

The BGP path handler.

This class provides handler APIs to react to BGP path changes in Adj-RIB-In. New path updates are notified once BGP has converged. An iterator must be used to retreive the existing paths after BGP convergence. This is only supported under multi-agent mode.

Public Functions

bgp_path_handler(bgp_path_mgr * mgr)
bgp_path_mgr * get_bgp_path_mgr() const
void watch_all_paths(bool)

Register to receive notifications when any path has changed.

void watch_ipv4_unicast_paths(bool)

Register to receive notifications when any IPv4 unicast path has changed.

void watch_ipv6_unicast_paths(bool)

Register to receive notifications when any IPv6 unicast path has changed.

virtual void on_ipv4_unicast_path(bgp_path_key_t const & path_key)

Handler called when a BGP IPv4 unicast path has changed in Adj-RIB-In.

virtual void on_ipv4_unicast_bgp_converged(bool converged)

Handler called when BGP convergence has changed in IPv4 unicast address family.

virtual void on_ipv6_unicast_path(bgp_path_key_t const & path_key)

Handler called when a BGP IPv6 unicast path has changed in Adj-RIB-In.

virtual void on_ipv6_unicast_bgp_converged(bool converged)

Handler called when BGP convergence has changed in IPv6 unicast address family.

class bgp_path_mgr
#include <bgp_path.h>

A manager of BGP RIB paths.

Public Functions

virtual ~bgp_path_mgr()
virtual bgp_path_iter_t ipv4_unicast_path_iter(bgp_path_options_t &) const = 0

Returns an iterator over IPv4 Unicast BGP paths in Adj-RIB-In, which contains unprocessed routing information that has been advertised to the local BGP speaker by its peers.

virtual bgp_path_t ipv4_unicast_path(bgp_path_key_t const &, bgp_path_options_t &) = 0

Returns an IPv4 Unicast BGP path in Adj-RIB-In with the corresponding path key. Returns an empty bgp_path_t if no matching path was found. This is only supported under multi-agent mode.

virtual bool ipv4_unicast_bgp_convergence() = 0

Returns true if bgp is converged for IPv4 Unicast address family This is only supported under multi-agent mode.

virtual bgp_path_iter_t ipv6_unicast_path_iter(bgp_path_options_t &) const = 0

Returns an iterator over IPv6 Unicast BGP paths in Adj-RIB-In, which contains unprocessed routing information that has been advertised to the local BGP speaker by its peers.

virtual bgp_path_t ipv6_unicast_path(bgp_path_key_t const &, bgp_path_options_t &) = 0

Returns an IPv6 Unicast BGP path in Adj-RIB-In with the corresponding path key. Returns an empty bgp_path_t if no matching path was found. This is only supported under multi-agent mode.

virtual bool ipv6_unicast_bgp_convergence() = 0

Returns true if bgp is converged for IPv6 Unicast address family This is only supported under multi-agent mode.

Protected Functions

bgp_path_mgr()

Private Members

bgp_path_mgr

Friends

friend class bgp_path_handler

Type definitions in bgp_path

namespace eos

Enums

bgp_afi_safi_t enum

BGP Address Family Identifiers and Subsequent Address Family Identifiers.

Values:

  • BGP_IPV4_UNICAST -
  • BGP_IPV6_UNICAST -
bgp_receive_route_stage_t enum

The BGP path stage before/after the inbound policies are applied on the route.

Values:

  • BGP_PATH_PRE_POLICY -
  • BGP_PATH_POST_POLICY -
class bgp_path_attr_fields_t
#include <bgp_path.h>

The BGP path option to enable lookup of additional path attributes fields.

Public Functions

bgp_path_attr_fields_t()
bgp_path_attr_fields_t(bool next_hop)

Create BGP path attribute field options.

bgp_path_attr_fields_t(const bgp_path_attr_fields_t & other)
bgp_path_attr_fields_t & operator=(bgp_path_attr_fields_t const & other)
bool next_hop() const

Getter for ‘next_hop’: true if these path attribute options enable next hop lookup, false otherwise.

void next_hop_is(bool next_hop)

Setter for ‘next_hop’.

bool community_list() const

Getter for ‘community_list’: true if these path attribute options enable community list lookup, false otherwise.

void community_list_is(bool community_list)

Setter for ‘community_list’.

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

The hash function for type bgp_path_attr_fields_t.

void mix_me(hash_mix & h) const

The hash mix function for type bgp_path_attr_fields_t.

std::string to_string() const

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

Private Members

std::shared_ptr< bgp_path_attr_fields_impl_t > pimpl

Friends

friend std::ostream & operator<<

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

class bgp_path_options_t
#include <bgp_path.h>

The BGP path lookup options.

Public Functions

bgp_path_options_t()
bgp_path_options_t(bgp_receive_route_stage_t receive_route_stage)

Create BGP path options.

bgp_path_options_t(const bgp_path_options_t & other)
bgp_path_options_t & operator=(bgp_path_options_t const & other)
bgp_receive_route_stage_t receive_route_stage() const

Getter for ‘receive_route_stage’: The received routes stage of a path to lookup when retrieving the path entry.

void receive_route_stage_is(bgp_receive_route_stage_t receive_route_stage)

Setter for ‘receive_route_stage’.

bgp_path_attr_fields_t path_attr_fields() const

Getter for ‘path_attr_fields’: The additional path attributes to populate when retrieving the path entry.

void path_attr_fields_is(bgp_path_attr_fields_t const & path_attr_fields)

Setter for ‘path_attr_fields’.

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

The hash function for type bgp_path_options_t.

void mix_me(hash_mix & h) const

The hash mix function for type bgp_path_options_t.

std::string to_string() const

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

Private Members

std::shared_ptr< bgp_path_options_impl_t > pimpl

Friends

friend std::ostream & operator<<

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

class bgp_path_attr_t
#include <bgp_path.h>

The BGP path attribute entry.

Public Functions

bgp_path_attr_t()
bgp_path_attr_t(uint8_t origin, uint32_t med, uint32_t local_pref)
bgp_path_attr_t(const bgp_path_attr_t & other)
bgp_path_attr_t & operator=(bgp_path_attr_t const & other)
ip_addr_t next_hop() const

Getter for ‘next_hop’: The nexthop address for the route.

void next_hop_is(ip_addr_t const & next_hop)

Setter for ‘next_hop’.

uint8_t origin() const

Getter for ‘origin’: The route origin.

void origin_is(uint8_t origin)

Setter for ‘origin’.

uint32_t med() const

Getter for ‘med’: The Multi Exit Discriminator for the route.

void med_is(uint32_t med)

Setter for ‘med’.

uint32_t local_pref() const

Getter for ‘local_pref’: The I-BGP Local preference indicator.

void local_pref_is(uint32_t local_pref)

Setter for ‘local_pref’.

std::unordered_set< uint32_t > const & community_list() const

Getter for ‘community_list’: The route community list.

void community_list_is(std::unordered_set< uint32_t > const & community_list)

Setter for ‘community_list’.

void community_list_set(uint32_t const & value)

Inserts one community_list of ‘value’ to the set.

void community_list_del(uint32_t const & value)

Deletes one community_list of ‘value’ from the set.

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

The hash function for type bgp_path_attr_t.

void mix_me(hash_mix & h) const

The hash mix function for type bgp_path_attr_t.

std::string to_string() const

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

Private Members

std::shared_ptr< bgp_path_attr_impl_t > pimpl

Friends

friend std::ostream & operator<<

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

class bgp_path_key_t
#include <bgp_path.h>

The key which uniquely identifies a BGP path. Supports IPV4/IPV6 Unicast.

Public Functions

bgp_path_key_t()
bgp_path_key_t(ip_prefix_t const & prefix, ip_addr_t const & peer_addr, std::string const & vrf_name)

Create BGP path key.

bgp_path_key_t(const bgp_path_key_t & other)
bgp_path_key_t & operator=(bgp_path_key_t const & other)
ip_prefix_t prefix() const

Getter for ‘prefix’: IPv4/IPv6 network prefix.

void prefix_is(ip_prefix_t const & prefix)

Setter for ‘prefix’.

ip_addr_t peer_addr() const

Getter for ‘peer_addr’: BGP peer address.

void peer_addr_is(ip_addr_t const & peer_addr)

Setter for ‘peer_addr’.

std::string vrf_name() const

Getter for ‘vrf_name’: VRF name.

void vrf_name_is(std::string const & vrf_name)

Setter for ‘vrf_name’.

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

The hash function for type bgp_path_key_t.

void mix_me(hash_mix & h) const

The hash mix function for type bgp_path_key_t.

std::string to_string() const

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

Private Members

std::shared_ptr< bgp_path_key_impl_t > pimpl

Friends

friend std::ostream & operator<<

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

class bgp_path_t
#include <bgp_path.h>

The BGP path entry.

Public Functions

bgp_path_t()
bgp_path_t(bgp_path_key_t const & path_key)
bgp_path_t(const bgp_path_t & other)
bgp_path_t & operator=(bgp_path_t const & other)
bgp_path_key_t path_key() const

Getter for ‘path_key’: The BGP path key.

void path_key_is(bgp_path_key_t const & path_key)

Setter for ‘path_key’.

bgp_path_attr_t path_attr() const

Getter for ‘path_attr’: The BGP path attributes.

void path_attr_is(bgp_path_attr_t const & path_attr)

Setter for ‘path_attr’.

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

The hash function for type bgp_path_t.

void mix_me(hash_mix & h) const

The hash mix function for type bgp_path_t.

std::string to_string() const

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

Private Members

std::shared_ptr< bgp_path_impl_t > pimpl

Friends

friend std::ostream & operator<<

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