[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241011220550.46040-11-kuniyu@amazon.com>
Date: Fri, 11 Oct 2024 15:05:49 -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>, Oliver Hartkopp
<socketcan@...tkopp.net>, Marc Kleine-Budde <mkl@...gutronix.de>
Subject: [PATCH v1 net-next 10/11] can: gw: Use rtnl_register_many().
We will remove rtnl_register_module() in favour of rtnl_register_many().
rtnl_register_many() will unwind the previous successful registrations
on failure and simplify module error handling.
Let's use rtnl_register_many() instead.
Signed-off-by: Kuniyuki Iwashima <kuniyu@...zon.com>
---
Cc: Oliver Hartkopp <socketcan@...tkopp.net>
Cc: Marc Kleine-Budde <mkl@...gutronix.de>
---
net/can/gw.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/net/can/gw.c b/net/can/gw.c
index 37528826935e..34d6b8c37b92 100644
--- a/net/can/gw.c
+++ b/net/can/gw.c
@@ -1265,6 +1265,12 @@ static struct pernet_operations cangw_pernet_ops = {
.exit_batch = cangw_pernet_exit_batch,
};
+static const struct rtnl_msg_handler cgw_rtnl_msg_handlers[] = {
+ {THIS_MODULE, PF_CAN, RTM_NEWROUTE, cgw_create_job, NULL, 0},
+ {THIS_MODULE, PF_CAN, RTM_DELROUTE, cgw_remove_job, NULL, 0},
+ {THIS_MODULE, PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, 0},
+};
+
static __init int cgw_module_init(void)
{
int ret;
@@ -1290,27 +1296,13 @@ static __init int cgw_module_init(void)
if (ret)
goto out_register_notifier;
- ret = rtnl_register_module(THIS_MODULE, PF_CAN, RTM_GETROUTE,
- NULL, cgw_dump_jobs, 0);
- if (ret)
- goto out_rtnl_register1;
-
- ret = rtnl_register_module(THIS_MODULE, PF_CAN, RTM_NEWROUTE,
- cgw_create_job, NULL, 0);
- if (ret)
- goto out_rtnl_register2;
- ret = rtnl_register_module(THIS_MODULE, PF_CAN, RTM_DELROUTE,
- cgw_remove_job, NULL, 0);
+ ret = rtnl_register_many(cgw_rtnl_msg_handlers);
if (ret)
- goto out_rtnl_register3;
+ goto out_rtnl_register;
return 0;
-out_rtnl_register3:
- rtnl_unregister(PF_CAN, RTM_NEWROUTE);
-out_rtnl_register2:
- rtnl_unregister(PF_CAN, RTM_GETROUTE);
-out_rtnl_register1:
+out_rtnl_register:
unregister_netdevice_notifier(¬ifier);
out_register_notifier:
kmem_cache_destroy(cgw_cache);
--
2.39.5 (Apple Git-154)
Powered by blists - more mailing lists