Commit e3bf14bd authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Doug Ledford

rdma: Autoload netlink client modules

If a message comes in and we do not have the client in the table, then
try to load the module supplying that client using MODULE_ALIAS to find
it.

This duplicates the scheme seen in other netlink muxes (eg nfnetlink).
Signed-off-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 1eb5be0e
...@@ -4537,5 +4537,7 @@ static void __exit cma_cleanup(void) ...@@ -4537,5 +4537,7 @@ static void __exit cma_cleanup(void)
destroy_workqueue(cma_wq); destroy_workqueue(cma_wq);
} }
MODULE_ALIAS_RDMA_NETLINK(RDMA_NL_RDMA_CM, 1);
module_init(cma_init); module_init(cma_init);
module_exit(cma_cleanup); module_exit(cma_cleanup);
...@@ -1252,5 +1252,7 @@ static void __exit ib_core_cleanup(void) ...@@ -1252,5 +1252,7 @@ static void __exit ib_core_cleanup(void)
destroy_workqueue(ib_wq); destroy_workqueue(ib_wq);
} }
MODULE_ALIAS_RDMA_NETLINK(RDMA_NL_LS, 4);
module_init(ib_core_init); module_init(ib_core_init);
module_exit(ib_core_cleanup); module_exit(ib_core_cleanup);
...@@ -1200,5 +1200,7 @@ static void __exit iw_cm_cleanup(void) ...@@ -1200,5 +1200,7 @@ static void __exit iw_cm_cleanup(void)
iwpm_exit(RDMA_NL_IWCM); iwpm_exit(RDMA_NL_IWCM);
} }
MODULE_ALIAS_RDMA_NETLINK(RDMA_NL_IWCM, 2);
module_init(iw_cm_init); module_init(iw_cm_init);
module_exit(iw_cm_cleanup); module_exit(iw_cm_cleanup);
...@@ -84,6 +84,15 @@ static bool is_nl_valid(unsigned int type, unsigned int op) ...@@ -84,6 +84,15 @@ static bool is_nl_valid(unsigned int type, unsigned int op)
return false; return false;
cb_table = rdma_nl_types[type].cb_table; cb_table = rdma_nl_types[type].cb_table;
#ifdef CONFIG_MODULES
if (!cb_table) {
mutex_unlock(&rdma_nl_mutex);
request_module("rdma-netlink-subsys-%d", type);
mutex_lock(&rdma_nl_mutex);
cb_table = rdma_nl_types[type].cb_table;
}
#endif
if (!cb_table || (!cb_table[op].dump && !cb_table[op].doit)) if (!cb_table || (!cb_table[op].dump && !cb_table[op].doit))
return false; return false;
return true; return true;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <linux/module.h>
#include <net/netlink.h> #include <net/netlink.h>
#include <rdma/rdma_netlink.h> #include <rdma/rdma_netlink.h>
...@@ -320,3 +321,5 @@ void __exit nldev_exit(void) ...@@ -320,3 +321,5 @@ void __exit nldev_exit(void)
{ {
rdma_nl_unregister(RDMA_NL_NLDEV); rdma_nl_unregister(RDMA_NL_NLDEV);
} }
MODULE_ALIAS_RDMA_NETLINK(RDMA_NL_NLDEV, 5);
...@@ -17,6 +17,18 @@ enum rdma_nl_flags { ...@@ -17,6 +17,18 @@ enum rdma_nl_flags {
RDMA_NL_ADMIN_PERM = 1 << 0, RDMA_NL_ADMIN_PERM = 1 << 0,
}; };
/* Define this module as providing netlink services for NETLINK_RDMA, with
* index _index. Since the client indexes were setup in a uapi header as an
* enum and we do no want to change that, the user must supply the expanded
* constant as well and the compiler checks they are the same.
*/
#define MODULE_ALIAS_RDMA_NETLINK(_index, _val) \
static inline void __chk_##_index(void) \
{ \
BUILD_BUG_ON(_index != _val); \
} \
MODULE_ALIAS("rdma-netlink-subsys-" __stringify(_val))
/** /**
* Register client in RDMA netlink. * Register client in RDMA netlink.
* @index: Index of the added client * @index: Index of the added client
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment