[PATCH v2 net] rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().

Subsystems: networking [general], the rest

STALE565d LANDED

Landed in mainline as 1b7fdc702c03 on 2025-04-03.

3 messages, 3 authors, 2025-04-03 · open the first message on its own page

[PATCH v2 net] rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().

From: Kuniyuki Iwashima <hidden>
Date: 2025-04-01 19:07:31

rtnl_net_debug_init() registers rtnl_net_debug_net_ops by
register_pernet_device() but calls unregister_pernet_subsys()
in case register_netdevice_notifier() fails.

It corrupts pernet_list because first_device is updated in
register_pernet_device() but not unregister_pernet_subsys().

Let's fix it by calling register_pernet_subsys() instead.

The _subsys() one fits better for the use case because it keeps
the notifier alive until default_device_exit_net(), giving it
more chance to test NETDEV_UNREGISTER.

Fixes: 03fa53485659 ("rtnetlink: Add ASSERT_RTNL_NET() placeholder for netdev notifier.")
Signed-off-by: Kuniyuki Iwashima <redacted>
---
v2: Correct changelog
v1: https://lore.kernel.org/netdev/20250328220453.97138-1-kuniyu@amazon.com/
---
 net/core/rtnl_net_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/rtnl_net_debug.c b/net/core/rtnl_net_debug.c
index 7ecd28cc1c22..f3272b09c255 100644
--- a/net/core/rtnl_net_debug.c
+++ b/net/core/rtnl_net_debug.c
@@ -102,7 +102,7 @@ static int __init rtnl_net_debug_init(void)
 {
 	int ret;
 
-	ret = register_pernet_device(&rtnl_net_debug_net_ops);
+	ret = register_pernet_subsys(&rtnl_net_debug_net_ops);
 	if (ret)
 		return ret;
 
-- 
2.48.1

Re: [PATCH v2 net] rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().

From: Simon Horman <horms@kernel.org>
Date: 2025-04-02 09:18:47

On Tue, Apr 01, 2025 at 12:07:08PM -0700, Kuniyuki Iwashima wrote:
rtnl_net_debug_init() registers rtnl_net_debug_net_ops by
register_pernet_device() but calls unregister_pernet_subsys()
in case register_netdevice_notifier() fails.

It corrupts pernet_list because first_device is updated in
register_pernet_device() but not unregister_pernet_subsys().

Let's fix it by calling register_pernet_subsys() instead.

The _subsys() one fits better for the use case because it keeps
the notifier alive until default_device_exit_net(), giving it
more chance to test NETDEV_UNREGISTER.

Fixes: 03fa53485659 ("rtnetlink: Add ASSERT_RTNL_NET() placeholder for netdev notifier.")
Signed-off-by: Kuniyuki Iwashima <redacted>
---
v2: Correct changelog
v1: https://lore.kernel.org/netdev/20250328220453.97138-1-kuniyu@amazon.com/
Thanks for the update.

Reviewed-by: Simon Horman <horms@kernel.org>

...

Re: [PATCH v2 net] rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().

From: patchwork-bot+netdevbpf@kernel.org
Date: 2025-04-03 00:30:00

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski [off-list ref]:

On Tue, 1 Apr 2025 12:07:08 -0700 you wrote:
rtnl_net_debug_init() registers rtnl_net_debug_net_ops by
register_pernet_device() but calls unregister_pernet_subsys()
in case register_netdevice_notifier() fails.

It corrupts pernet_list because first_device is updated in
register_pernet_device() but not unregister_pernet_subsys().

[...]
Here is the summary with links:
  - [v2,net] rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().
    https://git.kernel.org/netdev/net/c/1b7fdc702c03

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help