aboutsummaryrefslogtreecommitdiffstats
path: root/net/ethtool
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2024-02-07 15:35:14 +0000
committerJakub Kicinski <kuba@kernel.org>2024-02-08 19:08:51 -0800
commite7689879d14ee730085c2f5974003c2d0ebbebc6 (patch)
tree14577346aab60bf868e98dedcc645c609c3fe51b /net/ethtool
parentfd0bb2c7ccd93ae308ca1317c04765b26e88e3a1 (diff)
downloadlinux-e7689879d14ee730085c2f5974003c2d0ebbebc6.tar.gz
ethtool: do not use rtnl in ethnl_default_dumpit()
for_each_netdev_dump() can be used with RCU protection, no need for rtnl if we are going to use dev_hold()/dev_put(). Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://lore.kernel.org/r/20240207153514.3640952-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/ethtool')
-rw-r--r--net/ethtool/netlink.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index fe3553f60bf39e..bd04f28d5cf4bb 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -477,11 +477,7 @@ out:
return ret;
}
-/* Default ->dumpit() handler for GET requests. Device iteration copied from
- * rtnl_dump_ifinfo(); we have to be more careful about device hashtable
- * persistence as we cannot guarantee to hold RTNL lock through the whole
- * function as rtnetnlink does.
- */
+/* Default ->dumpit() handler for GET requests. */
static int ethnl_default_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
@@ -490,14 +486,14 @@ static int ethnl_default_dumpit(struct sk_buff *skb,
struct net_device *dev;
int ret = 0;
- rtnl_lock();
+ rcu_read_lock();
for_each_netdev_dump(net, dev, ctx->pos_ifindex) {
dev_hold(dev);
- rtnl_unlock();
+ rcu_read_unlock();
ret = ethnl_default_dump_one(skb, dev, ctx, genl_info_dump(cb));
- rtnl_lock();
+ rcu_read_lock();
dev_put(dev);
if (ret < 0 && ret != -EOPNOTSUPP) {
@@ -507,7 +503,7 @@ static int ethnl_default_dumpit(struct sk_buff *skb,
}
ret = 0;
}
- rtnl_unlock();
+ rcu_read_unlock();
return ret;
}