net: introduce default neigh_construct/destroy ndo calls for L2 upper devices
authorJiri Pirko <jiri@mellanox.com>
Tue, 5 Jul 2016 09:27:38 +0000 (11:27 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Jul 2016 16:06:28 +0000 (09:06 -0700)
L2 upper device needs to propagate neigh_construct/destroy calls down to
lower devices. Do this by defining default ndo functions and use them in
team, bond, bridge and vlan.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c
drivers/net/team/team.c
include/linux/netdevice.h
net/8021q/vlan_dev.c
net/bridge/br_device.c
net/core/dev.c

index 90157e20357e62f533f62887a3387bac63f088a6..480d73ac7d1b3cbff2c58ada05ce631016e6409a 100644 (file)
@@ -4137,6 +4137,8 @@ static const struct net_device_ops bond_netdev_ops = {
        .ndo_add_slave          = bond_enslave,
        .ndo_del_slave          = bond_release,
        .ndo_fix_features       = bond_fix_features,
+       .ndo_neigh_construct    = netdev_default_l2upper_neigh_construct,
+       .ndo_neigh_destroy      = netdev_default_l2upper_neigh_destroy,
        .ndo_bridge_setlink     = switchdev_port_bridge_setlink,
        .ndo_bridge_getlink     = switchdev_port_bridge_getlink,
        .ndo_bridge_dellink     = switchdev_port_bridge_dellink,
index f9eebea83516bf05360401f71e28bc4040998a84..a380649bf6b5c2242edac044b497bf15922cffe5 100644 (file)
@@ -2002,6 +2002,8 @@ static const struct net_device_ops team_netdev_ops = {
        .ndo_add_slave          = team_add_slave,
        .ndo_del_slave          = team_del_slave,
        .ndo_fix_features       = team_fix_features,
+       .ndo_neigh_construct    = netdev_default_l2upper_neigh_construct,
+       .ndo_neigh_destroy      = netdev_default_l2upper_neigh_destroy,
        .ndo_change_carrier     = team_change_carrier,
        .ndo_bridge_setlink     = switchdev_port_bridge_setlink,
        .ndo_bridge_getlink     = switchdev_port_bridge_getlink,
index 91af73c9dd5108a68b9fe8b4dd4ef2b035b81ace..49736a31acaa38846f175a305545a4083c540af5 100644 (file)
@@ -3845,6 +3845,10 @@ void *netdev_lower_dev_get_private(struct net_device *dev,
                                   struct net_device *lower_dev);
 void netdev_lower_state_changed(struct net_device *lower_dev,
                                void *lower_state_info);
+int netdev_default_l2upper_neigh_construct(struct net_device *dev,
+                                          struct neighbour *n);
+void netdev_default_l2upper_neigh_destroy(struct net_device *dev,
+                                         struct neighbour *n);
 
 /* RSS keys are 40 or 52 bytes long */
 #define NETDEV_RSS_KEY_LEN 52
index 86ae75b77390964ee42056c0dd1763650d9fb9ff..c8f422c90856fffe1b5761d0db733644c13b4b32 100644 (file)
@@ -790,6 +790,8 @@ static const struct net_device_ops vlan_netdev_ops = {
        .ndo_netpoll_cleanup    = vlan_dev_netpoll_cleanup,
 #endif
        .ndo_fix_features       = vlan_dev_fix_features,
+       .ndo_neigh_construct    = netdev_default_l2upper_neigh_construct,
+       .ndo_neigh_destroy      = netdev_default_l2upper_neigh_destroy,
        .ndo_fdb_add            = switchdev_port_fdb_add,
        .ndo_fdb_del            = switchdev_port_fdb_del,
        .ndo_fdb_dump           = switchdev_port_fdb_dump,
index 0c39e0f6da09d54a9a5b93afdc4662b16a73a048..8eecd0ec22f2c785b4a60d68440cc293181096bc 100644 (file)
@@ -349,6 +349,8 @@ static const struct net_device_ops br_netdev_ops = {
        .ndo_add_slave           = br_add_slave,
        .ndo_del_slave           = br_del_slave,
        .ndo_fix_features        = br_fix_features,
+       .ndo_neigh_construct     = netdev_default_l2upper_neigh_construct,
+       .ndo_neigh_destroy       = netdev_default_l2upper_neigh_destroy,
        .ndo_fdb_add             = br_fdb_add,
        .ndo_fdb_del             = br_fdb_delete,
        .ndo_fdb_dump            = br_fdb_dump,
index a4f3b0a9aeaf61050281d66933ef6efffd7e1cea..b92d63bfde7ae762eb3fc0201ca4709e5218858b 100644 (file)
@@ -6087,6 +6087,50 @@ void netdev_lower_state_changed(struct net_device *lower_dev,
 }
 EXPORT_SYMBOL(netdev_lower_state_changed);
 
+int netdev_default_l2upper_neigh_construct(struct net_device *dev,
+                                          struct neighbour *n)
+{
+       struct net_device *lower_dev, *stop_dev;
+       struct list_head *iter;
+       int err;
+
+       netdev_for_each_lower_dev(dev, lower_dev, iter) {
+               if (!lower_dev->netdev_ops->ndo_neigh_construct)
+                       continue;
+               err = lower_dev->netdev_ops->ndo_neigh_construct(lower_dev, n);
+               if (err) {
+                       stop_dev = lower_dev;
+                       goto rollback;
+               }
+       }
+       return 0;
+
+rollback:
+       netdev_for_each_lower_dev(dev, lower_dev, iter) {
+               if (lower_dev == stop_dev)
+                       break;
+               if (!lower_dev->netdev_ops->ndo_neigh_destroy)
+                       continue;
+               lower_dev->netdev_ops->ndo_neigh_destroy(lower_dev, n);
+       }
+       return err;
+}
+EXPORT_SYMBOL_GPL(netdev_default_l2upper_neigh_construct);
+
+void netdev_default_l2upper_neigh_destroy(struct net_device *dev,
+                                         struct neighbour *n)
+{
+       struct net_device *lower_dev;
+       struct list_head *iter;
+
+       netdev_for_each_lower_dev(dev, lower_dev, iter) {
+               if (!lower_dev->netdev_ops->ndo_neigh_destroy)
+                       continue;
+               lower_dev->netdev_ops->ndo_neigh_destroy(lower_dev, n);
+       }
+}
+EXPORT_SYMBOL_GPL(netdev_default_l2upper_neigh_destroy);
+
 static void dev_change_rx_flags(struct net_device *dev, int flags)
 {
        const struct net_device_ops *ops = dev->netdev_ops;