Skip to content

Commit 6cca9ad

Browse files
committed
Merge branch 'bonding-cleanups'
Nikolay Aleksandrov says: ==================== bonding: style, comment and assertion changes This is a small and simple patch-set that doesn't introduce (hopefully) any functional changes, but only stylistic and semantic ones. Patch 01 simply uses the already provided __rlb_next_rx_slave function inside rlb_next_rx_slave(), thus removing the duplication of code. Patch 02 changes all comments that I could find to netdev style, removes some outdated ones and fixes a few more small cosmetic issues (new line after declaration, braces around if; else and such) Patch 03 removes one extra ASSERT_RTNL() because we already have it in the parent function and consolidates two other ASSERT_RTNL()s to the function that is exported and supposed to be called with RTNL anyway. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 4370240 + e097458 commit 6cca9ad

6 files changed

Lines changed: 105 additions & 199 deletions

File tree

‎drivers/net/bonding/bond_3ad.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,14 @@ static u16 __get_link_speed(struct port *port)
297297
static u8 __get_duplex(struct port *port)
298298
{
299299
struct slave *slave = port->slave;
300-
301300
u8 retval;
302301

303302
/* handling a special case: when the configuration starts with
304303
* link down, it sets the duplex to 0.
305304
*/
306-
if (slave->link != BOND_LINK_UP)
305+
if (slave->link != BOND_LINK_UP) {
307306
retval = 0x0;
308-
else {
307+
} else {
309308
switch (slave->duplex) {
310309
case DUPLEX_FULL:
311310
retval = 0x1;

‎drivers/net/bonding/bond_alb.c‎

Lines changed: 30 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,15 @@ static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index,
261261
u32 skb_len)
262262
{
263263
struct slave *tx_slave;
264-
/*
265-
* We don't need to disable softirq here, becase
264+
265+
/* We don't need to disable softirq here, becase
266266
* tlb_choose_channel() is only called by bond_alb_xmit()
267267
* which already has softirq disabled.
268268
*/
269269
spin_lock(&bond->mode_lock);
270270
tx_slave = __tlb_choose_channel(bond, hash_index, skb_len);
271271
spin_unlock(&bond->mode_lock);
272+
272273
return tx_slave;
273274
}
274275

@@ -334,14 +335,15 @@ static int rlb_arp_recv(const struct sk_buff *skb, struct bonding *bond,
334335
return RX_HANDLER_ANOTHER;
335336
}
336337

337-
static struct slave *rlb_next_rx_slave(struct bonding *bond)
338+
/* Caller must hold rcu_read_lock() */
339+
static struct slave *__rlb_next_rx_slave(struct bonding *bond)
338340
{
339341
struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
340342
struct slave *before = NULL, *rx_slave = NULL, *slave;
341343
struct list_head *iter;
342344
bool found = false;
343345

344-
bond_for_each_slave(bond, slave, iter) {
346+
bond_for_each_slave_rcu(bond, slave, iter) {
345347
if (!bond_slave_can_tx(slave))
346348
continue;
347349
if (!found) {
@@ -366,35 +368,16 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond)
366368
return rx_slave;
367369
}
368370

369-
/* Caller must hold rcu_read_lock() */
370-
static struct slave *__rlb_next_rx_slave(struct bonding *bond)
371+
/* Caller must hold RTNL, rcu_read_lock is obtained only to silence checkers */
372+
static struct slave *rlb_next_rx_slave(struct bonding *bond)
371373
{
372-
struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
373-
struct slave *before = NULL, *rx_slave = NULL, *slave;
374-
struct list_head *iter;
375-
bool found = false;
374+
struct slave *rx_slave;
376375

377-
bond_for_each_slave_rcu(bond, slave, iter) {
378-
if (!bond_slave_can_tx(slave))
379-
continue;
380-
if (!found) {
381-
if (!before || before->speed < slave->speed)
382-
before = slave;
383-
} else {
384-
if (!rx_slave || rx_slave->speed < slave->speed)
385-
rx_slave = slave;
386-
}
387-
if (slave == bond_info->rx_slave)
388-
found = true;
389-
}
390-
/* we didn't find anything after the current or we have something
391-
* better before and up to the current slave
392-
*/
393-
if (!rx_slave || (before && rx_slave->speed < before->speed))
394-
rx_slave = before;
376+
ASSERT_RTNL();
395377

396-
if (rx_slave)
397-
bond_info->rx_slave = rx_slave;
378+
rcu_read_lock();
379+
rx_slave = __rlb_next_rx_slave(bond);
380+
rcu_read_unlock();
398381

399382
return rx_slave;
400383
}
@@ -587,7 +570,7 @@ static void rlb_req_update_subnet_clients(struct bonding *bond, __be32 src_ip)
587570
netdev_err(bond->dev, "found a client with no channel in the client's hash table\n");
588571
continue;
589572
}
590-
/*update all clients using this src_ip, that are not assigned
573+
/* update all clients using this src_ip, that are not assigned
591574
* to the team's address (curr_active_slave) and have a known
592575
* unicast mac address.
593576
*/
@@ -713,9 +696,7 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
713696
return NULL;
714697

715698
if (arp->op_code == htons(ARPOP_REPLY)) {
716-
/* the arp must be sent on the selected
717-
* rx channel
718-
*/
699+
/* the arp must be sent on the selected rx channel */
719700
tx_slave = rlb_choose_channel(skb, bond);
720701
if (tx_slave)
721702
ether_addr_copy(arp->mac_src, tx_slave->dev->dev_addr);
@@ -774,7 +755,7 @@ static void rlb_rebalance(struct bonding *bond)
774755
spin_unlock_bh(&bond->mode_lock);
775756
}
776757

777-
/* Caller must hold rx_hashtbl lock */
758+
/* Caller must hold mode_lock */
778759
static void rlb_init_table_entry_dst(struct rlb_client_info *entry)
779760
{
780761
entry->used_next = RLB_NULL_INDEX;
@@ -862,8 +843,9 @@ static void rlb_src_link(struct bonding *bond, u32 ip_src_hash, u32 ip_dst_hash)
862843
bond_info->rx_hashtbl[ip_src_hash].src_first = ip_dst_hash;
863844
}
864845

865-
/* deletes all rx_hashtbl entries with arp->ip_src if their mac_src does
866-
* not match arp->mac_src */
846+
/* deletes all rx_hashtbl entries with arp->ip_src if their mac_src does
847+
* not match arp->mac_src
848+
*/
867849
static void rlb_purge_src_ip(struct bonding *bond, struct arp_pkt *arp)
868850
{
869851
struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
@@ -1040,8 +1022,9 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[])
10401022
return 0;
10411023
}
10421024

1043-
/* for rlb each slave must have a unique hw mac addresses so that */
1044-
/* each slave will receive packets destined to a different mac */
1025+
/* for rlb each slave must have a unique hw mac addresses so that
1026+
* each slave will receive packets destined to a different mac
1027+
*/
10451028
memcpy(s_addr.sa_data, addr, dev->addr_len);
10461029
s_addr.sa_family = dev->type;
10471030
if (dev_set_mac_address(dev, &s_addr)) {
@@ -1052,13 +1035,10 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[])
10521035
return 0;
10531036
}
10541037

1055-
/*
1056-
* Swap MAC addresses between two slaves.
1038+
/* Swap MAC addresses between two slaves.
10571039
*
10581040
* Called with RTNL held, and no other locks.
1059-
*
10601041
*/
1061-
10621042
static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2)
10631043
{
10641044
u8 tmp_mac_addr[ETH_ALEN];
@@ -1069,8 +1049,7 @@ static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2)
10691049

10701050
}
10711051

1072-
/*
1073-
* Send learning packets after MAC address swap.
1052+
/* Send learning packets after MAC address swap.
10741053
*
10751054
* Called with RTNL and no other locks
10761055
*/
@@ -1143,7 +1122,6 @@ static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *sla
11431122
found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr);
11441123

11451124
if (found_slave) {
1146-
/* locking: needs RTNL and nothing else */
11471125
alb_swap_mac_addr(slave, found_slave);
11481126
alb_fasten_mac_swap(bond, slave, found_slave);
11491127
}
@@ -1192,7 +1170,8 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
11921170
return 0;
11931171

11941172
/* Try setting slave mac to bond address and fall-through
1195-
to code handling that situation below... */
1173+
* to code handling that situation below...
1174+
*/
11961175
alb_set_slave_mac_addr(slave, bond->dev->dev_addr);
11971176
}
11981177

@@ -1300,7 +1279,6 @@ int bond_alb_initialize(struct bonding *bond, int rlb_enabled)
13001279

13011280
if (rlb_enabled) {
13021281
bond->alb_info.rlb_enabled = 1;
1303-
/* initialize rlb */
13041282
res = rlb_initialize(bond);
13051283
if (res) {
13061284
tlb_deinitialize(bond);
@@ -1324,7 +1302,7 @@ void bond_alb_deinitialize(struct bonding *bond)
13241302
}
13251303

13261304
static int bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,
1327-
struct slave *tx_slave)
1305+
struct slave *tx_slave)
13281306
{
13291307
struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
13301308
struct ethhdr *eth_data = eth_hdr(skb);
@@ -1572,13 +1550,11 @@ void bond_alb_monitor(struct work_struct *work)
15721550
bond_info->tx_rebalance_counter = 0;
15731551
}
15741552

1575-
/* handle rlb stuff */
15761553
if (bond_info->rlb_enabled) {
15771554
if (bond_info->primary_is_promisc &&
15781555
(++bond_info->rlb_promisc_timeout_counter >= RLB_PROMISC_TIMEOUT)) {
15791556

1580-
/*
1581-
* dev_set_promiscuity requires rtnl and
1557+
/* dev_set_promiscuity requires rtnl and
15821558
* nothing else. Avoid race with bond_close.
15831559
*/
15841560
rcu_read_unlock();
@@ -1648,8 +1624,7 @@ int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
16481624
return 0;
16491625
}
16501626

1651-
/*
1652-
* Remove slave from tlb and rlb hash tables, and fix up MAC addresses
1627+
/* Remove slave from tlb and rlb hash tables, and fix up MAC addresses
16531628
* if necessary.
16541629
*
16551630
* Caller must hold RTNL and no other locks
@@ -1736,8 +1711,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
17361711
if (!swap_slave)
17371712
swap_slave = bond_slave_has_mac(bond, bond->dev->dev_addr);
17381713

1739-
/*
1740-
* Arrange for swap_slave and new_slave to temporarily be
1714+
/* Arrange for swap_slave and new_slave to temporarily be
17411715
* ignored so we can mess with their MAC addresses without
17421716
* fear of interference from transmit activity.
17431717
*/

‎drivers/net/bonding/bond_debugfs.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
static struct dentry *bonding_debug_root;
1515

16-
/*
17-
* Show RLB hash table
18-
*/
16+
/* Show RLB hash table */
1917
static int bond_debug_rlb_hash_show(struct seq_file *m, void *v)
2018
{
2119
struct bonding *bond = m->private;

0 commit comments

Comments
 (0)