netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: add check for current MAC address in dev_set_mac_address
@ 2023-06-09 16:52 Piotr Gardocki
  2023-06-09 17:00 ` Maciej Fijalkowski
  2023-06-10  6:44 ` Jakub Kicinski
  0 siblings, 2 replies; 8+ messages in thread
From: Piotr Gardocki @ 2023-06-09 16:52 UTC (permalink / raw)
  To: netdev
  Cc: piotrx.gardocki, przemyslaw.kitszel, michal.swiatkowski, pmenzel,
	kuba, maciej.fijalkowski, anthony.l.nguyen, simon.horman,
	aleksander.lobakin

In some cases it is possible for kernel to come with request
to change primary MAC address to the address that is already
set on the given interface.

This patch adds proper check to return fast from the function
in these cases.

An example of such case is adding an interface to bonding
channel in balance-alb mode:
modprobe bonding mode=balance-alb miimon=100 max_bonds=1
ip link set bond0 up
ifenslave bond0 <eth>

Signed-off-by: Piotr Gardocki <piotrx.gardocki@intel.com>
---
 net/core/dev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 99d99b247bc9..c2c3ec61397b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8820,6 +8820,8 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa,
 		return -EINVAL;
 	if (!netif_device_present(dev))
 		return -ENODEV;
+	if (ether_addr_equal(dev->dev_addr, sa->sa_data))
+		return 0;
 	err = dev_pre_changeaddr_notify(dev, sa->sa_data, extack);
 	if (err)
 		return err;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-06-12 17:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-09 16:52 [PATCH net-next] net: add check for current MAC address in dev_set_mac_address Piotr Gardocki
2023-06-09 17:00 ` Maciej Fijalkowski
2023-06-09 17:11   ` Piotr Gardocki
2023-06-10  6:44 ` Jakub Kicinski
2023-06-12 14:49   ` Piotr Gardocki
2023-06-12 15:37     ` Maciej Fijalkowski
2023-06-12 16:43       ` Piotr Gardocki
2023-06-12 17:39         ` Jakub Kicinski

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).