summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)Author
11 daysMerge pull request #282 from nbd168/ubusHEADmasterJo-Philipp Wich
ubus deferred request enhancements
11 daysubus: fix uninitialized variable warningJo-Philipp Wich
Explicitly zero-initialize `obi` in `_args_get()` to avoid the following compiler warning: .../ubus.c: In function ‘_args_get’: .../ubus.c:100:31: error: ‘obj’ may be used uninitialized [-Werror=maybe-uninitialized] 100 | arg = ucv_object_get(obj, name, NULL); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
11 daysubus: remove broken implied await when calling defer() outside of uloop.run()Felix Fietkau
Calling ubus.defer() outside of uloop.run() was apparently broken since commit 1cb04f9b76e2 ("ubus: add object publishing, notify and subscribe support") from March 2022. It was supposed to block until the request completes, however it blocked forever due to a counter imbalance introduced by the above commit. These days this 'feature' is of questionable value, since req.await() exists, and there is a legitimate use for issuing deferred requests from outside of uloop.run() and then calling uloop.run() or req.await() afterwards. Since nobody noticed the breakage in all this time, let's just get rid of this API footgun. Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 daysubus: support sending multiple reply messages on a requestFelix Fietkau
When passing UBUS_STATUS_CONTINUE (or -1) in the return code argument, assume that more reply calls are coming and only send a reply data message without the status code. Signed-off-by: Felix Fietkau <nbd@nbd.name> [minor whitespace changes] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
11 daysubus: add channel defer() methodFelix Fietkau
Works in the same way as regular defer calls, except that it operates on channels. Signed-off-by: Felix Fietkau <nbd@nbd.name> [use errval_return(), minor whitespace changes] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
11 daysubus: add errval_return() helper macroJo-Philipp Wich
Add a local helper macro errval_return() which sets a local error code and returns it. Also do some minor whitespace and code style fixes while we're at it. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-03-06Merge pull request #284 from nbd168/socket-reuseaddrJo-Philipp Wich
socket: add missing documentation for socket.listen() reuseaddr
2025-03-06socket: add missing documentation for socket.listen() reuseaddrFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-03-06Merge pull request #281 from nbd168/uciJo-Philipp Wich
uci: add support for altering the override config directory
2025-03-06Merge pull request #283 from nbd168/socket-reuseaddrJo-Philipp Wich
socket: add reuseaddr argument for socket.listen()
2025-03-06uci: add support for altering the override config directoryFelix Fietkau
This was added to libuci recently Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-03-06socket: add reuseaddr argument for socket.listen()Felix Fietkau
This socket option needs to be set before the bind call(). Since it's very commonly used, adding a parameter for it makes sense. Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-02-21Merge pull request #278 from nbd168/ubus-objJo-Philipp Wich
ubus: add support for calling system objects
2025-02-21ubus: add support for calling system objectsFelix Fietkau
Support passing integer object instead of string in ubus.call(). This makes it possible to query ACL data: let data = ubus.call(libubus.SYSTEM_OBJECT_ACL, "query"); Signed-off-by: Felix Fietkau <nbd@nbd.name> [adjust formatting, rebase] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-02-20docs: add detailed documentation article for dictionariesJo-Philipp Wich
To complement the array article, add another one about dictionaries to document common approaches and pitfalls. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-02-20uci: link save() and commit() functions in cursor class descriptionJo-Philipp Wich
In order to make the nested uci.cursor class description easier to discover, turn the mentioned `save()` and `commit()` functions into proper links pointing into the cursor class documentation. Ref: #277 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-02-20docs: add article with array specific informationJo-Philipp Wich
Ref: #277 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-02-20docs: cover switch statement in syntax articleJo-Philipp Wich
Ref: #277 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-02-20WIP: lib: support map() over objectsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-02-20zlib: add stream-oriented inflate operationsThibaut VARÈNE
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
2025-02-20zlib: add stream-oriented deflate operationsThibaut VARÈNE
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
2025-02-20zlib: deduplicate codeThibaut VARÈNE
No functional change Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
2025-02-20zlib: rework code logicThibaut VARÈNE
Prepare for stream-oriented operations Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
2025-02-20Merge pull request #280 from jow-/uci-list-manipulationJo-Philipp Wich
uci: implement cursor.list_append() and cursor.list_remove()
2025-02-20uci: implement cursor.list_append() and cursor.list_remove()Jo-Philipp Wich
Introduce two new functions list_append(conf, section, option, value) and list_remove(conf, section, option, value) which add and remove values from uci list options, respectively. Fixes: #279 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-02-10Merge pull request #276 from nbd168/frame-fixJo-Philipp Wich
vm: fix crash due to stale frame pointer
2025-02-10vm: fix crash due to stale frame pointerFelix Fietkau
In some cases, calls made while processing insns in uc_vm_execute_chunk can lead to realloc of vm->callframes without reloading the current frame pointer. This was observed with I_ADD (which can call an object's tostring method). Instead of playing whac-a-mole with insns affecting the frame pointer, let's reload it whenever necessary. Signed-off-by: Felix Fietkau <nbd@nbd.name> [further refactor to avoid redundant null pointer checks, fix native function callframe stop condition while looking for exception handler] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-02-06Merge pull request #269 from jonasjelonek/improve-ioctlJo-Philipp Wich
fs: improve ioctl implementation
2025-02-05Merge pull request #263 from nbd168/ubus-fdJo-Philipp Wich
ubus file descriptor passing and channel support
2025-02-04ubus: add support for channelsFelix Fietkau
A channel is a context that is directly connected to a peer instead of going through ubusd. The use of this context is limited to calling ubus_invoke and receiving requests not bound to any registered object. The main use case for this is having a more stateful interaction between processes. A service using channels can attach metadata to each individual channel and keep track of its lifetime, which is not possible through the regular subscribe/notify mechanism. Using channels also improves request latency, since messages are passed directly between processes. A channel can either be opened by fd using ubus.open_channel(), or created from within a request by using req.new_channel(). When calling req.new_channel, the fd for the other side of the channel is automatically passed to the remote caller. Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-02-04ubus: add support for receiving file descriptors in call and deferFelix Fietkau
Add a named parameter fd_cb, which is called when the callee returned a file descriptor. Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-02-04ubus: add support for sending file descriptors via ubus.call/deferFelix Fietkau
File descriptors can be passed via the named fd argument Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-02-04ubus: add request get_fd/set_fd methodsFelix Fietkau
This can be used to send and receive file descriptors from within an object method call. Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-02-04ubus: add defer.await() methodFelix Fietkau
This can be used to synchronously complete a deferred ubus request, waiting for completion or timeout. Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-02-04fs: ioctl: improve ioctl read to avoid allocating twiceJonas Jelonek
Allocate memory for 'uc_string_t' with the proper size upfront and use it's internal buffer as ioctl buffer. This avoids redundant 'ucv_string_new_length' calls and thus allocating memory a second time. Also simplify the signature of the function, using a single parameter for handling size and input buffer values. Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com> [simplify arguments, adjust documentation, prevent in-place string modifications] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-02-04fs: ioctl: export constants for direction valuesJonas Jelonek
Exports IOC_DIR_* constants to use for the direction parameter instead of plain integer values. The constants are based on the target's _IOC_* definitions. Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
2025-02-04Merge pull request #268 from stokito/fix-debian-lintianJo-Philipp Wich
debian: fix lintian warnings
2025-02-04Merge pull request #274 from jow-/socket-filter-sockopt-supportJo-Philipp Wich
socket: properly support SO_ATTACH_FILTER sockopt
2025-02-04ubus: add named parameter support in functions with many paramsFelix Fietkau
When a function supports many parameters, the order can be somewhat confusing, especially when dealing with several optional ones. In order to make this easier to use, support for passing an object with named parameters. for example: obj.notify("test", data, null, null, null, 1000); can be written as: obj.notify({ method: "test", data, timeout: 1000 }); Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-02-04socket: properly support SO_ATTACH_FILTER sockoptJo-Philipp Wich
The SO_ATTACH_FILTER socket option requires special handling as it is not passing a self-contained structure to the kernel but a pointer to user memory holding the actual BPF bytecode. In order to properly support this, first rework the ucode value to C struct conversion callback machinery to pass an indirect struct base pointer, allowing conversion callbacks to realloc the struct memory as needed. Finally introduce custom uv to C conversion for the BPF data which accepts either a raw bytecode string, an array of opcode arrays or a flat array of opcode values which are converted into a C array of struct sock_filter records appended to the reallocated struct memory. Attaching a BPF program equivalent to the tcpdump expression `vlan 20 && ether proto 0x1234` would then look like this: sock.setopt(SOL_SOCKET, SO_ATTACH_FILTER, { filter: [ [ 0x28, 0, 0, 0x0000000c ], [ 0x15, 2, 0, 0x00008100 ], [ 0x15, 1, 0, 0x000088a8 ], [ 0x15, 0, 6, 0x00009100 ], [ 0x28, 0, 0, 0x0000000e ], [ 0x54, 0, 0, 0x00000fff ], [ 0x15, 0, 3, 0x00000014 ], [ 0x28, 0, 0, 0x00000010 ], [ 0x15, 0, 1, 0x00001234 ], [ 0x6, 0, 0, 0x00040000 ], [ 0x6, 0, 0, 0x00000000 ], ] }); Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-02-01ci: bump actions/upload-artifact to v4Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-02-01rtnl: properly handle runtime exceptions in listener callbackJo-Philipp Wich
Avoid re-invoking any event listener callbacks after an invocation triggered an exception in order to avoid accidentially clearing the exception information. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-01-25Merge pull request #271 from jow-/socket-fixesJo-Philipp Wich
socket: fix AF_PACKET recvmsg() and sockaddr formatting
2025-01-25socket: fix AF_PACKET recvmsg() and sockaddr formattingJo-Philipp Wich
- Do not unconditionally pass the `MSG_CMSG_CLOEXEC` flag to `recvmsg()` invocations as not all protocol specific recvmsg implementations in the kernel tolerate it; `packet_recvmsg()` for example will immediately return yield `EINVAL` if any non-whitelisted flag is passed. - Ensure that the HW address string buffer is zero-terminated when converting MAC addresses from C to ucode values. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2025-01-24Merge pull request #270 from nbd168/argv0Jo-Philipp Wich
main: add global ARGV0 variable
2025-01-24main: add global SCRIPT_NAME variableFelix Fietkau
Fill it with the command line provided path to the source file Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-01-22Merge pull request #266 from aparcar/libmdJo-Philipp Wich
docs: Mention `libmd` in macOS docs
2025-01-22Merge pull request #267 from aparcar/macosJo-Philipp Wich
docs: Fix compilation command for macOS
2025-01-19debian: ignore lintian warning no-manual-pageSergey Ponomarev
2025-01-18.gitignore: ignore files generated by debuildSergey Ponomarev