summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorMatan Barak <matanb@mellanox.com>2015-07-30 18:33:24 +0300
committerDoug Ledford <dledford@redhat.com>2015-08-30 18:08:50 -0400
commite999869548b9ab97b7dffa053ba2fee81c31d069 (patch)
treed4c7bfbf220cd541d8d3426c50d7b257a68e733c /include/net
parent816dd19b3d191da88bc034fb85e21ed09a3ed320 (diff)
downloadlinux-e999869548b9ab97b7dffa053ba2fee81c31d069.tar.bz2
net/bonding: Export bond_option_active_slave_get_rcu
Some consumers of the netdev events API would like to know who is the active slave when a NETDEV_CHANGEUPPER or NETDEV_BONDING_FAILOVER events occur. For example, when managing RoCE GIDs, GIDs based on the bond's ips should only be set on the port which corresponds to active slave netdevice. Signed-off-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/bonding.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/net/bonding.h b/include/net/bonding.h
index 20defc0353d1..c1740a2794a3 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -310,6 +310,13 @@ static inline bool bond_uses_primary(struct bonding *bond)
return bond_mode_uses_primary(BOND_MODE(bond));
}
+static inline struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond)
+{
+ struct slave *slave = rcu_dereference(bond->curr_active_slave);
+
+ return bond_uses_primary(bond) && slave ? slave->dev : NULL;
+}
+
static inline bool bond_slave_is_up(struct slave *slave)
{
return netif_running(slave->dev) && netif_carrier_ok(slave->dev);