[systemd-devel] The enum udev_monitor_netlink_group contains bit masks

Andrey Wagin avagin at gmail.com
Tue Mar 12 22:09:08 PDT 2013

2013/3/13 Kay Sievers <kay at vrfy.org>

> On Tue, Mar 12, 2013 at 9:35 PM, Andrey Wagin <avagin at gmail.com> wrote:
> > According to netlink(7) nl_groups is a bit mask with every bit
> representing
> > a netlink group number.
> Netlink uses "numbers" not "a mask" since many years, we have just a
> 32bit number, not 32 groups today. The man page should really be
> updated:
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=d629b836d151d43332492651dd841d32e57ebe3b

> There might be magic for group 1-32, which is still in place, but
> there is generally no mask anymore for netlink groups.

I'm afraid, you are wrong. This patch is about kernel internals.
User-interfaces have not been changed.
 nlk->dst_group  = ffs(nladdr->nl_groups);

Here is another patch, which expands user interface to set more than 32

> > I found that constants from udev_monitor_netlink_group are set directly
> to
> > nl_groups. It's dangerous. Currently this enum contains only three
> constant
> > and all is ok, but the next constant will be incorrect.
> There will probably never be another netlink group inside libudev. If
> we ever change that low-level stuff here, we would move entirely to a
> kernel dbus facility, and not (mis-)use netlink anymore.

It's not a reason to not fix this code. People use code of system tools as
examples. I usually do that. It's the most probable place where kernel
interfaces are used by the right way.

> > I created a patch, but I have not tested it. It's just idea. Sorry, I
> would
> > have prefered to avoid investigation of how to execute my system with
> custom
> > systemd. So if someone wants to fix this issue, you are welcome.
> Just build systemd locally, and run
>   ./udevadm monitor
> locally, it will receive messages from the kernel and from the already
> running and unchanged udevd. Just plub/unplug any device.


> If the output is the same in the local build and the one from the
> system, all is fine, you can check with strace to verify the details
> too.
> Kay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130313/a8d84458/attachment-0001.html>

More information about the systemd-devel mailing list