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

From: Hangbin Liu
Date: Mon Apr 07 2025 - 03:57:22 EST


On Thu, Apr 03, 2025 at 04:02:33PM +0200, Paolo Abeni wrote:
> 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?)

I have talked about one of the duplicate mac issue with Jay before [1]. We
decided to print a warning for that. I will discuss with Jay for this one
in one new patch thread.

[1] https://lore.kernel.org/netdev/Z49yXz1dx2ZzqhC1@fedora

Thanks
Hangbin
>
> 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
>