* [PATCH net] bonding: use rcu_dereference_rtnl when get bonding active slave
@ 2022-01-21 8:25 Hangbin Liu
2022-01-24 12:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Hangbin Liu @ 2022-01-21 8:25 UTC (permalink / raw)
To: netdev; +Cc: Vladimir Oltean, Jay Vosburgh, David Miller, Hangbin Liu
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.
Reported-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Fixes: 94dd016ae538 ("bond: pass get_ts_info and SIOC[SG]HWTSTAMP ioctl to active device")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
drivers/net/bonding/bond_main.c | 4 ----
include/net/bonding.h | 2 +-
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index ec498ce70f35..238b56d77c36 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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;
diff --git a/include/net/bonding.h b/include/net/bonding.h
index f6ae3a4baea4..83cfd2d70247 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -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;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] bonding: use rcu_dereference_rtnl when get bonding active slave
2022-01-21 8:25 [PATCH net] bonding: use rcu_dereference_rtnl when get bonding active slave Hangbin Liu
@ 2022-01-24 12:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-24 12:00 UTC (permalink / raw)
To: Hangbin Liu; +Cc: netdev, vladimir.oltean, jay.vosburgh, davem
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Fri, 21 Jan 2022 16:25:18 +0800 you wrote:
> 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.
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-24 12:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-21 8:25 [PATCH net] bonding: use rcu_dereference_rtnl when get bonding active slave Hangbin Liu
2022-01-24 12:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).