Commit 3e36bb75 authored by Veaceslav Falico's avatar Veaceslav Falico Committed by David S. Miller

bonding: make ad_port_selection_logic() use bond_for_each_slave()

Currently, ad_port_selection_logic() uses

for (aggregator = __get_first_agg(port); aggregator;
     aggregator = __get_next_agg(aggregator)) {

construct, however it's suboptimal, difficult to read and understand.

Change it to a standard bond_for_each_slave(), so that we won't need
__get_first/next_agg() and have it more readable.

CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: default avatarVeaceslav Falico <vfalico@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fe9323da
...@@ -1239,12 +1239,17 @@ static void ad_port_selection_logic(struct port *port) ...@@ -1239,12 +1239,17 @@ static void ad_port_selection_logic(struct port *port)
{ {
struct aggregator *aggregator, *free_aggregator = NULL, *temp_aggregator; struct aggregator *aggregator, *free_aggregator = NULL, *temp_aggregator;
struct port *last_port = NULL, *curr_port; struct port *last_port = NULL, *curr_port;
struct list_head *iter;
struct bonding *bond;
struct slave *slave;
int found = 0; int found = 0;
// if the port is already Selected, do nothing // if the port is already Selected, do nothing
if (port->sm_vars & AD_PORT_SELECTED) if (port->sm_vars & AD_PORT_SELECTED)
return; return;
bond = __get_bond_by_port(port);
// if the port is connected to other aggregator, detach it // if the port is connected to other aggregator, detach it
if (port->aggregator) { if (port->aggregator) {
// detach the port from its former aggregator // detach the port from its former aggregator
...@@ -1285,8 +1290,8 @@ static void ad_port_selection_logic(struct port *port) ...@@ -1285,8 +1290,8 @@ static void ad_port_selection_logic(struct port *port)
} }
} }
// search on all aggregators for a suitable aggregator for this port // search on all aggregators for a suitable aggregator for this port
for (aggregator = __get_first_agg(port); aggregator; bond_for_each_slave(bond, slave, iter) {
aggregator = __get_next_agg(aggregator)) { aggregator = &(SLAVE_AD_INFO(slave).aggregator);
// keep a free aggregator for later use(if needed) // keep a free aggregator for later use(if needed)
if (!aggregator->lag_ports) { if (!aggregator->lag_ports) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment