mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-14 07:44:21 +08:00
mpls: Handle error of rtnl_register_module().
Since introduced, mpls_init() has been ignoring the returned
value of rtnl_register_module(), which could fail silently.
Handling the error allows users to view a module as an all-or-nothing
thing in terms of the rtnetlink functionality. This prevents syzkaller
from reporting spurious errors from its tests, where OOM often occurs
and module is automatically loaded.
Let's handle the errors by rtnl_register_many().
Fixes: 03c0566542
("mpls: Netlink commands to add, remove, and dump routes")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
d51705614f
commit
5be2062e30
@ -2728,6 +2728,15 @@ static struct rtnl_af_ops mpls_af_ops __read_mostly = {
|
||||
.get_stats_af_size = mpls_get_stats_af_size,
|
||||
};
|
||||
|
||||
static const struct rtnl_msg_handler mpls_rtnl_msg_handlers[] __initdata_or_module = {
|
||||
{THIS_MODULE, PF_MPLS, RTM_NEWROUTE, mpls_rtm_newroute, NULL, 0},
|
||||
{THIS_MODULE, PF_MPLS, RTM_DELROUTE, mpls_rtm_delroute, NULL, 0},
|
||||
{THIS_MODULE, PF_MPLS, RTM_GETROUTE, mpls_getroute, mpls_dump_routes, 0},
|
||||
{THIS_MODULE, PF_MPLS, RTM_GETNETCONF,
|
||||
mpls_netconf_get_devconf, mpls_netconf_dump_devconf,
|
||||
RTNL_FLAG_DUMP_UNLOCKED},
|
||||
};
|
||||
|
||||
static int __init mpls_init(void)
|
||||
{
|
||||
int err;
|
||||
@ -2746,24 +2755,25 @@ static int __init mpls_init(void)
|
||||
|
||||
rtnl_af_register(&mpls_af_ops);
|
||||
|
||||
rtnl_register_module(THIS_MODULE, PF_MPLS, RTM_NEWROUTE,
|
||||
mpls_rtm_newroute, NULL, 0);
|
||||
rtnl_register_module(THIS_MODULE, PF_MPLS, RTM_DELROUTE,
|
||||
mpls_rtm_delroute, NULL, 0);
|
||||
rtnl_register_module(THIS_MODULE, PF_MPLS, RTM_GETROUTE,
|
||||
mpls_getroute, mpls_dump_routes, 0);
|
||||
rtnl_register_module(THIS_MODULE, PF_MPLS, RTM_GETNETCONF,
|
||||
mpls_netconf_get_devconf,
|
||||
mpls_netconf_dump_devconf,
|
||||
RTNL_FLAG_DUMP_UNLOCKED);
|
||||
err = ipgre_tunnel_encap_add_mpls_ops();
|
||||
err = rtnl_register_many(mpls_rtnl_msg_handlers);
|
||||
if (err)
|
||||
goto out_unregister_rtnl_af;
|
||||
|
||||
err = ipgre_tunnel_encap_add_mpls_ops();
|
||||
if (err) {
|
||||
pr_err("Can't add mpls over gre tunnel ops\n");
|
||||
goto out_unregister_rtnl;
|
||||
}
|
||||
|
||||
err = 0;
|
||||
out:
|
||||
return err;
|
||||
|
||||
out_unregister_rtnl:
|
||||
rtnl_unregister_many(mpls_rtnl_msg_handlers);
|
||||
out_unregister_rtnl_af:
|
||||
rtnl_af_unregister(&mpls_af_ops);
|
||||
dev_remove_pack(&mpls_packet_type);
|
||||
out_unregister_pernet:
|
||||
unregister_pernet_subsys(&mpls_net_ops);
|
||||
goto out;
|
||||
|
Loading…
Reference in New Issue
Block a user