Skip to contentSkip to conversation

nbd: automatically load module on genl access

PATCH Applied Thomas Weißschuh 3 participants 3 messages Jul 13, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 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.

---
Changes in v3:
- Resend to gain some reviews
- Expand commit message
- Drop additional reviewers again
- Cc Christoph as reviewer, as he recently reviewed NBD stuff
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Expand Cc list to get some reviews
- Add concrete commit example to commit message
- Link to v1: https://lore.kernel.org/lkml/[email protected]/

---
 drivers/block/nbd.c | 1 +
 1 file changed, 1 insertion(+)
drivers/block/nbd.c +1 -0
index 8576d696c7a2..a346dbd73543 100644
@@ -2336,6 +2336,7 @@ static struct genl_family nbd_genl_family __ro_after_init = {
 	.mcgrps		= nbd_mcast_grps,
 	.n_mcgrps	= ARRAY_SIZE(nbd_mcast_grps),
 };
+MODULE_ALIAS_GENL_FAMILY(NBD_GENL_FAMILY_NAME);
 
 static int populate_nbd_status(struct nbd_device *nbd, struct sk_buff *reply)
 {

---
base-commit: eb26cbb1a754ccde5d4d74527dad5ba051808fad
change-id: 20230223-b4-nbd-genl-3a74ca638686

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>
maintainer Reviewed-by on v3 1/1
#1 lore raw
Quoted 10 lines · Thomas Weißschuh

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".

Quoted 7 lines

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.

Thanks,

Josef

maintainer Applied
#2 lore raw
In reply to Thomas Weißschuh
Quoted 11 lines · Thomas Weißschuh

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".

[...]

Applied, thanks!

[1/1] nbd: automatically load module on genl access

      commit: 82e37f43c37845b69955a0dfa5e0d1a2a830bdb7

Best regards,

Signature · 1 line
Jens Axboe