Skip to content

Commit 09aec57

Browse files
q2venkuba-moo
authored andcommitted
rtnetlink: Panic when __rtnl_register_many() fails for builtin callers.
We will replace all rtnl_register() and rtnl_register_module() with rtnl_register_many(). Currently, rtnl_register() returns nothing and prints an error message when it fails to register a rtnetlink message type and handlers. The failure happens only when rtnl_register_internal() fails to allocate rtnl_msg_handlers[protocol][msgtype], but it's unlikely for built-in callers on boot time. rtnl_register_many() unwinds the previous successful registrations on failure and returns an error, but it will be useless for built-in callers, especially some subsystems that do not have the legacy ioctl() interface and do not work without rtnetlink. Instead of booting up without rtnetlink functionality, let's panic on failure for built-in rtnl_register_many() callers. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20241014201828.91221-2-kuniyu@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent df24129 commit 09aec57

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/core/rtnetlink.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ int __rtnl_register_many(const struct rtnl_msg_handler *handlers, int n)
464464
handler->msgtype, handler->doit,
465465
handler->dumpit, handler->flags);
466466
if (err) {
467+
if (!handler->owner)
468+
panic("Unable to register rtnetlink message "
469+
"handlers, %pS\n", handlers);
470+
467471
__rtnl_unregister_many(handlers, i);
468472
break;
469473
}

0 commit comments

Comments
 (0)