Skip to content

Commit

Permalink
bonding: split bond_set_slave_link_state into two parts
Browse files Browse the repository at this point in the history
Split the function into two (a) propose (b) commit phase without
changing the semantics for the original API.

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Mahesh Bandewar authored and davem330 committed Mar 28, 2017
1 parent 205ed44 commit f307668
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions include/net/bonding.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ struct slave {
unsigned long last_link_up;
unsigned long last_rx;
unsigned long target_last_arp_rx[BOND_MAX_ARP_TARGETS];
s8 link; /* one of BOND_LINK_XXXX */
s8 link; /* one of BOND_LINK_XXXX */
s8 link_new_state; /* one of BOND_LINK_XXXX */
s8 new_link;
u8 backup:1, /* indicates backup slave. Value corresponds with
BOND_STATE_ACTIVE and BOND_STATE_BACKUP */
Expand Down Expand Up @@ -504,13 +505,17 @@ static inline bool bond_is_slave_inactive(struct slave *slave)
return slave->inactive;
}

static inline void bond_set_slave_link_state(struct slave *slave, int state,
bool notify)
static inline void bond_propose_link_state(struct slave *slave, int state)
{
slave->link_new_state = state;
}

static inline void bond_commit_link_state(struct slave *slave, bool notify)
{
if (slave->link == state)
if (slave->link == slave->link_new_state)
return;

slave->link = state;
slave->link = slave->link_new_state;
if (notify) {
bond_queue_slave_event(slave);
bond_lower_state_changed(slave);
Expand All @@ -523,6 +528,13 @@ static inline void bond_set_slave_link_state(struct slave *slave, int state,
}
}

static inline void bond_set_slave_link_state(struct slave *slave, int state,
bool notify)
{
bond_propose_link_state(slave, state);
bond_commit_link_state(slave, notify);
}

static inline void bond_slave_link_notify(struct bonding *bond)
{
struct list_head *iter;
Expand Down

0 comments on commit f307668

Please sign in to comment.