* [PATCH net v2] vlan: Propagate MAC address to VLANs unless explicitly set
[not found] <5728BA0B.6050807@brocade.com>
@ 2016-05-03 15:20 ` Mike Manning
2016-05-03 16:36 ` David Miller
2016-05-04 9:28 ` Michal Kubecek
0 siblings, 2 replies; 5+ messages in thread
From: Mike Manning @ 2016-05-03 15:20 UTC (permalink / raw)
To: netdev
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.
Continuing to inherit the MAC address unless explicitly changed for
the VLAN allows IPv6 EUI64 addresses for the VLAN to reflect the change
and thus for DAD to behave as expected for the given MAC.
Signed-off-by: Mike Manning <mmanning@brocade.com>
---
net/8021q/vlan.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -286,22 +286,25 @@ static void vlan_sync_address(struct net
struct net_device *vlandev)
{
struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);
+ bool real_addr_in_use;
/* May be called without an actual change */
if (ether_addr_equal(vlan->real_dev_addr, dev->dev_addr))
return;
- /* vlan address was different from the old address and is equal to
+ real_addr_in_use =
+ ether_addr_equal(vlandev->dev_addr, vlan->real_dev_addr);
+
+ /* vlan address was different from the real address and is equal to
* the new address */
- if (!ether_addr_equal(vlandev->dev_addr, vlan->real_dev_addr) &&
+ if ((vlandev->flags & IFF_UP) && !real_addr_in_use &&
ether_addr_equal(vlandev->dev_addr, dev->dev_addr))
dev_uc_del(dev, vlandev->dev_addr);
- /* vlan address was equal to the old address and is different from
+ /* vlan address was equal to the real address so now also inherit
* the new address */
- if (ether_addr_equal(vlandev->dev_addr, vlan->real_dev_addr) &&
- !ether_addr_equal(vlandev->dev_addr, dev->dev_addr))
- dev_uc_add(dev, vlandev->dev_addr);
+ if (real_addr_in_use)
+ ether_addr_copy(vlandev->dev_addr, dev->dev_addr);
ether_addr_copy(vlan->real_dev_addr, dev->dev_addr);
}
@@ -389,13 +392,8 @@ static int vlan_device_event(struct noti
case NETDEV_CHANGEADDR:
/* Adjust unicast filters on underlying device */
- vlan_group_for_each_dev(grp, i, vlandev) {
- flgs = vlandev->flags;
- if (!(flgs & IFF_UP))
- continue;
-
+ vlan_group_for_each_dev(grp, i, vlandev)
vlan_sync_address(dev, vlandev);
- }
break;
case NETDEV_CHANGEMTU:
--
1.7.10.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2] vlan: Propagate MAC address to VLANs unless explicitly set
2016-05-03 15:20 ` [PATCH net v2] vlan: Propagate MAC address to VLANs unless explicitly set Mike Manning
@ 2016-05-03 16:36 ` David Miller
2016-05-04 9:28 ` Michal Kubecek
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2016-05-03 16:36 UTC (permalink / raw)
To: mmanning; +Cc: netdev
There is, at the very least, a two byte hole in the vlan_dev_priv structure.
Put the boolean there as I asked you to.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2] vlan: Propagate MAC address to VLANs unless explicitly set
2016-05-03 15:20 ` [PATCH net v2] vlan: Propagate MAC address to VLANs unless explicitly set Mike Manning
2016-05-03 16:36 ` David Miller
@ 2016-05-04 9:28 ` Michal Kubecek
2016-05-04 15:58 ` David Miller
1 sibling, 1 reply; 5+ messages in thread
From: Michal Kubecek @ 2016-05-04 9:28 UTC (permalink / raw)
To: Mike Manning; +Cc: netdev
On Tue, May 03, 2016 at 04:20:12PM +0100, Mike Manning wrote:
> 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.
>
> Continuing to inherit the MAC address unless explicitly changed for
> the VLAN allows IPv6 EUI64 addresses for the VLAN to reflect the change
> and thus for DAD to behave as expected for the given MAC.
>
> Signed-off-by: Mike Manning <mmanning@brocade.com>
> ---
> net/8021q/vlan.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> --- a/net/8021q/vlan.c
> +++ b/net/8021q/vlan.c
> @@ -286,22 +286,25 @@ static void vlan_sync_address(struct net
> struct net_device *vlandev)
> {
> struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);
> + bool real_addr_in_use;
>
> /* May be called without an actual change */
> if (ether_addr_equal(vlan->real_dev_addr, dev->dev_addr))
> return;
>
> - /* vlan address was different from the old address and is equal to
> + real_addr_in_use =
> + ether_addr_equal(vlandev->dev_addr, vlan->real_dev_addr);
> +
> + /* vlan address was different from the real address and is equal to
> * the new address */
> - if (!ether_addr_equal(vlandev->dev_addr, vlan->real_dev_addr) &&
> + if ((vlandev->flags & IFF_UP) && !real_addr_in_use &&
> ether_addr_equal(vlandev->dev_addr, dev->dev_addr))
> dev_uc_del(dev, vlandev->dev_addr);
>
> - /* vlan address was equal to the old address and is different from
> + /* vlan address was equal to the real address so now also inherit
> * the new address */
> - if (ether_addr_equal(vlandev->dev_addr, vlan->real_dev_addr) &&
> - !ether_addr_equal(vlandev->dev_addr, dev->dev_addr))
> - dev_uc_add(dev, vlandev->dev_addr);
> + if (real_addr_in_use)
> + ether_addr_copy(vlandev->dev_addr, dev->dev_addr);
>
> ether_addr_copy(vlan->real_dev_addr, dev->dev_addr);
> }
> @@ -389,13 +392,8 @@ static int vlan_device_event(struct noti
>
> case NETDEV_CHANGEADDR:
> /* Adjust unicast filters on underlying device */
> - vlan_group_for_each_dev(grp, i, vlandev) {
> - flgs = vlandev->flags;
> - if (!(flgs & IFF_UP))
> - continue;
> -
> + vlan_group_for_each_dev(grp, i, vlandev)
> vlan_sync_address(dev, vlandev);
> - }
> break;
>
> case NETDEV_CHANGEMTU:
The commit message says "unless explicitly changed for the VLAN" but
what you really check is "if it is the same as real device MAC address".
This, in general, is not the same. (I believe this is what David tries
to explain from the start.)
Michal Kubecek
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2] vlan: Propagate MAC address to VLANs unless explicitly set
2016-05-04 9:28 ` Michal Kubecek
@ 2016-05-04 15:58 ` David Miller
2016-05-04 16:14 ` Alexander Duyck
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2016-05-04 15:58 UTC (permalink / raw)
To: mkubecek; +Cc: mmanning, netdev
From: Michal Kubecek <mkubecek@suse.cz>
Date: Wed, 4 May 2016 11:28:02 +0200
> The commit message says "unless explicitly changed for the VLAN" but
> what you really check is "if it is the same as real device MAC address".
> This, in general, is not the same. (I believe this is what David tries
> to explain from the start.)
Even more proof that these MAC checks are rediculous, confusing, and
that we need to use a boolean state stores in the vlan private in
order to implement the intended semantics properly and more importantly
"clearly".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2] vlan: Propagate MAC address to VLANs unless explicitly set
2016-05-04 15:58 ` David Miller
@ 2016-05-04 16:14 ` Alexander Duyck
0 siblings, 0 replies; 5+ messages in thread
From: Alexander Duyck @ 2016-05-04 16:14 UTC (permalink / raw)
To: David Miller; +Cc: Michal Kubecek, mmanning, Netdev
On Wed, May 4, 2016 at 8:58 AM, David Miller <davem@davemloft.net> wrote:
> From: Michal Kubecek <mkubecek@suse.cz>
> Date: Wed, 4 May 2016 11:28:02 +0200
>
>> The commit message says "unless explicitly changed for the VLAN" but
>> what you really check is "if it is the same as real device MAC address".
>> This, in general, is not the same. (I believe this is what David tries
>> to explain from the start.)
>
> Even more proof that these MAC checks are rediculous, confusing, and
> that we need to use a boolean state stores in the vlan private in
> order to implement the intended semantics properly and more importantly
> "clearly".
Actually last I knew the netdev already has a field called
addr_assign_type. You could probably borrow some code from how
bonding is currently handling MAC addresses and apply it to VLANs to
achieve the effect you are looking for since I believe the default for
VLAN is similar to NET_ADDR_STOLEN and when it is set you would switch
that over to NET_ADDR_SET.
- Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-05-04 16:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <5728BA0B.6050807@brocade.com>
2016-05-03 15:20 ` [PATCH net v2] vlan: Propagate MAC address to VLANs unless explicitly set Mike Manning
2016-05-03 16:36 ` David Miller
2016-05-04 9:28 ` Michal Kubecek
2016-05-04 15:58 ` David Miller
2016-05-04 16:14 ` Alexander Duyck
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).