]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net: introduce change lower state notifier
authorJiri Pirko <jiri@mellanox.com>
Thu, 3 Dec 2015 11:12:15 +0000 (12:12 +0100)
committerBrian Maly <brian.maly@oracle.com>
Tue, 20 Nov 2018 22:11:53 +0000 (17:11 -0500)
When lower device like bonding slave, team/bridge port, etc changes its
state, it is useful for others to notice this change. Currently this is
implemented specificly for bonding as NETDEV_BONDING_INFO notifier. This
patch aims to replace this specific usage and make this more generic to
be used for all upper-lower devices.

Introduce NETDEV_CHANGELOWERSTATE netdev notifier type and
netdev_lower_state_changed() helper.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 04d482660a07039fc4e9a42bb3517db236d98f96)
Orabug: 28122104
Signed-off-by: Vijay Balakrishna <vijay.balakrishna@oracle.com>
Reviewed-by: Si-Wei Liu <si-wei.liu@oracle.com>
Reviewed-by: Shannon Nelson <shannon.nelson@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Conflicts:
include/linux/netdevice.h
(a #define not present in UEK4)

Signed-off-by: Brian Maly <brian.maly@oracle.com>
include/linux/netdevice.h
net/core/dev.c

index 86642ed14c8417e1829995c95ffe7154d713fdb2..2bd91f5e47d8d48004f916805452506d2d177961 100644 (file)
@@ -2112,6 +2112,7 @@ struct netdev_lag_upper_info {
 #define NETDEV_PRECHANGEMTU    0x0017 /* notify before mtu change happened */
 #define NETDEV_CHANGEINFODATA  0x0018
 #define NETDEV_BONDING_INFO    0x0019
+#define NETDEV_CHANGELOWERSTATE        0x001A
 
 int register_netdevice_notifier(struct notifier_block *nb);
 int unregister_netdevice_notifier(struct notifier_block *nb);
@@ -2133,6 +2134,11 @@ struct netdev_notifier_changeupper_info {
        void *upper_info; /* upper dev info */
 };
 
+struct netdev_notifier_changelowerstate_info {
+       struct netdev_notifier_info info; /* must be first */
+       void *lower_state_info; /* is lower dev state */
+};
+
 static inline void netdev_notifier_info_init(struct netdev_notifier_info *info,
                                             struct net_device *dev)
 {
@@ -3629,6 +3635,8 @@ void netdev_upper_dev_unlink(struct net_device *dev,
 void netdev_adjacent_rename_links(struct net_device *dev, char *oldname);
 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);
 
 /* RSS keys are 40 or 52 bytes long */
 #define NETDEV_RSS_KEY_LEN 52
index e7111c4b4f8d1c198d9b60d7e9a9d9e14d658575..da4348252605a17dc8ad3d7e88bb9fa16d98c490 100644 (file)
@@ -5590,6 +5590,26 @@ int dev_get_nest_level(struct net_device *dev,
 }
 EXPORT_SYMBOL(dev_get_nest_level);
 
+/**
+ * netdev_lower_change - Dispatch event about lower device state change
+ * @lower_dev: device
+ * @lower_state_info: state to dispatch
+ *
+ * Send NETDEV_CHANGELOWERSTATE to netdev notifiers with info.
+ * The caller must hold the RTNL lock.
+ */
+void netdev_lower_state_changed(struct net_device *lower_dev,
+                               void *lower_state_info)
+{
+       struct netdev_notifier_changelowerstate_info changelowerstate_info;
+
+       ASSERT_RTNL();
+       changelowerstate_info.lower_state_info = lower_state_info;
+       call_netdevice_notifiers_info(NETDEV_CHANGELOWERSTATE, lower_dev,
+                                     &changelowerstate_info.info);
+}
+EXPORT_SYMBOL(netdev_lower_state_changed);
+
 static void dev_change_rx_flags(struct net_device *dev, int flags)
 {
        const struct net_device_ops *ops = dev->netdev_ops;