From: Jay Vosburgh <jv@jvosburgh.net>
To: Hangbin Liu <liuhangbin@gmail.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Nikolay Aleksandrov <razor@blackwall.org>,
Simon Horman <horms@kernel.org>, Cosmin Ratiu <cratiu@nvidia.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCHv2 net] bonding: use permanent address for MAC swapping if device address is same
Date: Thu, 17 Apr 2025 21:16:33 -0700 [thread overview]
Message-ID: <155385.1744949793@famine> (raw)
In-Reply-To: <Z_8bfpQb_3fqYEcn@fedora>
Hangbin Liu <liuhangbin@gmail.com> wrote:
>On Tue, Apr 15, 2025 at 06:15:12PM -0700, Jay Vosburgh wrote:
>> >>
>> >> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>> >> index 950d8e4d86f8..0d4e1ddd900d 100644
>> >> --- a/drivers/net/bonding/bond_main.c
>> >> +++ b/drivers/net/bonding/bond_main.c
>> >> @@ -2120,6 +2120,24 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
>> >> slave_err(bond_dev, slave_dev, "Error %d calling set_mac_address\n", res);
>> >> goto err_restore_mtu;
>> >> }
>> >> + } else if (bond->params.fail_over_mac == BOND_FOM_FOLLOW &&
>> >> + BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP &&
>> >> + memcmp(slave_dev->dev_addr, bond_dev->dev_addr, bond_dev->addr_len) == 0) {
>> >> + /* Set slave to current active slave's permanent mac address to
>> >> + * avoid duplicate mac address.
>> >> + */
>> >> + curr_active_slave = rcu_dereference(bond->curr_active_slave);
>> >> + if (curr_active_slave) {
>> >> + memcpy(ss.__data, curr_active_slave->perm_hwaddr,
>> >> + curr_active_slave->dev->addr_len);
>> >> + ss.ss_family = slave_dev->type;
>> >> + res = dev_set_mac_address(slave_dev, (struct sockaddr *)&ss,
>> >> + extack);
>> >> + if (res) {
>> >> + slave_err(bond_dev, slave_dev, "Error %d calling set_mac_address\n", res);
>> >> + goto err_restore_mtu;
>> >> + }
>> >> + }
>>
>> Is this in replacement of the prior patch (that does stuff
>> during failover), or in addition to?
>>
>> I'm asking because in the above, if there is no
>> curr_active_slave, e.g., all interfaces in the bond are down, the above
>> would permit MAC conflict in the absence of logic in failover to resolve
>> things.
>
>Hmm, then how about use bond_for_each_slave() and find out the link
>that has same MAC address with bond/new_slave?
But even if we find it, aren't we stuck at that point? The
situation would be that the bond and one backup interface have MAC#1.
MAC#1 may or may not be that backup interface's permanent MAC address,
and we're adding another interface, also with MAC#1, which might be the
newly added interface's permanent MAC. The MAC swap gyrations to
guarantee this would work correctly in all cases seem to be rather
involved.
Wouldn't it be equally effective to, when the conflicting
interface is added, give it a random MAC to avoid the conflict? That
random MAC shouldn't end up as the bond's MAC, so it would exist only as
a placeholder of sorts.
I'm unsure if there are many (any?) devices in common use today
that actually have issues with multiple ports using the same MAC, so I
don't think we need an overly complicated solution.
-J
---
-Jay Vosburgh, jv@jvosburgh.net
next prev parent reply other threads:[~2025-04-18 4:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 9:06 [PATCHv2 net] bonding: use permanent address for MAC swapping if device address is same Hangbin Liu
2025-04-04 21:36 ` Jay Vosburgh
2025-04-07 9:34 ` Hangbin Liu
2025-04-14 6:06 ` Hangbin Liu
2025-04-16 1:15 ` Jay Vosburgh
2025-04-16 2:52 ` Hangbin Liu
2025-04-18 4:16 ` Jay Vosburgh [this message]
2025-04-18 7:39 ` Hangbin Liu
2025-04-21 4:24 ` Hangbin Liu
2025-04-21 5:10 ` Jay Vosburgh
2025-04-21 6:11 ` Hangbin Liu
2025-04-23 16:27 ` Jay Vosburgh
2025-04-24 3:22 ` Hangbin Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=155385.1744949793@famine \
--to=jv@jvosburgh.net \
--cc=andrew+netdev@lunn.ch \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuhangbin@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).