Age | Commit message (Collapse) | Author |
|
ubus deferred request enhancements
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
socket: add missing documentation for socket.listen() reuseaddr
|
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
uci: add support for altering the override config directory
|
|
socket: add reuseaddr argument for socket.listen()
|
|
This was added to libuci recently
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
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>
|
|
ubus: add support for calling system objects
|
|
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>
|
|
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>
|
|
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>
|
|
Ref: #277
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Ref: #277
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
|
|
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
|
|
No functional change
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
|
|
Prepare for stream-oriented operations
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
|
|
uci: implement cursor.list_append() and cursor.list_remove()
|
|
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>
|
|
vm: fix crash due to stale frame pointer
|
|
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>
|
|
fs: improve ioctl implementation
|
|
ubus file descriptor passing and channel support
|
|
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>
|
|
Add a named parameter fd_cb, which is called when the callee returned a
file descriptor.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
File descriptors can be passed via the named fd argument
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
This can be used to send and receive file descriptors from within an object
method call.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
This can be used to synchronously complete a deferred ubus request,
waiting for completion or timeout.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
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>
|
|
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>
|
|
debian: fix lintian warnings
|
|
socket: properly support SO_ATTACH_FILTER sockopt
|
|
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>
|
|
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>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
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>
|
|
socket: fix AF_PACKET recvmsg() and sockaddr formatting
|
|
- 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>
|
|
main: add global ARGV0 variable
|
|
Fill it with the command line provided path to the source file
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
docs: Mention `libmd` in macOS docs
|
|
docs: Fix compilation command for macOS
|
|
|
|
|