* [PATCH v1 net] rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().
@ 2025-03-28 22:04 Kuniyuki Iwashima
2025-03-31 15:48 ` Simon Horman
0 siblings, 1 reply; 3+ messages in thread
From: Kuniyuki Iwashima @ 2025-03-28 22:04 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
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 not updated
in unregister_pernet_device().
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 <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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v1 net] rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().
2025-03-28 22:04 [PATCH v1 net] rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init() Kuniyuki Iwashima
@ 2025-03-31 15:48 ` Simon Horman
2025-03-31 18:25 ` Kuniyuki Iwashima
0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2025-03-31 15:48 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Kuniyuki Iwashima, netdev
On Fri, Mar 28, 2025 at 03:04:48PM -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 not updated
> in unregister_pernet_device().
Hi Iwashima-san,
Maybe I am confused, but should the above line refer to
unregister_pernet_subsys()?
And perhaps it would be yet clearer to say something like:
It corrupts pernet_list because first_device is not 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 <kuniyu@amazon.com>
...
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1 net] rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().
2025-03-31 15:48 ` Simon Horman
@ 2025-03-31 18:25 ` Kuniyuki Iwashima
0 siblings, 0 replies; 3+ messages in thread
From: Kuniyuki Iwashima @ 2025-03-31 18:25 UTC (permalink / raw)
To: horms; +Cc: davem, edumazet, kuba, kuni1840, kuniyu, netdev, pabeni
From: Simon Horman <horms@kernel.org>
Date: Mon, 31 Mar 2025 16:48:49 +0100
> On Fri, Mar 28, 2025 at 03:04:48PM -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 not updated
> > in unregister_pernet_device().
>
> Hi Iwashima-san,
>
> Maybe I am confused, but should the above line refer to
> unregister_pernet_subsys()?
Ah, exactly :)
>
> And perhaps it would be yet clearer to say something like:
>
> It corrupts pernet_list because first_device is not updated
> in register_pernet_device() but not unregister_pernet_subsys()?
Will rewrite in v2.
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-31 18:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-28 22:04 [PATCH v1 net] rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init() Kuniyuki Iwashima
2025-03-31 15:48 ` Simon Horman
2025-03-31 18:25 ` Kuniyuki Iwashima
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).