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); }
An LAG interface iterator iterating through all LAG interfaces created in the system.
Private Functions
Friends
An LAG member iterator iterating through all interfaces configured as a member of one LAG interface in the system.
Private Functions
Friends
The manager for LAG interface, this is the main entry point for applications to use EosSdk LAG APIs.
Public Functions
Iterate the LAG interfaces in system, intf_id_t pointer is returned for each LAG interface.
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.
This API creates an LAG interface, when given the LAG id. It may throw “invalid_argument_error” exception if the LAG exists already.
This API returns an LAG interface with the specified LAG id. May throw “invalid_argument_error” exception if the LAG does not exist already.
This API deletes an LAG interface, it will simply return if the specified LAG interface is not in existence.
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.
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.
This API returns the member intf operational status. It may throw “no_such_interface_error” if the specified “intf” does not exist.
This API sets the port LACP priority.
This API sets the mode of this member in an LAG interface.
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
Private Members
Enums
LAG interface fallback type.
Values:
Not a valid fallback type.
No fallback if no LACPDUs seen.
Fallback to static mode.
Fallback to individual mode.
How long to wait for LACP before fallback.
Values:
Values:
LAG interface mebmer LACP mode.
Values:
LAG interface mebmer timeout values.
Values:
This data structure is used to describe the operational status of an interface configured in an LAG interface.
Public Functions
Getter for ‘eth_lag_intf_id’: the LAG interface id this interface is configured to be in.
Setter for ‘eth_lag_intf_id’.
Getter for ‘active’: the attribute indicating whether this interface is active in an LAG.
Setter for ‘active’.
Getter for ‘reason’: if populated, reason this interface isn’t in LAG.
Setter for ‘reason’.
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.
Setter for ‘member_time’.
Getter for ‘mode’: the LACP mode this interface is configured.
Setter for ‘mode’.
Returns a string representation of the current object’s values.
Private Members
Friends
A utility stream operator that adds a string representation of eth_lag_intf_membership_t to the ostream.
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
Constructor with interface id.
Getter for ‘intf’: the id of this LAG interface.
Setter for ‘intf’.
Getter for ‘speed’: the aggregated capacity (speed) of this LAG interface in megabits.
Setter for ‘speed’.
Getter for ‘min_links’: the min links required up before bringing up an LAG interface.
Setter for ‘min_links’.
Getter for ‘fallback_type’: the fallback mode for this LAG interface.
Setter for ‘fallback_type’.
Getter for ‘fallback_timeout’: the LACP active mode timeout value in seconds.
Setter for ‘fallback_timeout’.
Returns the default fallback timeout value in seconds.
The hash function for type eth_lag_intf_t.
Returns a string representation of the current object’s values.
Private Members
Friends
A utility stream operator that adds a string representation of eth_lag_intf_t to the ostream.