Link Aggregation: Difference between revisions

From Leo's Notes
This page was last edited on 8 February 2022, at 01:50.
No edit summary
Line 105: Line 105:
| lang = terminal
| lang = terminal
}}
}}
==== Supported modes ====
{| class="wikitable"
!bond_mode
!Description
|-
|active-backup
|
|-
|balance-slb
|
|-
|balance-tcp
|
|}


==== LACP options ====
==== LACP options ====
Line 129: Line 114:
|<code>lacp</code>
|<code>lacp</code>
|
|
* active - ports can initiate LACP negotiations
* <code>active</code> - ports can initiate LACP negotiations
* passive - ports can participate in LACP negotiations if initiated by the switch
* <code>passive</code> - ports can participate in LACP negotiations if initiated by the switch
* off - do not use LACP (default)
* <code>off</code> - do not use LACP (default)
|-
|-
|<code>bond_mode</code>
|<code>bond_mode</code>
|
|
* balance-slb - Balances traffic based on source MAC address and output VLAN
* <code>balance-slb</code> - Balances traffic based on source MAC address and output VLAN
* active-backup - Uses one member and fails over to a backup member (default)
* <code>active-backup</code> - Uses one member and fails over to a backup member (default)
* balance-tcp - Requires 802.3ad / LACP enabled. Balances traffic based on l3/l4 information (Eg. IP addresses or ports).
* <code>balance-tcp</code> - Requires 802.3ad / LACP enabled. Balances traffic based on l3/l4 information (Eg. IP addresses or ports).
|-
|-
|<code>other_config:bond-detect-mode</code>
|<code>other_config:bond-detect-mode</code>
|
|
* carrier - check by the link's carrier status
* <code>carrier</code> - check by the link's carrier status
* miimon - check by polling each interface's MII
* <code>miimon</code> - check by polling each interface's MII
|-
|-
|<code>other_config:bond-miimon-interval</code>
|<code>other_config:bond-miimon-interval</code>
Line 155: Line 140:
|<code>other_config:lacp-fallback-ab</code>
|<code>other_config:lacp-fallback-ab</code>
|
|
* true - allows Open vSwitch to fallback to active-backup mode if the switch does not support LACP
* <code>true</code> - allows Open vSwitch to fallback to active-backup mode if the switch does not support LACP
* false - the bond will be disabled if LACP is not supported by the switch.
* <code>false</code> - the bond will be disabled if LACP is not supported by the switch (default).
|}
|}
To check on the status of your bond, run: <code>ovs-appctl lacp/show</code>
To check on the status of your bond, run: <code>ovs-appctl lacp/show</code>

Revision as of 01:50, 8 February 2022

Link Aggregation joins two or more network interfaces together. Depending on the configuration, you can increase bandwidth, throughput, performance and redundancy.

In ethernet, link aggregation is defined in the 802.3ad and later 802.1ax standards. Link Aggregation Control Protocol or LACP is the implementation of these standards. Needless to say, LACP can only be used on switches that support LACP.

Linux

Link aggregation on Linux is available using either the Linux kernel ethernet bonding driver, the Linux Team driver (which runs the link validation, LACP implementation, etc. in user space), or some other application such as Open vSwitch.

Linux ethernet bonding driver

The Linux Ethernet bonding driver is typically included with most common distros. The driver is able to aggregate multiple ethernet interfaces (slaves) into a single logical 'bonded' interface.

Docs: https://www.kernel.org/doc/html/latest/networking/bonding.html

Supported modes

Each bonded interface can be configured with one of the following modes.

Mode Type Description
0 balance-rr Round Robin policy and is the default mode. Packets alternate in sequential order across all available interfaces.
1 active-backup Only one slave is active at one time. All slave interfaces will share the same MAC address.
2 balance-xor Transmits based on the hash of a packet's source / destination IP (layer2+3) / MAC (layer2) as defined in the xmit_hash_policy option.
3 broadcase Everything is transmitted on all slave interfaces
4 802.3ad IEEE 802.3ad Dynamic link aggregation policy. Used with a switch that supports IEEE 802.3ad dynamic link. Use this option if your switch is configured for 802.3ad / LACP. Some switches block all traffic for ports configured to use LACP until LACP is negotiated, so setting this option properly is very important.
5 balance-tlb Adaptive transmit load balancing. Outgoing traffic is distributed based on load on each slave.
6 balance-alb Adaptive load balancing.

You can see the current bonding status by reading /proc/net/bonding/bond0:

# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
 
Bonding Mode: fault-tolerance (active-backup) (fail_over_mac active)
Primary Slave: None
Currently Active Slave: ib2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
 
Slave Interface: ib0
MII Status: up
Speed: 56000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: a0:00:00:2a:fe:80
Slave queue ID: 0
 
Slave Interface: ib1
MII Status: up
Speed: 56000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: a0:00:00:2c:fe:80
Slave queue ID: 0
 
Slave Interface: ib2
MII Status: up
Speed: 56000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: a0:00:00:2a:fe:80
Slave queue ID: 0
 
Slave Interface: ib3
MII Status: up
Speed: 56000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: a0:00:00:2c:fe:80
Slave queue ID: 0

Open vSwitch

Open vSwitch can be used to create a bonded network interface as a port to a virtual bridge.

To create a new bond, use the add-bond bridge-name bond-name interfaces options subcommand. For example:

# ovs-vsctl add-br nic0
# ovs-vsctl add-bond nic0 bond0 eth0 eth1 bond_mode=balance-tcp lacp=active

LACP options

Here are some common Open vSwitch options when working with LACP. More information can be found in the man 5 ovs-vswitchd.conf.db man page.

Option Description
lacp
  • active - ports can initiate LACP negotiations
  • passive - ports can participate in LACP negotiations if initiated by the switch
  • off - do not use LACP (default)
bond_mode
  • balance-slb - Balances traffic based on source MAC address and output VLAN
  • active-backup - Uses one member and fails over to a backup member (default)
  • balance-tcp - Requires 802.3ad / LACP enabled. Balances traffic based on l3/l4 information (Eg. IP addresses or ports).
other_config:bond-detect-mode
  • carrier - check by the link's carrier status
  • miimon - check by polling each interface's MII
other_config:bond-miimon-interval Sets the miimon interval (if using miimon as the detection method)
bond_updelay Milliseconds required for a link to remain up before it is considered up. Set to 0 to make interfaces up immediately.
bond_downdelay Milliseconds required for a link to remain down before it is considered down. Set to 0 to make interfaces down immediately.
other_config:lacp-fallback-ab
  • true - allows Open vSwitch to fallback to active-backup mode if the switch does not support LACP
  • false - the bond will be disabled if LACP is not supported by the switch (default).

To check on the status of your bond, run: ovs-appctl lacp/show

To bring a port down, run: ovs-ofctl mod-port br0 bond0 down

Troubleshooting

Bond link keeps on randomly dying

I have a bond0 interface that randomly stops communicating with another device on the infiniband network. Here's some duct tape to toggle the active slave down and up which causes the bond to pick another active slave which in doing so fixes the network issues (at least temporarily). I run this script every 5 minutes via cronjob.

#!/bin/bash

function fix_fail (){
        echo Fixing a bad connection
        ActiveIb=$(cat /proc/net/bonding/bond0 |grep -i "Currently Active" | awk '{print $4}')
        /sbin/ifconfig $ActiveIb down
        /sbin/ifconfig $ActiveIb up
}

ping -W 2 -c 5 ems1-ib || fix_fail

See Also