]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
neighbour: Use rtnl_register_many().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Mon, 14 Oct 2024 20:18:20 +0000 (13:18 -0700)
committerJakub Kicinski <kuba@kernel.org>
Wed, 16 Oct 2024 01:52:25 +0000 (18:52 -0700)
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-4-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/neighbour.c

index 77b819cd995b2510fed7ace688bce60c98a57563..395ae1626eef2f22f5b81051671371ed67eb5943 100644 (file)
@@ -3886,17 +3886,18 @@ EXPORT_SYMBOL(neigh_sysctl_unregister);
 
 #endif /* CONFIG_SYSCTL */
 
+static const struct rtnl_msg_handler neigh_rtnl_msg_handlers[] __initconst = {
+       {.msgtype = RTM_NEWNEIGH, .doit = neigh_add},
+       {.msgtype = RTM_DELNEIGH, .doit = neigh_delete},
+       {.msgtype = RTM_GETNEIGH, .doit = neigh_get, .dumpit = neigh_dump_info,
+        .flags = RTNL_FLAG_DUMP_UNLOCKED},
+       {.msgtype = RTM_GETNEIGHTBL, .dumpit = neightbl_dump_info},
+       {.msgtype = RTM_SETNEIGHTBL, .doit = neightbl_set},
+};
+
 static int __init neigh_init(void)
 {
-       rtnl_register(PF_UNSPEC, RTM_NEWNEIGH, neigh_add, NULL, 0);
-       rtnl_register(PF_UNSPEC, RTM_DELNEIGH, neigh_delete, NULL, 0);
-       rtnl_register(PF_UNSPEC, RTM_GETNEIGH, neigh_get, neigh_dump_info,
-                     RTNL_FLAG_DUMP_UNLOCKED);
-
-       rtnl_register(PF_UNSPEC, RTM_GETNEIGHTBL, NULL, neightbl_dump_info,
-                     0);
-       rtnl_register(PF_UNSPEC, RTM_SETNEIGHTBL, neightbl_set, NULL, 0);
-
+       rtnl_register_many(neigh_rtnl_msg_handlers);
        return 0;
 }