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.
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.
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.
This fixes recursion problems on config reload in netifd and simplifies
application handling of requests
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This allows sharing a policy array across methods, but masking out
unused entries for individual methods.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
The lua getglobal and rawgeti both push a value onto the lua stack,
but they weren't being removed by the ubus_method_handler function,
thus corrupting the lua stack.
In case the specified method wasn't a function, the stack was also
corrupted as the method name remained on the stack.
Signed-off-by: Karl Vogel <karl.vogel@gmail.com>
In C it is possible to have methods without arguments (UBUS_METHOD_NOARG).
Enable support for the same calls in Lua too.
This commit also fixes segfault which can be caused by passing non-table type
where table is expected. The lua_gettablelen() function is called after we have
made sure we are dealing with a table in the first place.
Signed-off-by: Luka Perkov <luka@openwrt.org>
It mostly mimick the style of the existing code.
With it and the ubox Lua bindings, you can now send ubus events
through Lua or listen for events (you can register for multiple events
at the same time).
Signed-off-by: Jeff Remy <jeff.remy@gmail.com>
When process unsubscribes then remove callback is called. But it
can be NULL if not defined, so we should check it before we call it.
Signed-off-by: Lukasz Baj <l.baj@radytek.com>
All iov's were sent only after the last were sent (iov_len == 0). We
could have 'cur_len == 0' if the sent iov's were sent wholly but not all
iov's were sent (how about all but the last).
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
When synchronous request completion loops are running, the innermost
loop can receive events that can unblock the outer loops, however the
loop clears uloop_cancelled (which is set by the request completion).
This causes the event loop to continue running even while a completion
loop has already been unblocked.
Fix this by not clearing uloop_cancelled for inner loops
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This adds basic systemd support, incl. socket activation.
If systemd build is disabled, there won't be any sign of it neither
during build nor after.
If systemd build is enabled (default), but systemd is not available,
no systemd stuff is installed, so there is no impact whatsoever.
this is mainly useful to have a single location to read the setting
from, when it is used multiple times at build time (which it will in a
following patch) :)