Network switch reports MAC flap when active-backup bonding fails over or fails back

Solution verified - Updated on

Request a new translation or translation update

A translation for your language preference does not exist. Click below to request a translation for your selected language.

Submit request

Environment

  • Red Hat Enterprise Linux (all versions)
  • Bonding in Mode 1 (active-backup)
  • Network switch with MAC Flap Detection enabled

Issue

  • Network switch reports MAC flap when active-backup bonding fails over or fails back
  • Why switch shows MAC flapping messages when failback to primary NIC?

Resolution

This is the expected result, as explained in the Root Cause section below.

There are several options to resolve this:

  • Use a bonding mode which requires switch configuration into a Link Aggregation Group, such as Bonding Mode 4 (LACP 802.3ad)
  • Use the fail_over_mac=active option on the existing Mode 1 (active-backup) bond
  • Disable MAC Flap Detection on the external network equipment

Root Cause

Bonding mode 1 (active-backup) requires no switch configuration, so the switch is not aware of the bond.

Bonding's default behaviour is to adopt the MAC address of the first added NIC, and then to change all other NICs to the same MAC address:

We can think of a bond with its active NIC like this:

,---------------,
|     Switch    |  "MAC address AA is out Port 1"
|-------+-------|
| Port1 | Port2 |
'---=---+---=---'
    |       |
    |       |
,---=---+---=---,
| NIC 1 | NIC 2 | <-- both NICs changed to MAC address AA
|-------+-------|
|     Bond      | <-- NIC 1 is the active NIC
'---------------'

Now if we pull NIC 1's cable and fail the bond over to NIC 2, the bond sends a Gratuitous ARP to announce its new location, and the switch learns the bond's MAC address is available down a different switch port:

,---------------,
|     Switch    |  "MAC address AA is now out Port 2"
|-------+-------|
| Port1 | Port2 |
'---=---+---=---'
            |
            |
,---=---+---=---,
| NIC 1 | NIC 2 | <-- both NICs changed to MAC address AA
|-------+-------|
|     Bond      | <-- NIC 2 is the active NIC
'---------------'

If the bond fails back to the first NIC, then the first diagram becomes the situation again.

If the network switch has some form of "MAC Flap Detection", then it might detect either the failover or fail-back as a "MAC Flap".

When MAC Flap occurred, pings might be slightly dropped during ping tests due to flapping occurrence.

A bonding mode which requires switch configuration (eg: Mode 2 XOR, or Mode 4 LACP) would not flap MAC addresses because the switch would consider the Link Aggregation Group (not the individual switchports) when making a decision about MAC addresses.

The active-backup bonding option fail_over_mac=active does NOT change all NIC MACs to the be the same thing. Instead, the NICs keep their original MAC address and the bond's MAC address changes on failover. This would be seen as:

,---------------,
|     Switch    |  "MAC address BB is now out Port 2"
|-------+-------|
| Port1 | Port2 |
'---=---+---=---'
            |
            |
,---=---+---=---,
| NIC 1 | NIC 2 | <-- NIC 1 has MAC addr AA, NIC 2 has MAC addr BB
|-------+-------|
|     Bond      | <-- fail_over_mac=active, NIC 2 is the active NIC
'---------------'

Note that it might take more time for failover to converge with this option, as all remote hosts need to update their neighbour (ARP) tables to learn the bond's IP is available at a new MAC address.

This solution is part of Red Hat's fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.