netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] ethtool: do not use rtnl in ethnl_default_dumpit()
@ 2024-02-07 15:35 Eric Dumazet
  2024-02-07 17:57 ` Jakub Kicinski
  2024-02-09  3:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2024-02-07 15:35 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: netdev, eric.dumazet, Eric Dumazet

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>
---
 net/ethtool/netlink.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index fe3553f60bf39e64602d932505a0851e692348a0..bd04f28d5cf4bbe368e0eb64717a4f7438e66924 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -477,11 +477,7 @@ static int ethnl_default_dump_one(struct sk_buff *skb, struct net_device *dev,
 	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;
 }
-- 
2.43.0.594.gd9cf4e227d-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] ethtool: do not use rtnl in ethnl_default_dumpit()
  2024-02-07 15:35 [PATCH net-next] ethtool: do not use rtnl in ethnl_default_dumpit() Eric Dumazet
@ 2024-02-07 17:57 ` Jakub Kicinski
  2024-02-09  3:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2024-02-07 17:57 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S . Miller, Paolo Abeni, netdev, eric.dumazet

On Wed,  7 Feb 2024 15:35:14 +0000 Eric Dumazet wrote:
> 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>

Reviewed-by: Jakub Kicinski <kuba@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] ethtool: do not use rtnl in ethnl_default_dumpit()
  2024-02-07 15:35 [PATCH net-next] ethtool: do not use rtnl in ethnl_default_dumpit() Eric Dumazet
  2024-02-07 17:57 ` Jakub Kicinski
@ 2024-02-09  3:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-09  3:20 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: davem, kuba, pabeni, netdev, eric.dumazet

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  7 Feb 2024 15:35:14 +0000 you wrote:
> 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>
> ---
>  net/ethtool/netlink.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)

Here is the summary with links:
  - [net-next] ethtool: do not use rtnl in ethnl_default_dumpit()
    https://git.kernel.org/netdev/net-next/c/e7689879d14e

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] 3+ messages in thread

end of thread, other threads:[~2024-02-09  3:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-07 15:35 [PATCH net-next] ethtool: do not use rtnl in ethnl_default_dumpit() Eric Dumazet
2024-02-07 17:57 ` Jakub Kicinski
2024-02-09  3:20 ` 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).