Skip to content

libubox: add boolean type support - #43

Open
BastienSAH wants to merge 2 commits into
openwrt:masterfrom
BastienSAH:add_bool_support
Open

libubox: add boolean type support#43
BastienSAH wants to merge 2 commits into
openwrt:masterfrom
BastienSAH:add_bool_support

Conversation

@BastienSAH

Copy link
Copy Markdown

Create a distinguished BLOBMSG_TYPE_BOOL in order to differenciate int8 and boolean types (both still use BLOB_ATTR_INT8 as storage format).

@BastienSAH

Copy link
Copy Markdown
Author

Ping @nbd168 @systemcrash @Alphix

@systemcrash

Copy link
Copy Markdown

Not sure how this interacts with ubus. ubus coerces u8 to bool. So bool is u8.

https://github.com/openwrt/ubus/blob/0d4bcb56f5e1386e7dc99f1ec9f3b6c9211c8ab6/cli.c#L466

Does this cause ABI breakage?

@Alphix

Alphix commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

I think this might intersect with #28; so you should probably get @Noltari into the loop?

@BastienSAH
BastienSAH force-pushed the add_bool_support branch 2 times, most recently from 4ba241f to 90705e4 Compare July 3, 2026 15:51
@BastienSAH
BastienSAH force-pushed the add_bool_support branch 3 times, most recently from 9b6cb9d to f7a85e3 Compare July 23, 2026 15:13
Create a distinguished BLOBMSG_TYPE_BOOL in order to differenciate int8 and boolean types (both still use BLOB_ATTR_INT8 as storage format).

Signed-off-by: Bastien BERNARD <bastien.bernard@softathome.com>
With the new distinguished BLOBMSG_TYPE_BOOL (equal to 8), libubox no longer can parse existing binary blobs compiled with BLOBMSG_TYPE_BOOL=BLOBMSG_TYPE_INT8 (equal to 7).
To fix that, allow an attribute encoded with BLOBMSG_TYPE_INT8, and whose policy indicates a BLOBMSG_TYPE_BOOL.

Signed-off-by: Bastien BERNARD <bastien.bernard@softathome.com>
@BastienSAH

Copy link
Copy Markdown
Author

@systemcrash: I indeed saw a regression in ubus, with the "ubus monitor" command. Some attributes like "no_reply" are now displayed as 1 instead of "true":
ubus -v monitor <- b6a665ab #9a10c460 notify: {"objid":-1710177184,..."no_reply":1}

I propose the following pull request to solve this: openwrt/ubus#25

Also, adding a boolean type indeed creates an ABI breakage, making one of the test failed (the test which parses procd-instance-nlbwmon.bin). I have added a second commit, to have backward compatibility with existing binary blobs.

@BastienSAH

BastienSAH commented Jul 28, 2026

Copy link
Copy Markdown
Author

@Alphix @Noltari: do you still plan to merge #28 ? In there a boolean function was added, but I think it would be nice to have a dedicated boolean type as well.
This would be useful for prplWRT, in which the system and other buses have the boolean type.
I have made tests which are OK, for example:

  • make a "ubus call" on a int8 parameter -> now the value is a real integer and not "true/false":
    ubus call WiFi.AccessPoint.1 _get -> { "WiFi.AccessPoint.1.": { "MultiAPProfile": 0,
    Before we had "MultiAPProfile": false

  • make a "ubus list" -> the int8 parameters are not marked as boolean anymore:
    ubus -v list hostapd.wlan0.3 -> 'hostapd.wlan0.3' @dfae2a16 "del_client":{"addr":"String","reason":"Integer","deauth":"Int8","ban_time":"Integer"}
    Before we had "deauth":"Boolean"

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.

3 participants