net: use rtnl_register_module where needed
authorFlorian Westphal <fw@strlen.de>
Sat, 2 Dec 2017 20:44:07 +0000 (21:44 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 4 Dec 2017 16:32:39 +0000 (11:32 -0500)
all of these can be compiled as a module, so use new
_module version to make sure module can no longer be removed
while callback/dump is in use.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_mdb.c
net/can/gw.c
net/decnet/dn_dev.c
net/decnet/dn_fib.c
net/decnet/dn_route.c
net/mpls/af_mpls.c
net/phonet/pn_netlink.c
net/qrtr/qrtr.c

index b0f4c734900bc3ac1ee15f967665e8ce3526e1ed..6d9f48bd374ab28d34d4a846b1b659c36110112b 100644 (file)
@@ -760,9 +760,9 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
 
 void br_mdb_init(void)
 {
-       rtnl_register(PF_BRIDGE, RTM_GETMDB, NULL, br_mdb_dump, 0);
-       rtnl_register(PF_BRIDGE, RTM_NEWMDB, br_mdb_add, NULL, 0);
-       rtnl_register(PF_BRIDGE, RTM_DELMDB, br_mdb_del, NULL, 0);
+       rtnl_register_module(THIS_MODULE, PF_BRIDGE, RTM_GETMDB, NULL, br_mdb_dump, 0);
+       rtnl_register_module(THIS_MODULE, PF_BRIDGE, RTM_NEWMDB, br_mdb_add, NULL, 0);
+       rtnl_register_module(THIS_MODULE, PF_BRIDGE, RTM_DELMDB, br_mdb_del, NULL, 0);
 }
 
 void br_mdb_uninit(void)
index 73a02af4b5d76015df42b7eae46f2ba153e79f5c..398dd0395ad99b23bb72320c6a8868ceb763b069 100644 (file)
@@ -1014,6 +1014,8 @@ static struct pernet_operations cangw_pernet_ops = {
 
 static __init int cgw_module_init(void)
 {
+       int ret;
+
        /* sanitize given module parameter */
        max_hops = clamp_t(unsigned int, max_hops, CGW_MIN_HOPS, CGW_MAX_HOPS);
 
@@ -1031,15 +1033,19 @@ static __init int cgw_module_init(void)
        notifier.notifier_call = cgw_notifier;
        register_netdevice_notifier(&notifier);
 
-       if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, 0)) {
+       ret = rtnl_register_module(THIS_MODULE, PF_CAN, RTM_GETROUTE,
+                                  NULL, cgw_dump_jobs, 0);
+       if (ret) {
                unregister_netdevice_notifier(&notifier);
                kmem_cache_destroy(cgw_cache);
                return -ENOBUFS;
        }
 
-       /* Only the first call to __rtnl_register can fail */
-       __rtnl_register(PF_CAN, RTM_NEWROUTE, cgw_create_job, NULL, 0);
-       __rtnl_register(PF_CAN, RTM_DELROUTE, cgw_remove_job, NULL, 0);
+       /* Only the first call to rtnl_register_module can fail */
+       rtnl_register_module(THIS_MODULE, PF_CAN, RTM_NEWROUTE,
+                            cgw_create_job, NULL, 0);
+       rtnl_register_module(THIS_MODULE, PF_CAN, RTM_DELROUTE,
+                            cgw_remove_job, NULL, 0);
 
        return 0;
 }
index 9153247dad28cdb8976fc9fd144a86f1a0eab10a..d1885cf59319a5e28c79aa12d1c20830a405ed46 100644 (file)
@@ -1418,9 +1418,12 @@ void __init dn_dev_init(void)
 
        dn_dev_devices_on();
 
-       rtnl_register(PF_DECnet, RTM_NEWADDR, dn_nl_newaddr, NULL, 0);
-       rtnl_register(PF_DECnet, RTM_DELADDR, dn_nl_deladdr, NULL, 0);
-       rtnl_register(PF_DECnet, RTM_GETADDR, NULL, dn_nl_dump_ifaddr, 0);
+       rtnl_register_module(THIS_MODULE, PF_DECnet, RTM_NEWADDR,
+                            dn_nl_newaddr, NULL, 0);
+       rtnl_register_module(THIS_MODULE, PF_DECnet, RTM_DELADDR,
+                            dn_nl_deladdr, NULL, 0);
+       rtnl_register_module(THIS_MODULE, PF_DECnet, RTM_GETADDR,
+                            NULL, dn_nl_dump_ifaddr, 0);
 
        proc_create("decnet_dev", S_IRUGO, init_net.proc_net, &dn_dev_seq_fops);
 
index b37a1b833c7723199a4deb3d743d6ca81d4f27a5..fce94cbd4378c3620e2b73bd8ec2ea64cbc93384 100644 (file)
@@ -792,8 +792,10 @@ void __init dn_fib_init(void)
 
        register_dnaddr_notifier(&dn_fib_dnaddr_notifier);
 
-       rtnl_register(PF_DECnet, RTM_NEWROUTE, dn_fib_rtm_newroute, NULL, 0);
-       rtnl_register(PF_DECnet, RTM_DELROUTE, dn_fib_rtm_delroute, NULL, 0);
+       rtnl_register_module(THIS_MODULE, PF_DECnet, RTM_NEWROUTE,
+                            dn_fib_rtm_newroute, NULL, 0);
+       rtnl_register_module(THIS_MODULE, PF_DECnet, RTM_DELROUTE,
+                            dn_fib_rtm_delroute, NULL, 0);
 }
 
 
index 4b3ca70be7231ac8e36ab5b8041da4d37978bc9b..73160d4aebbe0eb1de02e979924f4e9e8489e13e 100644 (file)
@@ -1923,11 +1923,11 @@ void __init dn_route_init(void)
                    &dn_rt_cache_seq_fops);
 
 #ifdef CONFIG_DECNET_ROUTER
-       rtnl_register(PF_DECnet, RTM_GETROUTE, dn_cache_getroute,
-                     dn_fib_dump, 0);
+       rtnl_register_module(THIS_MODULE, PF_DECnet, RTM_GETROUTE,
+                            dn_cache_getroute, dn_fib_dump, 0);
 #else
-       rtnl_register(PF_DECnet, RTM_GETROUTE, dn_cache_getroute,
-                     dn_cache_dump, 0);
+       rtnl_register_module(THIS_MODULE, PF_DECnet, RTM_GETROUTE,
+                            dn_cache_getroute, dn_cache_dump, 0);
 #endif
 }
 
index 8ca9915befc8caab8270281028d4eb0ee3983fbd..5dce8336d33f7b2838416320dfb15f41113b846b 100644 (file)
@@ -2510,12 +2510,15 @@ static int __init mpls_init(void)
 
        rtnl_af_register(&mpls_af_ops);
 
-       rtnl_register(PF_MPLS, RTM_NEWROUTE, mpls_rtm_newroute, NULL, 0);
-       rtnl_register(PF_MPLS, RTM_DELROUTE, mpls_rtm_delroute, NULL, 0);
-       rtnl_register(PF_MPLS, RTM_GETROUTE, mpls_getroute, mpls_dump_routes,
-                     0);
-       rtnl_register(PF_MPLS, RTM_GETNETCONF, mpls_netconf_get_devconf,
-                     mpls_netconf_dump_devconf, 0);
+       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, 0);
        err = ipgre_tunnel_encap_add_mpls_ops();
        if (err)
                pr_err("Can't add mpls over gre tunnel ops\n");
index da754fc926e72b11379216819d0608bd598d737d..871eaf2cb85e4d4bec7dd01292c4241dff82c29e 100644 (file)
@@ -299,16 +299,21 @@ out:
 
 int __init phonet_netlink_register(void)
 {
-       int err = __rtnl_register(PF_PHONET, RTM_NEWADDR, addr_doit,
-                                 NULL, 0);
+       int err = rtnl_register_module(THIS_MODULE, PF_PHONET, RTM_NEWADDR,
+                                      addr_doit, NULL, 0);
        if (err)
                return err;
 
-       /* Further __rtnl_register() cannot fail */
-       __rtnl_register(PF_PHONET, RTM_DELADDR, addr_doit, NULL, 0);
-       __rtnl_register(PF_PHONET, RTM_GETADDR, NULL, getaddr_dumpit, 0);
-       __rtnl_register(PF_PHONET, RTM_NEWROUTE, route_doit, NULL, 0);
-       __rtnl_register(PF_PHONET, RTM_DELROUTE, route_doit, NULL, 0);
-       __rtnl_register(PF_PHONET, RTM_GETROUTE, NULL, route_dumpit, 0);
+       /* 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, 0);
        return 0;
 }
index 77ab05e230010e807f9517d8e37bd60a80a113af..5fb3929e3d7d26cce02b2b866f3445e7123e15e0 100644 (file)
@@ -1116,9 +1116,13 @@ static int __init qrtr_proto_init(void)
                return rc;
        }
 
-       rtnl_register(PF_QIPCRTR, RTM_NEWADDR, qrtr_addr_doit, NULL, 0);
+       rc = rtnl_register_module(THIS_MODULE, PF_QIPCRTR, RTM_NEWADDR, qrtr_addr_doit, NULL, 0);
+       if (rc) {
+               sock_unregister(qrtr_family.family);
+               proto_unregister(&qrtr_proto);
+       }
 
-       return 0;
+       return rc;
 }
 postcore_initcall(qrtr_proto_init);