handle: use dynamic major/minor allocation (ABI break)

Instead of requiring 1 major per domain, we now allocate major/minor
combinations dynamically. So far, only a single major is allocated during
module init, but the code can easily be extended to even make those
dynamic. However, device-cgroups require us to have a fixed major. User
space must be aware that major/minor numbers no longer have any specific
meaning. Each major/minor combination might be assigned to any domain
and/or endpoint! Apart from this semantics change, the ABI stays the same.

Furthermore, this patch reworks the kdbus_domain_new() and kdbus_ep_new()
functions to avoid races against UEVENT_ADD. Both objects must be active
before we call device_add() and thus produce UEVENT_ADD.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
kdbus.h: factor out name info struct (ABI break)

Introduce struct kdbus_name_info and report information on name lists
with it, instead of (ab)using struct kdbus_cmd_name for it.

That way, we can get rid of two fields in the latter.

Signed-off-by: Daniel Mack <daniel@zonque.org>
kdbus.h: split in and out flags of ioctls (ABI break)

Instead of negotating kernel flags via the same field for input and
output, use two different bitfields for that, and call the returned
flags 'kernel_flags'.

The approach implemented before didn't turn out to work too well for
more complex userspace programs that retain the same ioctl buffers
for multiple calls, and which had to manually save and restore the
flags before.

While at it, rename conn_flags → flags in kdbus_cmd_hello to ease
the internal helper functions and unify the API a bit more.

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection.c: comments cleanup

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection: remove debugging printk()

This probably wasn't meant to be included in the commit. Remove stray
printk() debugging helper.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
connection: drop unused variable

The 'ts' variable is no longer used. Drop it.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
test-sync: implement send_reply()

Implement a new helper function to reply to pending messages.

Formerly, the test abused the timeout parameter to respond, knowing
that its value will eventually end up in the kdbus message in the
same union as the cookie_reply field.

In the process of switching to absolute timeouts, however, this bites
us, so move this hack out of the way first.

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection: switch to absolute timeouts (API break)

Make the timeouts in struct kdbus_msg.timeout_ns absolute.

This is necessary in order to support blocking sync calls with
SA_RESTART behavior.

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection.c: cosmetic cleanup

Signed-off-by: Daniel Mack <daniel@zonque.org>
test: use kdbus_msg_dump() to check for message integrity

Make kdbus_msg_dump() return an error in case there's anything wrong
with the message. Return such errors from kdbus_msg_recv(). We currently
fail with notifications.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Revert "notify: set item->size"

This reverts commit b62c3ed2b7bed76935a57a9a65e7bba63602b4c4.

m->msg.items[0].size is already set from kdbus_kmsg_new(), so this
is unnecessary. Furthermode, we need to ALIGN8() the item size, which
kdbus_kmsg_new() also does for us already.
handle.c: fix and add kernel-doc

Signed-off-by: Daniel Mack <daniel@zonque.org>
Makefile: add 'doc' target

So easy the process of checking kernel-doc entries

Signed-off-by: Daniel Mack <daniel@zonque.org>
test-sync: do a second recv only when SA_RESTART was passed

The test was working for all cases, but fix it to only check for the
SA_RESTART case.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test: make sure that creating endpoint with long names will fail

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test: just define KDBUS_SYSNAME_MAX_LEN here in test-endpoint

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
connection: remove unused variable

That was introduced by a wrong conflict resolution.

Signed-off-by: Daniel Mack <daniel@zonque.org>
message: allow memfds for broadcast messages

As discussed on LPC.

Signed-off-by: Daniel Mack <daniel@zonque.org>
test-fd: add a bloom filter to broadcast message

Satisfy a kernel check so we can be sure we really bail out due
to the check we're actually enforcing.

Signed-off-by: Daniel Mack <daniel@zonque.org>
message: we want to allow O_PATHed file descriptors

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>