Skip to content

Commit

Permalink
Merge branch 'bonding-cleanups'
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David S. Miller committed Sep 15, 2014
2 parents 4370240 + e097458 commit 6cca9ad
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 199 deletions.
5 changes: 2 additions & 3 deletions drivers/net/bonding/bond_3ad.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,14 @@ static u16 __get_link_speed(struct port *port)
static u8 __get_duplex(struct port *port)
{
struct slave *slave = port->slave;

u8 retval;

/* handling a special case: when the configuration starts with
* link down, it sets the duplex to 0.
*/
if (slave->link != BOND_LINK_UP)
if (slave->link != BOND_LINK_UP) {
retval = 0x0;
else {
} else {
switch (slave->duplex) {
case DUPLEX_FULL:
retval = 0x1;
Expand Down
86 changes: 30 additions & 56 deletions drivers/net/bonding/bond_alb.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,15 @@ static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index,
u32 skb_len)
{
struct slave *tx_slave;
/*
* We don't need to disable softirq here, becase

/* We don't need to disable softirq here, becase
* tlb_choose_channel() is only called by bond_alb_xmit()
* which already has softirq disabled.
*/
spin_lock(&bond->mode_lock);
tx_slave = __tlb_choose_channel(bond, hash_index, skb_len);
spin_unlock(&bond->mode_lock);

return tx_slave;
}

Expand Down Expand Up @@ -334,14 +335,15 @@ static int rlb_arp_recv(const struct sk_buff *skb, struct bonding *bond,
return RX_HANDLER_ANOTHER;
}

static struct slave *rlb_next_rx_slave(struct bonding *bond)
/* Caller must hold rcu_read_lock() */
static struct slave *__rlb_next_rx_slave(struct bonding *bond)
{
struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
struct slave *before = NULL, *rx_slave = NULL, *slave;
struct list_head *iter;
bool found = false;

bond_for_each_slave(bond, slave, iter) {
bond_for_each_slave_rcu(bond, slave, iter) {
if (!bond_slave_can_tx(slave))
continue;
if (!found) {
Expand All @@ -366,35 +368,16 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond)
return rx_slave;
}

/* Caller must hold rcu_read_lock() */
static struct slave *__rlb_next_rx_slave(struct bonding *bond)
/* Caller must hold RTNL, rcu_read_lock is obtained only to silence checkers */
static struct slave *rlb_next_rx_slave(struct bonding *bond)
{
struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
struct slave *before = NULL, *rx_slave = NULL, *slave;
struct list_head *iter;
bool found = false;
struct slave *rx_slave;

bond_for_each_slave_rcu(bond, slave, iter) {
if (!bond_slave_can_tx(slave))
continue;
if (!found) {
if (!before || before->speed < slave->speed)
before = slave;
} else {
if (!rx_slave || rx_slave->speed < slave->speed)
rx_slave = slave;
}
if (slave == bond_info->rx_slave)
found = true;
}
/* we didn't find anything after the current or we have something
* better before and up to the current slave
*/
if (!rx_slave || (before && rx_slave->speed < before->speed))
rx_slave = before;
ASSERT_RTNL();

if (rx_slave)
bond_info->rx_slave = rx_slave;
rcu_read_lock();
rx_slave = __rlb_next_rx_slave(bond);
rcu_read_unlock();

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

if (arp->op_code == htons(ARPOP_REPLY)) {
/* the arp must be sent on the selected
* rx channel
*/
/* the arp must be sent on the selected rx channel */
tx_slave = rlb_choose_channel(skb, bond);
if (tx_slave)
ether_addr_copy(arp->mac_src, tx_slave->dev->dev_addr);
Expand Down Expand Up @@ -774,7 +755,7 @@ static void rlb_rebalance(struct bonding *bond)
spin_unlock_bh(&bond->mode_lock);
}

/* Caller must hold rx_hashtbl lock */
/* Caller must hold mode_lock */
static void rlb_init_table_entry_dst(struct rlb_client_info *entry)
{
entry->used_next = RLB_NULL_INDEX;
Expand Down Expand Up @@ -862,8 +843,9 @@ static void rlb_src_link(struct bonding *bond, u32 ip_src_hash, u32 ip_dst_hash)
bond_info->rx_hashtbl[ip_src_hash].src_first = ip_dst_hash;
}

/* deletes all rx_hashtbl entries with arp->ip_src if their mac_src does
* not match arp->mac_src */
/* deletes all rx_hashtbl entries with arp->ip_src if their mac_src does
* not match arp->mac_src
*/
static void rlb_purge_src_ip(struct bonding *bond, struct arp_pkt *arp)
{
struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
Expand Down Expand Up @@ -1040,8 +1022,9 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[])
return 0;
}

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

/*
* Swap MAC addresses between two slaves.
/* Swap MAC addresses between two slaves.
*
* Called with RTNL held, and no other locks.
*
*/

static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2)
{
u8 tmp_mac_addr[ETH_ALEN];
Expand All @@ -1069,8 +1049,7 @@ static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2)

}

/*
* Send learning packets after MAC address swap.
/* Send learning packets after MAC address swap.
*
* Called with RTNL and no other locks
*/
Expand Down Expand Up @@ -1143,7 +1122,6 @@ static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *sla
found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr);

if (found_slave) {
/* locking: needs RTNL and nothing else */
alb_swap_mac_addr(slave, found_slave);
alb_fasten_mac_swap(bond, slave, found_slave);
}
Expand Down Expand Up @@ -1192,7 +1170,8 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
return 0;

/* Try setting slave mac to bond address and fall-through
to code handling that situation below... */
* to code handling that situation below...
*/
alb_set_slave_mac_addr(slave, bond->dev->dev_addr);
}

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

if (rlb_enabled) {
bond->alb_info.rlb_enabled = 1;
/* initialize rlb */
res = rlb_initialize(bond);
if (res) {
tlb_deinitialize(bond);
Expand All @@ -1324,7 +1302,7 @@ void bond_alb_deinitialize(struct bonding *bond)
}

static int bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,
struct slave *tx_slave)
struct slave *tx_slave)
{
struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
struct ethhdr *eth_data = eth_hdr(skb);
Expand Down Expand Up @@ -1572,13 +1550,11 @@ void bond_alb_monitor(struct work_struct *work)
bond_info->tx_rebalance_counter = 0;
}

/* handle rlb stuff */
if (bond_info->rlb_enabled) {
if (bond_info->primary_is_promisc &&
(++bond_info->rlb_promisc_timeout_counter >= RLB_PROMISC_TIMEOUT)) {

/*
* dev_set_promiscuity requires rtnl and
/* dev_set_promiscuity requires rtnl and
* nothing else. Avoid race with bond_close.
*/
rcu_read_unlock();
Expand Down Expand Up @@ -1648,8 +1624,7 @@ int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
return 0;
}

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

/*
* Arrange for swap_slave and new_slave to temporarily be
/* Arrange for swap_slave and new_slave to temporarily be
* ignored so we can mess with their MAC addresses without
* fear of interference from transmit activity.
*/
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/bonding/bond_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

static struct dentry *bonding_debug_root;

/*
* Show RLB hash table
*/
/* Show RLB hash table */
static int bond_debug_rlb_hash_show(struct seq_file *m, void *v)
{
struct bonding *bond = m->private;
Expand Down
Loading

0 comments on commit 6cca9ad

Please sign in to comment.