Commit graph

45 commits

Author SHA1 Message Date
Petr Štetiar
c5f2053dfc workaround possibly false positive uses of memory after it is freed
scan-build from clang-9 has reported following:

 libubox/list.h:83:22: warning: Use of memory after it is freed
        entry->next->prev = entry->prev;
                            ^~~~~~~~~~~

 ubusd_event.c:42:3: warning: Use of memory after it is freed
                ubusd_delete_event_source(ev);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which might be a false positives, but in order to make the code pass the
static analyzer checks, rewrite the while loops on lists with the safe
list iterator.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-12-19 11:18:07 +01:00
Alexandru Ardelean
5f87f5480e ubusd: move global retmsg per client
Even with the tx_queue-ing issue resolved, what
seems to happen afterwards, is that all the messages
seems to get through, but the client still loops
in the `ubus_complete_request()` waiting for
`req->status_msg` or for a timeout.

Though, the timeout does not seem to happen, because
the data is processed in `ubus_poll_data()`, with
a infinite poll() timeout (ubus_complete_request() is
called with timeout 0).

It's likely that either the `seq` or `peer` sent from
ubusd are wrong, and the client cannot get the correct
ubus request in `ubus_process_req_msg()`.
I haven't digged too deep into this ; setting the
`retmsg` object on the client struct seems to have
resolved any hanging with the `ubus list` command.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name> [fix placement of retmsg in cl]
2017-11-13 10:09:28 +01:00
Alexandru Ardelean
be146ad2bc ubusd: rename goto label from error to out
Semantic has changed a bit.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2017-11-13 09:55:48 +01:00
Alexandru Ardelean
e02813b2cc ubusd: don't free messages in ubus_send_msg() anymore
This makes it clear that `ubus_msg_send()` is only
about sending and queue-ing messages, and has nothing
to do with free-ing.

It can be a bit misleading/confusing when trying to go
through the code and make assumptions about whether a
buffer is free'd in ubus_send_msg(), or is free'd outside.

In `ubusd_proto_receive_message()` the `ubus_msg_free()`
is now called before the `if (ret == -1)` check.
That way, all callbacks will have their messages free'd,
which is what's desired, but confusing, because:
* ubusd_handle_invoke() called ubus_msg_free() before returning -1
* ubusd_handle_notify() called ubus_msg_free() before returning -1
* ubusd_handle_response() called ubus_msg_send(,,free=true) before returning -1
* ubus_msg_send() would call ubus_msg_send(,,free=false)
* all other callback callers would `ubus_msg_send(,,free=true)`
  (free the buffers in ubus_msg_send() )

In all other places, where `ubus_msg_send(,,free=true)`
an explicit `ubus_msg_free()` was added.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2017-11-13 09:55:19 +01:00
amine ahd
df088f03c0 Allow sending a fd along a ubus_request
Signed-off-by: amine.ahd <amine.ahd@gmail.com>
2016-12-24 14:31:04 +01:00
Felix Fietkau
5ca6bae3a2 ubusd: fix id lookup of objects with path and no methods
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-12-24 14:30:13 +01:00
Felix Fietkau
fd61773031 ubusd_proto: fix crash when trying to subscribe to system objects
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-11-20 16:40:06 +01:00
Felix Fietkau
686c05d738 ubusd: fix sending remove-object notification
Patch by Delio Brignoli <brignoli.delio@gmail.com>

Both ubusd_free_object (eventually via ubusd_create_object_event_msg)
and ubus_proto_send_msg_from_blob() use the same message buffer.
So ubusd_handle_remove_object builds the payload which gets (indirectly)
overwritten by the call to ubusd_free_object and then sent again by
ubus_proto_send_msg_from_blob.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-08-23 12:55:09 +02:00
Felix Fietkau
b405050ceb ubusd: add missing NULL pointer checks for obj->type
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-08-23 11:36:41 +02:00
Felix Fietkau
619f3a160d ubusd: fix a memory leak on user/group client info
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-01-26 10:10:39 +01:00
Felix Fietkau
8c9322c723 ubusd: fix the return code for acl check mismatch
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 19:48:08 +01:00
John Crispin
3df5b18af2 hook acl into ubusd
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
9ffec46f73 make ubus_proto_send_msg_from_blob() none static
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
8c992a556b make ubus_parse_msg() none static
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
ba607d976b pass ubus_msg_buf to callback of internal object
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
df0292c3af remove obseleted validation of key
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
Hans Dedecker
7798d56301 ubus: Fix issues reported by static code analysis tool Klocwork
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2015-04-20 15:43:19 +02:00
Zefir Kurtisi
4d1cdc5527 libubus: replace __init with __constructor
__init has a naming collision with C++ and prevents ubus_common.h
from being included. Instead, use __constructor as defined from
libubox.

Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
2014-09-17 13:29:24 +02:00
Felix Fietkau
7c9e76ed08 ubusd: fix processing object method signatures
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-01 13:45:29 +02:00
Felix Fietkau
37cc5d2f25 ubusd: implement protocol support for passing file descriptors as part of request completion msgs from objects to clients
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-02-18 15:03:53 +01:00
Felix Fietkau
79c40c95db ubusd: implement notify forwarding with status reporting
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-15 00:32:27 +01:00
Felix Fietkau
0fccce4445 remove the "method" argument for object subscription
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-14 13:11:40 +01:00
Felix Fietkau
a69f062cbd ubus: add notification for subscribers present/gone
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-14 13:00:57 +01:00
Felix Fietkau
d366a6de83 watch add/remove -> subscribe/unsubscribe:
rename the ADD_WATCH/REMOVE_WATCH messages to SUBSCRIBE/UNSUBSCRIBE and change
the message format and libubus API in preparation for adding object notifications

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-13 19:35:38 +01:00
Felix Fietkau
c6f7054515 ubusd: add support for watching objects to get notified when they go away 2012-05-19 21:09:35 +02:00
Felix Fietkau
3706552c1c fix unused but set variable 2011-10-28 22:21:52 +02:00
Felix Fietkau
f86ec180c0 ubusd: fix a use after free bug 2011-09-14 17:09:19 +02:00
Felix Fietkau
42bc27ae38 add copyright/license information 2011-06-17 16:35:11 +02:00
Felix Fietkau
27a16f8b1d remove some duplication 2011-02-07 03:01:36 +01:00
Felix Fietkau
37e914937b move more protocol related stuff to ubusd_proto.c 2011-02-07 02:59:09 +01:00
Felix Fietkau
1643f728e7 make ubusd_get_client_by_id static 2011-02-07 02:40:40 +01:00
Felix Fietkau
c4c0a2256d make ubus_parse_msg static 2011-02-07 02:38:57 +01:00
Felix Fietkau
f9f602533a add code for sending events and fix the code for receiving events 2011-02-07 01:25:28 +01:00
Felix Fietkau
d2f9e766ff implement a handler for UBUS_MSG_REMOVE_OBJECT 2011-02-06 21:41:29 +01:00
Felix Fietkau
cb1feedb5e follow blob_get_int* -> blob_get_u* rename 2011-02-06 21:37:37 +01:00
Felix Fietkau
f8d55af76b rename publish to add_object 2011-02-06 21:33:03 +01:00
Felix Fietkau
a84c6cac9a fix message buffering 2011-02-05 20:50:08 +01:00
Felix Fietkau
f6a6b0d492 add functionality for registering anonymous objects as event listeners 2011-02-05 19:53:14 +01:00
Felix Fietkau
fa989780bd add some stub functionality for the ubus event switch 2011-02-05 01:29:52 +01:00
Felix Fietkau
480a3d66a7 export the object type through lookup calls 2011-01-31 18:26:09 +01:00
Felix Fietkau
2e92ac29c1 cleanup, pass both data and status messages on to other clients 2011-01-31 16:32:29 +01:00
Felix Fietkau
a03acea49c remove support for path based invoke, add object id validation for responses 2011-01-31 16:25:22 +01:00
Felix Fietkau
527d252333 remove path based invoke functions, add stub implementation for invoking method calls 2011-01-31 02:41:32 +01:00
Felix Fietkau
8321f8c523 add stubs for invoke 2011-01-30 23:57:14 +01:00
Felix Fietkau
dbd4c2f121 Initial import 2011-01-30 14:16:09 +01:00