[systemd-devel] [libudev] is there a function to filter message from kernel with property and value
Wang, Yuan1
yuan1.wang at intel.com
Tue Jul 5 02:24:36 UTC 2022
Thanks for the suggestion! We will investigate.
- Yuan
-----Original Message-----
From: Lennart Poettering <lennart at poettering.net>
Sent: Sunday, July 3, 2022 5:20 AM
To: Wang, Yuan1 <yuan1.wang at intel.com>
Cc: systemd-devel at lists.freedesktop.org
Subject: Re: [systemd-devel] [libudev] is there a function to filter message from kernel with property and value
On Di, 31.05.22 02:48, Wang, Yuan1 (yuan1.wang at intel.com) wrote:
> Hi
>
> Need your kind help for one question!
>
> Do libudev have a function that could be used to filter the message with property from kernel socket?
No, because that is not optimizable. i.e. we have no way to filter these missages in kernel. We could filter them in userspace on the library once we have them, but that's not really too useful, since you might as well do that yourself, the library wouldn't be any more efficient.
Usually, what you want to do instead is mark devices to filter for with a "tag". Which are short strings that devices can be labelled with. Each device can have zero, one or more tags. You set them via udev rules. These tags can then efficiently be filtered for via the library. This is internally implemented via a Bloom Filter, that is tested via a BPF socket filter, which means the kernel already filters the messages, and userspace is never bothered anymore (well, bloom filters are probabilistic, so userspace has to check for false positives).
Anyway, long story short: filtering by properties is not supported because you should not do that, and should use tags instead.
Also, libudev is obsolete and does not recieve new additions. Use the sd-device API instead.
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list