Removing entries from an open addressed hash table creates holes in the
collision chains, preventing previous colliding entries to be found. By
inserting tombstones, rather than clearing deleted entries makes it
possible to distinguish the end of a chain from a hole.
Reviewed-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The dprintf macro shadows a real libc symbol which is called
differently, so we should change it to something else (in this
case LOGD) and change it to use the libqrtr logging facilities.
This also means we should add a minimum priority to the logging
library so we don't log DEBUG-level messages by default.
Additionally there were some warn/warnx calls left over that
have been changed to PLOGW/LOGW respectively.
The DIAG service has its own encoding for the instance number which
is unrelated to the version. This means that the information we
show to the user in the version and instance columns of the table is
parsed incorrectly and often useless. Instead, treat the instance
number as special if the service is a DIAG service and print out a
more meaningful interpretation.
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
waiter_wait_timeout() doesn't initialize the 'callback' and 'updated'
fields of the waiter_ticket struct. The 'updated' field may contain some
garbage value, which is later read in waiter_ticket_check().
Signed-off-by: Ben Chan <benchan@chromium.org>
This function in qrtr-ns was largely copied from the main
function of qrtr-cfg. We should just factor it out so there is
one implementation instead.
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The __progname symbol is a GNU extension and thus not portable,
but basename (from libgen.h) and argv[0] can be used portably
instead.
(qrtr-lookup already used argv[0] but did not apply basename, so
do that for consisntency.)
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
When running in Android we want to keep qrtr-ns in the foreground, so
that init's service handler can keep track of it. Add the -f flag to
skip the fork().
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Instead of calling qrtr-cfg separately to configure the local address
just pass this as an argument to qrtr-ns, allowing us to run a single
command to instantiate qrtr.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
By opening a socket before attempting to configure the address we
trigger kernel module loading, if qrtr is compiled as such.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The uapi qrtr.h is extended with additional types and constants. Drop
the local qrtr.h to use the one from linux-headers and extend it
conditionally while we're waiting for the updated file.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Restrict the origin of certain messages to limit the ability of clients
to inject invalid data in the service registry.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
When a server is disappearing, either from a DEL_SERVER, BYE or
DEL_CLIENT message the same messages needs to be sent; to local
observers and through broadcasts to remote nodes.
So move the logic from the DEL_SERVER command handler to server_del, in
order to invoke this regardless of reason for the server's
disappearance.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
As we propagate the BYE to local listeners we have to also pass the
information on which node is down, so use the typical "node" field for
this.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
A number of services are mentioned in the Qualcomm downstream kernels,
add these to the list of known names to improve the output.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Instead of reporting "service" as id:instance split the "instance" in version
and instance and present the three entities separately.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Instead of having a custom lookup result, just pass new and delete
server messages - allowing clients to receive notifications about dying
services as well, without having to extend the lookup result message.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Request the return value of the operation from the kernel and check if
it's an error, to inform the user about e.g. not having sufficient
permission.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Now that we only have one socket for our context we can simplify the
name of the struct member.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Now that we have moved all operations to the control socket we can
remove the ns handler. The query function in the library is racy, as
there might be non-response messages in our incoming buffer when we
start reading, so this is dropped too - rather than just being
translated to the new interface.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Convert qrtr-lookup to use the control port for queries, allowing us to
drop the ns service altogether.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Introduce a subscription based lookup model, in order for a client to be
able to listen to a future spawning service. The client can register any
number of queries with the ns and the ns will post lookup-results as
services are registred.
As a special case the list of lookup-results that is sent out as a
result of the registration of a new lookup will be finished by an empty
lookup response, allowing tools like qrtr-lookup to terminate as the
entire list of currently registed services is received.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The BYE control message signals that a node is gone, drop all services
from our register and propagate this message to all local servies - to
allow them to clean up any resources associated with potential remote
clients.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Following the downstream kernel we should propagate a del_client to all
local services as the dying socket might have acted - or once acted - as
a client as well.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Upon receiving a DEL_CLIENT some local or remote client has been
disconnected. If this is a local server we remove the server from the
lists and announce the removal to the remotes. Otherwise we need to
inform local servers that one of their clients might be gone, so we
propagate a DEL_SERVER message to all locally registered services.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Add a new set of operations to libqrtr for sending registration events
to the control service, rather than using the nameservice port.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Move the qrtr_ctrl_cmd struct to the shared header file, order to
facilitate sending control messages directly from the library.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
A number of operations broadcasts messages, so store a static
broadcast socketaddr in the context to facilitate this.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Store the local node id in the "context, rather than requesting the
local node id from the kernel every time we need it.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
In order to easily shoot down all services when a remote node goes away,
or list all local services when announcing inject a "node" layer above
the services map.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
With newer kernels AF_QIPCRTR is already defined in the system header
files, so don't define it unconditionaly.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The kernel will broadcast the presence of the qrtr-ns to all locally
opened sockets and any remote sockets will be notified through other
means; so drop the reset notification.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The final version of QRTR that was merged into v4.7 of the Linux kernel
requires a configuration step where we set the local node address.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>