forked from Minki/linux
net/bonding: Move slave state changes to a helper function
Move slave state changes to a helper function, this is a pre-step for adding functionality of dispatching an event when this helper is called. This commit doesn't add new functionality. Signed-off-by: Moni Shoua <monis@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
61bd3857ff
commit
69a2338e05
@ -790,7 +790,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_active->delay = 0;
|
new_active->delay = 0;
|
||||||
new_active->link = BOND_LINK_UP;
|
bond_set_slave_link_state(new_active, BOND_LINK_UP);
|
||||||
|
|
||||||
if (BOND_MODE(bond) == BOND_MODE_8023AD)
|
if (BOND_MODE(bond) == BOND_MODE_8023AD)
|
||||||
bond_3ad_handle_link_change(new_active, BOND_LINK_UP);
|
bond_3ad_handle_link_change(new_active, BOND_LINK_UP);
|
||||||
@ -1181,6 +1181,21 @@ static void bond_free_slave(struct slave *slave)
|
|||||||
kfree(slave);
|
kfree(slave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void bond_fill_ifbond(struct bonding *bond, struct ifbond *info)
|
||||||
|
{
|
||||||
|
info->bond_mode = BOND_MODE(bond);
|
||||||
|
info->miimon = bond->params.miimon;
|
||||||
|
info->num_slaves = bond->slave_cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bond_fill_ifslave(struct slave *slave, struct ifslave *info)
|
||||||
|
{
|
||||||
|
strcpy(info->slave_name, slave->dev->name);
|
||||||
|
info->link = slave->link;
|
||||||
|
info->state = bond_slave_state(slave);
|
||||||
|
info->link_failure_count = slave->link_failure_count;
|
||||||
|
}
|
||||||
|
|
||||||
/* enslave device <slave> to bond device <master> */
|
/* enslave device <slave> to bond device <master> */
|
||||||
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
|
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
|
||||||
{
|
{
|
||||||
@ -1444,19 +1459,22 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
|
|||||||
if (bond->params.miimon) {
|
if (bond->params.miimon) {
|
||||||
if (bond_check_dev_link(bond, slave_dev, 0) == BMSR_LSTATUS) {
|
if (bond_check_dev_link(bond, slave_dev, 0) == BMSR_LSTATUS) {
|
||||||
if (bond->params.updelay) {
|
if (bond->params.updelay) {
|
||||||
new_slave->link = BOND_LINK_BACK;
|
bond_set_slave_link_state(new_slave,
|
||||||
|
BOND_LINK_BACK);
|
||||||
new_slave->delay = bond->params.updelay;
|
new_slave->delay = bond->params.updelay;
|
||||||
} else {
|
} else {
|
||||||
new_slave->link = BOND_LINK_UP;
|
bond_set_slave_link_state(new_slave,
|
||||||
|
BOND_LINK_UP);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
new_slave->link = BOND_LINK_DOWN;
|
bond_set_slave_link_state(new_slave, BOND_LINK_DOWN);
|
||||||
}
|
}
|
||||||
} else if (bond->params.arp_interval) {
|
} else if (bond->params.arp_interval) {
|
||||||
new_slave->link = (netif_carrier_ok(slave_dev) ?
|
bond_set_slave_link_state(new_slave,
|
||||||
BOND_LINK_UP : BOND_LINK_DOWN);
|
(netif_carrier_ok(slave_dev) ?
|
||||||
|
BOND_LINK_UP : BOND_LINK_DOWN));
|
||||||
} else {
|
} else {
|
||||||
new_slave->link = BOND_LINK_UP;
|
bond_set_slave_link_state(new_slave, BOND_LINK_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_slave->link != BOND_LINK_DOWN)
|
if (new_slave->link != BOND_LINK_DOWN)
|
||||||
@ -1821,11 +1839,7 @@ static int bond_release_and_destroy(struct net_device *bond_dev,
|
|||||||
static int bond_info_query(struct net_device *bond_dev, struct ifbond *info)
|
static int bond_info_query(struct net_device *bond_dev, struct ifbond *info)
|
||||||
{
|
{
|
||||||
struct bonding *bond = netdev_priv(bond_dev);
|
struct bonding *bond = netdev_priv(bond_dev);
|
||||||
|
bond_fill_ifbond(bond, info);
|
||||||
info->bond_mode = BOND_MODE(bond);
|
|
||||||
info->miimon = bond->params.miimon;
|
|
||||||
info->num_slaves = bond->slave_cnt;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1839,10 +1853,7 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in
|
|||||||
bond_for_each_slave(bond, slave, iter) {
|
bond_for_each_slave(bond, slave, iter) {
|
||||||
if (i++ == (int)info->slave_id) {
|
if (i++ == (int)info->slave_id) {
|
||||||
res = 0;
|
res = 0;
|
||||||
strcpy(info->slave_name, slave->dev->name);
|
bond_fill_ifslave(slave, info);
|
||||||
info->link = slave->link;
|
|
||||||
info->state = bond_slave_state(slave);
|
|
||||||
info->link_failure_count = slave->link_failure_count;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1872,7 +1883,7 @@ static int bond_miimon_inspect(struct bonding *bond)
|
|||||||
if (link_state)
|
if (link_state)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
slave->link = BOND_LINK_FAIL;
|
bond_set_slave_link_state(slave, BOND_LINK_FAIL);
|
||||||
slave->delay = bond->params.downdelay;
|
slave->delay = bond->params.downdelay;
|
||||||
if (slave->delay) {
|
if (slave->delay) {
|
||||||
netdev_info(bond->dev, "link status down for %sinterface %s, disabling it in %d ms\n",
|
netdev_info(bond->dev, "link status down for %sinterface %s, disabling it in %d ms\n",
|
||||||
@ -1887,7 +1898,7 @@ static int bond_miimon_inspect(struct bonding *bond)
|
|||||||
case BOND_LINK_FAIL:
|
case BOND_LINK_FAIL:
|
||||||
if (link_state) {
|
if (link_state) {
|
||||||
/* recovered before downdelay expired */
|
/* recovered before downdelay expired */
|
||||||
slave->link = BOND_LINK_UP;
|
bond_set_slave_link_state(slave, BOND_LINK_UP);
|
||||||
slave->last_link_up = jiffies;
|
slave->last_link_up = jiffies;
|
||||||
netdev_info(bond->dev, "link status up again after %d ms for interface %s\n",
|
netdev_info(bond->dev, "link status up again after %d ms for interface %s\n",
|
||||||
(bond->params.downdelay - slave->delay) *
|
(bond->params.downdelay - slave->delay) *
|
||||||
@ -1909,7 +1920,7 @@ static int bond_miimon_inspect(struct bonding *bond)
|
|||||||
if (!link_state)
|
if (!link_state)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
slave->link = BOND_LINK_BACK;
|
bond_set_slave_link_state(slave, BOND_LINK_BACK);
|
||||||
slave->delay = bond->params.updelay;
|
slave->delay = bond->params.updelay;
|
||||||
|
|
||||||
if (slave->delay) {
|
if (slave->delay) {
|
||||||
@ -1922,7 +1933,8 @@ static int bond_miimon_inspect(struct bonding *bond)
|
|||||||
/*FALLTHRU*/
|
/*FALLTHRU*/
|
||||||
case BOND_LINK_BACK:
|
case BOND_LINK_BACK:
|
||||||
if (!link_state) {
|
if (!link_state) {
|
||||||
slave->link = BOND_LINK_DOWN;
|
bond_set_slave_link_state(slave,
|
||||||
|
BOND_LINK_DOWN);
|
||||||
netdev_info(bond->dev, "link status down again after %d ms for interface %s\n",
|
netdev_info(bond->dev, "link status down again after %d ms for interface %s\n",
|
||||||
(bond->params.updelay - slave->delay) *
|
(bond->params.updelay - slave->delay) *
|
||||||
bond->params.miimon,
|
bond->params.miimon,
|
||||||
@ -1960,7 +1972,7 @@ static void bond_miimon_commit(struct bonding *bond)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
case BOND_LINK_UP:
|
case BOND_LINK_UP:
|
||||||
slave->link = BOND_LINK_UP;
|
bond_set_slave_link_state(slave, BOND_LINK_UP);
|
||||||
slave->last_link_up = jiffies;
|
slave->last_link_up = jiffies;
|
||||||
|
|
||||||
primary = rtnl_dereference(bond->primary_slave);
|
primary = rtnl_dereference(bond->primary_slave);
|
||||||
@ -2000,7 +2012,7 @@ static void bond_miimon_commit(struct bonding *bond)
|
|||||||
if (slave->link_failure_count < UINT_MAX)
|
if (slave->link_failure_count < UINT_MAX)
|
||||||
slave->link_failure_count++;
|
slave->link_failure_count++;
|
||||||
|
|
||||||
slave->link = BOND_LINK_DOWN;
|
bond_set_slave_link_state(slave, BOND_LINK_DOWN);
|
||||||
|
|
||||||
if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP ||
|
if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP ||
|
||||||
BOND_MODE(bond) == BOND_MODE_8023AD)
|
BOND_MODE(bond) == BOND_MODE_8023AD)
|
||||||
@ -2583,7 +2595,7 @@ static void bond_ab_arp_commit(struct bonding *bond)
|
|||||||
struct slave *current_arp_slave;
|
struct slave *current_arp_slave;
|
||||||
|
|
||||||
current_arp_slave = rtnl_dereference(bond->current_arp_slave);
|
current_arp_slave = rtnl_dereference(bond->current_arp_slave);
|
||||||
slave->link = BOND_LINK_UP;
|
bond_set_slave_link_state(slave, BOND_LINK_UP);
|
||||||
if (current_arp_slave) {
|
if (current_arp_slave) {
|
||||||
bond_set_slave_inactive_flags(
|
bond_set_slave_inactive_flags(
|
||||||
current_arp_slave,
|
current_arp_slave,
|
||||||
@ -2606,7 +2618,7 @@ static void bond_ab_arp_commit(struct bonding *bond)
|
|||||||
if (slave->link_failure_count < UINT_MAX)
|
if (slave->link_failure_count < UINT_MAX)
|
||||||
slave->link_failure_count++;
|
slave->link_failure_count++;
|
||||||
|
|
||||||
slave->link = BOND_LINK_DOWN;
|
bond_set_slave_link_state(slave, BOND_LINK_DOWN);
|
||||||
bond_set_slave_inactive_flags(slave,
|
bond_set_slave_inactive_flags(slave,
|
||||||
BOND_SLAVE_NOTIFY_NOW);
|
BOND_SLAVE_NOTIFY_NOW);
|
||||||
|
|
||||||
@ -2685,7 +2697,7 @@ static bool bond_ab_arp_probe(struct bonding *bond)
|
|||||||
* up when it is actually down
|
* up when it is actually down
|
||||||
*/
|
*/
|
||||||
if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) {
|
if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) {
|
||||||
slave->link = BOND_LINK_DOWN;
|
bond_set_slave_link_state(slave, BOND_LINK_DOWN);
|
||||||
if (slave->link_failure_count < UINT_MAX)
|
if (slave->link_failure_count < UINT_MAX)
|
||||||
slave->link_failure_count++;
|
slave->link_failure_count++;
|
||||||
|
|
||||||
@ -2705,7 +2717,7 @@ static bool bond_ab_arp_probe(struct bonding *bond)
|
|||||||
if (!new_slave)
|
if (!new_slave)
|
||||||
goto check_state;
|
goto check_state;
|
||||||
|
|
||||||
new_slave->link = BOND_LINK_BACK;
|
bond_set_slave_link_state(new_slave, BOND_LINK_BACK);
|
||||||
bond_set_slave_active_flags(new_slave, BOND_SLAVE_NOTIFY_LATER);
|
bond_set_slave_active_flags(new_slave, BOND_SLAVE_NOTIFY_LATER);
|
||||||
bond_arp_send_all(bond, new_slave);
|
bond_arp_send_all(bond, new_slave);
|
||||||
new_slave->last_link_up = jiffies;
|
new_slave->last_link_up = jiffies;
|
||||||
|
@ -490,6 +490,11 @@ static inline bool bond_is_slave_inactive(struct slave *slave)
|
|||||||
return slave->inactive;
|
return slave->inactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void bond_set_slave_link_state(struct slave *slave, int state)
|
||||||
|
{
|
||||||
|
slave->link = state;
|
||||||
|
}
|
||||||
|
|
||||||
static inline __be32 bond_confirm_addr(struct net_device *dev, __be32 dst, __be32 local)
|
static inline __be32 bond_confirm_addr(struct net_device *dev, __be32 dst, __be32 local)
|
||||||
{
|
{
|
||||||
struct in_device *in_dev;
|
struct in_device *in_dev;
|
||||||
|
Loading…
Reference in New Issue
Block a user