-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Is there an existing issue for this?
- I have searched among all existing issues (including closed issues)
screenshots or captures
No response
Actual behaviour
On my glinet router, all DHCPv4 (wrongly) show up as expired in LUCI.
Expected behaviour
Active DHCPv4 leases should show up as active, like in the leases file.
Steps to reproduce
The issue as i found it, lies in the expire value in my lease file, wichh has this format:
<expiration_duration> <MAC_address> <IP_address> <client_id>
isntead of the (presumably expected)
<expiration_timestamp> <MAC_address> <IP_address> <client_id>
For example:
not 1708365600 aa:bb:cc:dd:ee:ff 192.168.1.100 mydevice *
but 3600 aa:bb:cc:dd:ee:ff 192.168.1.100 mydevice *
I found this to be caused by a feature of dnsmasq, the HAVE_BROKEN_RTC flag. (It can be checked using dnsmasq --version | grep "no-RTC")
If set, it stores realtive times, to fix issues on bad hardware, and seems to be recommended in the git repo of dnsmasq.
I tried to patch luci-static/resources/view/status/include/40_dhcp.js to detect heuristically, if the flag is set and i need to parse it differently.
if (hasBrokenRTC) {
return {
isUnlimited: false,
isExpired: lease.expires <= 0,
expiresAt: now + lease.expires // lease_length is stored in dhcp.leases
};
}
return {
isUnlimited: false,
isExpired: lease.expires <= now,
expiresAt: lease.expires // lease_expires is stored in dhcp.leases
};
...If most lease expiry values are unreasonably small compared to current time, hey're likely relative durations (seconds), not absolute timestamps (since 1970). Absolute timestamps should be > 100,000,000 (~1973). Relative durations are typically 1-86400 seconds (1 second to 1 day), so < 100,000,000 (~3 years).
But it seems this data is actually being passed wrongly from the rpc backend! There is always 0 coming back:
{
"10": {
"jsonrpc": "2.0",
"id": 788,
"result": [
0,
{
"dhcp_leases": [
{
"expires": 0,
"hostname": "Devicename",
"macaddr": "11:11:11:11:11:11",
"duid": "1111",
"ipaddr": "192.168.111.111"
},
{
...Additional Information
{
"kernel": "5.4.164",
"hostname": "xxx",
"system": "ARMv8 Processor rev 4",
"model": "GL Technologies, Inc. AX1800",
"board_name": "glinet,ax1800",
"rootfs_type": "squashfs",
"release": {
"distribution": "OpenWrt",
"version": "23.05-SNAPSHOT",
"revision": "",
"target": "ipq60xx/generic",
"description": "OpenWrt 23.05-SNAPSHOT ",
"tip-revision": "OpenWrt 23.05-SNAPSHOT / TIP-devel-aa312cd8",
"tip-version": "devel"
}
}What browsers do you see the problem on?
No response