queue: take conn_dst->attach_flags_recv into account

Look at what the connection actually wants to see when exporting
metadata.

Signed-off-by: Daniel Mack <daniel@zonque.org>
metadata: split kdbus_meta_add_current()

Get the timestamp from its own function, so we can call it without
a source connection.

Also, call kdbus_meta_add_timestamp() as soon as a kmsg has a meta
object, so kernel notifications also get such an item.

Signed-off-by: Daniel Mack <daniel@zonque.org>
message: take timestamp when kmsg is created

As we want to have timestamps for all messages, we need a meta database
for them. Allocate one unconditionally when the kmsg object is created,
and take the timestamp right away.

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection: do not record metadata from 'current' if connection has faked creds

Signed-off-by: Daniel Mack <daniel@zonque.org>
metadata: remove 'locked' flag

This logic no longer needed, so remove it to not confuse readers.

Signed-off-by: Daniel Mack <daniel@zonque.org>
handle: don't copy return-flags twice

We already copy the whole hello object back, so don't copy the
return-flags early. Unlike kernel_flags, the return-flags don't have to be
copied on failure.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
kdbus: return bloom-parameters as items

This makes KDBUS_CMD_HELLO return a pool-offset which contains additional
items that are returned by the ioctl. They now contain bloom parameters
but may be extended in the future.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
connection: split switch case

No need to catch both KDBUS_ITEM_ATTACH_FLAGS_SEND and _RECV in the
same case and then distinguish again between the two with if().

Signed-off-by: Daniel Mack <daniel@zonque.org>
tree-wide: assorted checkpatch.pl fixes

Signed-off-by: Daniel Mack <daniel@zonque.org>
test: make bus with different fd

Making bus with different fd could succeed, while we cannot use the
same fd for bus make twice, even though a different bus name is used.

Signed-off-by: Sheng Yong <shyodx@gmail.com>
main: include metadata.h to slience a sparse warning

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

Signed-off-by: Daniel Mack <daniel@zonque.org>
queue, message: clean up address space annotations

Annotate variables correctly to make sparse happy.

Signed-off-by: Daniel Mack <daniel@zonque.org>
tree-wide: use struct kvec rather than iovec when referencing kernel memory

When dealing with kernel memory, user struct kref to store the source
addresses, rather than struct iovec.

For now, cast the iovec into a kvec in kdbus_pool_slice_copy().

Signed-off-by: Daniel Mack <daniel@zonque.org>
tree-wide: s/{ }/{}/g

Nit-pick. Just to be consistent.

Signed-off-by: Daniel Mack <daniel@zonque.org>
tree-wide: clean up variable declarations

Christmas is coming. Let's reorder variable declarations so they
look like reverse Christmas trees.

Signed-off-by: Daniel Mack <daniel@zonque.org>
test: move kdbus_item_in_message to kdbus-util.c

... and make use of it in test-connection.c. There might be more.

Signed-off-by: Daniel Mack <daniel@zonque.org>
pool: rename copy functions

Now that things are separated between iovec and kvec, use better names
for the copy functions:

  kdbus_pool_slice_copy_user	→ kdbus_pool_slice_copy_iovec
  kdbus_pool_slice_copy		→ kdbus_pool_slice_copy_kvec

Signed-off-by: Daniel Mack <daniel@zonque.org>
test: fix build error

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

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