vlan: make vlan_dev_real_dev work over stacked vlans
authornikolay@redhat.com <nikolay@redhat.com>
Sat, 3 Aug 2013 20:07:46 +0000 (22:07 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 5 Aug 2013 19:17:42 +0000 (12:17 -0700)
Sometimes we might have stacked vlans on top of each other, and we're
interested in the first non-vlan real device on the path, so transform
vlan_dev_real_dev to go over the stacked vlans and extract the first
non-vlan device.

Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/8021q/vlan_core.c

index 4a78c4de9f200831c75e5c87bad683bbf669bbfb..6ee48aac776fbe84db68a503d9aca10ca45b0081 100644 (file)
@@ -91,7 +91,12 @@ EXPORT_SYMBOL(__vlan_find_dev_deep);
 
 struct net_device *vlan_dev_real_dev(const struct net_device *dev)
 {
-       return vlan_dev_priv(dev)->real_dev;
+       struct net_device *ret = vlan_dev_priv(dev)->real_dev;
+
+       while (is_vlan_dev(ret))
+               ret = vlan_dev_priv(ret)->real_dev;
+
+       return ret;
 }
 EXPORT_SYMBOL(vlan_dev_real_dev);