From e8cffd29ccf812c67d5fc1159b5c5905aab283dc Mon Sep 17 00:00:00 2001 From: Chen Minqiang Date: Fri, 9 Oct 2026 00:32:36 +0800 Subject: [PATCH] rtnl, nl80211: return true on successful acknowledgment without data When a netlink request is acknowledged by the kernel (e.g. NL_CB_ACK received), cb_done() transitions the request state to STATE_REPLIED. However, because standard ACK messages carry no payload attributes, st.res remains NULL. Previously, both uc_nl_request() in rtnl and uc_nl_request_common() in nl80211 returned st.res directly under STATE_REPLIED, evaluating to null in ucode script context. This contradicts both the documented return type (@returns {Object|boolean} ... or true for successful acknowledgment without data) and the STATE_UNREPLIED case which already returns true. As a result, scripts checking if (!ret) or comparing against true falsely treat a successful request as a failure. Return ucv_boolean_new(true) when st.state is STATE_REPLIED and st.res is NULL, properly signaling success when acknowledged by the kernel. Signed-off-by: Chen Minqiang --- lib/nl80211.c | 2 +- lib/rtnl.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/nl80211.c b/lib/nl80211.c index 289ce7ae..0ba9bf3b 100644 --- a/lib/nl80211.c +++ b/lib/nl80211.c @@ -2867,7 +2867,7 @@ uc_nl_request_common(struct nl_sock *sock, uc_vm_t *vm, size_t nargs) switch (st.state) { case STATE_REPLIED: - return st.res; + return st.res ? st.res : ucv_boolean_new(true); case STATE_UNREPLIED: return ucv_boolean_new(true); diff --git a/lib/rtnl.c b/lib/rtnl.c index 6a32cb31..e64beffb 100644 --- a/lib/rtnl.c +++ b/lib/rtnl.c @@ -3542,7 +3542,8 @@ static const struct { * @param {number} flags - The netlink flags for the request * @param {*} payload - The payload data for the request * - * @returns {?*} - The response data or null on error + * @returns {Object|boolean} Response object from the kernel, true for + * successful acknowledgment without data, or false on error * * @example * // Send a route request @@ -3662,7 +3663,7 @@ uc_nl_request(uc_vm_t *vm, size_t nargs) switch (st.state) { case STATE_REPLIED: - return st.res; + return st.res ? st.res : ucv_boolean_new(true); case STATE_UNREPLIED: return ucv_boolean_new(true);