summaryrefslogtreecommitdiff
path: root/drivers/net/bonding
diff options
context:
space:
mode:
authorVeaceslav Falico <vfalico@redhat.com>2013-09-25 09:20:26 +0200
committerDavid S. Miller <davem@davemloft.net>2013-09-26 16:02:07 -0400
commit18e1e9bc5d1b9b89853a23aaeeed39686a95551b (patch)
tree118c56c0b01e6bc50e513a467ceb84ee8b97b46a /drivers/net/bonding
parentc8c23903f12a62708606b5cdba8cd8550cd6bdcd (diff)
bonding: add __bond_next_slave() which uses neighbours
Add a new function, __bond_next_slave(), which uses neighbours to find the next slave after the slave provided. It will be further used to gradually go start using neighbour netdev_adjacent infrastructure instead of bonding's own lists. CC: Jay Vosburgh <fubar@us.ibm.com> CC: Andy Gospodarek <andy@greyhouse.net> CC: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: Veaceslav Falico <vfalico@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r--drivers/net/bonding/bonding.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 454d6affa06a..4a3fbe307ee8 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -250,6 +250,34 @@ struct bonding {
((struct slave *) rtnl_dereference(dev->rx_handler_data))
/**
+ * __bond_next_slave - get the next slave after the one provided
+ * @bond - bonding struct
+ * @slave - the slave provided
+ *
+ * Returns the next slave after the slave provided, first slave if the
+ * slave provided is the last slave and NULL if slave is not found
+ */
+static inline struct slave *__bond_next_slave(struct bonding *bond,
+ struct slave *slave)
+{
+ struct slave *slave_iter;
+ struct list_head *iter;
+ bool found = false;
+
+ netdev_for_each_lower_private(bond->dev, slave_iter, iter) {
+ if (found)
+ return slave_iter;
+ if (slave_iter == slave)
+ found = true;
+ }
+
+ if (found)
+ return bond_first_slave(bond);
+
+ return NULL;
+}
+
+/**
* Returns NULL if the net_device does not belong to any of the bond's slaves
*
* Caller must hold bond lock for read