1
1

ucode: update to Git HEAD (2026-04-24)

3d999b21f4ba socket: add include for older kernels
552ca3cf55ed compiler: allow export function declarations without trailing semicolon
d9e24e4ad13d compiler: add function forward declaration syntax
de986520017a fs: add statvfs flags and fs error codes
e6bf0a9dca79 nl80211: fix listener.request() dropping multicast events
520d9f4c8781 nl80211: fix waitfor() busy-spinning on non-blocking event socket
05328e33f078 nl80211: fix memory leak in waitfor() on repeated matching events
e4a165976dbb nl80211: don't report waitfor() match on event parse failure
57367e880e9d nl80211: add missing survey info attributes
a39b74fe329e nl80211: fix dfs_cac_time attribute type
beafcff845fc compiler, lib, resolv: fix const string pointers
4170c8dcc568 lib: fix system() inheriting blocked SIGCHLD mask in child process
d2c74298e22d fs: document glob
8a8b4d12a867 types: fix regexp `/.../s` flag inversion
d7bc7adcb99d lib: slightly expand regexp() JSDoc
826fbfef2df9 nl80211: fix HE MCS set parsing
617967a3ceb9 socket: strip brackets from IPv6 addresses in addrinfo()
a078b72a90bb socket: increase IPv6 scope ID buffer to support 15-char interface names
ed23cf5aa182 rtnl, nl80211: fix segfault when listener.close() is called explicitly
3e585662394b docs: add function forward declarations to syntax tutorial
bda4a0e454de vm: free thread context on vm_free to prevent memory leak
13158a73c96b nl80211: get iftype extended capabilites
30ffbd6c07dc ubus: add module documentation
ce0c8fc0ffea docs: spelling fixes and usage notes
35a74e92ad69 docs: rewrite ubus module intro to expand pub/sub and fix OpenWrt capitalization
b3380068a7e1 docs: flatten ubus class hierarchy and fix capitalization
3c9d3b5272d7 docs: math: fix spelling mistakes in documentation
aae2250ab519 fs: fix popen() documentation
eff52f0d262a digest: implement FNV-1a 64 bit hash algorithm
35ed1d1efd64 ubus: fix refcounting bug
c7e7dfa7b64a ubus: avoid double close of externally owned channel fds
896ac72caffb tests: make run_tests.uc default to build/
b50372e8e8a0 tests: implement automatic library test skipping
81066c54a07f math: degrees <-> radians convertors
388ef3f35e0a ubus: drop unconditional garbage collection calls
aebdb2c0262e main: fix option argument parsing on glibc

Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau 2026-04-14 15:36:04 +00:00
parent bcaa6a8367
commit 4ae4759e0b
7 changed files with 3 additions and 275 deletions

View File

@ -12,9 +12,9 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=https://github.com/jow-/ucode.git
PKG_SOURCE_DATE:=2026-02-27
PKG_SOURCE_VERSION:=934bb593dba520e84920865703bd4fe94490d11e
PKG_MIRROR_HASH:=baa59093c5a32303f64c2507664f7b36e2b7b7c14ed65524e5d1130633e5b639
PKG_SOURCE_DATE:=2026-04-24
PKG_SOURCE_VERSION:=0beaa9dc244f16c52c0a7dc3f180cca0539124cd
PKG_MIRROR_HASH:=9a58c061541cd98d248335c351a10049823a0dd317475fa0be73593c6d90a70a
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
PKG_LICENSE:=ISC

View File

@ -1,20 +0,0 @@
From 165d395ffa2a22e293160b24d4791302a156eab8 Mon Sep 17 00:00:00 2001
From: Rosen Penev <rosenp@gmail.com>
Date: Mon, 8 Dec 2025 12:48:01 -0800
Subject: add include for older kernels
in6.h is needed for some macros. Seems newer kernels include this implicitly.
---
lib/socket.c | 1 +
1 file changed, 1 insertion(+)
--- a/lib/socket.c
+++ b/lib/socket.c
@@ -77,6 +77,7 @@
#include "ucode/platform.h"
#if defined(__linux__)
+# include <linux/in6.h>
# include <linux/if_packet.h>
# include <linux/filter.h>

View File

@ -1,25 +0,0 @@
From: Felix Fietkau <nbd@nbd.name>
Date: Fri, 6 Feb 2026 19:04:54 +0000
Subject: [PATCH] ubus: fix refcounting bug
In uc_ubus_channel_req_cb an extra ref is taken for args and method,
which are not used elsewhere.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
--- a/lib/ubus.c
+++ b/lib/ubus.c
@@ -2395,10 +2395,10 @@ uc_ubus_channel_req_cb(struct ubus_conte
args = blob_array_to_ucv(c->vm, blob_data(msg), blob_len(msg), true);
reqproto = ucv_object_new(c->vm);
- ucv_object_add(reqproto, "args", ucv_get(args));
+ ucv_object_add(reqproto, "args", args);
if (method)
- ucv_object_add(reqproto, "type", ucv_get(ucv_string_new(method)));
+ ucv_object_add(reqproto, "type", ucv_string_new(method));
return uc_ubus_handle_reply_common(ctx, req, c->vm, c->res, func, reqproto);
}

View File

@ -1,130 +0,0 @@
From: Felix Fietkau <nbd@nbd.name>
Date: Fri, 6 Feb 2026 20:19:59 +0000
Subject: [PATCH] ubus: avoid double close of externally owned channel fds
When a channel is opened via an fd obtained through fileno(), the fd is
owned by an external resource. Track this in fd_handle and detach from
uloop without closing the fd on disconnect/shutdown.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
--- a/lib/ubus.c
+++ b/lib/ubus.c
@@ -132,6 +132,7 @@ typedef struct {
struct ubus_context ctx;
struct blob_buf buf;
int timeout;
+ bool fd_handle;
uc_vm_t *vm;
uc_value_t *res;
@@ -739,7 +740,7 @@ uc_ubus_call_timeout_cb(struct uloop_tim
}
static int
-get_fd(uc_vm_t *vm, uc_value_t *val)
+get_fd(uc_vm_t *vm, uc_value_t *val, bool *handle)
{
uc_value_t *fn;
int64_t n;
@@ -747,6 +748,9 @@ get_fd(uc_vm_t *vm, uc_value_t *val)
fn = ucv_property_get(val, "fileno");
if (ucv_is_callable(fn)) {
+ if (handle)
+ *handle = true;
+
uc_vm_stack_push(vm, ucv_get(val));
uc_vm_stack_push(vm, ucv_get(fn));
@@ -816,7 +820,7 @@ uc_ubus_call_common(uc_vm_t *vm, uc_ubus
ucv_object_to_blob(funargs, &c->buf);
if (fd) {
- fd_val = get_fd(vm, fd);
+ fd_val = get_fd(vm, fd, NULL);
if (fd_val < 0)
errval_return(UBUS_STATUS_INVALID_ARGUMENT,
@@ -938,7 +942,7 @@ uc_ubus_defer_common(uc_vm_t *vm, uc_ubu
ucv_object_to_blob(funargs, &c->buf);
if (fd) {
- fd_val = get_fd(vm, fd);
+ fd_val = get_fd(vm, fd, NULL);
if (fd_val < 0)
errval_return(UBUS_STATUS_INVALID_ARGUMENT,
@@ -1174,7 +1178,7 @@ uc_ubus_request_set_fd(uc_vm_t *vm, size
if (!callctx)
err_return(UBUS_STATUS_INVALID_ARGUMENT, "Invalid call context");
- fd = get_fd(vm, uc_fn_arg(0));
+ fd = get_fd(vm, uc_fn_arg(0), NULL);
if (fd < 0)
err_return(UBUS_STATUS_INVALID_ARGUMENT, "Invalid file descriptor");
@@ -2313,6 +2317,10 @@ uc_ubus_disconnect(uc_vm_t *vm, size_t n
#ifdef HAVE_UBUS_FLUSH_REQUESTS
ubus_flush_requests(&c->ctx);
#endif
+ if (c->fd_handle) {
+ uloop_fd_delete(&c->ctx.sock);
+ c->ctx.sock.fd = -1;
+ }
ubus_shutdown(&c->ctx);
c->ctx.sock.fd = -1;
uc_ubus_put_res(&c->res);
@@ -2422,6 +2430,10 @@ uc_ubus_channel_disconnect_cb(struct ubu
blob_buf_free(&c->buf);
if (c->ctx.sock.fd >= 0) {
+ if (c->fd_handle) {
+ uloop_fd_delete(&c->ctx.sock);
+ c->ctx.sock.fd = -1;
+ }
ubus_shutdown(&c->ctx);
c->ctx.sock.fd = -1;
}
@@ -2486,6 +2498,7 @@ uc_ubus_channel_connect(uc_vm_t *vm, siz
{
#ifdef HAVE_UBUS_CHANNEL_SUPPORT
uc_value_t *fd, *cb, *disconnect_cb, *timeout;
+ bool handle = false;
uc_ubus_connection_t *c;
int fd_val;
@@ -2495,7 +2508,7 @@ uc_ubus_channel_connect(uc_vm_t *vm, siz
"disconnect_cb", UC_CLOSURE, true, &disconnect_cb,
"timeout", UC_INTEGER, true, &timeout);
- fd_val = get_fd(vm, fd);
+ fd_val = get_fd(vm, fd, &handle);
if (fd_val < 0)
err_return(UBUS_STATUS_INVALID_ARGUMENT, "Invalid file descriptor argument");
@@ -2505,6 +2518,8 @@ uc_ubus_channel_connect(uc_vm_t *vm, siz
if (!c)
return NULL;
+ c->fd_handle = handle;
+
if (ubus_channel_connect(&c->ctx, fd_val, cb ? uc_ubus_channel_req_cb : NULL)) {
ucv_put(c->res);
err_return(UBUS_STATUS_UNKNOWN_ERROR, "Unable to create ubus channel");
@@ -2602,8 +2617,13 @@ static void free_connection(void *ud) {
blob_buf_free(&conn->buf);
- if (conn->ctx.sock.fd >= 0)
+ if (conn->ctx.sock.fd >= 0) {
+ if (conn->fd_handle) {
+ uloop_fd_delete(&conn->ctx.sock);
+ conn->ctx.sock.fd = -1;
+ }
ubus_shutdown(&conn->ctx);
+ }
}
static void free_deferred(void *ud) {

View File

@ -1,36 +0,0 @@
From: Felix Fietkau <nbd@nbd.name>
Date: Sat, 28 Feb 2026 11:12:22 +0000
Subject: [PATCH] nl80211: add missing survey info attributes
Add in_use, time_bss_rx and frequency_offset to the survey info
nested attribute spec.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
--- a/lib/nl80211.c
+++ b/lib/nl80211.c
@@ -867,16 +867,19 @@ static const uc_nl_nested_spec_t nl80211
static const uc_nl_nested_spec_t nl80211_survey_info_nla = {
.headsize = 0,
- .nattrs = 8,
+ .nattrs = 11,
.attrs = {
{ NL80211_SURVEY_INFO_FREQUENCY, "frequency", DT_U32, 0, NULL },
+ { NL80211_SURVEY_INFO_NOISE, "noise", DT_S8, 0, NULL },
+ { NL80211_SURVEY_INFO_IN_USE, "in_use", DT_FLAG, 0, NULL },
{ NL80211_SURVEY_INFO_TIME, "time", DT_U64, 0, NULL },
- { NL80211_SURVEY_INFO_TIME_TX, "time_tx", DT_U64, 0, NULL },
- { NL80211_SURVEY_INFO_TIME_RX, "time_rx", DT_U64, 0, NULL },
{ NL80211_SURVEY_INFO_TIME_BUSY, "busy", DT_U64, 0, NULL },
{ NL80211_SURVEY_INFO_TIME_EXT_BUSY, "ext_busy", DT_U64, 0, NULL },
+ { NL80211_SURVEY_INFO_TIME_RX, "time_rx", DT_U64, 0, NULL },
+ { NL80211_SURVEY_INFO_TIME_TX, "time_tx", DT_U64, 0, NULL },
{ NL80211_SURVEY_INFO_TIME_SCAN, "scan", DT_U64, 0, NULL },
- { NL80211_SURVEY_INFO_NOISE, "noise", DT_S8, 0, NULL },
+ { NL80211_SURVEY_INFO_TIME_BSS_RX, "time_bss_rx", DT_U64, 0, NULL },
+ { NL80211_SURVEY_INFO_FREQUENCY_OFFSET, "frequency_offset", DT_U32, 0, NULL },
}
};

View File

@ -1,18 +0,0 @@
From: Felix Fietkau <nbd@nbd.name>
Date: Sun, 1 Mar 2026 15:32:06 +0000
Subject: [PATCH] nl80211: fix dfs_cac_time attribute type
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
--- a/lib/nl80211.c
+++ b/lib/nl80211.c
@@ -610,7 +610,7 @@ static const uc_nl_nested_spec_t nl80211
{ NL80211_FREQUENCY_ATTR_NO_HT40_PLUS, "no_ht40_plus", DT_FLAG, 0, NULL },
{ NL80211_FREQUENCY_ATTR_NO_80MHZ, "no_80mhz", DT_FLAG, 0, NULL },
{ NL80211_FREQUENCY_ATTR_NO_160MHZ, "no_160mhz", DT_FLAG, 0, NULL },
- { NL80211_FREQUENCY_ATTR_DFS_CAC_TIME, "dfs_cac_time", DT_FLAG, 0, NULL },
+ { NL80211_FREQUENCY_ATTR_DFS_CAC_TIME, "dfs_cac_time", DT_U32, 0, NULL },
{ NL80211_FREQUENCY_ATTR_INDOOR_ONLY, "indoor_only", DT_FLAG, 0, NULL },
{ NL80211_FREQUENCY_ATTR_IR_CONCURRENT, "ir_concurrent", DT_FLAG, 0, NULL },
{ NL80211_FREQUENCY_ATTR_NO_20MHZ, "no_20mhz", DT_FLAG, 0, NULL },

View File

@ -1,43 +0,0 @@
From: Felix Fietkau <nbd@nbd.name>
Date: Fri, 20 Mar 2026 11:53:30 +0000
Subject: [PATCH] nl80211: fix HE MCS set parsing
The Channel Width Set bits occupy B1-B4 of byte 0 of he_cap_phy.
Since this attribute is a byte array, not an integer, reading it via
nla_get_u16() produces an endian-dependent result. The << 8 shift was
correct on big-endian but wrong on little-endian.
Fix this by reading byte 0 directly as a uint8_t, making the check
endian-neutral.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
--- a/lib/nl80211.c
+++ b/lib/nl80211.c
@@ -1575,21 +1575,22 @@ uc_nl_convert_rta_he_mcs(const uc_nl_att
uint8_t bw_support_mask[] = { (1 << 1) | (1 << 2), (1 << 3), (1 << 4) };
uc_value_t *mcs_set, *mcs_bw, *mcs_dir, *mcs_entry, *mcs_idx;
uint16_t bw[] = { 80, 160, 8080 }, mcs[6];
- uint16_t u16, phy_cap_0 = 0;
+ uint8_t phy_cap_0 = 0;
+ uint16_t u16;
size_t i, j, k, l, max_idx;
if (!nla_check_len(attr, sizeof(mcs)))
return NULL;
if (nla_check_len(phy_attr, sizeof(phy_cap_0)))
- phy_cap_0 = nla_get_u16(phy_attr);
+ phy_cap_0 = *(uint8_t *)nla_data(phy_attr);
memcpy(mcs, nla_data(attr), sizeof(mcs));
mcs_set = ucv_array_new_length(vm, 3);
for (i = 0; i < ARRAY_SIZE(bw); i++) {
- if (!(phy_cap_0 & (bw_support_mask[i] << 8)))
+ if (!(phy_cap_0 & bw_support_mask[i]))
continue;
mcs_bw = ucv_object_new(vm);