Skip to content

Commit ff013a6

Browse files
Mike Manninggregkh
authored andcommitted
vlan: Propagate MAC address to VLANs
commit 308453aa9156a3b8ee382c0949befb507a32b0c1 upstream. The MAC address of the physical interface is only copied to the VLAN when it is first created, resulting in an inconsistency after MAC address changes of only newly created VLANs having an up-to-date MAC. The VLANs should continue inheriting the MAC address of the physical interface until the VLAN MAC address is explicitly set to any value. This allows IPv6 EUI64 addresses for the VLAN to reflect any changes to the MAC of the physical interface and thus for DAD to behave as expected. Signed-off-by: Mike Manning <mmanning@brocade.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e8aff60 commit ff013a6

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

net/8021q/vlan.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ static void vlan_sync_address(struct net_device *dev,
292292
if (ether_addr_equal(vlan->real_dev_addr, dev->dev_addr))
293293
return;
294294

295+
/* vlan continues to inherit address of lower device */
296+
if (vlan_dev_inherit_address(vlandev, dev))
297+
goto out;
298+
295299
/* vlan address was different from the old address and is equal to
296300
* the new address */
297301
if (!ether_addr_equal(vlandev->dev_addr, vlan->real_dev_addr) &&
@@ -304,6 +308,7 @@ static void vlan_sync_address(struct net_device *dev,
304308
!ether_addr_equal(vlandev->dev_addr, dev->dev_addr))
305309
dev_uc_add(dev, vlandev->dev_addr);
306310

311+
out:
307312
ether_addr_copy(vlan->real_dev_addr, dev->dev_addr);
308313
}
309314

net/8021q/vlan.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ int vlan_check_real_dev(struct net_device *real_dev,
109109
void vlan_setup(struct net_device *dev);
110110
int register_vlan_dev(struct net_device *dev);
111111
void unregister_vlan_dev(struct net_device *dev, struct list_head *head);
112+
bool vlan_dev_inherit_address(struct net_device *dev,
113+
struct net_device *real_dev);
112114

113115
static inline u32 vlan_get_ingress_priority(struct net_device *dev,
114116
u16 vlan_tci)

net/8021q/vlan_dev.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,17 @@ void vlan_dev_get_realdev_name(const struct net_device *dev, char *result)
244244
strncpy(result, vlan_dev_priv(dev)->real_dev->name, 23);
245245
}
246246

247+
bool vlan_dev_inherit_address(struct net_device *dev,
248+
struct net_device *real_dev)
249+
{
250+
if (dev->addr_assign_type != NET_ADDR_STOLEN)
251+
return false;
252+
253+
ether_addr_copy(dev->dev_addr, real_dev->dev_addr);
254+
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
255+
return true;
256+
}
257+
247258
static int vlan_dev_open(struct net_device *dev)
248259
{
249260
struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
@@ -254,7 +265,8 @@ static int vlan_dev_open(struct net_device *dev)
254265
!(vlan->flags & VLAN_FLAG_LOOSE_BINDING))
255266
return -ENETDOWN;
256267

257-
if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr)) {
268+
if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr) &&
269+
!vlan_dev_inherit_address(dev, real_dev)) {
258270
err = dev_uc_add(real_dev, dev->dev_addr);
259271
if (err < 0)
260272
goto out;
@@ -558,8 +570,10 @@ static int vlan_dev_init(struct net_device *dev)
558570
/* ipv6 shared card related stuff */
559571
dev->dev_id = real_dev->dev_id;
560572

561-
if (is_zero_ether_addr(dev->dev_addr))
562-
eth_hw_addr_inherit(dev, real_dev);
573+
if (is_zero_ether_addr(dev->dev_addr)) {
574+
ether_addr_copy(dev->dev_addr, real_dev->dev_addr);
575+
dev->addr_assign_type = NET_ADDR_STOLEN;
576+
}
563577
if (is_zero_ether_addr(dev->broadcast))
564578
memcpy(dev->broadcast, real_dev->broadcast, dev->addr_len);
565579

0 commit comments

Comments
 (0)