rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().
Subsystems (2)
PATCH 1/1 rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().
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.
--- net/core/rtnl_net_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/rtnl_net_debug.c +1 -1
@@ -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;
Signature · 1 line
2.48.1
Simon Horman
reviewerQuoted 6 lines · Kuniyuki Iwashima
rtnl_net_debug_init()registersrtnl_net_debug_net_opsbyregister_pernet_device()but callsunregister_pernet_subsys()in caseregister_netdevice_notifier()fails.It corrupts
pernet_listbecausefirst_deviceis not updated inunregister_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()?
Quoted 9 lines
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 untildefault_device_exit_net(), giving it more chance to testNETDEV_UNREGISTER.Fixes 03fa53485659 ("rtnetlink: Add ASSERT_RTNL_NET() placeholder for netdev notifier.")Signed-off-by Kuniyuki Iwashima <[email protected]>
...
From: Simon Horman <[email protected]>
Date: Mon, 31 Mar 2025 16:48:49 +0100
Quoted 5 lines · Kuniyuki Iwashima
Quoted 4 lines
rtnl_net_debug_init()registersrtnl_net_debug_net_opsbyregister_pernet_device()but callsunregister_pernet_subsys()in caseregister_netdevice_notifier()fails.
Quoted 7 lines
Quoted 2 lines
It corrupts
pernet_listbecausefirst_deviceis not updated inunregister_pernet_device().Hi Iwashima-san,
Maybe I am confused, but should the above line refer to
unregister_pernet_subsys()?
Ah, exactly :)
Quoted 5 lines
And perhaps it would be yet clearer to say something like:
It corrupts
pernet_listbecausefirst_deviceis not updated inregister_pernet_device()but notunregister_pernet_subsys()?
Will rewrite in v2.
Thanks!