[PATCH 0/5] RFC: Multicast and filtering features on AF_UNIX

Lennart Poettering mzqohf at 0pointer.de
Sat Sep 25 12:06:46 PDT 2010

On Fri, 24.09.10 21:09, Havoc Pennington (hp at pobox.com) wrote:

> Hi,
> Dumping most of CC since my comments are really about dbus, not the
> kernel patches
> On Fri, Sep 24, 2010 at 1:22 PM, Alban Crequy
> <alban.crequy at collabora.co.uk> wrote:
> > Another possibility is to add the needed features directly in AF_UNIX
> > sockets (and avoid to create a new address family for D-Bus):
> >
> > - multicast
> > - some kind of BSD socket filters?
> > - untables?
> >
> It seems like the routing is the handwavy part (I mean, that is what
> the userspace dbus-daemon is doing). Any client connected to the
> daemon can end up getting any message depending on what that client
> has requested. Perhaps it would be possible to optimize only the very
> simplest, but also most common, case, which is that a message has a
> specific client as destination, and no other clients have asked to
> eavesdrop on that message. I don't know what percentage of dbus
> traffic this would cover but it might be a lot (unless running some
> kind of monitor app). The bus daemon could maintain a table of
> destinations that are safe to route in this way.

Note that BSD socket filters are generic and should work on any kind of
socket, be it AF_INET, AF_NETLINK or AF_UNIX. Right now, as we speak,
not needing any kernel patches. They can be used to minimize the amount
of wakeups as every client could upload its own filters into its socket
that matches exactly what it is interested in.

libudev's netlink usage can be used as an example for this. Note that
the udev packet format is designed with BSD socket filters in mind,
i.e. has a couple of hash values in the header that make it possible to
do probabilistic string comparison. Also, it adds a small bloom filter
to each packet to make it possible to test against one or more "tags"
that might be set for a packet.

To make use of BSD socket filters for the routing in D-Bus a scheme
inspired by this could be used: put hashes of the destination, member
and interface into the header, plus a bloom filter for the member
arguments. Then, on the receiving side simply upload the appropriate BSD
socket filter into the AF_UNIX and hence receive only the packets you
are interested in. 


Lennart Poettering - Red Hat, Inc.

More information about the dbus mailing list