Linux Ethernet Bonding Driver HOWTO¶
Latest update: 27 April 2011
Initial release: Thomas Davis <tadavis at lbl.gov>
Corrections, HA extensions: 2000/10/03-15:
Willy Tarreau <willy at meta-x.org>
Constantine Gavrilov <const-g at xpert.com>
Chad N. Tindel <ctindel at ieee dot org>
Janice Girouard <girouard at us dot ibm dot com>
Jay Vosburgh <fubar at us dot ibm dot com>
Reorganized and updated Feb 2005 by Jay VosburghAdded Sysfs information: 2006/04/24
Mitch Williams <mitch.a.williams at intel.com>
Introduction¶
The Linux bonding driver provides a method for aggregatingmultiple network interfaces into a single logical “bonded” interface.The behavior of the bonded interfaces depends upon the mode; generallyspeaking, modes provide either hot standby or load balancing services.Additionally, link integrity monitoring may be performed.
The bonding driver originally came from Donald Becker’sbeowulf patches for kernel 2.0. It has changed quite a bit since, andthe original tools from extreme-linux and beowulf sites will not workwith this version of the driver.
For new versions of the driver, updated userspace tools, andwho to ask for help, please follow the links at the end of this file.
1. Bonding Driver Installation¶
Most popular distro kernels ship with the bonding driveralready available as a module. If your distro does not, or youhave need to compile bonding from source (e.g., configuring andinstalling a mainline kernel from kernel.org), you’ll need to performthe following steps:
1.1 Configure and build the kernel with bonding¶
The current version of the bonding driver is available in thedrivers/net/bonding subdirectory of the most recent kernel source(which is available onhttp://kernel.org). Most users “rolling theirown” will want to use the most recent kernel from kernel.org.
Configure kernel with “make menuconfig” (or “make xconfig” or“make config”), then select “Bonding driver support” in the “Networkdevice support” section. It is recommended that you configure thedriver as module since it is currently the only way to pass parametersto the driver or configure more than one bonding device.
Build and install the new kernel and modules.
1.2 Bonding Control Utility¶
It is recommended to configure bonding via iproute2 (netlink)or sysfs, the old ifenslave control utility is obsolete.
2. Bonding Driver Options¶
Options for the bonding driver are supplied as parameters to thebonding module at load time, or are specified via sysfs.
Module options may be given as command line arguments to theinsmod or modprobe command, but are usually specified in either the/etc/modprobe.d/*.conf configuration files, or in a distro-specificconfiguration file (some of which are detailed in the next section).
Details on bonding support for sysfs is provided in the“Configuring Bonding Manually via Sysfs” section, below.
The available bonding driver parameters are listed below. If aparameter is not specified the default value is used. When initiallyconfiguring a bond, it is recommended “tail -f /var/log/messages” berun in a separate window to watch for bonding driver error messages.
It is critical that either the miimon or arp_interval andarp_ip_target parameters be specified, otherwise serious networkdegradation will occur during link failures. Very few devices do notsupport at least miimon, so there is really no reason not to use it.
Options with textual values will accept either the text nameor, for backwards compatibility, the option value. E.g.,“mode=802.3ad” and “mode=4” set the same mode.
The parameters are as follows:
active_slave
Specifies the new active slave for modes that support it(active-backup, balance-alb and balance-tlb). Possible valuesare the name of any currently enslaved interface, or an emptystring. If a name is given, the slave and its link must be up in orderto be selected as the new active slave. If an empty string isspecified, the current active slave is cleared, and a new activeslave is selected automatically.
Note that this is only available through the sysfs interface. No moduleparameter by this name exists.
The normal value of this option is the name of the currentlyactive slave, or the empty string if there is no active slave orthe current mode does not use an active slave.
ad_actor_sys_prio
In an AD system, this specifies the system priority. The allowed rangeis 1 - 65535. If the value is not specified, it takes 65535 as thedefault value.
This parameter has effect only in 802.3ad mode and is available throughSysFs interface.
actor_port_prio
In an AD system, this specifies the port priority. The allowed rangeis 1 - 65535. If the value is not specified, it takes 255 as thedefault value.
This parameter has effect only in 802.3ad mode and is available throughnetlink interface.
ad_actor_system
In an AD system, this specifies the mac-address for the actor inprotocol packet exchanges (LACPDUs). The value cannot be a multicastaddress. If the all-zeroes MAC is specified, bonding will internallyuse the MAC of the bond itself. It is preferred to have thelocal-admin bit set for this mac but driver does not enforce it. Ifthe value is not given then system defaults to using the masters’mac address as actors’ system address.
This parameter has effect only in 802.3ad mode and is available throughSysFs interface.
ad_select
Specifies the 802.3ad aggregation selection logic to use. Thepossible values and their effects are:
stable or 0
The active aggregator is chosen by largest aggregatebandwidth.
Reselection of the active aggregator occurs only when allslaves of the active aggregator are down or the activeaggregator has no slaves.
This is the default value.
bandwidth or 1
The active aggregator is chosen by largest aggregatebandwidth. Reselection occurs if:
A slave is added to or removed from the bond
Any slave’s link state changes
Any slave’s 802.3ad association state changes
The bond’s administrative state changes to up
count or 2
The active aggregator is chosen by the largest number ofports (slaves). Reselection occurs as described under the“bandwidth” setting, above.
actor_port_prio or 3
The active aggregator is chosen by the highest total sum ofactor port priorities across its active ports. Note thispriority is actor_port_prio, not per port prio, which isused for primary reselect.
The bandwidth, count and actor_port_prio selection policies permitfailover of 802.3ad aggregations when partial failure of the activeaggregator occurs. This keeps the aggregator with the highestavailability (either in bandwidth, number of ports, or total valueof port priorities) active at all times.
This option was added in bonding version 3.4.0.
ad_user_port_key
In an AD system, the port-key has three parts as shown below -
Bits
Use
00
Duplex
01-05
Speed
06-15
User-defined
This defines the upper 10 bits of the port key. The values can befrom 0 - 1023. If not given, the system defaults to 0.
This parameter has effect only in 802.3ad mode and is available throughSysFs interface.
all_slaves_active
Specifies that duplicate frames (received on inactive ports) should bedropped (0) or delivered (1).
Normally, bonding will drop duplicate frames (received on inactiveports), which is desirable for most users. But there are some timesit is nice to allow duplicate frames to be delivered.
The default value is 0 (drop duplicate frames received on inactiveports).
arp_interval
Specifies the ARP link monitoring frequency in milliseconds.
The ARP monitor works by periodically checking the slavedevices to determine whether they have sent or receivedtraffic recently (the precise criteria depends upon thebonding mode, and the state of the slave). Regular traffic isgenerated via ARP probes issued for the addresses specified bythe arp_ip_target option.
This behavior can be modified by the arp_validate option,below.
If ARP monitoring is used in an etherchannel compatible mode(modes 0 and 2), the switch should be configured in a modethat evenly distributes packets across all links. If theswitch is configured to distribute the packets in an XORfashion, all replies from the ARP targets will be received onthe same link which could cause the other team members tofail. ARP monitoring should not be used in conjunction withmiimon. A value of 0 disables ARP monitoring. The defaultvalue is 0.
arp_ip_target
Specifies the IP addresses to use as ARP monitoring peers whenarp_interval is > 0. These are the targets of the ARP requestsent to determine the health of the link to the targets.Specify these values in ddd.ddd.ddd.ddd format. Multiple IPaddresses must be separated by a comma. At least one IPaddress must be given for ARP monitoring to function. Themaximum number of targets that can be specified is 16. Thedefault value is no IP addresses.
ns_ip6_target
Specifies the IPv6 addresses to use as IPv6 monitoring peers whenarp_interval is > 0. These are the targets of the NS requestsent to determine the health of the link to the targets.Specify these values in ffff:ffff::ffff:ffff format. Multiple IPv6addresses must be separated by a comma. At least one IPv6address must be given for NS/NA monitoring to function. Themaximum number of targets that can be specified is 16. Thedefault value is no IPv6 addresses.
arp_validate
Specifies whether or not ARP probes and replies should bevalidated in any mode that supports arp monitoring, or whethernon-ARP traffic should be filtered (disregarded) for linkmonitoring purposes.
Possible values are:
none or 0
No validation or filtering is performed.
active or 1
Validation is performed only for the active slave.
backup or 2
Validation is performed only for backup slaves.
all or 3
Validation is performed for all slaves.
filter or 4
Filtering is applied to all slaves. No validation isperformed.
filter_active or 5
Filtering is applied to all slaves, validation is performedonly for the active slave.
filter_backup or 6
Filtering is applied to all slaves, validation is performedonly for backup slaves.
Validation:
Enabling validation causes the ARP monitor to examine the incomingARP requests and replies, and only consider a slave to be up if itis receiving the appropriate ARP traffic.
For an active slave, the validation checks ARP replies to confirmthat they were generated by an arp_ip_target. Since backup slavesdo not typically receive these replies, the validation performedfor backup slaves is on the broadcast ARP request sent out via theactive slave. It is possible that some switch or networkconfigurations may result in situations wherein the backup slavesdo not receive the ARP requests; in such a situation, validationof backup slaves must be disabled.
The validation of ARP requests on backup slaves is mainly helpingbonding to decide which slaves are more likely to work in case ofthe active slave failure, it doesn’t really guarantee that thebackup slave will work if it’s selected as the next active slave.
Validation is useful in network configurations in which multiplebonding hosts are concurrently issuing ARPs to one or more targetsbeyond a common switch. Should the link between the switch andtarget fail (but not the switch itself), the probe trafficgenerated by the multiple bonding instances will fool the standardARP monitor into considering the links as still up. Use ofvalidation can resolve this, as the ARP monitor will only considerARP requests and replies associated with its own instance ofbonding.
Filtering:
Enabling filtering causes the ARP monitor to only use incoming ARPpackets for link availability purposes. Arriving packets that arenot ARPs are delivered normally, but do not count when determiningif a slave is available.
Filtering operates by only considering the reception of ARPpackets (any ARP packet, regardless of source or destination) whendetermining if a slave has received traffic for link availabilitypurposes.
Filtering is useful in network configurations in which significantlevels of third party broadcast traffic would fool the standardARP monitor into considering the links as still up. Use offiltering can resolve this, as only ARP traffic is considered forlink availability purposes.
This option was added in bonding version 3.1.0.
arp_all_targets
Specifies the quantity of arp_ip_targets that must be reachablein order for the ARP monitor to consider a slave as being up.This option affects only active-backup mode for slaves witharp_validation enabled.
Possible values are:
any or 0
consider the slave up only when any of the arp_ip_targetsis reachable
all or 1
consider the slave up only when all of the arp_ip_targetsare reachable
arp_missed_max
Specifies the number of arp_interval monitor checks that mustfail in order for an interface to be marked down by the ARP monitor.
In order to provide orderly failover semantics, backup interfacesare permitted an extra monitor check (i.e., they must failarp_missed_max + 1 times before being marked down).
The default value is 2, and the allowable range is 1 - 255.
coupled_control
Specifies whether the LACP state machine’s MUX in the 802.3ad modeshould have separate Collecting and Distributing states.
This is by implementing the independent control state machine perIEEE 802.1AX-2008 5.4.15 in addition to the existing coupled controlstate machine.
The default value is 1. This setting does not separate the Collectingand Distributing states, maintaining the bond in coupled control.
downdelay
Specifies the time, in milliseconds, to wait before disablinga slave after a link failure has been detected. This optionis only valid for the miimon link monitor. The downdelayvalue should be a multiple of the miimon value; if not, itwill be rounded down to the nearest multiple. The defaultvalue is 0.
fail_over_mac
Specifies whether active-backup mode should set all slaves tothe same MAC address at enslavement (the traditionalbehavior), or, when enabled, perform special handling of thebond’s MAC address in accordance with the selected policy.
Possible values are:
none or 0
This setting disables fail_over_mac, and causesbonding to set all slaves of an active-backup bond tothe same MAC address at enslavement time. This is thedefault.
active or 1
The “active” fail_over_mac policy indicates that theMAC address of the bond should always be the MACaddress of the currently active slave. The MACaddress of the slaves is not changed; instead, the MACaddress of the bond changes during a failover.
This policy is useful for devices that cannot everalter their MAC address, or for devices that refuseincoming broadcasts with their own source MAC (whichinterferes with the ARP monitor).
The down side of this policy is that every device onthe network must be updated via gratuitous ARP,vs. just updating a switch or set of switches (whichoften takes place for any traffic, not just ARPtraffic, if the switch snoops incoming traffic toupdate its tables) for the traditional method. If thegratuitous ARP is lost, communication may bedisrupted.
When this policy is used in conjunction with the miimonitor, devices which assert link up prior to beingable to actually transmit and receive are particularlysusceptible to loss of the gratuitous ARP, and anappropriate updelay setting may be required.
follow or 2
The “follow” fail_over_mac policy causes the MACaddress of the bond to be selected normally (normallythe MAC address of the first slave added to the bond).However, the second and subsequent slaves are not setto this MAC address while they are in a backup role; aslave is programmed with the bond’s MAC address atfailover time (and the formerly active slave receivesthe newly active slave’s MAC address).
This policy is useful for multiport devices thateither become confused or incur a performance penaltywhen multiple ports are programmed with the same MACaddress.
The default policy is none, unless the first slave cannotchange its MAC address, in which case the active policy isselected by default.
This option may be modified via sysfs only when no slaves arepresent in the bond.
This option was added in bonding version 3.2.0. The “follow”policy was added in bonding version 3.3.0.
- lacp_active
Option specifying whether to send LACPDU frames periodically.
- off or 0
LACPDU frames acts as “speak when spoken to”.
- on or 1
LACPDU frames are sent along the configured linksperiodically. See lacp_rate for more details.
The default is on.
lacp_rate
Option specifying the rate in which we’ll ask our link partnerto transmit LACPDU packets in 802.3ad mode. Possible valuesare:
- slow or 0
Request partner to transmit LACPDUs every 30 seconds
- fast or 1
Request partner to transmit LACPDUs every 1 second
The default is slow.
broadcast_neighbor
Option specifying whether to broadcast ARP/ND packets to allactive slaves. This option has no effect in modes other than802.3ad mode. The default is off (0).
max_bonds
Specifies the number of bonding devices to create for thisinstance of the bonding driver. E.g., if max_bonds is 3, andthe bonding driver is not already loaded, then bond0, bond1and bond2 will be created. The default value is 1. Specifyinga value of 0 will load bonding, but will not create any devices.
miimon
Specifies the MII link monitoring frequency in milliseconds.This determines how often the link state of each slave isinspected for link failures. A value of zero disables MIIlink monitoring. A value of 100 is a good starting point.
The default value is 100 if arp_interval is not set.
min_links
Specifies the minimum number of links that must be active beforeasserting carrier. It is similar to the Cisco EtherChannel min-linksfeature. This allows setting the minimum number of member ports thatmust be up (link-up state) before marking the bond device as up(carrier on). This is useful for situations where higher level servicessuch as clustering want to ensure a minimum number of low bandwidthlinks are active before switchover. This option only affect 802.3admode.
The default value is 0. This will cause carrier to be asserted (for802.3ad mode) whenever there is an active aggregator, regardless of thenumber of available links in that aggregator. Note that, because anaggregator cannot be active without at least one available link,setting this option to 0 or to 1 has the exact same effect.
mode
Specifies one of the bonding policies. The default isbalance-rr (round robin). Possible values are:
balance-rr or 0
Round-robin policy: Transmit packets in sequentialorder from the first available slave through thelast. This mode provides load balancing and faulttolerance.
active-backup or 1
Active-backup policy: Only one slave in the bond isactive. A different slave becomes active if, and onlyif, the active slave fails. The bond’s MAC address isexternally visible on only one port (network adapter)to avoid confusing the switch.
In bonding version 2.6.2 or later, when a failoveroccurs in active-backup mode, bonding will issue oneor more gratuitous ARPs on the newly active slave.One gratuitous ARP is issued for the bonding masterinterface and each VLAN interfaces configured aboveit, provided that the interface has at least one IPaddress configured. Gratuitous ARPs issued for VLANinterfaces are tagged with the appropriate VLAN id.
This mode provides fault tolerance. The primaryoption, documented below, affects the behavior of thismode.
balance-xor or 2
XOR policy: Transmit based on the selected transmithash policy. The default policy is a simple [(sourceMAC address XOR’d with destination MAC address XORpacket type ID) modulo slave count]. Alternate transmitpolicies may be selected via the xmit_hash_policy option,described below.
This mode provides load balancing and fault tolerance.
broadcast or 3
Broadcast policy: transmits everything on all slaveinterfaces. This mode provides fault tolerance.
802.3ad or 4
IEEE 802.3ad Dynamic link aggregation. Createsaggregation groups that share the same speed andduplex settings. Utilizes all slaves in the activeaggregator according to the 802.3ad specification.
Slave selection for outgoing traffic is done accordingto the transmit hash policy, which may be changed fromthe default simple XOR policy via the xmit_hash_policyoption, documented below. Note that not all transmitpolicies may be 802.3ad compliant, particularly inregards to the packet mis-ordering requirements ofsection 43.2.4 of the 802.3ad standard. Differingpeer implementations will have varying tolerances fornoncompliance.
Prerequisites:
1. Ethtool support in the base drivers for retrievingthe speed and duplex of each slave.
2. A switch that supports IEEE 802.3ad Dynamic linkaggregation.
Most switches will require some type of configurationto enable 802.3ad mode.
balance-tlb or 5
Adaptive transmit load balancing: channel bonding thatdoes not require any special switch support.
In tlb_dynamic_lb=1 mode; the outgoing traffic isdistributed according to the current load (computedrelative to the speed) on each slave.
In tlb_dynamic_lb=0 mode; the load balancing based oncurrent load is disabled and the load is distributedonly using the hash distribution.
Incoming traffic is received by the current slave.If the receiving slave fails, another slave takes overthe MAC address of the failed receiving slave.
Prerequisite:
Ethtool support in the base drivers for retrieving thespeed of each slave.
balance-alb or 6
Adaptive load balancing: includes balance-tlb plusreceive load balancing (rlb) for IPV4 traffic, anddoes not require any special switch support. Thereceive load balancing is achieved by ARP negotiation.The bonding driver intercepts the ARP Replies sent bythe local system on their way out and overwrites thesource hardware address with the unique hardwareaddress of one of the slaves in the bond such thatdifferent peers use different hardware addresses forthe server.
Receive traffic from connections created by the serveris also balanced. When the local system sends an ARPRequest the bonding driver copies and saves the peer’sIP information from the ARP packet. When the ARPReply arrives from the peer, its hardware address isretrieved and the bonding driver initiates an ARPreply to this peer assigning it to one of the slavesin the bond. A problematic outcome of using ARPnegotiation for balancing is that each time that anARP request is broadcast it uses the hardware addressof the bond. Hence, peers learn the hardware addressof the bond and the balancing of receive trafficcollapses to the current slave. This is handled bysending updates (ARP Replies) to all the peers withtheir individually assigned hardware address such thatthe traffic is redistributed. Receive traffic is alsoredistributed when a new slave is added to the bondand when an inactive slave is re-activated. Thereceive load is distributed sequentially (round robin)among the group of highest speed slaves in the bond.
When a link is reconnected or a new slave joins thebond the receive traffic is redistributed among allactive slaves in the bond by initiating ARP Replieswith the selected MAC address to each of theclients. The updelay parameter (detailed below) mustbe set to a value equal or greater than the switch’sforwarding delay so that the ARP Replies sent to thepeers will not be blocked by the switch.
Prerequisites:
1. Ethtool support in the base drivers for retrievingthe speed of each slave.
2. Base driver support for setting the hardwareaddress of a device while it is open. This isrequired so that there will always be one slave in theteam using the bond hardware address (thecurr_active_slave) while having a unique hardwareaddress for each slave in the bond. If thecurr_active_slave fails its hardware address isswapped with the new curr_active_slave that waschosen.
num_grat_arp,num_unsol_na
Specify the number of peer notifications (gratuitous ARPs andunsolicited IPv6 Neighbor Advertisements) to be issued after afailover event. As soon as the link is up on the new slave(possibly immediately) a peer notification is sent on thebonding device and each VLAN sub-device. This is repeated atthe rate specified by peer_notif_delay if the number isgreater than 1.
The valid range is 0 - 255; the default value is 1. These optionsaffect the active-backup or 802.3ad (broadcast_neighbor enabled) mode.These options were added for bonding versions 3.3.0 and 3.4.0respectively.
From Linux 3.0 and bonding version 3.7.1, these notificationsare generated by the ipv4 and ipv6 code and the numbers ofrepetitions cannot be set independently.
packets_per_slave
Specify the number of packets to transmit through a slave beforemoving to the next one. When set to 0 then a slave is chosen atrandom.
The valid range is 0 - 65535; the default value is 1. This optionhas effect only in balance-rr mode.
peer_notif_delay
Specify the delay, in milliseconds, between each peernotification (gratuitous ARP and unsolicited IPv6 NeighborAdvertisement) when they are issued after a failover event.This delay should be a multiple of the MII link monitor interval(miimon).
The valid range is 0 - 300000. The default value is 0, which meansto match the value of the MII link monitor interval.
- prio
Slave priority. A higher number means higher priority.The primary slave has the highest priority. This option alsofollows the primary_reselect rules.
This option could only be configured via netlink, and is only validfor active-backup(1), balance-tlb (5) and balance-alb (6) mode.The valid value range is a signed 32 bit integer.
The default value is 0.
primary
A string (eth0, eth2, etc) specifying which slave is theprimary device. The specified device will always be theactive slave while it is available. Only when the primary isoff-line will alternate devices be used. This is useful whenone slave is preferred over another, e.g., when one slave hashigher throughput than another.
The primary option is only valid for active-backup(1),balance-tlb (5) and balance-alb (6) mode.
primary_reselect
Specifies the reselection policy for the primary slave. Thisaffects how the primary slave is chosen to become the active slavewhen failure of the active slave or recovery of the primary slaveoccurs. This option is designed to prevent flip-flopping betweenthe primary slave and other slaves. Possible values are:
always or 0 (default)
The primary slave becomes the active slave whenever itcomes back up.
better or 1
The primary slave becomes the active slave when it comesback up, if the speed and duplex of the primary slave isbetter than the speed and duplex of the current activeslave.
failure or 2
The primary slave becomes the active slave only if thecurrent active slave fails and the primary slave is up.
The primary_reselect setting is ignored in two cases:
If no slaves are active, the first slave to recover ismade the active slave.
When initially enslaved, the primary slave is always madethe active slave.
Changing the primary_reselect policy via sysfs will cause animmediate selection of the best active slave according to the newpolicy. This may or may not result in a change of the activeslave, depending upon the circumstances.
This option was added for bonding version 3.6.0.
tlb_dynamic_lb
Specifies if dynamic shuffling of flows is enabled in tlbor alb mode. The value has no effect on any other modes.
The default behavior of tlb mode is to shuffle active flows acrossslaves based on the load in that interval. This gives nice lbcharacteristics but can cause packet reordering. If re-ordering isa concern use this variable to disable flow shuffling and rely onload balancing provided solely by the hash distribution.xmit-hash-policy can be used to select the appropriate hashing forthe setup.
The sysfs entry can be used to change the setting per bond deviceand the initial value is derived from the module parameter. Thesysfs entry is allowed to be changed only if the bond device isdown.
The default value is “1” that enables flow shuffling while value “0”disables it. This option was added in bonding driver 3.7.1
updelay
Specifies the time, in milliseconds, to wait before enabling aslave after a link recovery has been detected. This option isonly valid for the miimon link monitor. The updelay valueshould be a multiple of the miimon value; if not, it will berounded down to the nearest multiple. The default value is 0.
use_carrier
Obsolete option that previously selected between MII /ETHTOOL ioctls and
netif_carrier_ok()to determine linkstate.All link state checks are now done with
netif_carrier_ok().For backwards compatibility, this option’s value may be inspectedor set. The only valid setting is 1.
xmit_hash_policy
Selects the transmit hash policy to use for slave selection inbalance-xor, 802.3ad, and tlb modes. Possible values are:
layer2
Uses XOR of hardware MAC addresses and packet type IDfield to generate the hash. The formula is
hash = source MAC[5] XOR destination MAC[5] XOR packet type IDslave number = hash modulo slave count
This algorithm will place all traffic to a particularnetwork peer on the same slave.
This algorithm is 802.3ad compliant.
layer2+3
This policy uses a combination of layer2 and layer3protocol information to generate the hash.
Uses XOR of hardware MAC addresses and IP addresses togenerate the hash. The formula is
hash = source MAC[5] XOR destination MAC[5] XOR packet type IDhash = hash XOR source IP XOR destination IPhash = hash XOR (hash RSHIFT 16)hash = hash XOR (hash RSHIFT 8)And then hash is reduced modulo slave count.
If the protocol is IPv6 then the source and destinationaddresses are first hashed using ipv6_addr_hash.
This algorithm will place all traffic to a particularnetwork peer on the same slave. For non-IP traffic,the formula is the same as for the layer2 transmithash policy.
This policy is intended to provide a more balanceddistribution of traffic than layer2 alone, especiallyin environments where a layer3 gateway device isrequired to reach most destinations.
This algorithm is 802.3ad compliant.
layer3+4
This policy uses upper layer protocol information,when available, to generate the hash. This allows fortraffic to a particular network peer to span multipleslaves, although a single connection will not spanmultiple slaves.
The formula for unfragmented TCP and UDP packets is
hash = source port, destination port (as in the header)hash = hash XOR source IP XOR destination IPhash = hash XOR (hash RSHIFT 16)hash = hash XOR (hash RSHIFT 8)hash = hash RSHIFT 1And then hash is reduced modulo slave count.
If the protocol is IPv6 then the source and destinationaddresses are first hashed using ipv6_addr_hash.
For fragmented TCP or UDP packets and all other IPv4 andIPv6 protocol traffic, the source and destination portinformation is omitted. For non-IP traffic, theformula is the same as for the layer2 transmit hashpolicy.
This algorithm is not fully 802.3ad compliant. Asingle TCP or UDP conversation containing bothfragmented and unfragmented packets will see packetsstriped across two interfaces. This may result in outof order delivery. Most traffic types will not meetthis criteria, as TCP rarely fragments traffic, andmost UDP traffic is not involved in extendedconversations. Other implementations of 802.3ad mayor may not tolerate this noncompliance.
encap2+3
This policy uses the same formula as layer2+3 but itrelies on skb_flow_dissect to obtain the header fieldswhich might result in the use of inner headers if anencapsulation protocol is used. For example this willimprove the performance for tunnel users because thepackets will be distributed according to the encapsulatedflows.
encap3+4
This policy uses the same formula as layer3+4 but itrelies on skb_flow_dissect to obtain the header fieldswhich might result in the use of inner headers if anencapsulation protocol is used. For example this willimprove the performance for tunnel users because thepackets will be distributed according to the encapsulatedflows.
vlan+srcmac
This policy uses a very rudimentary vlan ID and source machash to load-balance traffic per-vlan, with failovershould one leg fail. The intended use case is for a bondshared by multiple virtual machines, all configured touse their own vlan, to give lacp-like functionalitywithout requiring lacp-capable switching hardware.
The formula for the hash is simply
hash = (vlan ID) XOR (source MAC vendor) XOR (source MAC dev)
The default value is layer2. This option was added in bondingversion 2.6.3. In earlier versions of bonding, this parameterdoes not exist, and the layer2 policy is the only policy. Thelayer2+3 value was added for bonding version 3.2.2.
resend_igmp
Specifies the number of IGMP membership reports to be issued aftera failover event. One membership report is issued immediately afterthe failover, subsequent packets are sent in each 200ms interval.
The valid range is 0 - 255; the default value is 1. A value of 0prevents the IGMP membership report from being issued in responseto the failover event.
This option is useful for bonding modes balance-rr (0), active-backup(1), balance-tlb (5) and balance-alb (6), in which a failover canswitch the IGMP traffic from one slave to another. Therefore a freshIGMP report must be issued to cause the switch to forward the incomingIGMP traffic over the newly selected slave.
This option was added for bonding version 3.7.0.
lp_interval
Specifies the number of seconds between instances where the bondingdriver sends learning packets to each slaves peer switch.
The valid range is 1 - 0x7fffffff; the default value is 1. This Optionhas effect only in balance-tlb and balance-alb modes.
3. Configuring Bonding Devices¶
You can configure bonding using either your distro’s networkinitialization scripts, or manually using either iproute2 or thesysfs interface. Distros generally use one of three packages for thenetwork initialization scripts: initscripts, sysconfig or interfaces.Recent versions of these packages have support for bonding, while olderversions do not.
We will first describe the options for configuring bonding fordistros using versions of initscripts, sysconfig and interfaces with fullor partial support for bonding, then provide information on enablingbonding without support from the network initialization scripts (i.e.,older versions of initscripts or sysconfig).
If you’re unsure whether your distro uses sysconfig,initscripts or interfaces, or don’t know if it’s new enough, have no fear.Determining this is fairly straightforward.
First, look for a file called interfaces in /etc/network directory.If this file is present in your system, then your system use interfaces. SeeConfiguration with Interfaces Support.
Else, issue the command:
$ rpm -qf /sbin/ifup
It will respond with a line of text starting with either“initscripts” or “sysconfig,” followed by some numbers. This is thepackage that provides your network initialization scripts.
Next, to determine if your installation supports bonding,issue the command:
$ grep ifenslave /sbin/ifup
If this returns any matches, then your initscripts orsysconfig has support for bonding.
3.1 Configuration with Sysconfig Support¶
This section applies to distros using a version of sysconfigwith bonding support, for example, SuSE Linux Enterprise Server 9.
SuSE SLES 9’s networking configuration system does supportbonding, however, at this writing, the YaST system configurationfront end does not provide any means to work with bonding devices.Bonding devices can be managed by hand, however, as follows.
First, if they have not already been configured, configure theslave devices. On SLES 9, this is most easily done by running theyast2 sysconfig configuration utility. The goal is for to create anifcfg-id file for each slave device. The simplest way to accomplishthis is to configure the devices for DHCP (this is only to get thefile ifcfg-id file created; see below for some issues with DHCP). Thename of the configuration file for each device will be of the form:
ifcfg-id-xx:xx:xx:xx:xx:xx
Where the “xx” portion will be replaced with the digits fromthe device’s permanent MAC address.
Once the set of ifcfg-id-xx:xx:xx:xx:xx:xx files has beencreated, it is necessary to edit the configuration files for the slavedevices (the MAC addresses correspond to those of the slave devices).Before editing, the file will contain multiple lines, and will looksomething like this:
BOOTPROTO='dhcp'STARTMODE='on'USERCTL='no'UNIQUE='XNzu.WeZGOGF+4wE'_nm_name='bus-pci-0001:61:01.0'
Change the BOOTPROTO and STARTMODE lines to the following:
BOOTPROTO='none'STARTMODE='off'
Do not alter the UNIQUE or _nm_name lines. Remove any otherlines (USERCTL, etc).
Once the ifcfg-id-xx:xx:xx:xx:xx:xx files have been modified,it’s time to create the configuration file for the bonding deviceitself. This file is named ifcfg-bondX, where X is the number of thebonding device to create, starting at 0. The first such file isifcfg-bond0, the second is ifcfg-bond1, and so on. The sysconfignetwork configuration system will correctly start multiple instancesof bonding.
The contents of the ifcfg-bondX file is as follows:
BOOTPROTO="static"BROADCAST="10.0.2.255"IPADDR="10.0.2.10"NETMASK="255.255.0.0"NETWORK="10.0.2.0"REMOTE_IPADDR=""STARTMODE="onboot"BONDING_MASTER="yes"BONDING_MODULE_OPTS="mode=active-backup miimon=100"BONDING_SLAVE0="eth0"BONDING_SLAVE1="bus-pci-0000:06:08.1"
Replace the sample BROADCAST, IPADDR, NETMASK and NETWORKvalues with the appropriate values for your network.
The STARTMODE specifies when the device is brought online.The possible values are:
onboot
The device is started at boot time. If you’re notsure, this is probably what you want.
manual
The device is started only when ifup is calledmanually. Bonding devices may be configured thisway if you do not wish them to start automaticallyat boot for some reason.
hotplug
The device is started by a hotplug event. This is nota valid choice for a bonding device.
off or
The device configuration is ignored.
ignore
The line BONDING_MASTER=’yes’ indicates that the device is abonding master device. The only useful value is “yes.”
The contents of BONDING_MODULE_OPTS are supplied to theinstance of the bonding module for this device. Specify the optionsfor the bonding mode, link monitoring, and so on here. Do not includethe max_bonds bonding parameter; this will confuse the configurationsystem if you have multiple bonding devices.
Finally, supply one BONDING_SLAVEn=”slave device” for eachslave. where “n” is an increasing value, one for each slave. The“slave device” is either an interface name, e.g., “eth0”, or a devicespecifier for the network device. The interface name is easier tofind, but the ethN names are subject to change at boot time if, e.g.,a device early in the sequence has failed. The device specifiers(bus-pci-0000:06:08.1 in the example above) specify the physicalnetwork device, and will not change unless the device’s bus locationchanges (for example, it is moved from one PCI slot to another). Theexample above uses one of each type for demonstration purposes; mostconfigurations will choose one or the other for all slave devices.
When all configuration files have been modified or created,networking must be restarted for the configuration changes to takeeffect. This can be accomplished via the following:
# /etc/init.d/network restart
Note that the network control script (/sbin/ifdown) willremove the bonding module as part of the network shutdown processing,so it is not necessary to remove the module by hand if, e.g., themodule parameters have changed.
Also, at this writing, YaST/YaST2 will not manage bondingdevices (they do not show bonding interfaces on its list of networkdevices). It is necessary to edit the configuration file by hand tochange the bonding configuration.
Additional general options and details of the ifcfg fileformat can be found in an example ifcfg template file:
/etc/sysconfig/network/ifcfg.template
Note that the template does not document the variousBONDING_*settings described above, but does describe many of the other options.
3.1.1 Using DHCP with Sysconfig¶
Under sysconfig, configuring a device with BOOTPROTO=’dhcp’will cause it to query DHCP for its IP address information. At thiswriting, this does not function for bonding devices; the scriptsattempt to obtain the device address from DHCP prior to adding any ofthe slave devices. Without active slaves, the DHCP requests are notsent to the network.
3.1.2 Configuring Multiple Bonds with Sysconfig¶
The sysconfig network initialization system is capable ofhandling multiple bonding devices. All that is necessary is for eachbonding instance to have an appropriately configured ifcfg-bondX file(as described above). Do not specify the “max_bonds” parameter to anyinstance of bonding, as this will confuse sysconfig. If you requiremultiple bonding devices with identical parameters, create multipleifcfg-bondX files.
Because the sysconfig scripts supply the bonding moduleoptions in the ifcfg-bondX file, it is not necessary to add them tothe system/etc/modules.d/*.conf configuration files.
3.2 Configuration with Initscripts Support¶
This section applies to distros using a recent version ofinitscripts with bonding support, for example, Red Hat Enterprise Linuxversion 3 or later, Fedora, etc. On these systems, the networkinitialization scripts have knowledge of bonding, and can be configured tocontrol bonding devices. Note that older versions of the initscriptspackage have lower levels of support for bonding; this will be noted whereapplicable.
These distros will not automatically load the network adapterdriver unless the ethX device is configured with an IP address.Because of this constraint, users must manually configure anetwork-script file for all physical adapters that will be members ofa bondX link. Network script files are located in the directory:
/etc/sysconfig/network-scripts
The file name must be prefixed with “ifcfg-eth” and suffixedwith the adapter’s physical adapter number. For example, the scriptfor eth0 would be named /etc/sysconfig/network-scripts/ifcfg-eth0.Place the following text in the file:
DEVICE=eth0USERCTL=noONBOOT=yesMASTER=bond0SLAVE=yesBOOTPROTO=none
The DEVICE= line will be different for every ethX device andmust correspond with the name of the file, i.e., ifcfg-eth1 must havea device line of DEVICE=eth1. The setting of the MASTER= line willalso depend on the final bonding interface name chosen for your bond.As with other network devices, these typically start at 0, and go upone for each device, i.e., the first bonding instance is bond0, thesecond is bond1, and so on.
Next, create a bond network script. The file name for thisscript will be /etc/sysconfig/network-scripts/ifcfg-bondX where X isthe number of the bond. For bond0 the file is named “ifcfg-bond0”,for bond1 it is named “ifcfg-bond1”, and so on. Within that file,place the following text:
DEVICE=bond0IPADDR=192.168.1.1NETMASK=255.255.255.0NETWORK=192.168.1.0BROADCAST=192.168.1.255ONBOOT=yesBOOTPROTO=noneUSERCTL=no
Be sure to change the networking specific lines (IPADDR,NETMASK, NETWORK and BROADCAST) to match your network configuration.
For later versions of initscripts, such as that found with Fedora7 (or later) and Red Hat Enterprise Linux version 5 (or later), it is possible,and, indeed, preferable, to specify the bonding options in the ifcfg-bond0file, e.g. a line of the format:
BONDING_OPTS="mode=active-backup arp_interval=60 arp_ip_target=192.168.1.254"
will configure the bond with the specified options. The optionsspecified in BONDING_OPTS are identical to the bonding module parametersexcept for the arp_ip_target field when using versions of initscripts olderthan and 8.57 (Fedora 8) and 8.45.19 (Red Hat Enterprise Linux 5.2). Whenusing older versions each target should be included as a separate option andshould be preceded by a ‘+’ to indicate it should be added to the list ofqueried targets, e.g.,:
arp_ip_target=+192.168.1.1 arp_ip_target=+192.168.1.2
is the proper syntax to specify multiple targets. When specifyingoptions via BONDING_OPTS, it is not necessary to edit/etc/modprobe.d/*.conf.
For even older versions of initscripts that do not supportBONDING_OPTS, it is necessary to edit /etc/modprobe.d/.conf, depending uponyour distro) to load the bonding module with your desired options when thebond0 interface is brought up. The following lines in /etc/modprobe.d/.confwill load the bonding module, and select its options:
alias bond0 bondingoptions bond0 mode=balance-alb miimon=100
Replace the sample parameters with the appropriate set ofoptions for your configuration.
Finally run “/etc/rc.d/init.d/network restart” as root. Thiswill restart the networking subsystem and your bond link should be nowup and running.
3.2.1 Using DHCP with Initscripts¶
Recent versions of initscripts (the versions supplied with FedoraCore 3 and Red Hat Enterprise Linux 4, or later versions, are reported towork) have support for assigning IP information to bonding devices viaDHCP.
To configure bonding for DHCP, configure it as describedabove, except replace the line “BOOTPROTO=none” with “BOOTPROTO=dhcp”and add a line consisting of “TYPE=Bonding”. Note that the TYPE valueis case sensitive.
3.2.2 Configuring Multiple Bonds with Initscripts¶
Initscripts packages that are included with Fedora 7 and Red HatEnterprise Linux 5 support multiple bonding interfaces by simplyspecifying the appropriate BONDING_OPTS= in ifcfg-bondX where X is thenumber of the bond. This support requires sysfs support in the kernel,and a bonding driver of version 3.0.0 or later. Other configurations maynot support this method for specifying multiple bonding interfaces; forthose instances, see the “Configuring Multiple Bonds Manually” section,below.
3.3 Configuring Bonding Manually with iproute2¶
This section applies to distros whose network initializationscripts (the sysconfig or initscripts package) do not have specificknowledge of bonding. One such distro is SuSE Linux Enterprise Serverversion 8.
The general method for these systems is to place the bondingmodule parameters into a config file in /etc/modprobe.d/ (asappropriate for the installed distro), then add modprobe and/orip link commands to the system’s global init script. The name ofthe global init script differs; for sysconfig, it is/etc/init.d/boot.local and for initscripts it is /etc/rc.d/rc.local.
For example, if you wanted to make a simple bond of two e100devices (presumed to be eth0 and eth1), and have it persist acrossreboots, edit the appropriate file (/etc/init.d/boot.local or/etc/rc.d/rc.local), and add the following:
modprobe bonding mode=balance-alb miimon=100modprobe e100ifconfig bond0 192.168.1.1 netmask 255.255.255.0 upip link set eth0 master bond0ip link set eth1 master bond0
Replace the example bonding module parameters and bond0network configuration (IP address, netmask, etc) with the appropriatevalues for your configuration.
Unfortunately, this method will not provide support for theifup and ifdown scripts on the bond devices. To reload the bondingconfiguration, it is necessary to run the initialization script, e.g.,:
# /etc/init.d/boot.local
or:
# /etc/rc.d/rc.local
It may be desirable in such a case to create a separate scriptwhich only initializes the bonding configuration, then call thatseparate script from within boot.local. This allows for bonding to beenabled without re-running the entire global init script.
To shut down the bonding devices, it is necessary to firstmark the bonding device itself as being down, then remove theappropriate device driver modules. For our example above, you can dothe following:
# ifconfig bond0 down# rmmod bonding# rmmod e100
Again, for convenience, it may be desirable to create a scriptwith these commands.
3.3.1 Configuring Multiple Bonds Manually¶
This section contains information on configuring multiplebonding devices with differing options for those systems whose networkinitialization scripts lack support for configuring multiple bonds.
If you require multiple bonding devices, but all with the sameoptions, you may wish to use the “max_bonds” module parameter,documented above.
To create multiple bonding devices with differing options, it ispreferable to use bonding parameters exported by sysfs, documented in thesection below.
For versions of bonding without sysfs support, the only means toprovide multiple instances of bonding with differing options is to loadthe bonding driver multiple times. Note that current versions of thesysconfig network initialization scripts handle this automatically; ifyour distro uses these scripts, no special action is needed. See thesection Configuring Bonding Devices, above, if you’re not sure about yournetwork initialization scripts.
To load multiple instances of the module, it is necessary tospecify a different name for each instance (the module loading systemrequires that every loaded module, even multiple instances of the samemodule, have a unique name). This is accomplished by supplying multiplesets of bonding options in/etc/modprobe.d/*.conf, for example:
alias bond0 bondingoptions bond0 -o bond0 mode=balance-rr miimon=100alias bond1 bondingoptions bond1 -o bond1 mode=balance-alb miimon=50
will load the bonding module two times. The first instance isnamed “bond0” and creates the bond0 device in balance-rr mode with anmiimon of 100. The second instance is named “bond1” and creates thebond1 device in balance-alb mode with an miimon of 50.
In some circumstances (typically with older distributions),the above does not work, and the second bonding instance never seesits options. In that case, the second options line can be substitutedas follows:
install bond1 /sbin/modprobe --ignore-install bonding -o bond1 \ mode=balance-alb miimon=50
This may be repeated any number of times, specifying a new andunique name in place of bond1 for each subsequent instance.
It has been observed that some Red Hat supplied kernels are unableto rename modules at load time (the “-o bond1” part). Attempts to passthat option to modprobe will produce an “Operation not permitted” error.This has been reported on some Fedora Core kernels, and has been seen onRHEL 4 as well. On kernels exhibiting this problem, it will be impossibleto configure multiple bonds with differing parameters (as they are olderkernels, and also lack sysfs support).
3.4 Configuring Bonding Manually via Sysfs¶
Starting with version 3.0.0, Channel Bonding may be configuredvia the sysfs interface. This interface allows dynamic configurationof all bonds in the system without unloading the module. It alsoallows for adding and removing bonds at runtime. Ifenslave is nolonger required, though it is still supported.
Use of the sysfs interface allows you to use multiple bondswith different configurations without having to reload the module.It also allows you to use multiple, differently configured bonds whenbonding is compiled into the kernel.
You must have the sysfs filesystem mounted to configurebonding this way. The examples in this document assume that youare using the standard mount point for sysfs, e.g. /sys. If yoursysfs filesystem is mounted elsewhere, you will need to adjust theexample paths accordingly.
Creating and Destroying Bonds¶
To add a new bond foo:
# echo +foo > /sys/class/net/bonding_masters
To remove an existing bond bar:
# echo -bar > /sys/class/net/bonding_masters
To show all existing bonds:
# cat /sys/class/net/bonding_masters
Note
due to 4K size limitation of sysfs files, this list may betruncated if you have more than a few hundred bonds. This is unlikelyto occur under normal operating conditions.
Adding and Removing Slaves¶
Interfaces may be enslaved to a bond using the file/sys/class/net/<bond>/bonding/slaves. The semantics for this fileare the same as for the bonding_masters file.
To enslave interface eth0 to bond bond0:
# ifconfig bond0 up# echo +eth0 > /sys/class/net/bond0/bonding/slaves
To free slave eth0 from bond bond0:
# echo -eth0 > /sys/class/net/bond0/bonding/slaves
When an interface is enslaved to a bond, symlinks between thetwo are created in the sysfs filesystem. In this case, you would get/sys/class/net/bond0/slave_eth0 pointing to /sys/class/net/eth0, and/sys/class/net/eth0/master pointing to /sys/class/net/bond0.
This means that you can tell quickly whether or not aninterface is enslaved by looking for the master symlink. Thus:# echo -eth0 > /sys/class/net/eth0/master/bonding/slaveswill free eth0 from whatever bond it is enslaved to, regardless ofthe name of the bond interface.
Changing a Bond’s Configuration¶
Each bond may be configured individually by manipulating thefiles located in /sys/class/net/<bond name>/bonding
The names of these files correspond directly with the command-line parameters described elsewhere in this file, and, with theexception of arp_ip_target, they accept the same values. To see thecurrent setting, simply cat the appropriate file.
A few examples will be given here; for specific usageguidelines for each parameter, see the appropriate section in thisdocument.
To configure bond0 for balance-alb mode:
# ifconfig bond0 down# echo 6 > /sys/class/net/bond0/bonding/mode- or -# echo balance-alb > /sys/class/net/bond0/bonding/mode
Note
The bond interface must be down before the mode can be changed.
To enable MII monitoring on bond0 with a 1 second interval:
# echo 1000 > /sys/class/net/bond0/bonding/miimon
Note
If ARP monitoring is enabled, it will disabled when MIImonitoring is enabled, and vice-versa.
To add ARP targets:
# echo +192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target# echo +192.168.0.101 > /sys/class/net/bond0/bonding/arp_ip_target
Note
up to 16 target addresses may be specified.
To remove an ARP target:
# echo -192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target
To configure the interval between learning packet transmits:
# echo 12 > /sys/class/net/bond0/bonding/lp_interval
Note
the lp_interval is the number of seconds between instances wherethe bonding driver sends learning packets to each slaves peer switch. Thedefault interval is 1 second.
Example Configuration¶
We begin with the same example that is shown in section 3.3,executed with sysfs, and without using ifenslave.
To make a simple bond of two e100 devices (presumed to be eth0and eth1), and have it persist across reboots, edit the appropriatefile (/etc/init.d/boot.local or /etc/rc.d/rc.local), and add thefollowing:
modprobe bondingmodprobe e100echo balance-alb > /sys/class/net/bond0/bonding/modeifconfig bond0 192.168.1.1 netmask 255.255.255.0 upecho 100 > /sys/class/net/bond0/bonding/miimonecho +eth0 > /sys/class/net/bond0/bonding/slavesecho +eth1 > /sys/class/net/bond0/bonding/slaves
To add a second bond, with two e1000 interfaces inactive-backup mode, using ARP monitoring, add the following lines toyour init script:
modprobe e1000echo +bond1 > /sys/class/net/bonding_mastersecho active-backup > /sys/class/net/bond1/bonding/modeifconfig bond1 192.168.2.1 netmask 255.255.255.0 upecho +192.168.2.100 /sys/class/net/bond1/bonding/arp_ip_targetecho 2000 > /sys/class/net/bond1/bonding/arp_intervalecho +eth2 > /sys/class/net/bond1/bonding/slavesecho +eth3 > /sys/class/net/bond1/bonding/slaves
3.5 Configuration with Interfaces Support¶
This section applies to distros which use /etc/network/interfaces fileto describe network interface configuration, most notably Debian and itsderivatives.
The ifup and ifdown commands on Debian don’t support bonding out ofthe box. The ifenslave-2.6 package should be installed to provide bondingsupport. Once installed, this package will providebond-* optionsto be used into /etc/network/interfaces.
Note that ifenslave-2.6 package will load the bonding module and usethe ifenslave command when appropriate.
Example Configurations¶
In /etc/network/interfaces, the following stanza will configure bond0, inactive-backup mode, with eth0 and eth1 as slaves:
auto bond0iface bond0 inet dhcp bond-slaves eth0 eth1 bond-mode active-backup bond-miimon 100 bond-primary eth0 eth1
If the above configuration doesn’t work, you might have a system usingupstart for system startup. This is most notably true for recentUbuntu versions. The following stanza in /etc/network/interfaces willproduce the same result on those systems:
auto bond0iface bond0 inet dhcp bond-slaves none bond-mode active-backup bond-miimon 100auto eth0iface eth0 inet manual bond-master bond0 bond-primary eth0 eth1auto eth1iface eth1 inet manual bond-master bond0 bond-primary eth0 eth1
For a full list ofbond-* supported options in /etc/network/interfaces andsome more advanced examples tailored to you particular distros, see the files in/usr/share/doc/ifenslave-2.6.
3.6 Overriding Configuration for Special Cases¶
When using the bonding driver, the physical port which transmits a frame istypically selected by the bonding driver, and is not relevant to the user orsystem administrator. The output port is simply selected using the policies ofthe selected bonding mode. On occasion however, it is helpful to direct certainclasses of traffic to certain physical interfaces on output to implementslightly more complex policies. For example, to reach a web server over abonded interface in which eth0 connects to a private network, while eth1connects via a public network, it may be desirous to bias the bond to send saidtraffic over eth0 first, using eth1 only as a fall back, while all other trafficcan safely be sent over either interface. Such configurations may be achievedusing the traffic control utilities inherent in linux.
By default the bonding driver is multiqueue aware and 16 queues are createdwhen the driver initializes (seeHOWTO for multiqueue network device supportfor details). If more or less queues are desired the module parametertx_queues can be used to change this value. There is no sysfs parameteravailable as the allocation is done at module init time.
The output of the file /proc/net/bonding/bondX has changed so the output QueueID is now printed for each slave:
Bonding Mode: fault-tolerance (active-backup)Primary Slave: NoneCurrently Active Slave: eth0MII Status: upMII Polling Interval (ms): 0Up Delay (ms): 0Down Delay (ms): 0Slave Interface: eth0MII Status: upLink Failure Count: 0Permanent HW addr: 00:1a:a0:12:8f:cbSlave queue ID: 0Slave Interface: eth1MII Status: upLink Failure Count: 0Permanent HW addr: 00:1a:a0:12:8f:ccSlave queue ID: 2
The queue_id for a slave can be set using the command:
# echo "eth1:2" > /sys/class/net/bond0/bonding/queue_id
Any interface that needs a queue_id set should set it with multiple callslike the one above until proper priorities are set for all interfaces. Ondistributions that allow configuration via initscripts, multiple ‘queue_id’arguments can be added to BONDING_OPTS to set all needed slave queues.
These queue id’s can be used in conjunction with the tc utility to configurea multiqueue qdisc and filters to bias certain traffic to transmit on certainslave devices. For instance, say we wanted, in the above configuration toforce all traffic bound to 192.168.1.100 to use eth1 in the bond as its outputdevice. The following commands would accomplish this:
# tc qdisc add dev bond0 handle 1 root multiq# tc filter add dev bond0 protocol ip parent 1: prio 1 u32 match ip \ dst 192.168.1.100 action skbedit queue_mapping 2
These commands tell the kernel to attach a multiqueue queue discipline to thebond0 interface and filter traffic enqueued to it, such that packets with a dstip of 192.168.1.100 have their output queue mapping value overwritten to 2.This value is then passed into the driver, causing the normal output pathselection policy to be overridden, selecting instead qid 2, which maps to eth1.
Note that qid values begin at 1. Qid 0 is reserved to initiate to the driverthat normal output policy selection should take place. One benefit to simplyleaving the qid for a slave to 0 is the multiqueue awareness in the bondingdriver that is now present. This awareness allows tc filters to be placed onslave devices as well as bond devices and the bonding driver will simply act asa pass-through for selecting output queues on the slave device rather thanoutput port selection.
This feature first appeared in bonding driver version 3.7.0 and support foroutput slave selection was limited to round-robin and active-backup modes.
3.7 Configuring LACP for 802.3ad mode in a more secure way¶
When using 802.3ad bonding mode, the Actor (host) and Partner (switch)exchange LACPDUs. These LACPDUs cannot be sniffed, because they aredestined to link local mac addresses (which switches/bridges are notsupposed to forward). However, most of the values are easily predictableor are simply the machine’s MAC address (which is trivially known to allother hosts in the same L2). This implies that other machines in the L2domain can spoof LACPDU packets from other hosts to the switch and potentiallycause mayhem by joining (from the point of view of the switch) anothermachine’s aggregate, thus receiving a portion of that hosts incomingtraffic and / or spoofing traffic from that machine themselves (potentiallyeven successfully terminating some portion of flows). Though this is nota likely scenario, one could avoid this possibility by simply configuringfew bonding parameters:
ad_actor_system : You can set a random mac-address that can be used forthese LACPDU exchanges. The value can not be either NULL or Multicast.Also it’s preferable to set the local-admin bit. Following shell codegenerates a random mac-address as described above:
# sys_mac_addr=$(printf '%02x:%02x:%02x:%02x:%02x:%02x' \ $(( (RANDOM & 0xFE) | 0x02 )) \ $(( RANDOM & 0xFF )) \ $(( RANDOM & 0xFF )) \ $(( RANDOM & 0xFF )) \ $(( RANDOM & 0xFF )) \ $(( RANDOM & 0xFF )))# echo $sys_mac_addr > /sys/class/net/bond0/bonding/ad_actor_systemad_actor_sys_prio : Randomize the system priority. The default valueis 65535, but system can take the value from 1 - 65535. Following shellcode generates random priority and sets it:
# sys_prio=$(( 1 + RANDOM + RANDOM ))# echo $sys_prio > /sys/class/net/bond0/bonding/ad_actor_sys_prioad_user_port_key : Use the user portion of the port-key. The defaultkeeps this empty. These are the upper 10 bits of the port-key and valueranges from 0 - 1023. Following shell code generates these 10 bits andsets it:
# usr_port_key=$(( RANDOM & 0x3FF ))# echo $usr_port_key > /sys/class/net/bond0/bonding/ad_user_port_key
4 Querying Bonding Configuration¶
4.1 Bonding Configuration¶
Each bonding device has a read-only file residing in the/proc/net/bonding directory. The file contents include informationabout the bonding configuration, options and state of each slave.
For example, the contents of /proc/net/bonding/bond0 after thedriver is loaded with parameters of mode=0 and miimon=1000 isgenerally as follows:
Ethernet Channel Bonding Driver: 2.6.1 (October 29, 2004)Bonding Mode: load balancing (round-robin)Currently Active Slave: eth0MII Status: upMII Polling Interval (ms): 1000Up Delay (ms): 0Down Delay (ms): 0Slave Interface: eth1MII Status: upLink Failure Count: 1Slave Interface: eth0MII Status: upLink Failure Count: 1
The precise format and contents will change depending upon thebonding configuration, state, and version of the bonding driver.
4.2 Network configuration¶
The network configuration can be inspected using the ifconfigcommand. Bonding devices will have the MASTER flag set; Bonding slavedevices will have the SLAVE flag set. The ifconfig output does notcontain information on which slaves are associated with which masters.
In the example below, the bond0 interface is the master(MASTER) while eth0 and eth1 are slaves (SLAVE). Notice all slaves ofbond0 have the same MAC address (HWaddr) as bond0 for all modes exceptTLB and ALB that require a unique MAC address for each slave:
# /sbin/ifconfigbond0 Link encap:Ethernet HWaddr 00:C0:F0:1F:37:B4 inet addr:XXX.XXX.XXX.YYY Bcast:XXX.XXX.XXX.255 Mask:255.255.252.0 UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1 RX packets:7224794 errors:0 dropped:0 overruns:0 frame:0 TX packets:3286647 errors:1 dropped:0 overruns:1 carrier:0 collisions:0 txqueuelen:0eth0 Link encap:Ethernet HWaddr 00:C0:F0:1F:37:B4 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:3573025 errors:0 dropped:0 overruns:0 frame:0 TX packets:1643167 errors:1 dropped:0 overruns:1 carrier:0 collisions:0 txqueuelen:100 Interrupt:10 Base address:0x1080eth1 Link encap:Ethernet HWaddr 00:C0:F0:1F:37:B4 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:3651769 errors:0 dropped:0 overruns:0 frame:0 TX packets:1643480 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 Interrupt:9 Base address:0x1400
5. Switch Configuration¶
For this section, “switch” refers to whatever system thebonded devices are directly connected to (i.e., where the other end ofthe cable plugs into). This may be an actual dedicated switch device,or it may be another regular system (e.g., another computer runningLinux),
The active-backup, balance-tlb and balance-alb modes do notrequire any specific configuration of the switch.
The 802.3ad mode requires that the switch have the appropriateports configured as an 802.3ad aggregation. The precise method usedto configure this varies from switch to switch, but, for example, aCisco 3550 series switch requires that the appropriate ports first begrouped together in a single etherchannel instance, then thatetherchannel is set to mode “lacp” to enable 802.3ad (instead ofstandard EtherChannel).
The balance-rr, balance-xor and broadcast modes generallyrequire that the switch have the appropriate ports grouped together.The nomenclature for such a group differs between switches, it may becalled an “etherchannel” (as in the Cisco example, above), a “trunkgroup” or some other similar variation. For these modes, each switchwill also have its own configuration options for the switch’s transmitpolicy to the bond. Typical choices include XOR of either the MAC orIP addresses. The transmit policy of the two peers does not need tomatch. For these three modes, the bonding mode really selects atransmit policy for an EtherChannel group; all three will interoperatewith another EtherChannel group.
6. 802.1q VLAN Support¶
It is possible to configure VLAN devices over a bond interfaceusing the 8021q driver. However, only packets coming from the 8021qdriver and passing through bonding will be tagged by default. Selfgenerated packets, for example, bonding’s learning packets or ARPpackets generated by either ALB mode or the ARP monitor mechanism, aretagged internally by bonding itself. As a result, bonding must“learn” the VLAN IDs configured above it, and use those IDs to tagself generated packets.
For reasons of simplicity, and to support the use of adaptersthat can do VLAN hardware acceleration offloading, the bondinginterface declares itself as fully hardware offloading capable, it getsthe add_vid/kill_vid notifications to gather the necessaryinformation, and it propagates those actions to the slaves. In caseof mixed adapter types, hardware accelerated tagged packets thatshould go through an adapter that is not offloading capable are“un-accelerated” by the bonding driver so the VLAN tag sits in theregular location.
VLAN interfacesmust be added on top of a bonding interfaceonly after enslaving at least one slave. The bonding interface has ahardware address of 00:00:00:00:00:00 until the first slave is added.If the VLAN interface is created prior to the first enslavement, itwould pick up the all-zeroes hardware address. Once the first slaveis attached to the bond, the bond device itself will pick up theslave’s hardware address, which is then available for the VLAN device.
Also, be aware that a similar problem can occur if all slavesare released from a bond that still has one or more VLAN interfaces ontop of it. When a new slave is added, the bonding interface willobtain its hardware address from the first slave, which might notmatch the hardware address of the VLAN interfaces (which wasultimately copied from an earlier slave).
There are two methods to ensure that the VLAN device operateswith the correct hardware address if all slaves are removed from abond interface:
Remove all VLAN interfaces then recreate them
2. Set the bonding interface’s hardware address so that itmatches the hardware address of the VLAN interfaces.
Note that changing a VLAN interface’s HW address would set theunderlying device -- i.e. the bonding interface -- to promiscuousmode, which might not be what you want.
7. Link Monitoring¶
The bonding driver at present supports two schemes formonitoring a slave device’s link state: the ARP monitor and the MIImonitor.
At the present time, due to implementation restrictions in thebonding driver itself, it is not possible to enable both ARP and MIImonitoring simultaneously.
7.1 ARP Monitor Operation¶
The ARP monitor operates as its name suggests: it sends ARPqueries to one or more designated peer systems on the network, anduses the response as an indication that the link is operating. Thisgives some assurance that traffic is actually flowing to and from oneor more peers on the local network.
7.2 Configuring Multiple ARP Targets¶
While ARP monitoring can be done with just one target, it canbe useful in a High Availability setup to have several targets tomonitor. In the case of just one target, the target itself may godown or have a problem making it unresponsive to ARP requests. Havingan additional target (or several) increases the reliability of the ARPmonitoring.
Multiple ARP targets must be separated by commas as follows:
# example options for ARP monitoring with three targetsalias bond0 bondingoptions bond0 arp_interval=60 arp_ip_target=192.168.0.1,192.168.0.3,192.168.0.9
For just a single target the options would resemble:
# example options for ARP monitoring with one targetalias bond0 bondingoptions bond0 arp_interval=60 arp_ip_target=192.168.0.100
7.3 MII Monitor Operation¶
The MII monitor monitors only the carrier state of the localnetwork interface. It accomplishes this in one of three ways: bydepending upon the device driver to maintain its carrier state, byquerying the device’s MII registers, or by making an ethtool query tothe device.
The MII monitor relies on the driver for carrier state information (viathe netif_carrier subsystem).
8. Potential Sources of Trouble¶
8.1 Adventures in Routing¶
When bonding is configured, it is important that the slavedevices not have routes that supersede routes of the master (or,generally, not have routes at all). For example, suppose the bondingdevice bond0 has two slaves, eth0 and eth1, and the routing table isas follows:
Kernel IP routing tableDestination Gateway Genmask Flags MSS Window irtt Iface10.0.0.0 0.0.0.0 255.255.0.0 U 40 0 0 eth010.0.0.0 0.0.0.0 255.255.0.0 U 40 0 0 eth110.0.0.0 0.0.0.0 255.255.0.0 U 40 0 0 bond0127.0.0.0 0.0.0.0 255.0.0.0 U 40 0 0 lo
This routing configuration will likely still update thereceive/transmit times in the driver (needed by the ARP monitor), butmay bypass the bonding driver (because outgoing traffic to, in thiscase, another host on network 10 would use eth0 or eth1 before bond0).
The ARP monitor (and ARP itself) may become confused by thisconfiguration, because ARP requests (generated by the ARP monitor)will be sent on one interface (bond0), but the corresponding replywill arrive on a different interface (eth0). This reply looks to ARPas an unsolicited ARP reply (because ARP matches replies on aninterface basis), and is discarded. The MII monitor is not affectedby the state of the routing table.
The solution here is simply to ensure that slaves do not haveroutes of their own, and if for some reason they must, those routes donot supersede routes of their master. This should generally be thecase, but unusual configurations or errant manual or automatic staticroute additions may cause trouble.
8.2 Ethernet Device Renaming¶
On systems with network configuration scripts that do notassociate physical devices directly with network interface names (sothat the same physical device always has the same “ethX” name), it maybe necessary to add some special logic to config files in/etc/modprobe.d/.
For example, given a modules.conf containing the following:
alias bond0 bondingoptions bond0 mode=some-mode miimon=50alias eth0 tg3alias eth1 tg3alias eth2 e1000alias eth3 e1000
If neither eth0 and eth1 are slaves to bond0, then when thebond0 interface comes up, the devices may end up reordered. Thishappens because bonding is loaded first, then its slave device’sdrivers are loaded next. Since no other drivers have been loaded,when the e1000 driver loads, it will receive eth0 and eth1 for itsdevices, but the bonding configuration tries to enslave eth2 and eth3(which may later be assigned to the tg3 devices).
Adding the following:
add above bonding e1000 tg3
causes modprobe to load e1000 then tg3, in that order, whenbonding is loaded. This command is fully documented in themodules.conf manual page.
On systems utilizing modprobe an equivalent problem can occur.In this case, the following can be added to config files in/etc/modprobe.d/ as:
softdep bonding pre: tg3 e1000
This will load tg3 and e1000 modules before loading the bonding one.Full documentation on this can be found in the modprobe.d and modprobemanual pages.
9. SNMP agents¶
If running SNMP agents, the bonding driver should be loadedbefore any network drivers participating in a bond. This requirementis due to the interface index (ipAdEntIfIndex) being associated tothe first interface found with a given IP address. That is, there isonly one ipAdEntIfIndex for each IP address. For example, if eth0 andeth1 are slaves of bond0 and the driver for eth0 is loaded before thebonding driver, the interface for the IP address will be associatedwith the eth0 interface. This configuration is shown below, the IPaddress 192.168.1.1 has an interface index of 2 which indexes to eth0in the ifDescr table (ifDescr.2).
interfaces.ifTable.ifEntry.ifDescr.1 = lointerfaces.ifTable.ifEntry.ifDescr.2 = eth0interfaces.ifTable.ifEntry.ifDescr.3 = eth1interfaces.ifTable.ifEntry.ifDescr.4 = eth2interfaces.ifTable.ifEntry.ifDescr.5 = eth3interfaces.ifTable.ifEntry.ifDescr.6 = bond0ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.10.10.10.10 = 5ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.1.1 = 2ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.10.74.20.94 = 4ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
This problem is avoided by loading the bonding driver beforeany network drivers participating in a bond. Below is an example ofloading the bonding driver first, the IP address 192.168.1.1 iscorrectly associated with ifDescr.2.
interfaces.ifTable.ifEntry.ifDescr.1 = lointerfaces.ifTable.ifEntry.ifDescr.2 = bond0interfaces.ifTable.ifEntry.ifDescr.3 = eth0interfaces.ifTable.ifEntry.ifDescr.4 = eth1interfaces.ifTable.ifEntry.ifDescr.5 = eth2interfaces.ifTable.ifEntry.ifDescr.6 = eth3ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.10.10.10.10 = 6ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.1.1 = 2ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.10.74.20.94 = 5ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
While some distributions may not report the interface name inifDescr, the association between the IP address and IfIndex remainsand SNMP functions such as Interface_Scan_Next will report thatassociation.
10. Promiscuous mode¶
When running network monitoring tools, e.g., tcpdump, it iscommon to enable promiscuous mode on the device, so that all trafficis seen (instead of seeing only traffic destined for the local host).The bonding driver handles promiscuous mode changes to the bondingmaster device (e.g., bond0), and propagates the setting to the slavedevices.
For the balance-rr, balance-xor, broadcast, and 802.3ad modes,the promiscuous mode setting is propagated to all slaves.
For the active-backup, balance-tlb and balance-alb modes, thepromiscuous mode setting is propagated only to the active slave.
For balance-tlb mode, the active slave is the slave currentlyreceiving inbound traffic.
For balance-alb mode, the active slave is the slave used as a“primary.” This slave is used for mode-specific control traffic, forsending to peers that are unassigned or if the load is unbalanced.
For the active-backup, balance-tlb and balance-alb modes, whenthe active slave changes (e.g., due to a link failure), thepromiscuous setting will be propagated to the new active slave.
11. Configuring Bonding for High Availability¶
High Availability refers to configurations that providemaximum network availability by having redundant or backup devices,links or switches between the host and the rest of the world. Thegoal is to provide the maximum availability of network connectivity(i.e., the network always works), even though other configurationscould provide higher throughput.
11.1 High Availability in a Single Switch Topology¶
If two hosts (or a host and a single switch) are directlyconnected via multiple physical links, then there is no availabilitypenalty to optimizing for maximum bandwidth. In this case, there isonly one switch (or peer), so if it fails, there is no alternativeaccess to fail over to. Additionally, the bonding load balance modessupport link monitoring of their members, so if individual links fail,the load will be rebalanced across the remaining devices.
See Section 12, “Configuring Bonding for Maximum Throughput”for information on configuring bonding with one peer device.
11.2 High Availability in a Multiple Switch Topology¶
With multiple switches, the configuration of bonding and thenetwork changes dramatically. In multiple switch topologies, there isa trade off between network availability and usable bandwidth.
Below is a sample network, configured to maximize theavailability of the network:
| | |port3 port3|+-----+----+ +-----+----+| |port2 ISL port2| || switch A +--------------------------+ switch B || | | |+-----+----+ +-----++---+ |port1 port1| | +-------+ | +-------------+ host1 +---------------+ eth0 +-------+ eth1
In this configuration, there is a link between the twoswitches (ISL, or inter switch link), and multiple ports connecting tothe outside world (“port3” on each switch). There is no technicalreason that this could not be extended to a third switch.
11.2.1 HA Bonding Mode Selection for Multiple Switch Topology¶
In a topology such as the example above, the active-backup andbroadcast modes are the only useful bonding modes when optimizing foravailability; the other modes require all links to terminate on thesame peer for them to behave rationally.
- active-backup:
This is generally the preferred mode, particularly ifthe switches have an ISL and play together well. If thenetwork configuration is such that one switch is specificallya backup switch (e.g., has lower capacity, higher cost, etc),then the primary option can be used to ensure that thepreferred link is always used when it is available.
- broadcast:
This mode is really a special purpose mode, and is suitableonly for very specific needs. For example, if the twoswitches are not connected (no ISL), and the networks beyondthem are totally independent. In this case, if it isnecessary for some specific one-way traffic to reach bothindependent networks, then the broadcast mode may be suitable.
11.2.2 HA Link Monitoring Selection for Multiple Switch Topology¶
The choice of link monitoring ultimately depends upon yourswitch. If the switch can reliably fail ports in response to otherfailures, then either the MII or ARP monitors should work. Forexample, in the above example, if the “port3” link fails at the remoteend, the MII monitor has no direct means to detect this. The ARPmonitor could be configured with a target at the remote end of port3,thus detecting that failure without switch support.
In general, however, in a multiple switch topology, the ARPmonitor can provide a higher level of reliability in detecting end toend connectivity failures (which may be caused by the failure of anyindividual component to pass traffic for any reason). Additionally,the ARP monitor should be configured with multiple targets (at leastone for each switch in the network). This will ensure that,regardless of which switch is active, the ARP monitor has a suitabletarget to query.
Note, also, that of late many switches now support a functionalitygenerally referred to as “trunk failover.” This is a feature of theswitch that causes the link state of a particular switch port to be setdown (or up) when the state of another switch port goes down (or up).Its purpose is to propagate link failures from logically “exterior” portsto the logically “interior” ports that bonding is able to monitor viamiimon. Availability and configuration for trunk failover varies byswitch, but this can be a viable alternative to the ARP monitor when usingsuitable switches.
12. Configuring Bonding for Maximum Throughput¶
12.1 Maximizing Throughput in a Single Switch Topology¶
In a single switch configuration, the best method to maximizethroughput depends upon the application and network environment. Thevarious load balancing modes each have strengths and weaknesses indifferent environments, as detailed below.
For this discussion, we will break down the topologies intotwo categories. Depending upon the destination of most traffic, wecategorize them into either “gatewayed” or “local” configurations.
In a gatewayed configuration, the “switch” is acting primarilyas a router, and the majority of traffic passes through this router toother networks. An example would be the following:
+----------+ +----------+| |eth0 port1| | to other networks| Host A +---------------------+ router +------------------->| +---------------------+ | Hosts B and C are out| |eth1 port2| | here somewhere+----------+ +----------+
The router may be a dedicated router device, or another hostacting as a gateway. For our discussion, the important point is thatthe majority of traffic from Host A will pass through the router tosome other network before reaching its final destination.
In a gatewayed network configuration, although Host A maycommunicate with many other systems, all of its traffic will be sentand received via one other peer on the local network, the router.
Note that the case of two systems connected directly viamultiple physical links is, for purposes of configuring bonding, thesame as a gatewayed configuration. In that case, it happens that alltraffic is destined for the “gateway” itself, not some other networkbeyond the gateway.
In a local configuration, the “switch” is acting primarily asa switch, and the majority of traffic passes through this switch toreach other stations on the same network. An example would be thefollowing:
+----------+ +----------+ +--------+| |eth0 port1| +-------+ Host B || Host A +------------+ switch |port3 +--------+| +------------+ | +--------+| |eth1 port2| +------------------+ Host C |+----------+ +----------+port4 +--------+
Again, the switch may be a dedicated switch device, or anotherhost acting as a gateway. For our discussion, the important point isthat the majority of traffic from Host A is destined for other hostson the same local network (Hosts B and C in the above example).
In summary, in a gatewayed configuration, traffic to and fromthe bonded device will be to the same MAC level peer on the network(the gateway itself, i.e., the router), regardless of its finaldestination. In a local configuration, traffic flows directly to andfrom the final destinations, thus, each destination (Host B, Host C)will be addressed directly by their individual MAC addresses.
This distinction between a gatewayed and a local networkconfiguration is important because many of the load balancing modesavailable use the MAC addresses of the local network source anddestination to make load balancing decisions. The behavior of eachmode is described below.
12.1.1 MT Bonding Mode Selection for Single Switch Topology¶
This configuration is the easiest to set up and to understand,although you will have to decide which bonding mode best suits yourneeds. The trade offs for each mode are detailed below:
- balance-rr:
This mode is the only mode that will permit a singleTCP/IP connection to stripe traffic across multipleinterfaces. It is therefore the only mode that will allow asingle TCP/IP stream to utilize more than one interface’sworth of throughput. This comes at a cost, however: thestriping generally results in peer systems receiving packets outof order, causing TCP/IP’s congestion control system to kickin, often by retransmitting segments.
It is possible to adjust TCP/IP’s congestion limits byaltering the net.ipv4.tcp_reordering sysctl parameter. Theusual default value is 3. But keep in mind TCP stack is ableto automatically increase this when it detects reorders.
Note that the fraction of packets that will be delivered out oforder is highly variable, and is unlikely to be zero. The levelof reordering depends upon a variety of factors, including thenetworking interfaces, the switch, and the topology of theconfiguration. Speaking in general terms, higher speed networkcards produce more reordering (due to factors such as packetcoalescing), and a “many to many” topology will reorder at ahigher rate than a “many slow to one fast” configuration.
Many switches do not support any modes that stripe traffic(instead choosing a port based upon IP or MAC level addresses);for those devices, traffic for a particular connection flowingthrough the switch to a balance-rr bond will not utilize greaterthan one interface’s worth of bandwidth.
If you are utilizing protocols other than TCP/IP, UDP forexample, and your application can tolerate out of orderdelivery, then this mode can allow for single stream datagramperformance that scales near linearly as interfaces are addedto the bond.
This mode requires the switch to have the appropriate portsconfigured for “etherchannel” or “trunking.”
- active-backup:
There is not much advantage in this network topology tothe active-backup mode, as the inactive backup devices are allconnected to the same peer as the primary. In this case, aload balancing mode (with link monitoring) will provide thesame level of network availability, but with increasedavailable bandwidth. On the plus side, active-backup modedoes not require any configuration of the switch, so it mayhave value if the hardware available does not support any ofthe load balance modes.
- balance-xor:
This mode will limit traffic such that packets destinedfor specific peers will always be sent over the sameinterface. Since the destination is determined by the MACaddresses involved, this mode works best in a “local” networkconfiguration (as described above), with destinations all onthe same local network. This mode is likely to be suboptimalif all your traffic is passed through a single router (i.e., a“gatewayed” network configuration, as described above).
As with balance-rr, the switch ports need to be configured for“etherchannel” or “trunking.”
- broadcast:
Like active-backup, there is not much advantage to thismode in this type of network topology.
- 802.3ad:
This mode can be a good choice for this type of networktopology. The 802.3ad mode is an IEEE standard, so all peersthat implement 802.3ad should interoperate well. The 802.3adprotocol includes automatic configuration of the aggregates,so minimal manual configuration of the switch is needed(typically only to designate that some set of devices isavailable for 802.3ad). The 802.3ad standard also mandatesthat frames be delivered in order (within certain limits), soin general single connections will not see misordering ofpackets. The 802.3ad mode does have some drawbacks: thestandard mandates that all devices in the aggregate operate atthe same speed and duplex. Also, as with all bonding loadbalance modes other than balance-rr, no single connection willbe able to utilize more than a single interface’s worth ofbandwidth.
Additionally, the linux bonding 802.3ad implementationdistributes traffic by peer (using an XOR of MAC addressesand packet type ID), so in a “gatewayed” configuration, alloutgoing traffic will generally use the same device. Incomingtraffic may also end up on a single device, but that isdependent upon the balancing policy of the peer’s 802.3adimplementation. In a “local” configuration, traffic will bedistributed across the devices in the bond.
Finally, the 802.3ad mode mandates the use of the MII monitor,therefore, the ARP monitor is not available in this mode.
- balance-tlb:
The balance-tlb mode balances outgoing traffic by peer.Since the balancing is done according to MAC address, in a“gatewayed” configuration (as described above), this mode willsend all traffic across a single device. However, in a“local” network configuration, this mode balances multiplelocal network peers across devices in a vaguely intelligentmanner (not a simple XOR as in balance-xor or 802.3ad mode),so that mathematically unlucky MAC addresses (i.e., ones thatXOR to the same value) will not all “bunch up” on a singleinterface.
Unlike 802.3ad, interfaces may be of differing speeds, and nospecial switch configuration is required. On the down side,in this mode all incoming traffic arrives over a singleinterface, this mode requires certain ethtool support in thenetwork device driver of the slave interfaces, and the ARPmonitor is not available.
- balance-alb:
This mode is everything that balance-tlb is, and more.It has all of the features (and restrictions) of balance-tlb,and will also balance incoming traffic from local networkpeers (as described in the Bonding Module Options section,above).
The only additional down side to this mode is that the networkdevice driver must support changing the hardware address whilethe device is open.
12.1.2 MT Link Monitoring for Single Switch Topology¶
The choice of link monitoring may largely depend upon whichmode you choose to use. The more advanced load balancing modes do notsupport the use of the ARP monitor, and are thus restricted to usingthe MII monitor (which does not provide as high a level of end to endassurance as the ARP monitor).
12.2 Maximum Throughput in a Multiple Switch Topology¶
Multiple switches may be utilized to optimize for throughputwhen they are configured in parallel as part of an isolated networkbetween two or more systems, for example:
+-----------+ | Host A | +-+---+---+-+ | | | +--------+ | +---------+ | | |+------+---+ +-----+----+ +-----+----+| Switch A | | Switch B | | Switch C |+------+---+ +-----+----+ +-----+----+ | | | +--------+ | +---------+ | | | +-+---+---+-+ | Host B | +-----------+
In this configuration, the switches are isolated from oneanother. One reason to employ a topology such as this is for anisolated network with many hosts (a cluster configured for highperformance, for example), using multiple smaller switches can be morecost effective than a single larger switch, e.g., on a network with 24hosts, three 24 port switches can be significantly less expensive thana single 72 port switch.
If access beyond the network is required, an individual hostcan be equipped with an additional network device connected to anexternal network; this host then additionally acts as a gateway.
12.2.1 MT Bonding Mode Selection for Multiple Switch Topology¶
In actual practice, the bonding mode typically employed inconfigurations of this type is balance-rr. Historically, in thisnetwork configuration, the usual caveats about out of order packetdelivery are mitigated by the use of network adapters that do not doany kind of packet coalescing (via the use of NAPI, or because thedevice itself does not generate interrupts until some number ofpackets has arrived). When employed in this fashion, the balance-rrmode allows individual connections between two hosts to effectivelyutilize greater than one interface’s bandwidth.
12.2.2 MT Link Monitoring for Multiple Switch Topology¶
Again, in actual practice, the MII monitor is most often usedin this configuration, as performance is given preference overavailability. The ARP monitor will function in this topology, but itsadvantages over the MII monitor are mitigated by the volume of probesneeded as the number of systems involved grows (remember that eachhost in the network is configured with bonding).
13. Switch Behavior Issues¶
13.1 Link Establishment and Failover Delays¶
Some switches exhibit undesirable behavior with regard to thetiming of link up and down reporting by the switch.
First, when a link comes up, some switches may indicate thatthe link is up (carrier available), but not pass traffic over theinterface for some period of time. This delay is typically due tosome type of autonegotiation or routing protocol, but may also occurduring switch initialization (e.g., during recovery after a switchfailure). If you find this to be a problem, specify an appropriatevalue to the updelay bonding module option to delay the use of therelevant interface(s).
Second, some switches may “bounce” the link state one or moretimes while a link is changing state. This occurs most commonly whilethe switch is initializing. Again, an appropriate updelay value mayhelp.
Note that when a bonding interface has no active links, thedriver will immediately reuse the first link that goes up, even if theupdelay parameter has been specified (the updelay is ignored in thiscase). If there are slave interfaces waiting for the updelay timeoutto expire, the interface that first went into that state will beimmediately reused. This reduces down time of the network if thevalue of updelay has been overestimated, and since this occurs only incases with no connectivity, there is no additional penalty forignoring the updelay.
In addition to the concerns about switch timings, if yourswitches take a long time to go into backup mode, it may be desirableto not activate a backup interface immediately after a link goes down.Failover may be delayed via the downdelay bonding module option.
13.2 Duplicated Incoming Packets¶
NOTE: Starting with version 3.0.2, the bonding driver has logic tosuppress duplicate packets, which should largely eliminate this problem.The following description is kept for reference.
It is not uncommon to observe a short burst of duplicatedtraffic when the bonding device is first used, or after it has beenidle for some period of time. This is most easily observed by issuinga “ping” to some other host on the network, and noticing that theoutput from ping flags duplicates (typically one per slave).
For example, on a bond in active-backup mode with five slavesall connected to one switch, the output may appear as follows:
# ping -n 10.0.4.2PING 10.0.4.2 (10.0.4.2) from 10.0.3.10 : 56(84) bytes of data.64 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.7 ms64 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.8 ms (DUP!)64 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.8 ms (DUP!)64 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.8 ms (DUP!)64 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.8 ms (DUP!)64 bytes from 10.0.4.2: icmp_seq=2 ttl=64 time=0.216 ms64 bytes from 10.0.4.2: icmp_seq=3 ttl=64 time=0.267 ms64 bytes from 10.0.4.2: icmp_seq=4 ttl=64 time=0.222 ms
This is not due to an error in the bonding driver, rather, itis a side effect of how many switches update their MAC forwardingtables. Initially, the switch does not associate the MAC address inthe packet with a particular switch port, and so it may send thetraffic to all ports until its MAC forwarding table is updated. Sincethe interfaces attached to the bond may occupy multiple ports on asingle switch, when the switch (temporarily) floods the traffic to allports, the bond device receives multiple copies of the same packet(one per slave device).
The duplicated packet behavior is switch dependent, someswitches exhibit this, and some do not. On switches that display thisbehavior, it can be induced by clearing the MAC forwarding table (onmost Cisco switches, the privileged command “clear mac address-tabledynamic” will accomplish this).
14. Hardware Specific Considerations¶
This section contains additional information for configuringbonding on specific hardware platforms, or for interfacing bondingwith particular switches or other devices.
14.1 IBM BladeCenter¶
This applies to the JS20 and similar systems.
On the JS20 blades, the bonding driver supports onlybalance-rr, active-backup, balance-tlb and balance-alb modes. This islargely due to the network topology inside the BladeCenter, detailedbelow.
JS20 network adapter information¶
All JS20s come with two Broadcom Gigabit Ethernet portsintegrated on the planar (that’s “motherboard” in IBM-speak). In theBladeCenter chassis, the eth0 port of all JS20 blades is hard wired toI/O Module #1; similarly, all eth1 ports are wired to I/O Module #2.An add-on Broadcom daughter card can be installed on a JS20 to providetwo more Gigabit Ethernet ports. These ports, eth2 and eth3, arewired to I/O Modules 3 and 4, respectively.
Each I/O Module may contain either a switch or a passthroughmodule (which allows ports to be directly connected to an externalswitch). Some bonding modes require a specific BladeCenter internalnetwork topology in order to function; these are detailed below.
Additional BladeCenter-specific networking information can befound in two IBM Redbooks (www.ibm.com/redbooks):
“IBM eServer BladeCenter Networking Options”
“IBM eServer BladeCenter Layer 2-7 Network Switching”
BladeCenter networking configuration¶
Because a BladeCenter can be configured in a very large numberof ways, this discussion will be confined to describing basicconfigurations.
Normally, Ethernet Switch Modules (ESMs) are used in I/Omodules 1 and 2. In this configuration, the eth0 and eth1 ports of aJS20 will be connected to different internal switches (in therespective I/O modules).
A passthrough module (OPM or CPM, optical or copper,passthrough module) connects the I/O module directly to an externalswitch. By using PMs in I/O module #1 and #2, the eth0 and eth1interfaces of a JS20 can be redirected to the outside world andconnected to a common external switch.
Depending upon the mix of ESMs and PMs, the network willappear to bonding as either a single switch topology (all PMs) or as amultiple switch topology (one or more ESMs, zero or more PMs). It isalso possible to connect ESMs together, resulting in a configurationmuch like the example in “High Availability in a Multiple SwitchTopology,” above.
Requirements for specific modes¶
The balance-rr mode requires the use of passthrough modulesfor devices in the bond, all connected to an common external switch.That switch must be configured for “etherchannel” or “trunking” on theappropriate ports, as is usual for balance-rr.
The balance-alb and balance-tlb modes will function witheither switch modules or passthrough modules (or a mix). The onlyspecific requirement for these modes is that all network interfacesmust be able to reach all destinations for traffic sent over thebonding device (i.e., the network must converge at some point outsidethe BladeCenter).
The active-backup mode has no additional requirements.
Link monitoring issues¶
When an Ethernet Switch Module is in place, only the ARPmonitor will reliably detect link loss to an external switch. This isnothing unusual, but examination of the BladeCenter cabinet wouldsuggest that the “external” network ports are the ethernet ports forthe system, when it fact there is a switch between these “external”ports and the devices on the JS20 system itself. The MII monitor isonly able to detect link failures between the ESM and the JS20 system.
When a passthrough module is in place, the MII monitor doesdetect failures to the “external” port, which is then directlyconnected to the JS20 system.
Other concerns¶
The Serial Over LAN (SoL) link is established over the primaryethernet (eth0) only, therefore, any loss of link to eth0 will resultin losing your SoL connection. It will not fail over with othernetwork traffic, as the SoL system is beyond the control of thebonding driver.
It may be desirable to disable spanning tree on the switch(either the internal Ethernet Switch Module, or an external switch) toavoid fail-over delay issues when using bonding.
15. Frequently Asked Questions¶
1. Is it SMP safe?¶
Yes. The old 2.0.xx channel bonding patch was not SMP safe.The new driver was designed to be SMP safe from the start.
2. What type of cards will work with it?¶
Any Ethernet type cards (you can even mix cards - a IntelEtherExpress PRO/100 and a 3com 3c905b, for example). For most modes,devices need not be of the same speed.
Starting with version 3.2.1, bonding also supports Infinibandslaves in active-backup mode.
3. How many bonding devices can I have?¶
There is no limit.
4. How many slaves can a bonding device have?¶
This is limited only by the number of network interfaces Linuxsupports and/or the number of network cards you can place in yoursystem.
5. What happens when a slave link dies?¶
If link monitoring is enabled, then the failing device will bedisabled. The active-backup mode will fail over to a backup link, andother modes will ignore the failed link. The link will continue to bemonitored, and should it recover, it will rejoin the bond (in whatevermanner is appropriate for the mode). See the sections on HighAvailability and the documentation for each mode for additionalinformation.
Link monitoring can be enabled via either the miimon orarp_interval parameters (described in the module parameters section,above). In general, miimon monitors the carrier state as sensed bythe underlying network device, and the arp monitor (arp_interval)monitors connectivity to another host on the local network.
If no link monitoring is configured, the bonding driver willbe unable to detect link failures, and will assume that all links arealways available. This will likely result in lost packets, and aresulting degradation of performance. The precise performance lossdepends upon the bonding mode and network configuration.
6. Can bonding be used for High Availability?¶
Yes. See the section on High Availability for details.
7. Which switches/systems does it work with?¶
The full answer to this depends upon the desired mode.
In the basic balance modes (balance-rr and balance-xor), itworks with any system that supports etherchannel (also calledtrunking). Most managed switches currently available have suchsupport, and many unmanaged switches as well.
The advanced balance modes (balance-tlb and balance-alb) donot have special switch requirements, but do need device drivers thatsupport specific features (described in the appropriate section undermodule parameters, above).
In 802.3ad mode, it works with systems that support IEEE802.3ad Dynamic Link Aggregation. Most managed and many unmanagedswitches currently available support 802.3ad.
The active-backup mode should work with any Layer-II switch.
8. Where does a bonding device get its MAC address from?¶
When using slave devices that have fixed MAC addresses, or whenthe fail_over_mac option is enabled, the bonding device’s MAC address isthe MAC address of the active slave.
For other configurations, if not explicitly configured (withifconfig or ip link), the MAC address of the bonding device is taken fromits first slave device. This MAC address is then passed to all followingslaves and remains persistent (even if the first slave is removed) untilthe bonding device is brought down or reconfigured.
If you wish to change the MAC address, you can set it withifconfig or ip link:
# ifconfig bond0 hw ether 00:11:22:33:44:55# ip link set bond0 address 66:77:88:99:aa:bb
The MAC address can be also changed by bringing down/up thedevice and then changing its slaves (or their order):
# ifconfig bond0 down ; modprobe -r bonding# ifconfig bond0 .... up# ifenslave bond0 eth...
This method will automatically take the address from the nextslave that is added.
To restore your slaves’ MAC addresses, you need to detach themfrom the bond (ifenslave-dbond0eth0). The bonding driver willthen restore the MAC addresses that the slaves had before they wereenslaved.
9. What bonding modes support native XDP?¶
balance-rr (0)
active-backup (1)
balance-xor (2)
802.3ad (4)
Note that the vlan+srcmac hash policy does not support native XDP.For other bonding modes, the XDP program must be loaded with generic mode.
16. Resources and Links¶
The latest version of the bonding driver can be found in the latestversion of the linux kernel, found onhttp://kernel.org
The latest version of this document can be found in the latest kernelsource (namedLinux Ethernet Bonding Driver HOWTO).
Discussions regarding the development of the bonding driver take placeon the main Linux network mailing list, hosted at vger.kernel.org. The listaddress is:
The administrative interface (to subscribe or unsubscribe) canbe found at: