Skip to contentSkip to conversation

net: loopback: Hold rtnl_net_lock() in blackhole_netdev_init().

PATCH Applied Kuniyuki Iwashima 2 participants 2 messages Jan 14, 2025 – Jan 15, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: loopback: Hold rtnl_net_lock() in blackhole_netdev_init().

blackhole_netdev is the global device in init_net.

Let's hold rtnl_net_lock(&init_net) in blackhole_netdev_init().

While at it, the unnecessary dev_net_set() call is removed, which is done in alloc_netdev_mqs().

---
 drivers/net/loopback.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/loopback.c +2 -3
index 1993b90b1a5f..c8840c3b9a1b 100644
@@ -264,13 +264,12 @@ static int __init blackhole_netdev_init(void)
 	if (!blackhole_netdev)
 		return -ENOMEM;
 
-	rtnl_lock();
+	rtnl_net_lock(&init_net);
 	dev_init_scheduler(blackhole_netdev);
 	dev_activate(blackhole_netdev);
-	rtnl_unlock();
+	rtnl_net_unlock(&init_net);
 
 	blackhole_netdev->flags |= IFF_UP | IFF_RUNNING;
-	dev_net_set(blackhole_netdev, &init_net);
 
 	return 0;
 }
Signature · 1 line
2.39.5 (Apple Git-154)
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Tue, 14 Jan 2025 17:13:52 +0900 you wrote:

blackhole_netdev is the global device in init_net.

Let's hold rtnl_net_lock(&init_net) in blackhole_netdev_init().

While at it, the unnecessary dev_net_set() call is removed, which is done in alloc_netdev_mqs().

[...]

Here is the summary with links:
- [v1,net-next] net: loopback: Hold rtnl_net_lock() in blackhole_netdev_init().

    https://git.kernel.org/netdev/net-next/c/2248c05340a6

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html