Skip to content

Commit 5ee14e6

Browse files
Nikolay Aleksandrovdavem330
authored andcommitted
bonding: 3ad: apply ad_actor settings changes immediately
Currently the bonding allows to set ad_actor_system and prio while the bond device is down, but these are actually applied only if there aren't any slaves yet (applied to bond device when first slave shows up, and to slaves at 3ad bind time). After this patch changes are applied immediately and the new values can be used/seen after the bond's upped so it's not necessary anymore to release all and enslave again to see the changes. CC: Jay Vosburgh <[email protected]> CC: Veaceslav Falico <[email protected]> CC: Andy Gospodarek <[email protected]> Signed-off-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: Jay Vosburgh <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a1b486a commit 5ee14e6

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

drivers/net/bonding/bond_3ad.c

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,14 @@ static u8 __get_duplex(struct port *port)
357357
return retval;
358358
}
359359

360+
static void __ad_actor_update_port(struct port *port)
361+
{
362+
const struct bonding *bond = bond_get_bond_by_slave(port->slave);
363+
364+
port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr;
365+
port->actor_system_priority = BOND_AD_INFO(bond).system.sys_priority;
366+
}
367+
360368
/* Conversions */
361369

362370
/**
@@ -1963,9 +1971,7 @@ void bond_3ad_bind_slave(struct slave *slave)
19631971
port->actor_admin_port_key = bond->params.ad_user_port_key << 6;
19641972
ad_update_actor_keys(port, false);
19651973
/* actor system is the bond's system */
1966-
port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr;
1967-
port->actor_system_priority =
1968-
BOND_AD_INFO(bond).system.sys_priority;
1974+
__ad_actor_update_port(port);
19691975
/* tx timer(to verify that no more than MAX_TX_IN_SECOND
19701976
* lacpdu's are sent in one second)
19711977
*/
@@ -2147,6 +2153,34 @@ void bond_3ad_unbind_slave(struct slave *slave)
21472153
spin_unlock_bh(&bond->mode_lock);
21482154
}
21492155

2156+
/**
2157+
* bond_3ad_update_ad_actor_settings - reflect change of actor settings to ports
2158+
* @bond: bonding struct to work on
2159+
*
2160+
* If an ad_actor setting gets changed we need to update the individual port
2161+
* settings so the bond device will use the new values when it gets upped.
2162+
*/
2163+
void bond_3ad_update_ad_actor_settings(struct bonding *bond)
2164+
{
2165+
struct list_head *iter;
2166+
struct slave *slave;
2167+
2168+
ASSERT_RTNL();
2169+
2170+
BOND_AD_INFO(bond).system.sys_priority = bond->params.ad_actor_sys_prio;
2171+
if (is_zero_ether_addr(bond->params.ad_actor_system))
2172+
BOND_AD_INFO(bond).system.sys_mac_addr =
2173+
*((struct mac_addr *)bond->dev->dev_addr);
2174+
else
2175+
BOND_AD_INFO(bond).system.sys_mac_addr =
2176+
*((struct mac_addr *)bond->params.ad_actor_system);
2177+
2178+
spin_lock_bh(&bond->mode_lock);
2179+
bond_for_each_slave(bond, slave, iter)
2180+
__ad_actor_update_port(&(SLAVE_AD_INFO(slave)->port));
2181+
spin_unlock_bh(&bond->mode_lock);
2182+
}
2183+
21502184
/**
21512185
* bond_3ad_state_machine_handler - handle state machines timeout
21522186
* @bond: bonding struct to work on

drivers/net/bonding/bond_options.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,8 @@ static int bond_option_ad_actor_sys_prio_set(struct bonding *bond,
13921392
newval->value);
13931393

13941394
bond->params.ad_actor_sys_prio = newval->value;
1395+
bond_3ad_update_ad_actor_settings(bond);
1396+
13951397
return 0;
13961398
}
13971399

@@ -1418,6 +1420,8 @@ static int bond_option_ad_actor_system_set(struct bonding *bond,
14181420

14191421
netdev_info(bond->dev, "Setting ad_actor_system to %pM\n", mac);
14201422
ether_addr_copy(bond->params.ad_actor_system, mac);
1423+
bond_3ad_update_ad_actor_settings(bond);
1424+
14211425
return 0;
14221426

14231427
err:

include/net/bond_3ad.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,5 +306,6 @@ int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond,
306306
struct slave *slave);
307307
int bond_3ad_set_carrier(struct bonding *bond);
308308
void bond_3ad_update_lacp_rate(struct bonding *bond);
309+
void bond_3ad_update_ad_actor_settings(struct bonding *bond);
309310
#endif /* _NET_BOND_3AD_H */
310311

0 commit comments

Comments
 (0)