eth_lag_intf module reference

The eth_lag_intf module manages link aggregation groups (LAGs), also known as Port Channels.

LAGs bundle physical interfaces together into a single logical link to provide combined bandwidth and other benefits. This module provides APIs to provision LAG interfaces. APIs include LAG creation, deletion, retrieval, member interface adding to or removal from LAG interfaces. Two iterators are also provided to allow iteration through all the LAG interfaces and also all the member interfaces that are configured on the system.

The LAG APIs are best working with “intf” module, as shown in the sample code below.

 {.cpp}

   #include <eos/agent.h>
   #include <eos/eth_lag_intf.h>
   #include <eos/panic.h>
   #include <eos/sdk.h>

   static eos::eth_lag_intf_mgr *eth_lag_intf_mgr;

   class ApplicationAgent : public eos::agent_handler,
                                   eos::intf_handler {
    public:
      explicit ApplicationAgent(eos::sdk & sdk) :
                             eos::agent_handler(sdk.get_agent_mgr()),
                             eos::intf_handler(sdk.get_intf_mgr()) {
          watch_intf( eos::intf_id_t("Port-Channel23"), true );
          watch_intf( eos::intf_id_t("Port-Channel24"), true );
      }

      // Called when all agents are initialized
      void on_initialized() {
         // Creates PC 23, no mode specified
         eth_lag_intf_mgr->eth_lag_intf_is(eos::intf_id_t("Port-Channel23"));
      }

      // Handler for LAG interface creation
      void on_intf_create(eos::intf_id_t i) {
         if (i == eos::intf_id_t("Port-Channel23")) {
            try {
               eth_lag_intf_mgr->eth_lag_intf_is(eos::intf_id_t("Port-Channel23"));
            } catch (eos::invalid_argument_error &ia) {
               // Expected, since LAG 23 created already in "on_initialized" handler
               assert(ia.argument_name()=="eth_lag_intf.pc_create");
            }

            // Application logic goes here, such as creating more LAG interfaces
            // or adding member interfaces to it.
            try {
               eth_lag_intf_mgr->membership_set(intf_id_t("Ethernet1"),
                                    i,
                                    eos::ETH_LAG_INTF_MEMBER_LACP_MODE_PASSIVE);
            } catch (eos::invalid_argument_error &ia) {
               assert(false);
            } catch (eos::no_such_interface_error &e) {
               assert(false);
            }
         }
         return;
      }
   }

   int main(int argc, char **argv) {
      eos::sdk sdk;
      eth_lag_intf_mgr = sdk.get_eth_lag_intf_mgr();
      ApplicationAgent agent(sdk);
      sdk.main_loop(argc, argv);
   }

namespace eos
class eth_lag_intf_iter_t
#include <eth_lag_intf.h>

An LAG interface iterator iterating through all LAG interfaces created in the system.

Private Functions

eth_lag_intf_iter_t(eth_lag_intf_iter_impl * const)

Friends

friend class eth_lag_intf_iter_impl
class eth_lag_intf_member_iter_t
#include <eth_lag_intf.h>

An LAG member iterator iterating through all interfaces configured as a member of one LAG interface in the system.

Private Functions

eth_lag_intf_member_iter_t(eth_lag_intf_member_iter_impl * const)

Friends

friend class eth_lag_intf_member_iter_impl
class eth_lag_intf_mgr
#include <eth_lag_intf.h>

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

Public Functions

virtual ~eth_lag_intf_mgr()
virtual eth_lag_intf_iter_t eth_lag_intf_iter() const = 0

Iterate the LAG interfaces in system, intf_id_t pointer is returned for each LAG interface.

virtual eth_lag_intf_member_iter_t eth_lag_intf_member_iter() const = 0

Iterate the physical interfaces configured as a member of an LAG interface in system, note the interface may not be in an LAG interface yet, but still shows up if its priority/mode/timeout set. “intf_id_t *” is returned for each member intf.

virtual eth_lag_intf_t eth_lag_intf_is(intf_id_t eth_lag_intf_id) = 0

This API creates an LAG interface, when given the LAG id. It may throw “invalid_argument_error” exception if the LAG exists already.

virtual eth_lag_intf_t eth_lag_intf(intf_id_t eth_lag_intf_id) const = 0

This API returns an LAG interface with the specified LAG id. May throw “invalid_argument_error” exception if the LAG does not exist already.

virtual void eth_lag_intf_del(intf_id_t eth_lag_intf_id) = 0

This API deletes an LAG interface, it will simply return if the specified LAG interface is not in existence.

virtual void membership_set(intf_id_t intf, intf_id_t eth_lag_intf_id, eth_lag_intf_member_lacp_mode_t mode) = 0

This API adds/removes one eth intf to/from an LAG interface. To add an interface, the interface id and its LACP mode are needed. To remove an interface from an LAG interface, the “intf” needs to be provided, and eth_lag_intf_id needs to be the empty intf with intf_type()==INTF_TYPE_NULL (created by intf_id_t()).

When removing an interface from an LAG interface, this API may throw “no_such_interface_error” exception if the specified LAG interface does not exist. It may also throw “invalid_argument_error” exception if the specified “intf” is not in any LAG interface.

When adding an interface to an LAG interface, this API may throw “Invalid_ argument_error” error if the interface’s mode is not compatible with the LAG interface mode.

virtual intf_id_t membership(intf_id_t intf) = 0

This API returns the LAG interface id to which the physical intf is configured to belong. May throw “no_such_interface_error” if the “intf” does not exist.

virtual eth_lag_intf_membership_t eth_lag_intf_membership_status(intf_id_t intf) = 0

This API returns the member intf operational status. It may throw “no_such_interface_error” if the specified “intf” does not exist.

virtual void eth_lag_intf_member_priority_is(intf_id_t intf, uint16_t priority) = 0

This API sets the port LACP priority.

virtual void eth_lag_intf_member_mode_is(intf_id_t intf, eth_lag_intf_member_lacp_mode_t mode) = 0

This API sets the mode of this member in an LAG interface.

virtual void eth_lag_intf_member_timeout_is(intf_id_t intf, eth_lag_intf_member_lacp_timeout_t timeout) = 0

This API sets the LACP timeout for this member, the valid values are “short” or “long”. It may throw “invalid_argument_error” exception, if the “timeout” value is invalid.

Protected Functions

eth_lag_intf_mgr()

Private Members

eth_lag_intf_mgr

eth_lag_intf type definitions

namespace eos

Enums

eth_lag_intf_fallback_type_t enum

LAG interface fallback type.

Values:

  • ETH_LAG_INTF_FALLBACK_NULL -

    Not a valid fallback type.

  • ETH_LAG_INTF_FALLBACK_NONE -

    No fallback if no LACPDUs seen.

  • ETH_LAG_INTF_FALLBACK_STATIC -

    Fallback to static mode.

  • ETH_LAG_INTF_FALLBACK_INDIVIDUAL -

    Fallback to individual mode.

eth_lag_intf_fallback_timeout_default_t enum

How long to wait for LACP before fallback.

Values:

  • ETH_LAG_INTF_FALLBACK_TIMEOUT_DEFAULT = 90 -
eth_lag_intf_member_priority_t enum

Values:

  • ETH_LAG_INTF_PORT_PRIORITY_DEFAULT = 0x8000 -
eth_lag_intf_member_lacp_mode_t enum

LAG interface mebmer LACP mode.

Values:

  • ETH_LAG_INTF_MEMBER_LACP_MODE_NULL -
  • ETH_LAG_INTF_MEMBER_LACP_MODE_OFF -
  • ETH_LAG_INTF_MEMBER_LACP_MODE_PASSIVE -
  • ETH_LAG_INTF_MEMBER_LACP_MODE_ACTIVE -
eth_lag_intf_member_lacp_timeout_t enum

LAG interface mebmer timeout values.

Values:

  • ETH_LAG_INTF_MEMBER_LACP_TIMEOUT_NULL -
  • ETH_LAG_INTF_MEMBER_LACP_TIMEOUT_SHORT -
  • ETH_LAG_INTF_MEMBER_LACP_TIMEOUT_LONG -
class eth_lag_intf_membership_t
#include <eth_lag_intf.h>

This data structure is used to describe the operational status of an interface configured in an LAG interface.

Public Functions

eth_lag_intf_membership_t()
intf_id_t eth_lag_intf_id() const

Getter for ‘eth_lag_intf_id’: the LAG interface id this interface is configured to be in.

void eth_lag_intf_id_is(intf_id_t eth_lag_intf_id)

Setter for ‘eth_lag_intf_id’.

bool active() const

Getter for ‘active’: the attribute indicating whether this interface is active in an LAG.

void active_is(bool active)

Setter for ‘active’.

std::string reason() const

Getter for ‘reason’: if populated, reason this interface isn’t in LAG.

void reason_is(std::string const & reason)

Setter for ‘reason’.

double member_time() const

Getter for ‘member_time’: the time when this interface became member of an LAG. If never a member, then the value is 0; if once was member, but now is not, then this is the time the interface was removed from member.

void member_time_is(double member_time)

Setter for ‘member_time’.

eth_lag_intf_member_lacp_mode_t mode() const

Getter for ‘mode’: the LACP mode this interface is configured.

void mode_is(eth_lag_intf_member_lacp_mode_t mode)

Setter for ‘mode’.

std::string to_string() const

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

Private Members

intf_id_t eth_lag_intf_id_
bool active_
std::string reason_
double member_time_
eth_lag_intf_member_lacp_mode_t mode_

Friends

friend std::ostream & operator<<

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

class eth_lag_intf_t
#include <eth_lag_intf.h>

This data structure defines a LAG interface, which is also known as a Link-Aggregation Group, or Port-Channel. LAGs bundle physical interfaces together into a single logical link to provide combined bandwidth and other benefits.

Public Functions

eth_lag_intf_t()
eth_lag_intf_t(intf_id_t intf)

Constructor with interface id.

intf_id_t intf() const

Getter for ‘intf’: the id of this LAG interface.

void intf_is(intf_id_t intf)

Setter for ‘intf’.

double speed() const

Getter for ‘speed’: the aggregated capacity (speed) of this LAG interface in megabits.

void speed_is(double speed)

Setter for ‘speed’.

uint32_t min_links() const

Getter for ‘min_links’: the min links required up before bringing up an LAG interface.

void min_links_is(uint32_t min_links)

Setter for ‘min_links’.

eth_lag_intf_fallback_type_t fallback_type() const

Getter for ‘fallback_type’: the fallback mode for this LAG interface.

void fallback_type_is(eth_lag_intf_fallback_type_t fallback_type)

Setter for ‘fallback_type’.

uint16_t fallback_timeout() const

Getter for ‘fallback_timeout’: the LACP active mode timeout value in seconds.

void fallback_timeout_is(uint16_t fallback_timeout)

Setter for ‘fallback_timeout’.

uint16_t fallback_timeout_default() const

Returns the default fallback timeout value in seconds.

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

The hash function for type eth_lag_intf_t.

std::string to_string() const

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

Private Members

intf_id_t intf_
double speed_
uint32_t min_links_
eth_lag_intf_fallback_type_t fallback_type_
uint16_t fallback_timeout_

Friends

friend std::ostream & operator<<

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

Table Of Contents

Previous topic

eth_intf module reference

Next topic

eth_phy_intf module reference