OSDN Git Service

nbd: automatically load module on genl access
authorThomas Weißschuh <linux@weissschuh.net>
Thu, 13 Jul 2023 19:29:35 +0000 (21:29 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 17 Jul 2023 14:18:17 +0000 (08:18 -0600)
commitffe357c868e7796f20bc0eac61f5b952731c0fa8
treee1f1e6e896a30c2a3d5db498477879ce2cbf7252
parent16291561e125ef50cb1875227fce9c1583f0de3c
nbd: automatically load module on genl access

Add a module alias to nbd.ko that allows the generic netlink core to
automatically load the module when netlink messages for nbd are
received.

This frees the user from manually having to load the module before using
nbd functionality via netlink.
If the system policy allows it this can even be used to load the nbd
module from containers which would otherwise not have access to the
necessary module files to do a normal "modprobe nbd".

For example this avoids the following error when using nbd-client:

$ nbd-client localhost 10809 /dev/nbd0
...
Error: Couldn't resolve the nbd netlink family, make sure the nbd module is loaded and your nbd driver supports the netlink interface.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Josef Bacik <josef@toxicpadna.com>
Link: https://lore.kernel.org/r/20230713-b4-nbd-genl-v3-1-226cbddba04b@weissschuh.net
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/nbd.c