From: Hangbin Liu <liuhangbin@gmail.com>
To: Jay Vosburgh <jv@jvosburgh.net>
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: Wed, 16 Apr 2025 02:52:46 +0000 [thread overview]
Message-ID: <Z_8bfpQb_3fqYEcn@fedora> (raw)
In-Reply-To: <4177946.1744766112@famine>
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?
Thanks
Hangbin
next prev parent reply other threads:[~2025-04-16 2:52 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 [this message]
2025-04-18 4:16 ` Jay Vosburgh
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=Z_8bfpQb_3fqYEcn@fedora \
--to=liuhangbin@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jv@jvosburgh.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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).