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>,
Remi Denis-Courmont <courmisch@gmail.com>,
Florian Westphal <fw@strlen.de>
Subject: [PATCH v1 net 6/6] phonet: Handle error of rtnl_register_module().
Date: Thu, 3 Oct 2024 13:57:25 -0700 [thread overview]
Message-ID: <20241003205725.5612-7-kuniyu@amazon.com> (raw)
In-Reply-To: <20241003205725.5612-1-kuniyu@amazon.com>
Before commit addf9b90de22 ("net: rtnetlink: use rcu to free rtnl
message handlers"), once the first rtnl_register_module() allocated
rtnl_msg_handlers[PF_PHONET], the following calls never failed.
However, after the commit, rtnl_register_module() could fail to allocate
rtnl_msg_handlers[PF_PHONET][msgtype] and requires error handling for
each call.
Let's use rtnl_register_module_many() to handle the errors easily.
Fixes: addf9b90de22 ("net: rtnetlink: use rcu to free rtnl message handlers")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
Cc: Remi Denis-Courmont <courmisch@gmail.com>
Cc: Florian Westphal <fw@strlen.de>
---
net/phonet/pn_netlink.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/net/phonet/pn_netlink.c b/net/phonet/pn_netlink.c
index 7008d402499d..d39e6983926b 100644
--- a/net/phonet/pn_netlink.c
+++ b/net/phonet/pn_netlink.c
@@ -285,23 +285,16 @@ static int route_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
return err;
}
+static struct rtnl_msg_handler phonet_rtnl_msg_handlers[] __initdata_or_module = {
+ {PF_PHONET, RTM_NEWADDR, addr_doit, NULL, 0},
+ {PF_PHONET, RTM_DELADDR, addr_doit, NULL, 0},
+ {PF_PHONET, RTM_GETADDR, NULL, getaddr_dumpit, 0},
+ {PF_PHONET, RTM_NEWROUTE, route_doit, NULL, 0},
+ {PF_PHONET, RTM_DELROUTE, route_doit, NULL, 0},
+ {PF_PHONET, RTM_GETROUTE, NULL, route_dumpit, RTNL_FLAG_DUMP_UNLOCKED},
+};
+
int __init phonet_netlink_register(void)
{
- int err = rtnl_register_module(THIS_MODULE, PF_PHONET, RTM_NEWADDR,
- addr_doit, NULL, 0);
- if (err)
- return err;
-
- /* Further rtnl_register_module() cannot fail */
- rtnl_register_module(THIS_MODULE, PF_PHONET, RTM_DELADDR,
- addr_doit, NULL, 0);
- rtnl_register_module(THIS_MODULE, PF_PHONET, RTM_GETADDR,
- NULL, getaddr_dumpit, 0);
- rtnl_register_module(THIS_MODULE, PF_PHONET, RTM_NEWROUTE,
- route_doit, NULL, 0);
- rtnl_register_module(THIS_MODULE, PF_PHONET, RTM_DELROUTE,
- route_doit, NULL, 0);
- rtnl_register_module(THIS_MODULE, PF_PHONET, RTM_GETROUTE,
- NULL, route_dumpit, RTNL_FLAG_DUMP_UNLOCKED);
- return 0;
+ return rtnl_register_module_many(phonet_rtnl_msg_handlers);
}
--
2.30.2
next prev parent reply other threads:[~2024-10-03 21:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-03 20:57 [PATCH v1 net 0/6] rtnetlink: Handle error of rtnl_register_module() Kuniyuki Iwashima
2024-10-03 20:57 ` [PATCH v1 net 1/6] rtnetlink: Add bulk registration helpers for rtnetlink message handlers Kuniyuki Iwashima
2024-10-03 20:57 ` [PATCH v1 net 2/6] vxlan: Handle error of rtnl_register_module() Kuniyuki Iwashima
2024-10-03 20:57 ` [PATCH v1 net 3/6] bridge: " Kuniyuki Iwashima
2024-10-03 20:57 ` [PATCH v1 net 4/6] mctp: " Kuniyuki Iwashima
2024-10-04 0:39 ` Jakub Kicinski
2024-10-04 1:00 ` Kuniyuki Iwashima
2024-10-04 16:06 ` Jakub Kicinski
2024-10-04 19:49 ` Kuniyuki Iwashima
2024-10-03 20:57 ` [PATCH v1 net 5/6] mpls: " Kuniyuki Iwashima
2024-10-03 20:57 ` Kuniyuki Iwashima [this message]
2024-10-04 7:12 ` [PATCH v1 net 6/6] phonet: " Rémi Denis-Courmont
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=20241003205725.5612-7-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=courmisch@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--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).