Skip to content

Commit 8557cd7

Browse files
vfalicodavem330
authored andcommitted
bonding: replace SLAVE_IS_OK() with bond_slave_can_tx()
They're verifying the same thing (except of IFF_UP, which is implied for netif_running(), which is also a prerequisite). CC: Jay Vosburgh <j.vosburgh@gmail.com> CC: Andy Gospodarek <andy@greyhouse.net> Signed-off-by: Veaceslav Falico <vfalico@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 891ab54 commit 8557cd7

4 files changed

Lines changed: 11 additions & 20 deletions

File tree

‎drivers/net/bonding/bond_3ad.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,13 +2449,13 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
24492449
continue;
24502450

24512451
if (slave_agg_no >= 0) {
2452-
if (!first_ok_slave && SLAVE_IS_OK(slave))
2452+
if (!first_ok_slave && bond_slave_can_tx(slave))
24532453
first_ok_slave = slave;
24542454
slave_agg_no--;
24552455
continue;
24562456
}
24572457

2458-
if (SLAVE_IS_OK(slave)) {
2458+
if (bond_slave_can_tx(slave)) {
24592459
bond_dev_queue_xmit(bond, skb, slave->dev);
24602460
goto out;
24612461
}

‎drivers/net/bonding/bond_alb.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static struct slave *tlb_get_least_loaded_slave(struct bonding *bond)
228228

229229
/* Find the slave with the largest gap */
230230
bond_for_each_slave_rcu(bond, slave, iter) {
231-
if (SLAVE_IS_OK(slave)) {
231+
if (bond_slave_can_tx(slave)) {
232232
long long gap = compute_gap(slave);
233233

234234
if (max_gap < gap) {
@@ -383,7 +383,7 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond)
383383
bool found = false;
384384

385385
bond_for_each_slave(bond, slave, iter) {
386-
if (!SLAVE_IS_OK(slave))
386+
if (!bond_slave_can_tx(slave))
387387
continue;
388388
if (!found) {
389389
if (!before || before->speed < slave->speed)
@@ -416,7 +416,7 @@ static struct slave *__rlb_next_rx_slave(struct bonding *bond)
416416
bool found = false;
417417

418418
bond_for_each_slave_rcu(bond, slave, iter) {
419-
if (!SLAVE_IS_OK(slave))
419+
if (!bond_slave_can_tx(slave))
420420
continue;
421421
if (!found) {
422422
if (!before || before->speed < slave->speed)
@@ -1100,13 +1100,13 @@ static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2)
11001100
static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1,
11011101
struct slave *slave2)
11021102
{
1103-
int slaves_state_differ = (SLAVE_IS_OK(slave1) != SLAVE_IS_OK(slave2));
1103+
int slaves_state_differ = (bond_slave_can_tx(slave1) != bond_slave_can_tx(slave2));
11041104
struct slave *disabled_slave = NULL;
11051105

11061106
ASSERT_RTNL();
11071107

11081108
/* fasten the change in the switch */
1109-
if (SLAVE_IS_OK(slave1)) {
1109+
if (bond_slave_can_tx(slave1)) {
11101110
alb_send_learning_packets(slave1, slave1->dev->dev_addr);
11111111
if (bond->alb_info.rlb_enabled) {
11121112
/* inform the clients that the mac address
@@ -1118,7 +1118,7 @@ static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1,
11181118
disabled_slave = slave1;
11191119
}
11201120

1121-
if (SLAVE_IS_OK(slave2)) {
1121+
if (bond_slave_can_tx(slave2)) {
11221122
alb_send_learning_packets(slave2, slave2->dev->dev_addr);
11231123
if (bond->alb_info.rlb_enabled) {
11241124
/* inform the clients that the mac address
@@ -1360,7 +1360,7 @@ static int bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,
13601360
bond_info->unbalanced_load += skb->len;
13611361
}
13621362

1363-
if (tx_slave && SLAVE_IS_OK(tx_slave)) {
1363+
if (tx_slave && bond_slave_can_tx(tx_slave)) {
13641364
if (tx_slave != rcu_dereference(bond->curr_active_slave)) {
13651365
ether_addr_copy(eth_data->h_source,
13661366
tx_slave->dev->dev_addr);

‎drivers/net/bonding/bond_main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3850,14 +3850,14 @@ static int bond_ethtool_get_settings(struct net_device *bond_dev,
38503850
ecmd->duplex = DUPLEX_UNKNOWN;
38513851
ecmd->port = PORT_OTHER;
38523852

3853-
/* Since SLAVE_IS_OK returns false for all inactive or down slaves, we
3853+
/* Since bond_slave_can_tx returns false for all inactive or down slaves, we
38543854
* do not need to check mode. Though link speed might not represent
38553855
* the true receive or transmit bandwidth (not all modes are symmetric)
38563856
* this is an accurate maximum.
38573857
*/
38583858
read_lock(&bond->lock);
38593859
bond_for_each_slave(bond, slave, iter) {
3860-
if (SLAVE_IS_OK(slave)) {
3860+
if (bond_slave_can_tx(slave)) {
38613861
if (slave->speed != SPEED_UNKNOWN)
38623862
speed += slave->speed;
38633863
if (ecmd->duplex == DUPLEX_UNKNOWN &&

‎drivers/net/bonding/bonding.h‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@
4040

4141
#define BOND_DEFAULT_MIIMON 100
4242

43-
/*
44-
* Checks whether slave is ready for transmit.
45-
*/
46-
#define SLAVE_IS_OK(slave) \
47-
(((slave)->dev->flags & IFF_UP) && \
48-
netif_running((slave)->dev) && \
49-
((slave)->link == BOND_LINK_UP) && \
50-
bond_is_active_slave(slave))
51-
5243
/*
5344
* Less bad way to call ioctl from within the kernel; this needs to be
5445
* done some other way to get the call out of interrupt context.

0 commit comments

Comments
 (0)