libubus: reset ctx->sock.error when doing ubus reconnect When ubus connect fails ctx->sock.eof will be set but ctx->sock.error can be set as well. Reset ctx->sock.error as well when doing ubus reconnect Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
libubus: do not modify uloop_cancelled uloop_cancelled was used for two purposes within ubus_complete_request: - interrupting recursive requests on SIGINT/SIGTERM - breaking out of the poll loop in a recursive request that completed Saving/restorung uloop_cancelled was buggy, leading to SIGTERM not being processed properly. Simplify the logic by using a separate field for internal use Signed-off-by: Felix Fietkau <nbd@nbd.name>
libubus: reset ctx->sock.eof to fix reconnect issues Signed-off-by: Felix Fietkau <nbd@nbd.name>
Fix the length of msg buffer after realloc Signed-off-by: Rujun Wang <chinawrj@gmail.com>
ubus: use network order in ubus message header fields Changing the ubus message header fields from 'host' order to 'network' order allows passing ubus messages between hosts with different endianity. Example use (creating a ubus proxy): on host A (e.g. big endian router already running ubusd), run: $ socat TCP-LISTEN:5699,fork UNIX:/var/run/ubus.sock & On host B (e.g. little endian development PC) run: $ socat UNIX-LISTEN:/var/run/ubus.sock,fork TCP:<host A IP>:5699 & Now ubus applications can be run on host B and seamlessly interact with ubus applications on host A. Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
libubus: fix error handling during close after partially receiving a message Signed-off-by: Felix Fietkau <nbd@openwrt.org>
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>
libubus: define _GNU_SOURCE, needed for O_CLOEXEC Signed-off-by: Felix Fietkau <nbd@openwrt.org>
libubus: rework buffer allocation code Signed-off-by: Felix Fietkau <nbd@openwrt.org>
libubus: remove ubus_msghdr_data() by passing in the right data structure pointer Signed-off-by: Felix Fietkau <nbd@openwrt.org>
libubus: fix msgbuf reduction logic during receive Signed-off-by: Alexandru Ardelean <aa@ocedo.com> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
libubus: mark ubus socket with close-on-exec Signed-off-by: Felix Fietkau <nbd@openwrt.org>
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.
libubus: add logic to reduce msgbuf data size after 16 small messages
ubus: increase message size limit and make it configurable at build-time
libubus: refactor ubus_context msgbuf data to be dynamically allocated
libubus: do not use uloop_run() inside ubus_complete_request Avoid unrelated uloop callbacks by using poll() on the ubus fd instead. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
libubus: close file descriptor after passing it in the status msg Simplifies handling of non-deferred requests Signed-off-by: Felix Fietkau <nbd@openwrt.org>
libubus: implement file descriptor passing support Signed-off-by: Felix Fietkau <nbd@openwrt.org>
libubus: pull the variable length data array out of struct ubus_msghdr to fix builds with clang Signed-off-by: Felix Fietkau <nbd@openwrt.org>