bonding: use rcu_dereference_rtnl when get bonding active slave
Subsystems (3)
PATCH 1/1 bonding: use rcu_dereference_rtnl when get bonding active slave
bond_option_active_slave_get_rcu() should not be used in rtnl_mutex as it use rcu_dereference(). Replace to rcu_dereference_rtnl() so we also can use this function in rtnl protected context.
With this update, we can rmeove the rcu_read_lock/unlock in bonding .ndo_eth_ioctl and .get_ts_info.
--- drivers/net/bonding/bond_main.c | 4 ---- include/net/bonding.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-)
drivers/net/bonding/bond_main.c +0 -4
@@ -4133,9 +4133,7 @@ static int bond_eth_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cm fallthrough;case SIOCGHWTSTAMP : -rcu_read_lock (); real_dev =bond_option_active_slave_get_rcu (bond); -rcu_read_unlock ();if (!real_dev)return -EOPNOTSUPP ;
@@ -5382,9 +5380,7 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev,struct net_device *real_dev;struct phy_device *phydev; -rcu_read_lock (); real_dev =bond_option_active_slave_get_rcu (bond); -rcu_read_unlock ();if (real_dev) { ops = real_dev->ethtool_ops; phydev = real_dev->phydev;
include/net/bonding.h +1 -1
@@ -346,7 +346,7 @@ static inline bool bond_uses_primary(struct bonding *bond)static inline struct net_device *bond_option_active_slave_get_rcu (struct bonding *bond) { -struct slave *slave =rcu_dereference (bond->curr_active_slave); +struct slave *slave =rcu_dereference_rtnl (bond->curr_active_slave);return bond_uses_primary (bond) && slave ? slave->dev :NULL ; }
Signature · 1 line
2.31.1
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 8 lines · On Fri, 21 Jan 2022 16:25:18 +0800 you wrote:
bond_option_active_slave_get_rcu()should not be used inrtnl_mutexas it usercu_dereference(). Replace torcu_dereference_rtnl()so we also can use this function in rtnl protected context.With this update, we can rmeove the rcu_read_lock/unlock in bonding .ndo_eth_ioctl and .get_ts_info.
[...]
Here is the summary with links:
- [net] bonding: use rcu_dereference_rtnl when get bonding active slave
https://git.kernel.org/netdev/net/c/aa6034678e87
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html