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: Mon, 14 Apr 2025 06:06:38 +0000 [thread overview]
Message-ID: <Z_yl7tQne6YTcU6S@fedora> (raw)
In-Reply-To: <Z_OcP36h_XOhAfjv@fedora>
Hi Jay,
On Mon, Apr 07, 2025 at 09:35:03AM +0000, Hangbin Liu wrote:
> > So this patch's change wouldn't actually resolve the MAC
> > conflict until a failover takes place? I.e., if we only do step 4 but
> > not step 5 or 6, eth0 and eth1 will both have the same MAC address. Am
> > I understanding correctly?
>
> Yes, you are right. At step 4, there is no failover, so eth0 is still using
> it's own mac address. How about set the mac at enslave time, with this we
> can get correct mac directly. e.g.
Any comments for the new approach?
Thanks
Hangbin
>
> 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;
> + }
> + }
> }
>
> Thanks
> Hangbin
next prev parent reply other threads:[~2025-04-14 6:06 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 [this message]
2025-04-16 1:15 ` Jay Vosburgh
2025-04-16 2:52 ` Hangbin Liu
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_yl7tQne6YTcU6S@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).