Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ubus file descriptor passing and channel support #263

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nbd168
Copy link
Contributor

@nbd168 nbd168 commented Jan 1, 2025

Happy new year!
These changes implement support for the various ways of passing file descriptors via ubus, as well as opening channels.

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 <[email protected]>
This can be used to synchronously complete a deferred ubus request,
waiting for completion or timeout.

Signed-off-by: Felix Fietkau <[email protected]>
This can be used to send and receive file descriptors from within an object
method call.

Signed-off-by: Felix Fietkau <[email protected]>
File descriptors can be passed via the named fd argument

Signed-off-by: Felix Fietkau <[email protected]>
Add a named parameter fd_cb, which is called when the callee returned a
file descriptor.

Signed-off-by: Felix Fietkau <[email protected]>
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 <[email protected]>
@nbd168 nbd168 changed the title ubus file descriptor passing support ubus file descriptor passing and channel support Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant