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

The VRF handler.

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

Public Functions

vrf_handler(vrf_mgr * mgr)
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
#include <vrf.h>

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

Private Functions

vrf_iter_t(vrf_iter_impl * const)

Friends

friend class vrf_iter_impl
class vrf_mgr
#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’.

Return
fd on success, -1 on error, and errno is set appropriately.
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.

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.

Protected Functions

vrf_mgr()

Private Members

vrf_mgr

Friends

friend class vrf_handler

Type definitions in vrf

namespace eos

Enums

vrf_state_t enum

VRF state.

Values:

  • VRF_NULL -

    VRF does not exist.

  • VRF_INITIALIZING -

    VRF is being initialized.

  • VRF_ACTIVE -

    VRF is active.

  • VRF_DELETING -

    VRF is being deleted.

class vrf_t
#include <vrf.h>

Public Functions

vrf_t()
vrf_t(std::string name, vrf_state_t state, uint64_t rd)
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.

std::string to_string() const

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

Private Members

std::string name_
vrf_state_t state_
uint64_t rd_

Friends

friend std::ostream & operator<<

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

Table Of Contents

Previous topic

version