[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1402127143-6456-5-git-send-email-dingtianhong@huawei.com>
Date: Sat, 7 Jun 2014 15:45:43 +0800
From: Ding Tianhong <dingtianhong@...wei.com>
To: <kaber@...sh.net>, <davem@...emloft.net>, <edumazet@...gle.com>,
<vyasevic@...hat.com>, <makita.toshiaki@....ntt.co.jp>
CC: <netdev@...r.kernel.org>
Subject: [PATCH net-next v2 RESEND 4/4] net: dev: don't set the same mac address for netdev
Most of netdev just link bond, team, vlan will set the mac address
and propagate to the upperdev or lowerdev regardless the mac address
is same or not, setting a same mac address make no sense for most of
the netdev, but some netdev need a flag to see whether the ndo_set_mac_address()
is called and decide what to do next, so don't do anything if the address
has already been set by user and it is the same as before, otherwise set
the same address to the netdev.
Signed-off-by: Ding Tianhong <dingtianhong@...wei.com>
---
net/core/dev.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index b0fb3dd..201d88b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5572,6 +5572,13 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
if (!netif_device_present(dev))
return -ENODEV;
+ /* If the address has already been set by user and it
+ * is the same as before, don't do anything.
+ */
+ if (dev->addr_assign_type == NET_ADDR_SET &&
+ ether_addr_equal_64bits(dev->dev_addr, sa->sa_data))
+ return 0;
+
old_sa.sa_family = dev->type;
ether_addr_copy(old_sa.sa_data, dev->dev_addr);
--
1.8.0
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists