Skip to content

Commit 803838a

Browse files
q2venkuba-moo
authored andcommitted
net: Use rtnl_register_many().
We will remove rtnl_register() in favour of rtnl_register_many(). When it succeeds, rtnl_register_many() guarantees all rtnetlink types in the passed array are supported, and there is no chance that a part of message types is not supported. Let's use rtnl_register_many() instead. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20241014201828.91221-6-kuniyu@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent cc72bb0 commit 803838a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

net/core/net_namespace.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,14 @@ static void __init netns_ipv4_struct_check(void)
11691169
}
11701170
#endif
11711171

1172+
static const struct rtnl_msg_handler net_ns_rtnl_msg_handlers[] __initconst = {
1173+
{.msgtype = RTM_NEWNSID, .doit = rtnl_net_newid,
1174+
.flags = RTNL_FLAG_DOIT_UNLOCKED},
1175+
{.msgtype = RTM_GETNSID, .doit = rtnl_net_getid,
1176+
.dumpit = rtnl_net_dumpid,
1177+
.flags = RTNL_FLAG_DOIT_UNLOCKED | RTNL_FLAG_DUMP_UNLOCKED},
1178+
};
1179+
11721180
void __init net_ns_init(void)
11731181
{
11741182
struct net_generic *ng;
@@ -1206,11 +1214,7 @@ void __init net_ns_init(void)
12061214
if (register_pernet_subsys(&net_ns_ops))
12071215
panic("Could not register network namespace subsystems");
12081216

1209-
rtnl_register(PF_UNSPEC, RTM_NEWNSID, rtnl_net_newid, NULL,
1210-
RTNL_FLAG_DOIT_UNLOCKED);
1211-
rtnl_register(PF_UNSPEC, RTM_GETNSID, rtnl_net_getid, rtnl_net_dumpid,
1212-
RTNL_FLAG_DOIT_UNLOCKED |
1213-
RTNL_FLAG_DUMP_UNLOCKED);
1217+
rtnl_register_many(net_ns_rtnl_msg_handlers);
12141218
}
12151219

12161220
static void free_exit_list(struct pernet_operations *ops, struct list_head *net_exit_list)

0 commit comments

Comments
 (0)