eth_lag_intf

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.

namespace eos
class eth_lag_intf_handler
#include <eth_lag_intf.h>

The handler for LAG interface events.

Public Functions

eth_lag_intf_handler(eth_lag_intf_mgr *)
virtual ~eth_lag_intf_handler()
eth_lag_intf_mgr * get_eth_lag_intf_mgr() const
void watch_all_eth_lag_intfs(bool)

Registers this class to receive change updates on all interfaces.

Expects a boolean signifying whether notifications should be enabled on all interfaces and propogated to this instance.

void watch_eth_lag_intf(intf_id_t, bool)

Registers this class to receive change updates on the given interface.

Expects the ID of the corresponding LAG interface and a boolean signifying whether notifications should be propagated to this instance or not.

virtual void on_eth_lag_intf_create(intf_id_t)

Handler called when a LAG ethernet interface is created.

After on_eth_lag_intf_create is called, the given intf_id is guaranteed to exist (ie eth_lag_intf_mgr::exists will return true). At that point, the intf_id can be used will all methods of the eth_lag_intf_mgr class.

This also means that the intf_id can be used with all other relevant *intf_mgr classes (ie intf_mgr and eth_intf_mgr).

virtual void on_eth_lag_intf_delete(intf_id_t)

Handler called when a LAG ethernet interface is deleted.

After on_eth_lag_intf_delete is called, the given intf_id is guaranteed to not exist (ie eth_lag_intf_mgr::exists will return false). At that point, the intf_id cannot be used will any methods in the eth_lag_intf_mgr class, with the exception of methods used to create new LAG interfaces.

This also means that the intf_id can no longer be used with all other relevant *intf_mgr classes (ie intf_mgr and eth_intf_mgr).

virtual void on_lag_member_set(intf_id_t lag, intf_id_t member)

Handler called when a member interface is added to a watched LAG.

virtual void on_lag_member_del(intf_id_t lag, intf_id_t member)

Handler called when a member interface is removed from a watched LAG.

virtual void on_lag_intf_speed(intf_id_t lag, uint64_t speed)

Handler called when a LAG interface’s speed changes

class eth_lag_intf_iter_t
#include <eth_lag_intf.h>

An LAG interface iterator for 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 for 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 interfaces. 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

Iterates through the LAG interfaces in system. An intf_id_t pointer is returned for each LAG interface.

virtual bool exists(intf_id_t) const = 0

Returns whether the given ethernet LAG interface exists.

If exists returns true, then this intf_id_t can be successfully passed into every method of the eth_lag_intf_mgr. If not, then methods of the eth_lag_intf_mgr can throw a no_such_interface_error exception, or return empty data like intf_id_t().

The exists method of all *intf_mgr classes that manage a given interface (ie intf_mgr, eth_intf_mgr, and eth_lag_intf_mgr for LAG interfaces) are all guaranteed to return the same result.

virtual eth_lag_intf_member_iter_t eth_lag_intf_member_iter() const = 0

Iterates over physical interfaces configured as a member of any LAG interface in system. Note the interface may not be in a LAG interface yet, but still shows up if its priority/mode/timeout set. Yields an intf_id_t for each member.

virtual eth_lag_intf_member_iter_t eth_lag_intf_member_iter(intf_id_t eth_lag_intf_id) const = 0

Iterates over physical interfaces configured as members of a given LAG interface. Yields an intf_id_t for each member.

virtual void eth_lag_intf_is(intf_id_t eth_lag_intf_id) = 0

Creates a LAG interface, when given the LAG interface. No action will be taken if the LAG exists already.

virtual eth_lag_intf_t eth_lag_intf(intf_id_t eth_lag_intf_id) const = 0

Returns a LAG interface with the specified LAG interface. Will return an empty eth_lag_intf_t if the LAG does not exist already.

virtual void eth_lag_intf_del(intf_id_t eth_lag_intf_id) = 0

This API deletes a LAG interface. It is a no-op if the specified LAG interface doesn’t exist.

virtual uint64_t speed(intf_id_t eth_lag_intf_id) const = 0

Returns the speed of a LAG interface in megabits. If the interface does not exist, 0 is returned.

virtual void min_links_is(intf_id_t eth_lag_intf_id, uint32_t min_links) = 0

Sets the min links for a LAG interface. It’s a no-op if the specified LAG interface does not exist.

virtual uint32_t min_links(intf_id_t eth_lag_intf_id) const = 0

Returns the minimum number of member interfaces required to be `OPER_STATUS_UP` before this LAG interface considered `OPER_STATUS_UP`. If the LAG interface does not exist, 0 will be returned.

virtual void fallback_type_is(intf_id_t eth_lag_intf_id, eth_lag_intf_fallback_type_t fallback_type) = 0

Sets the fallback type for a LAG interface. It’s a no-op if the LAG interface does not exist. Throws “invalid_argument_error” exception if invalid fallback type is passed in.

virtual eth_lag_intf_fallback_type_t fallback_type(intf_id_t eth_lag_intf_id) const = 0

Returns the fallback mode for a LAG interface. ETH_LAG_INTF_FALLBACK_NULL is returned if the LAG interface does not exist.

virtual void fallback_timeout_is(intf_id_t eth_lag_intf_id, uint16_t fallback_timeout) = 0

Sets the fallback timeout for a LAG interface. It’s a no-op if the LAG interface does not exist.

virtual uint16_t fallback_timeout(intf_id_t eth_lag_intf_id) const = 0

Returns the LACP active mode timeout value in seconds. 0 is returned if the LAG interface does not exist.

virtual uint16_t fallback_timeout_default(intf_id_t eth_lag_intf_id) const = 0

Returns the default fallback timeout value in seconds.

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

This API adds/removes a physical interface to/from a LAG interface. To add an interface, the interface id and its LACP mode are needed. To remove an interface from a 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 a 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 a 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 member_intf_id) const = 0

Returns the LAG interface ID to which the physical interface is configured to belong. An empty intf_id_t is returned if the physical interface is not configured or is not in a LAG.

virtual eth_lag_intf_membership_t membership_status(intf_id_t member_intf_id) const = 0

Returns the member interface’s status details. Will return empty eth_lag_intf_membership_t if the physical interface is not configured, or it’s not active in a LAG.

virtual void member_priority_is(intf_id_t member_intf_id, uint16_t priority) = 0

Sets the port LACP priority.

virtual uint16_t member_priority(intf_id_t member_intf_id) const = 0

Gets the interface’s configured LACP priority. 0 will be returned if the member interface is not existing.

virtual void member_mode_is(intf_id_t member_intf_id, eth_lag_intf_member_lacp_mode_t mode) = 0

Sets the mode of this member in a LAG interface.

virtual eth_lag_intf_member_lacp_mode_t member_mode(intf_id_t member_intf_id) const = 0

Returns the mode of this member in a LAG interface. If the member interface is not existing, ETH_LAG_INTF_MEMBER_LACP_MODE_NULL is returned.

virtual void member_timeout_is(intf_id_t member_intf_id, eth_lag_intf_member_lacp_timeout_t timeout) = 0

Sets the LACP timeout for a member in a LAG.

virtual eth_lag_intf_member_lacp_timeout_t member_timeout(intf_id_t member_intf_id) const = 0

Gets the configured LACP timeout for a member in a LAG. If the member interface does not exist, ETH_LAG_INTF_MEMBER_LACP_TIMEOUT_NULL will be returned.

virtual bool member_active(intf_id_t member_intf_id) const = 0

Returns whether this interface is active in a LAG. False is returned if the member interface does not exist.

virtual double member_time(intf_id_t member_intf_id) const = 0

Returns the time in seconds since reboot when this interface was last added or removed as a member from a LAG. If this interface has never been a LAG member, this returns 0.

virtual std::string member_reason(intf_id_t member_intf_id) const = 0

Returns the reason this interface isn’t active in LAG. Returns the empty string if the interface is not configured to be in any LAG, or if the interface is active in the LAg.

virtual eth_lag_intf_membership_t eth_lag_intf_membership_status(intf_id_t member_intf_id) const = 0

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

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

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

Protected Functions

eth_lag_intf_mgr()

Private Members

eth_lag_intf_mgr

Friends

friend class eth_lag_intf_handler

Type definitions in eth_lag_intf

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()
eth_lag_intf_membership_t(intf_id_t eth_lag_intf_id, bool active, std::string const & reason, double member_time, eth_lag_intf_member_lacp_mode_t mode)

Constructor with paremeters.

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.

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.

eth_lag_intf_member_lacp_mode_t mode() const

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

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

The hash function for type eth_lag_intf_membership_t.

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.

eth_lag_intf_t(intf_id_t intf, uint32_t min_links, uint64_t speed, eth_lag_intf_fallback_type_t fallback_type, uint16_t fallback_timeout)

Constructor with interface id.

intf_id_t intf() const

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

uint64_t speed() const

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

uint32_t min_links() const

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

eth_lag_intf_fallback_type_t fallback_type() const

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

uint16_t fallback_timeout() const

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

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
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_
uint64_t 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

Next topic

eth_phy_intf