From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>, <netdev@vger.kernel.org>
Subject: [PATCH v1 net-next 08/11] ipmr: Use rtnl_register_many().
Date: Fri, 11 Oct 2024 15:05:47 -0700 [thread overview]
Message-ID: <20241011220550.46040-9-kuniyu@amazon.com> (raw)
In-Reply-To: <20241011220550.46040-1-kuniyu@amazon.com>
We will remove rtnl_register() and rtnl_register_module() in favour
of rtnl_register_many().
When it succeeds for built-in callers, 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>
---
net/ipv4/ipmr.c | 19 ++++++++++---------
net/ipv6/ip6mr.c | 12 ++++++++----
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 089864c6a35e..2a5a6927229f 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -3139,6 +3139,14 @@ static struct pernet_operations ipmr_net_ops = {
.exit_batch = ipmr_net_exit_batch,
};
+static const struct rtnl_msg_handler ipmr_rtnl_msg_handlers[] = {
+ {NULL, RTNL_FAMILY_IPMR, RTM_GETLINK, NULL, ipmr_rtm_dumplink, 0},
+ {NULL, RTNL_FAMILY_IPMR, RTM_NEWROUTE, ipmr_rtm_route, NULL, 0},
+ {NULL, RTNL_FAMILY_IPMR, RTM_DELROUTE, ipmr_rtm_route, NULL, 0},
+ {NULL, RTNL_FAMILY_IPMR, RTM_GETROUTE,
+ ipmr_rtm_getroute, ipmr_rtm_dumproute, 0},
+};
+
int __init ip_mr_init(void)
{
int err;
@@ -3159,15 +3167,8 @@ int __init ip_mr_init(void)
goto add_proto_fail;
}
#endif
- rtnl_register(RTNL_FAMILY_IPMR, RTM_GETROUTE,
- ipmr_rtm_getroute, ipmr_rtm_dumproute, 0);
- rtnl_register(RTNL_FAMILY_IPMR, RTM_NEWROUTE,
- ipmr_rtm_route, NULL, 0);
- rtnl_register(RTNL_FAMILY_IPMR, RTM_DELROUTE,
- ipmr_rtm_route, NULL, 0);
-
- rtnl_register(RTNL_FAMILY_IPMR, RTM_GETLINK,
- NULL, ipmr_rtm_dumplink, 0);
+ rtnl_register_many(ipmr_rtnl_msg_handlers);
+
return 0;
#ifdef CONFIG_IP_PIMSM_V2
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 2ce4ae0d8dc3..8bb7bf4346f0 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1369,6 +1369,11 @@ static struct pernet_operations ip6mr_net_ops = {
.exit_batch = ip6mr_net_exit_batch,
};
+static const struct rtnl_msg_handler ip6mr_rtnl_msg_handlers[] = {
+ {THIS_MODULE, RTNL_FAMILY_IP6MR, RTM_GETROUTE,
+ ip6mr_rtm_getroute, ip6mr_rtm_dumproute, 0},
+};
+
int __init ip6_mr_init(void)
{
int err;
@@ -1391,9 +1396,8 @@ int __init ip6_mr_init(void)
goto add_proto_fail;
}
#endif
- err = rtnl_register_module(THIS_MODULE, RTNL_FAMILY_IP6MR, RTM_GETROUTE,
- ip6mr_rtm_getroute, ip6mr_rtm_dumproute, 0);
- if (err == 0)
+ err = rtnl_register_many(ip6mr_rtnl_msg_handlers);
+ if (!err)
return 0;
#ifdef CONFIG_IPV6_PIMSM_V2
@@ -1410,7 +1414,7 @@ int __init ip6_mr_init(void)
void ip6_mr_cleanup(void)
{
- rtnl_unregister(RTNL_FAMILY_IP6MR, RTM_GETROUTE);
+ rtnl_unregister_many(ip6mr_rtnl_msg_handlers);
#ifdef CONFIG_IPV6_PIMSM_V2
inet6_del_protocol(&pim6_protocol, IPPROTO_PIM);
#endif
--
2.39.5 (Apple Git-154)
next prev parent reply other threads:[~2024-10-11 22:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 22:05 [PATCH v1 net-next 00/11] rtnetlink: Use rtnl_register_many() Kuniyuki Iwashima
2024-10-11 22:05 ` [PATCH v1 net-next 01/11] rtnetlink: Panic when __rtnl_register_many() fails for builtin callers Kuniyuki Iwashima
2024-10-11 22:05 ` [PATCH v1 net-next 02/11] rtnetlink: Use rtnl_register_many() Kuniyuki Iwashima
2024-10-11 22:05 ` [PATCH v1 net-next 03/11] neighbour: " Kuniyuki Iwashima
2024-10-14 8:01 ` Eric Dumazet
2024-10-14 17:35 ` Kuniyuki Iwashima
2024-10-11 22:05 ` [PATCH v1 net-next 04/11] net: sched: " Kuniyuki Iwashima
2024-10-11 22:05 ` [PATCH v1 net-next 05/11] net: " Kuniyuki Iwashima
2024-10-11 22:05 ` [PATCH v1 net-next 06/11] ipv4: " Kuniyuki Iwashima
2024-10-11 22:05 ` [PATCH v1 net-next 07/11] ipv6: " Kuniyuki Iwashima
2024-10-11 22:05 ` Kuniyuki Iwashima [this message]
2024-10-11 22:05 ` [PATCH v1 net-next 09/11] dcb: " Kuniyuki Iwashima
2024-10-11 22:05 ` [PATCH v1 net-next 10/11] can: gw: " Kuniyuki Iwashima
2024-10-11 22:05 ` [PATCH v1 net-next 11/11] rtnetlink: Remove rtnl_register() and rtnl_register_module() Kuniyuki Iwashima
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241011220550.46040-9-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).