net: add possibility to pass information about upper device via notifier
authorJiri Pirko <jiri@mellanox.com>
Thu, 3 Dec 2015 11:12:11 +0000 (12:12 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Dec 2015 16:49:25 +0000 (11:49 -0500)
Sometimes the drivers and other code would find it handy to know some
internal information about upper device being changed. So allow upper-code
to pass information down to notifier listeners during linking.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c
drivers/net/team/team.c
drivers/net/vrf.c
include/linux/netdevice.h
net/batman-adv/hard-interface.c
net/bridge/br_if.c
net/core/dev.c
net/openvswitch/vport-netdev.c

index 924015729b2d43bd5235eb47dca4bda79a75c04b..fa3ed1d8a12d9ea612017c1d2840e6b9d8e62b27 100644 (file)
@@ -1204,7 +1204,7 @@ static int bond_master_upper_dev_link(struct net_device *bond_dev,
 {
        int err;
 
-       err = netdev_master_upper_dev_link(slave_dev, bond_dev, slave);
+       err = netdev_master_upper_dev_link(slave_dev, bond_dev, slave, NULL);
        if (err)
                return err;
        slave_dev->flags |= IFF_SLAVE;
index b37f8d14dca01000680f3ce9b47ad0ef36cb155d..f7b6ff7948b8c66c43fbb2022c74abfec45ae532 100644 (file)
@@ -1083,7 +1083,7 @@ static int team_upper_dev_link(struct net_device *dev,
 {
        int err;
 
-       err = netdev_master_upper_dev_link(port_dev, dev, NULL);
+       err = netdev_master_upper_dev_link(port_dev, dev, NULL, NULL);
        if (err)
                return err;
        port_dev->priv_flags |= IFF_TEAM_PORT;
index 59c5bddeaedd1c01beb092cd41fc1e4214dc90b2..8944a49cda15bc59414328ec7c404aaf7b70d1e4 100644 (file)
@@ -624,7 +624,7 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
                goto out_fail;
        }
 
-       ret = netdev_master_upper_dev_link(port_dev, dev, NULL);
+       ret = netdev_master_upper_dev_link(port_dev, dev, NULL, NULL);
        if (ret < 0)
                goto out_unregister;
 
index 939b8f3de8105237840b12b852eedad7d38b19a9..aea556c64f2c568972c7a8627c0b19bd657f02a3 100644 (file)
@@ -2163,6 +2163,7 @@ struct netdev_notifier_changeupper_info {
        struct net_device *upper_dev; /* new upper dev */
        bool master; /* is upper dev master */
        bool linking; /* is the nofication for link or unlink */
+       void *upper_info; /* upper dev info */
 };
 
 static inline void netdev_notifier_info_init(struct netdev_notifier_info *info,
@@ -3620,7 +3621,7 @@ struct net_device *netdev_master_upper_dev_get_rcu(struct net_device *dev);
 int netdev_upper_dev_link(struct net_device *dev, struct net_device *upper_dev);
 int netdev_master_upper_dev_link(struct net_device *dev,
                                 struct net_device *upper_dev,
-                                void *upper_priv);
+                                void *upper_priv, void *upper_info);
 void netdev_upper_dev_unlink(struct net_device *dev,
                             struct net_device *upper_dev);
 void netdev_adjacent_rename_links(struct net_device *dev, char *oldname);
index a7f4f1085dbb679cd254d88b096a5551a4672662..aa8867e1d9839b957790157aaaf4dc3fa53c69f6 100644 (file)
@@ -465,7 +465,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
        bat_priv = netdev_priv(hard_iface->soft_iface);
 
        ret = netdev_master_upper_dev_link(hard_iface->net_dev,
-                                          soft_iface, NULL);
+                                          soft_iface, NULL, NULL);
        if (ret)
                goto err_dev;
 
index 781abc34667ace21eeb2b15a5612f3a6a92ce130..8d1d4a22c50df1bf598962cfb71270ce2d8c23fa 100644 (file)
@@ -493,7 +493,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 
        dev->priv_flags |= IFF_BRIDGE_PORT;
 
-       err = netdev_master_upper_dev_link(dev, br->dev, NULL);
+       err = netdev_master_upper_dev_link(dev, br->dev, NULL, NULL);
        if (err)
                goto err5;
 
index 27d052bb78bc0894656940125c8ec7636c72b4ce..8ed886663c6d9238020daec30b9ad6899fbd4b9a 100644 (file)
@@ -5421,7 +5421,7 @@ static void __netdev_adjacent_dev_unlink_neighbour(struct net_device *dev,
 
 static int __netdev_upper_dev_link(struct net_device *dev,
                                   struct net_device *upper_dev, bool master,
-                                  void *upper_priv)
+                                  void *upper_priv, void *upper_info)
 {
        struct netdev_notifier_changeupper_info changeupper_info;
        struct netdev_adjacent *i, *j, *to_i, *to_j;
@@ -5445,6 +5445,7 @@ static int __netdev_upper_dev_link(struct net_device *dev,
        changeupper_info.upper_dev = upper_dev;
        changeupper_info.master = master;
        changeupper_info.linking = true;
+       changeupper_info.upper_info = upper_info;
 
        ret = call_netdevice_notifiers_info(NETDEV_PRECHANGEUPPER, dev,
                                            &changeupper_info.info);
@@ -5549,7 +5550,7 @@ rollback_mesh:
 int netdev_upper_dev_link(struct net_device *dev,
                          struct net_device *upper_dev)
 {
-       return __netdev_upper_dev_link(dev, upper_dev, false, NULL);
+       return __netdev_upper_dev_link(dev, upper_dev, false, NULL, NULL);
 }
 EXPORT_SYMBOL(netdev_upper_dev_link);
 
@@ -5558,6 +5559,7 @@ EXPORT_SYMBOL(netdev_upper_dev_link);
  * @dev: device
  * @upper_dev: new upper device
  * @upper_priv: upper device private
+ * @upper_info: upper info to be passed down via notifier
  *
  * Adds a link to device which is upper to this one. In this case, only
  * one master upper device can be linked, although other non-master devices
@@ -5567,9 +5569,10 @@ EXPORT_SYMBOL(netdev_upper_dev_link);
  */
 int netdev_master_upper_dev_link(struct net_device *dev,
                                 struct net_device *upper_dev,
-                                void *upper_priv)
+                                void *upper_priv, void *upper_info)
 {
-       return __netdev_upper_dev_link(dev, upper_dev, true, upper_priv);
+       return __netdev_upper_dev_link(dev, upper_dev, true,
+                                      upper_priv, upper_info);
 }
 EXPORT_SYMBOL(netdev_master_upper_dev_link);
 
index 3ee3df1edeae11f83b63d0354a80b17da96c8ef8..8f4dd4c39bfe9444200404434f5fbaaf9b919dd9 100644 (file)
@@ -105,7 +105,7 @@ struct vport *ovs_netdev_link(struct vport *vport, const char *name)
 
        rtnl_lock();
        err = netdev_master_upper_dev_link(vport->dev,
-                                          get_dpdev(vport->dp), NULL);
+                                          get_dpdev(vport->dp), NULL, NULL);
        if (err)
                goto error_unlock;