mwan3: fix empty rpcd integer state in 2.12.3

An empty mwan3track state file becomes NaN in the rpcd response. Default
failed integer conversions to zero, as the shell handler did.

Add a focused regression for the installed integer helpers in a separate
ucode file called from test.sh, and bump the package version.

Fixes: #29653
Signed-off-by: Yuen Su <zypulsecore@gmail.com>
This commit is contained in:
Yuen Su authored and Florian Eckert committed 2026-10-21 14:20:31 +02:00
1 parent 17c50f6eba
commit 2a5d230190
4 files changed
+24 -3

No files matched your search

+2 -2
View File
@@ -8,8 +8,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mwan3
PKG_VERSION:=2.12.2
PKG_RELEASE:=2
PKG_VERSION:=2.12.3
PKG_RELEASE:=1
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
PKG_LICENSE:=GPL-2.0
+1 -1
View File
@@ -14,7 +14,7 @@ function get_str(iface, property) {
}
function get_int(iface, property) {
return int(get_str(iface, property));
return int(get_str(iface, property)) || 0;
}
function get_uptime() {
+17
View File
@@ -0,0 +1,17 @@
import { readfile } from 'fs';
const source = readfile('/usr/share/rpcd/ucode/mwan3');
const begin = index(source, 'function get_str_raw(');
const end = index(source, 'function get_uptime(');
if (begin < 0 || end <= begin)
die('Cannot find mwan3 integer helpers\n');
const read_integer = loadstring(substr(source, begin, end - begin) +
'\nreturn get_int("wan", "SCORE");', { raw_mode: true });
for (let sample in [['', 0], [null, 0], ['\n', 0], ['invalid', 0],
['0', 0], ['17', 17], ['17\n', 17]]) {
const actual = call(read_integer, null, { readfile: () => sample[0] });
if (actual !== sample[1])
die(sprintf('get_int(%J): expected %d, got %J\n', sample[0], sample[1], actual));
printf('get_int(%J): %d\n', sample[0], actual);
}
+4
View File
@@ -37,3 +37,7 @@ actual=$(sanitize_route "$ipv6_route")
echo "actual: '$actual'" >&2
exit 1
}
# Check that empty, missing and invalid rpcd state becomes zero.
# Numeric values must be preserved.
ucode -S "$(dirname "$0")/test-rpcd.uc"