Skip to content

Commit aa60346

Browse files
liuhangbindavem330
authored andcommitted
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. Reported-by: Vladimir Oltean <[email protected]> Fixes: 94dd016 ("bond: pass get_ts_info and SIOC[SG]HWTSTAMP ioctl to active device") Signed-off-by: Hangbin Liu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2148927 commit aa60346

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4133,9 +4133,7 @@ static int bond_eth_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cm
41334133

41344134
fallthrough;
41354135
case SIOCGHWTSTAMP:
4136-
rcu_read_lock();
41374136
real_dev = bond_option_active_slave_get_rcu(bond);
4138-
rcu_read_unlock();
41394137
if (!real_dev)
41404138
return -EOPNOTSUPP;
41414139

@@ -5382,9 +5380,7 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev,
53825380
struct net_device *real_dev;
53835381
struct phy_device *phydev;
53845382

5385-
rcu_read_lock();
53865383
real_dev = bond_option_active_slave_get_rcu(bond);
5387-
rcu_read_unlock();
53885384
if (real_dev) {
53895385
ops = real_dev->ethtool_ops;
53905386
phydev = real_dev->phydev;

include/net/bonding.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ static inline bool bond_uses_primary(struct bonding *bond)
346346

347347
static inline struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond)
348348
{
349-
struct slave *slave = rcu_dereference(bond->curr_active_slave);
349+
struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave);
350350

351351
return bond_uses_primary(bond) && slave ? slave->dev : NULL;
352352
}

0 commit comments

Comments
 (0)