Skip to content

Commit 7e878b6

Browse files
hao022davem330
authored andcommitted
bonding: introduce link change helper
Introduce an new common helper to avoid redundancy. Signed-off-by: Tonghao Zhang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 10e361e commit 7e878b6

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,6 +2137,24 @@ static int bond_miimon_inspect(struct bonding *bond)
21372137
return commit;
21382138
}
21392139

2140+
static void bond_miimon_link_change(struct bonding *bond,
2141+
struct slave *slave,
2142+
char link)
2143+
{
2144+
switch (BOND_MODE(bond)) {
2145+
case BOND_MODE_8023AD:
2146+
bond_3ad_handle_link_change(slave, link);
2147+
break;
2148+
case BOND_MODE_TLB:
2149+
case BOND_MODE_ALB:
2150+
bond_alb_handle_link_change(bond, slave, link);
2151+
break;
2152+
case BOND_MODE_XOR:
2153+
bond_update_slave_arr(bond, NULL);
2154+
break;
2155+
}
2156+
}
2157+
21402158
static void bond_miimon_commit(struct bonding *bond)
21412159
{
21422160
struct list_head *iter;
@@ -2178,16 +2196,7 @@ static void bond_miimon_commit(struct bonding *bond)
21782196
slave->speed == SPEED_UNKNOWN ? 0 : slave->speed,
21792197
slave->duplex ? "full" : "half");
21802198

2181-
/* notify ad that the link status has changed */
2182-
if (BOND_MODE(bond) == BOND_MODE_8023AD)
2183-
bond_3ad_handle_link_change(slave, BOND_LINK_UP);
2184-
2185-
if (bond_is_lb(bond))
2186-
bond_alb_handle_link_change(bond, slave,
2187-
BOND_LINK_UP);
2188-
2189-
if (BOND_MODE(bond) == BOND_MODE_XOR)
2190-
bond_update_slave_arr(bond, NULL);
2199+
bond_miimon_link_change(bond, slave, BOND_LINK_UP);
21912200

21922201
if (!bond->curr_active_slave || slave == primary)
21932202
goto do_failover;
@@ -2209,16 +2218,7 @@ static void bond_miimon_commit(struct bonding *bond)
22092218
netdev_info(bond->dev, "link status definitely down for interface %s, disabling it\n",
22102219
slave->dev->name);
22112220

2212-
if (BOND_MODE(bond) == BOND_MODE_8023AD)
2213-
bond_3ad_handle_link_change(slave,
2214-
BOND_LINK_DOWN);
2215-
2216-
if (bond_is_lb(bond))
2217-
bond_alb_handle_link_change(bond, slave,
2218-
BOND_LINK_DOWN);
2219-
2220-
if (BOND_MODE(bond) == BOND_MODE_XOR)
2221-
bond_update_slave_arr(bond, NULL);
2221+
bond_miimon_link_change(bond, slave, BOND_LINK_DOWN);
22222222

22232223
if (slave == rcu_access_pointer(bond->curr_active_slave))
22242224
goto do_failover;

0 commit comments

Comments
 (0)