vrf

VRF management

This module manages Virtual Routing & Forwarding instances, known commonly as VRFs. VRFs let you partition your switch’s routing tables so you can have unique IP domains.

VRFs are keyed by a unique name across the system, and can be used in other modules to configure routes and nexthops in different domains. If a route is not programmed in a specific VRF, it belongs to the VRF named “default”.

namespace eos
class vrf_handler : public eos::base_handler<vrf_mgr, vrf_handler>
#include <vrf.h>

The VRF handler.

This class provides handler APIs to react to a VRF’s operational state change.

Public Functions

explicit vrf_handler(vrf_mgr *mgr)
inline vrf_mgr *get_vrf_mgr() const
void watch_all_vrfs(bool)

Register to receive notifications when any VRF on the system changes state.

void watch_vrf(std::string const &vrf_name, bool)

Register to receive notifications when the specified VRF on the system changes state.

virtual void on_vrf_state(std::string vrf_name, vrf_state_t vrf_state)

Called when a VRF’s operational state changes.

class vrf_iter_t : public eos::iter_base<std::string, vrf_iter_impl>
#include <vrf.h>

An iterator that yields a vrf_t for each VRF on the system.

Private Functions

explicit vrf_iter_t(vrf_iter_impl*const)

Friends

friend class vrf_iter_impl
class vrf_mgr : public eos::base_mgr<vrf_handler, std::string>
#include <vrf.h>

The manager for VRF, this is the main entry point for applications to use EosSdk VRF APIs.

Public Functions

virtual ~vrf_mgr()
virtual vrf_iter_t vrf_iter() const = 0

Iterates through all configured VRFs on the system, yielding a vrf_t for each VRF.

virtual bool exists(std::string const &vrf_name) const = 0

Returns true if the VRF is currently configured.

virtual uint64_t rd(std::string const &vrf_name) const = 0

Returns the route distinguisher associated with this VRF. The returned value is obtained from status that is the result of the RD configuration under the ‘vrf definition’ submode and the RD configuration under the ‘router bgp vrf’ submode. When configuration for the VRF exists in both locations, the value configured under ‘router bgp’ takes precedence and is returned.

If no VRF matches the given name, this returns 0.

virtual vrf_state_t state(std::string const &vrf_name) const = 0

Returns the operational status of this VRF.

If the given VRF name does not have a current status (e.g. a newly configured VRF), or if it does not match any VRFs on the system, this returns VRF_STATE_NULL.

virtual int socket_at(int domain, int type, int protocol, std::string const &vrf_name) = 0

Opens a socket inside a VRF specified by ‘vrf_name’.

Parameters
  • domain – A communication domain, same as in socket().

  • type – The communication semantics, such as SOCK_STREAM, same as in socket().

  • protocol – The protocol to be used with the socket, same as in socket().

  • vrf_name – The name of the vrf_name in which the socket will be created.

Returns

fd on success, -1 on error, and errno is set appropriately.

virtual vrf_t vrf(std::string const &vrf_name) const = 0

Returns a composite vrf_t for the named VRF, or a default VRF object if it does not exist.

Deprecated:

, please use the state(), exists(), and rd() methods instead.

Protected Functions

vrf_mgr()

Private Members

vrf_mgr

Friends

friend class vrf_handler

Type definitions in vrf

namespace eos

Enums

enum vrf_state_t

VRF state.

Values:

enumerator VRF_NULL

VRF does not exist.

enumerator VRF_INITIALIZING

VRF is being initialized.

enumerator VRF_ACTIVE

VRF is active.

enumerator VRF_DELETING

VRF is being deleted.

class vrf_t
#include <vrf.h>

Deprecated:

. This data structure is used to describe a VRF on a switch.

Public Functions

vrf_t()
vrf_t(std::string name, vrf_state_t state, uint64_t rd)
vrf_t(const vrf_t &other)
vrf_t &operator=(vrf_t const &other)
vrf_t(vrf_t &&other) noexcept
vrf_t &operator=(vrf_t &&other) noexcept
std::string name() const

Getter for ‘name’: the name of the VRF.

vrf_state_t state() const

Getter for ‘state’: the state of this VRF.

uint64_t rd() const

Getter for ‘rd’: the route distinguisher of the VRF.

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

The hash function for type vrf_t.

void mix_me(hash_mix &h) const

The hash mix function for type vrf_t.

std::string to_string() const

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

Public Static Functions

static inline void *operator new(std::size_t, void *ptr)
static void *operator new(std::size_t)
static void operator delete(void*) noexcept

Private Members

std::shared_ptr<vrf_impl_t> pimpl

Friends

friend std::ostream &operator<<(std::ostream &os, const vrf_t &obj)

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