Link Aggregation: Difference between revisions
No edit summary |
|||
| Line 1: | Line 1: | ||
Link Aggregation joins two or more network interfaces together. Depending on the configuration, you can increase bandwidth, throughput, performance and redundancy. | 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== | ==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. | |||
{| class="wikitable" | {| class="wikitable" | ||
!Mode | |||
!Type | !Type | ||
!Description | !Description | ||
|- | |- | ||
| | |0 | ||
|Round Robin policy and is the default mode. | |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. | |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 <code>xmit_hash_policy</code> option. | |||
|- | |||
|3 | |||
|broadcase | |||
|Everything is transmitted on all slave interfaces | |Everything is transmitted on all slave interfaces | ||
|- | |- | ||
| | |4 | ||
|Dynamic | |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. | |Adaptive transmit load balancing. Outgoing traffic is distributed based on load on each slave. | ||
|- | |- | ||
| | |6 | ||
|balance-alb | |||
|Adaptive load balancing. | |Adaptive load balancing. | ||
|} | |} | ||
You can see the current bonding status by reading {{code|/proc/net/bonding/bond0}}: | You can see the current bonding status by reading {{code|/proc/net/bonding/bond0}}: | ||
{{highlight|lang=terminal|code= | {{highlight | ||
# cat /proc/net/bonding/bond0 | | lang = terminal | ||
| style = max-height:350px;overflow:scroll; | |||
| code = # cat /proc/net/bonding/bond0 | |||
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) | Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) | ||
| Line 72: | Line 95: | ||
Slave queue ID: 0 | 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 <code>add-bond bridge-name bond-name interfaces options</code> subcommand. For example: | |||
{{Highlight | |||
| code = # ovs-vsctl add-br nic0 | |||
# ovs-vsctl add-bond nic0 bond0 eth0 eth1 bond_mode=balance-tcp lacp=active | |||
| lang = terminal | |||
}} | |||
==== Supported modes ==== | |||
{| class="wikitable" | |||
!bond_mode | |||
!Description | |||
|- | |||
|active-backup | |||
| | |||
|- | |||
|balance-slb | |||
| | |||
|- | |||
|balance-tcp | |||
| | |||
|} | |||
==== LACP options ==== | |||
Here are some common Open vSwitch options when working with LACP. More information can be found in the <code>man 5 ovs-vswitchd.conf.db</code> man page. | |||
{| class="wikitable" | |||
!Option | |||
!Description | |||
|- | |||
|<code>lacp</code> | |||
| | |||
* active - ports can initiate LACP negotiations | |||
* passive - ports can participate in LACP negotiations if initiated by the switch | |||
* off - do not use LACP (default) | |||
|- | |||
|<code>bond_mode</code> | |||
| | |||
* 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). | |||
|- | |||
|<code>other_config:bond-detect-mode</code> | |||
| | |||
* carrier - check by the link's carrier status | |||
* miimon - check by polling each interface's MII | |||
|- | |||
|<code>other_config:bond-miimon-interval</code> | |||
|Sets the miimon interval (if using miimon as the detection method) | |||
|- | |||
|<code>bond_updelay</code> | |||
|Milliseconds required for a link to remain up before it is considered up. Set to 0 to make interfaces up immediately. | |||
|- | |||
|<code>bond_downdelay</code> | |||
|Milliseconds required for a link to remain down before it is considered down. Set to 0 to make interfaces down immediately. | |||
|- | |||
|<code>other_config:lacp-fallback-ab</code> | |||
| | |||
* 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. | |||
|} | |||
To check on the status of your bond, run: <code>ovs-appctl lacp/show</code> | |||
To bring a port down, run: <code>ovs-ofctl mod-port br0 bond0 down</code> | |||
== Troubleshooting == | == Troubleshooting == | ||
Revision as of 01:33, 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
Supported modes
| bond_mode | Description |
|---|---|
| active-backup | |
| balance-slb | |
| balance-tcp |
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
|
|
bond_mode
|
|
other_config:bond-detect-mode
|
|
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
|
|
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
- https://en.wikipedia.org/wiki/Link_aggregation
- http://www.linuxhorizon.ro/bonding.html
- https://wiki.debian.org/Bonding
- https://www.interserver.net/tips/kb/network-bonding-types-network-bonding/