skarnet/mdevd

Rebroadcast uevents

illiliti opened this issue · 8 comments

Currently, libudev-zero uses files to get uevents from device manager. I admit that this looks hacky and improper, but I can't do anything on my side.

I propose to rebroadcast uevent messages. This way, I could implement race-free file-less hotplugging for libudev-zero.

As far as I know, there are two ways how it could be done.

  1. Rebroadcast uevents to named unix socket
  2. Rebroadcast uevents via custom netlink group number[1]

[1]
https://man7.org/linux/man-pages/man7/netlink.7.html nl_groups
oasislinux/hotplugd@6d19eb4

Isn't the -o outputfd option enough? Couldn't libudev-zero read the stream of events from a file descriptor? (Fields are null-terminated, and an additional null terminates the uevent.)

How I'm supposed to control that option if mdevd usually started by service manager/init script? By rudely killing mdevd and restarting it with new option? No, I think this option isn't what I'm looking for. Correct me if I'm wrong.

Ah, what I missed is that libudev-zero doesn't provide any daemon per se, so there needs to be a mechanism to allow clients to individually subscribe to uevents.

I have no objection to adding an option to rebroadcast uevents to a netlink group, but what is the advantage of this over simply connecting to the kernel's source of uevents itself? Do you need to ensure the uevents have been processed by the device manager before notifying clients?

Do you need to ensure the uevents have been processed by the device manager before notifying clients?

Exactly. I need to ensure that there is no race condition.

I will add an option to rebroadcast to netlink some time this week, but it will only be in master - the next release may not be in a while because I'm sitting on a skalibs+s6 major update, trying to cram as many incompatible changes as I need before cutting the release.

Sure, take your time.

master branch now supports a -O nlgroups option, that rebroadcasts events to the netlink groups identified by the nlgroups mask, with 1 ignored because it's the kernel one. Please test and tell me if it works for your purposes.

Awesome. Just tested master branch by plugging/unplugging my mouse and everything works flawlessly. Thanks