Skip to contentSkip to conversation

net: dsa: Inherit dev addr from master

PATCH In review Vinod Koul 3 participants 5 messages Feb 22, 2019 – Mar 27, 2019

Subsystems (4)
lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

PATCH 1/1 net: dsa: Inherit dev addr from master

From: Xiaofei Shen <[email protected]>

When we create slave netdevice, the dev addr is inherited from master but the master dev addr maybe NULL at that time, so inherit it again while opening the slave.

---
 net/dsa/slave.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/dsa/slave.c +3 -1
index 8e64c4e947c6..5f95c538b58c 100644
@@ -77,7 +77,9 @@ static int dsa_slave_open(struct net_device *dev)
 	if (!(master->flags & IFF_UP))
 		return -ENETDOWN;
 
-	if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) {
+	if (!is_valid_ether_addr(dev->dev_addr)) {
+		eth_hw_addr_inherit(dev, master);
+	} else if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) {
 		err = dev_uc_add(master, dev->dev_addr);
 		if (err < 0)
 			goto out;
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 5 lines · Vinod Koul

From: Xiaofei Shen <[email protected]>

When we create slave netdevice, the dev addr is inherited from master but the master dev addr maybe NULL at that time, so inherit it again while opening the slave.

Hi Xiaofei, Vinod

Inheriting it twice seems a bit clumsy. Can the first inherit be removed? Can you change your MAC driver to set its MAC address in probe?

Andrew

#2 lore raw
Quoted 7 lines · Andrew Lunn
Quoted 5 lines · Vinod Koul

From: Xiaofei Shen <[email protected]>

When we create slave netdevice, the dev addr is inherited from master but the master dev addr maybe NULL at that time, so inherit it again while opening the slave.

Quoted 7 lines

Hi Xiaofei, Vinod

Inheriting it twice seems a bit clumsy. Can the first inherit be removed? Can you change your MAC driver to set its MAC address in probe?

Andrew

Hi Andrew

Some mac driver set its MAC address in probe while some MAC driver do it in the open function in the kernel.

This patch is checking whether the address is valid firstly, if it already inherits a valid mac address, it will not inherit again.

I think we can remove the first inherit, but if keep it, we can see consistent address output by ifconfig -a before open master and slave interface.

Xiaofeis

maintainer
#3 lore raw
Quoted 3 lines

I think we can remove the first inherit, but if keep it, we can see consistent address output by ifconfig -a before open master and slave interface.

True

But it also means we see inconsistent MAC addresses on the master. The MAC address changes on open.

Maybe it would be better to change your master so it sets its MAC address during probe? Everything is then consistent all the time.

Andrew

#4 lore raw
Quoted 6 lines · Andrew Lunn
Quoted 3 lines

I think we can remove the first inherit, but if keep it, we can see consistent address output by ifconfig -a before open master and slave interface.

True

Quoted 7 lines

But it also means we see inconsistent MAC addresses on the master. The MAC address changes on open.

Maybe it would be better to change your master so it sets its MAC address during probe? Everything is then consistent all the time.

Andrew

I'm trying to suggest our master driver owner to set MAC address during probe.

I found in kernel, different driver has different implementation, some set it in probe, while some in open. DSA should be generic to work with all these master drivers. I think this change can help. Thanks.