Commit graph

237 commits

Author SHA1 Message Date
Felix Fietkau
635ada4251 libubus: add socket EOF handling to ubus_complete_request()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 18:35:07 +01:00
Felix Fietkau
04e644bcce libubus: fix error handling during close after partially receiving a message
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 18:26:43 +01:00
Felix Fietkau
83461b9791 ubusd: make ACL path configurable on the command line
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 17:44:00 +01:00
Felix Fietkau
152dd96f63 ubusd: remove a faulty and redundant check
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 17:36:08 +01:00
Karl Vogel
f09d18878b ubus: Correct usage of timeout on poll function
As the man page explains:

"Specifying a timeout of zero causes poll() to return immediately,
even if no file descriptors are ready."

The use of 0 as timeout could cause libubus to busy loop if the
socket was non-blocking. For blocking sockets, this was less
apparent as the subsequent read() would then block.

Signed-off-by: Karl Vogel <karl.vogel@gmail.com>
2015-12-07 18:03:13 +01:00
Felix Fietkau
259450f414 cli: add monitor support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-19 22:32:29 +01:00
Felix Fietkau
44a62711e0 libubus: add monitor support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-19 22:32:25 +01:00
Felix Fietkau
47d75dd84a ubusd: add monitor support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-19 22:32:11 +01:00
Hans Dedecker
95648dadba libubus: Fix reverse order processing of pending ubus notifications messages
Append ubus notification messages to the tail of the pending list
so they're processed in the order as they're put onto the pending list

Signed-off-by: Xinxing Hu <xinxing.huchn@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2015-11-02 19:02:53 +01:00
Hans Dedecker
d23b07a9ff lua: Fix stack imbalance in ubus_event_handler
The value from getglobal wasn't being removed from the stack,
resulting in an ever growing stack in the ubus event handler.

Signed-off-by: Karl Vogel <karl.vogel@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2015-11-02 19:02:35 +01:00
John Crispin
33b2abf631 fix off-by-one in acl match iteration
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-09-22 06:20:55 +02:00
John Crispin
f7f899d2d3 unbreak acl allocation
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-09-22 06:12:08 +02:00
John Crispin
7ec9b8dec7 fix a copy & paste bug
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-07-01 02:22:36 +02:00
Felix Fietkau
ab1bffddb3 ubusd: fix offset calculation (based on patch by Yang Chao)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-07-06 18:42:36 +02:00
Felix Fietkau
e59b445734 ubusd: fix build on non-linux systems without peercred support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-06-24 18:28:37 +02:00
John Crispin
b2e629a4e9 change socket permission to allow !root users to connect
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02: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
2cfdb81889 hook acl into libubus
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
8309c75828 add acl code
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
3bfa6ab128 make ubusd load the acl on start and HUP
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
e3815962c1 add optional tags to the ubus methos struct and the wrapper macros
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
6c0fa3a8cf call openlog on startup
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
0bb927125f make ubusd_send_event() 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
陈斌
f361bfa5fc lua: fix memory leak problem
Signed-off-by: Chen Bin <ewolfok@126.com>
2015-05-25 23:06:19 +02:00
Felix Fietkau
2c30506a4f cli: flush stdout after printing an event
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-05-12 16:56:09 +02:00
Hans Dedecker
38174a05a5 ubus: Fix memleak in examples/client in case of failure
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2015-05-08 12:06:39 +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
Felix Fietkau
2d660c519d libubus: fix processing queued messages after blocking requests
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-01-22 13:30:20 +01:00
Delio Brignoli
7b79b6226e libubus: expose ubus_connect_ctx() in public API
ubus_connect_ctx() is equivalent to ubus_connect() but accepts a
pointer to a previously allocated ubus_context struct.
ubus_shutdown() is made available as an alternative to ubus_free()
to clean up contexts initialised by ubus_connect_ctx().

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2014-10-14 09:57:11 +02:00
Felix Fietkau
4c4f35cf22 libubus: define _GNU_SOURCE, needed for O_CLOEXEC
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-17 13:32:43 +02:00
Zefir Kurtisi
9841dae95a libubus: fix build error in examples/server
This fixes build warning:
/ubus.git/examples/server.c: In function 'test_hello_reply':
/ubus.git/examples/server.c:69:6: error: ignoring return value of 'pipe', declared with attribute warn_unused_result [-Werror=unused-result]

Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
2014-09-17 13:29:30 +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
Alexandru Ardelean
e52db46c9c libubus: restore uloop_cancelled on timeout
Context: 1 loop with a single ubus_invoke() that times out calls
uloop_end() which ends the loop, and thus ends the application.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-15 15:48:54 +02:00
Felix Fietkau
9562291f68 libubus: preserve the received message buffer for incoming invoke calls
Set ctx->msgbuf.data to NULL during the call. If ctx->msgbuf is needed
during the call, a new buffer will be allocated. If not,
ctx->msgbuf.data is restored to the previous value afterwards

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-15 15:40:07 +02:00
Felix Fietkau
6a285141d9 libubus: rework buffer allocation code
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-15 15:36:03 +02:00
Felix Fietkau
3e45a782b2 libubus: remove ubus_msghdr_data() by passing in the right data structure pointer
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-15 15:33:27 +02:00
Felix Fietkau
7c25c119a5 libubus: use calloc_a for queued msgs to reduce the number of allocations
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-15 15:21:40 +02:00
Felix Fietkau
73cbb94b48 libubus: fix a small memleak in ubus_register_event_handler()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-04 20:01:13 +02:00
Alexandru Ardelean
6280cbaf09 libubus: fix msgbuf reduction logic during receive
Signed-off-by: Alexandru Ardelean <aa@ocedo.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-08-31 14:12:55 +02:00
Felix Fietkau
b79e808944 libubus: mark ubus socket with close-on-exec
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-08-31 14:10:26 +02:00
Felix Fietkau
f688c7ad0b libubus: use explicit type name in ubus_msghdr_data instead of typeof()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-07-03 20:58:37 +02:00
Felix Fietkau
382a05f54d libubus: move ubus_msghdr_data to libubus-internal.h
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-07-03 20:58:01 +02:00
Alexandru Ardelean
af63ab64af ubus: add count test to validate large message sizes
Client creates a string "1 2 3 ... 10000 ...", sends it to the server
along with the maximum number in the string.

Server creates another string like the client sent.

It validates it and, returns strcmp()'s result.

This is loop-ed every 2 seconds.
2014-07-03 12:47:11 +02:00
Alexandru Ardelean
f47005a44c libubus: fix ubus_invoke() to return err in case ubus_start_request() fails
Seems the UBUS_MAX_MSGLEN is ignored by ubus_invoke(),
and then segfault happens.

This issue is present before this set of patches.
2014-07-03 12:46:44 +02:00
Alexandru Ardelean
996e16b2cb ubusd: replace ubusd_msg_unshare() with ubus_msg_new() to prevent invalid free-ing
The realloc is problematic mostly with large packets, as the pointer changes
so what eventually gets free'd is invalid.
Note that ub ptr param in the  call will be passed on to a ubus_msg_free(),
right after ubus_msg_ref() finishes.

This bug stayed hidden the same way as the bug in libubus writev_retry().
Since the write/sendmsg function can send about ~200k the ubus_msg_enqueue()
call does not get triggered.
2014-07-03 12:45:49 +02:00
Alexandru Ardelean
5db90dbc94 libubus: fix writev_retry() function when writing large packets
Seems this bug stayed hidden for a while, because the write/sendmsg function
can send up to ~200k in one send, so it looked at first why there was
some data mismatch.
2014-07-03 12:45:30 +02:00