test: add kdbys_sysfs_{get|set}_parameter_mask() helpers

Add functions to get and set the mask module parameter.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test-connection: check kdbus parameter mask

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
pool: clean up child logic

 * re-order 'child' member in struct for nicer alignment

 * Add a BUG() in kdbus_pool_add_busy_slice() so we're notified when
   two slices with the same offset are landing in the tree, rather
   than getting into an endless loop

 * When merging slices with regions *before*, make sure to maintain
   the child pointer

 * Warn in kdbus_pool_slice_set_child() if current child is non-NULL

 * Call kdbus_pool_slice_flush() on the child as well

Signed-off-by: Daniel Mack <daniel@zonque.org>
test: kdbus_msg_dump(): dump KDBUS_ITEM_FDS items

Signed-off-by: Daniel Mack <daniel@zonque.org>
test: make kdbus_conn->buf 'unsigned char *'

For clearer pointer arithmetics.

Signed-off-by: Daniel Mack <daniel@zonque.org>
metadata: kdbus_meta_collect_from_src() capture everything

Capture both the description and all owned names from
kdbus_meta_collect_from_src(). The current mask check doesn't make
any sense.

We need to revisit all these bits, anyway.

Signed-off-by: Daniel Mack <daniel@zonque.org>
pool: remove child assignment in __kdbus_pool_slice_release()

This can't happen. We're only merging free slices, which don't have
children. While at it, fix a minor coding sytle issue.

Signed-off-by: Daniel Mack <daniel@zonque.org>
pool: preserve pointer to child before destroying parent

If we merge two slices, we would lose the pointer to our child.
Preserve it by taking a pointer before, and simplify the code a bit.

Signed-off-by: Daniel Mack <daniel@zonque.org>
test: add skeleton for the test attach flags mask

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test: add the test attach flags source

Oups add the test-attach-flags source file.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test-connection: fix a bug by checking against the appropriate flags

This fixes a copy past bug, we have to check against the invalid flags

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test-kdbus: when creating buses make sure to use the current kdbus mask

Since we are going to force MAKE_BUS ioctl to always provide the correct
attach flags that will not overlap with the kdbus attach flags mask,
make sure to use here the right attach flags when creating buses.

Setting the kdbus attach mask needs write access into /sys/module/kdbus
which normal users should not have, so just adapt and fix any test that
assumes that all the ATTACH items are provided.

Currently all tests succeed. Anyway we'll push later a more specific
test for this case that changes the attach flags mask and inspect the
returned items.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test-attach-flags: test MAKE_BUS ioctl with different masks and flags

Change kdbus flags mask and test the MAKE_BUS ioctl

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
bus: the attach flags required by a bus should honor system-wide kdbus mask

Make sure that MAKE_BUS ioctl will only require attach flags that are
allowed by the system-wide kdbus mask, and that they will not overlap.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
pool: ensure children are in the same pool than its parents

Other situations are clearly a bug, so be agressive.

Signed-off-by: Daniel Mack <daniel@zonque.org>
queue, connection: store payload in separate slice (ABI break)

In order to support translating metadata to 'current', we need to
delay translations until the very last point. This opens a can of
worms, because we cannot determine the metadata size until then
(pathnames may change in length), so the entire logic has to be
changed:

 * On message arrival, allocate a pool slice to only store the
   data vector payload of a message, and remember offsets to them

 * Also, record the metadata, and pin it with a queue entry item

 * When the message is delivered to its destination, allocate the
   actual message header slice, copy over the message header,
   the metadata and possible extra message items (for notifications),
   and reconstruct the PAYLOAD_VEC_OFF items.

 * Link the payload slice to to the message header slice, so the
   payload will be released along with the message. The message
   payload slice's offset will never be publishes to userspace,
   so the slice will have ref_user = false.

 * This also means that offsets in PAYLOAD_VEC_OFF items are now
   relative to the entire pool, not to the message. Hence, user
   space applications have to be updated.

Signed-off-by: Daniel Mack <daniel@zonque.org>
test: follow latest PAYLOAD_VEC_OFF changes

PAYLOAD_VEC_OFF items are now referencing offsets relative to the
connection's pool, not to the item itself. Follow this change in
the test suite.

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection: code cleaning for kdbus_cmd_msg_recv()

Just use 'install' variable which I think is more readable.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
meta: use 'current' in kdbus_meta_export()

Now that we export metadata in the context of 'current', the conn_dst
parameter to kdbus_meta_export() can go away.

However, we need to remember the root path under which the executable
path was recorded, and we now do that in the metadata object.

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection: remove namespace and root path pinning

These information is not needed anymore, so remove it altogether,
along with kdbus_conn_namespace_eq(), which had no users yet anyway.

Signed-off-by: Daniel Mack <daniel@zonque.org>