[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241011220550.46040-3-kuniyu@amazon.com>
Date: Fri, 11 Oct 2024 15:05:41 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: "David S. Miller" <davem@...emloft.net>, Eric Dumazet
<edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
<pabeni@...hat.com>
CC: Kuniyuki Iwashima <kuniyu@...zon.com>, Kuniyuki Iwashima
<kuni1840@...il.com>, <netdev@...r.kernel.org>
Subject: [PATCH v1 net-next 02/11] rtnetlink: 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@...zon.com>
---
net/core/rtnetlink.c | 57 +++++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 30 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 8f2cdb0de4a9..edaafdcd24ad 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -6843,6 +6843,32 @@ static struct pernet_operations rtnetlink_net_ops = {
.exit = rtnetlink_net_exit,
};
+static const struct rtnl_msg_handler rtnetlink_rtnl_msg_handlers[] = {
+ {NULL, PF_UNSPEC, RTM_NEWLINK, rtnl_newlink, NULL, 0},
+ {NULL, PF_UNSPEC, RTM_DELLINK, rtnl_dellink, NULL, 0},
+ {NULL, PF_UNSPEC, RTM_GETLINK, rtnl_getlink, rtnl_dump_ifinfo,
+ RTNL_FLAG_DUMP_SPLIT_NLM_DONE},
+ {NULL, PF_UNSPEC, RTM_SETLINK, rtnl_setlink, NULL, 0},
+ {NULL, PF_UNSPEC, RTM_GETADDR, NULL, rtnl_dump_all, 0},
+ {NULL, PF_UNSPEC, RTM_GETROUTE, NULL, rtnl_dump_all, 0},
+ {NULL, PF_UNSPEC, RTM_GETNETCONF, NULL, rtnl_dump_all, 0},
+ {NULL, PF_UNSPEC, RTM_GETSTATS, rtnl_stats_get, rtnl_stats_dump, 0},
+ {NULL, PF_UNSPEC, RTM_SETSTATS, rtnl_stats_set, NULL, 0},
+ {NULL, PF_UNSPEC, RTM_NEWLINKPROP, rtnl_newlinkprop, NULL, 0},
+ {NULL, PF_UNSPEC, RTM_DELLINKPROP, rtnl_dellinkprop, NULL, 0},
+ {NULL, PF_BRIDGE, RTM_GETLINK, NULL, rtnl_bridge_getlink, 0},
+ {NULL, PF_BRIDGE, RTM_DELLINK, rtnl_bridge_dellink, NULL, 0},
+ {NULL, PF_BRIDGE, RTM_SETLINK, rtnl_bridge_setlink, NULL, 0},
+ {NULL, PF_BRIDGE, RTM_NEWNEIGH, rtnl_fdb_add, NULL, 0},
+ {NULL, PF_BRIDGE, RTM_DELNEIGH, rtnl_fdb_del, NULL,
+ RTNL_FLAG_BULK_DEL_SUPPORTED},
+ {NULL, PF_BRIDGE, RTM_GETNEIGH, rtnl_fdb_get, rtnl_fdb_dump, 0},
+ {NULL, PF_BRIDGE, RTM_NEWMDB, rtnl_mdb_add, NULL, 0},
+ {NULL, PF_BRIDGE, RTM_DELMDB, rtnl_mdb_del, NULL,
+ RTNL_FLAG_BULK_DEL_SUPPORTED},
+ {NULL, PF_BRIDGE, RTM_GETMDB, rtnl_mdb_get, rtnl_mdb_dump, 0},
+};
+
void __init rtnetlink_init(void)
{
if (register_pernet_subsys(&rtnetlink_net_ops))
@@ -6850,34 +6876,5 @@ void __init rtnetlink_init(void)
register_netdevice_notifier(&rtnetlink_dev_notifier);
- rtnl_register(PF_UNSPEC, RTM_GETLINK, rtnl_getlink,
- rtnl_dump_ifinfo, RTNL_FLAG_DUMP_SPLIT_NLM_DONE);
- rtnl_register(PF_UNSPEC, RTM_SETLINK, rtnl_setlink, NULL, 0);
- rtnl_register(PF_UNSPEC, RTM_NEWLINK, rtnl_newlink, NULL, 0);
- rtnl_register(PF_UNSPEC, RTM_DELLINK, rtnl_dellink, NULL, 0);
-
- rtnl_register(PF_UNSPEC, RTM_GETADDR, NULL, rtnl_dump_all, 0);
- rtnl_register(PF_UNSPEC, RTM_GETROUTE, NULL, rtnl_dump_all, 0);
- rtnl_register(PF_UNSPEC, RTM_GETNETCONF, NULL, rtnl_dump_all, 0);
-
- rtnl_register(PF_UNSPEC, RTM_NEWLINKPROP, rtnl_newlinkprop, NULL, 0);
- rtnl_register(PF_UNSPEC, RTM_DELLINKPROP, rtnl_dellinkprop, NULL, 0);
-
- rtnl_register(PF_BRIDGE, RTM_NEWNEIGH, rtnl_fdb_add, NULL, 0);
- rtnl_register(PF_BRIDGE, RTM_DELNEIGH, rtnl_fdb_del, NULL,
- RTNL_FLAG_BULK_DEL_SUPPORTED);
- rtnl_register(PF_BRIDGE, RTM_GETNEIGH, rtnl_fdb_get, rtnl_fdb_dump, 0);
-
- rtnl_register(PF_BRIDGE, RTM_GETLINK, NULL, rtnl_bridge_getlink, 0);
- rtnl_register(PF_BRIDGE, RTM_DELLINK, rtnl_bridge_dellink, NULL, 0);
- rtnl_register(PF_BRIDGE, RTM_SETLINK, rtnl_bridge_setlink, NULL, 0);
-
- rtnl_register(PF_UNSPEC, RTM_GETSTATS, rtnl_stats_get, rtnl_stats_dump,
- 0);
- rtnl_register(PF_UNSPEC, RTM_SETSTATS, rtnl_stats_set, NULL, 0);
-
- rtnl_register(PF_BRIDGE, RTM_GETMDB, rtnl_mdb_get, rtnl_mdb_dump, 0);
- rtnl_register(PF_BRIDGE, RTM_NEWMDB, rtnl_mdb_add, NULL, 0);
- rtnl_register(PF_BRIDGE, RTM_DELMDB, rtnl_mdb_del, NULL,
- RTNL_FLAG_BULK_DEL_SUPPORTED);
+ rtnl_register_many(rtnetlink_rtnl_msg_handlers);
}
--
2.39.5 (Apple Git-154)
Powered by blists - more mailing lists