bonding: implement lower state change propagation
authorJiri Pirko <jiri@mellanox.com>
Thu, 3 Dec 2015 11:12:20 +0000 (12:12 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Dec 2015 16:49:27 +0000 (11:49 -0500)
Let netdev notifier listeners know about link and slave state change.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c
include/net/bonding.h

index 7695490061ec28658421078aae31a0c90f34eff3..2f1145063c60493901f2f22c7dadb8f6a9bfe092 100644 (file)
@@ -1317,6 +1317,16 @@ void bond_queue_slave_event(struct slave *slave)
        queue_delayed_work(slave->bond->wq, &nnw->work, 0);
 }
 
+void bond_lower_state_changed(struct slave *slave)
+{
+       struct netdev_lag_lower_state_info info;
+
+       info.link_up = slave->link == BOND_LINK_UP ||
+                      slave->link == BOND_LINK_FAIL;
+       info.tx_enabled = bond_is_active_slave(slave);
+       netdev_lower_state_changed(slave->dev, &info);
+}
+
 /* enslave device <slave> to bond device <master> */
 int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
 {
index 1df437715e2f58660f37718964b107c5dbe45fcf..ee6c52053aa324800f82baf4cbe2674f47d56399 100644 (file)
@@ -247,6 +247,7 @@ struct bonding {
        ((struct slave *) rtnl_dereference(dev->rx_handler_data))
 
 void bond_queue_slave_event(struct slave *slave);
+void bond_lower_state_changed(struct slave *slave);
 
 struct bond_vlan_tag {
        __be16          vlan_proto;
@@ -328,6 +329,7 @@ static inline void bond_set_active_slave(struct slave *slave)
        if (slave->backup) {
                slave->backup = 0;
                bond_queue_slave_event(slave);
+               bond_lower_state_changed(slave);
                rtmsg_ifinfo(RTM_NEWLINK, slave->dev, 0, GFP_ATOMIC);
        }
 }
@@ -337,6 +339,7 @@ static inline void bond_set_backup_slave(struct slave *slave)
        if (!slave->backup) {
                slave->backup = 1;
                bond_queue_slave_event(slave);
+               bond_lower_state_changed(slave);
                rtmsg_ifinfo(RTM_NEWLINK, slave->dev, 0, GFP_ATOMIC);
        }
 }
@@ -349,6 +352,7 @@ static inline void bond_set_slave_state(struct slave *slave,
 
        slave->backup = slave_state;
        if (notify) {
+               bond_lower_state_changed(slave);
                rtmsg_ifinfo(RTM_NEWLINK, slave->dev, 0, GFP_ATOMIC);
                bond_queue_slave_event(slave);
                slave->should_notify = 0;
@@ -380,6 +384,7 @@ static inline void bond_slave_state_notify(struct bonding *bond)
 
        bond_for_each_slave(bond, tmp, iter) {
                if (tmp->should_notify) {
+                       bond_lower_state_changed(tmp);
                        rtmsg_ifinfo(RTM_NEWLINK, tmp->dev, 0, GFP_ATOMIC);
                        tmp->should_notify = 0;
                }
@@ -514,6 +519,7 @@ static inline void bond_set_slave_link_state(struct slave *slave, int state,
        slave->link = state;
        if (notify) {
                bond_queue_slave_event(slave);
+               bond_lower_state_changed(slave);
                slave->should_notify_link = 0;
        } else {
                if (slave->should_notify_link)
@@ -531,6 +537,7 @@ static inline void bond_slave_link_notify(struct bonding *bond)
        bond_for_each_slave(bond, tmp, iter) {
                if (tmp->should_notify_link) {
                        bond_queue_slave_event(tmp);
+                       bond_lower_state_changed(tmp);
                        tmp->should_notify_link = 0;
                }
        }