diff options
author | Piotr Gardocki <piotrx.gardocki@intel.com> | 2023-06-14 16:53:00 +0200 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-06-15 22:54:54 -0700 |
commit | ad72c4a06acc6762e84994ac2f722da7a07df34e (patch) | |
tree | 2c5e36320dfce7748106c59d70909a61e6260953 /net/core | |
parent | 8f72fb1578a910571b3f25457e3b7855edfac6cf (diff) | |
download | lwn-ad72c4a06acc6762e84994ac2f722da7a07df34e.tar.gz lwn-ad72c4a06acc6762e84994ac2f722da7a07df34e.zip |
net: add check for current MAC address in dev_set_mac_address
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.
Add 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>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 63abb0463c24..e4ff0adf5523 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -8781,6 +8781,8 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa, return -EINVAL; if (!netif_device_present(dev)) return -ENODEV; + if (!memcmp(dev->dev_addr, sa->sa_data, dev->addr_len)) + return 0; err = dev_pre_changeaddr_notify(dev, sa->sa_data, extack); if (err) return err; |