Re: [PATCH net] bonding: use permanent address for MAC swapping if device address is same

From: Paolo Abeni
Date: Thu Apr 03 2025 - 10:05:14 EST


On 3/19/25 9:09 AM, Hangbin Liu wrote:
> Similar with a951bc1e6ba5 ("bonding: correct the MAC address for "follow"
> fail_over_mac policy"). The fail_over_mac follow mode requires the formerly
> active slave to swap MAC addresses with the newly active slave during
> failover. However, the slave's MAC address can be same under certain
> conditions:
>
> 1) ip link set eth0 master bond0
> bond0 adopts eth0's MAC address (MAC0).
>
> 1) ip link set eth1 master bond0
> eth1 is added as a backup with its own MAC (MAC1).
>
> 3) ip link set eth0 nomaster
> eth0 is released and restores its MAC (MAC0).
> eth1 becomes the active slave, and bond0 assigns MAC0 to eth1.

It was not immediately clear to me that the mac-dance in the code below
happens only at failover time.

I second Jakub's doubt, I think it would be better to change eth0 mac
address here (possibly to permanent eth1 mac, to preserve some consistency?)

Doing that in ndo_del_slave() should allow bonding to change the mac
while still owning the old slave and avoid races with user-space.

WDYT?

Thanks,

Paolo