[LEDE-DEV] Fw: [openwrt/luci] BUG: DHCP Leases "infinite" time shows as "expired" not as "unlimited" in IPv4 (#963)
dedeckeh at gmail.com
Thu Jan 19 23:59:23 PST 2017
odhcpd uses 0 to indicate a lease is expired while -1 is used to
reperesent infinite leasetime since the support of infinite leasetime
I have my doubts can you make a distinction in dnsmasq between
infinite leasetime and a lease which is expired knowing the code
quality of dnsmasq.
So I would prefer to keep -1 for infinite leasetime to make it clear
it's "infinite" and to make a distinction with an expired lease.
On Fri, Jan 20, 2017 at 7:58 AM, Daniel Dickinson
<lede-daniel at cshore.thecshore.com> wrote:
> Hi Hans,
> In LuCI GitHub issue 963 (https://github.com/openwrt/luci/issues/963),
> a user discovered that LuCI incorrectly reports dnsmasq infinite
> leasetime as expired because the LuCI check is based on odhcpd's -1 for
> INFINITE_VALID, but dnsmasq uses 0 in the dhcp.leases file for
> infinite leases. Would it be preferable to sync odhcpd and dnsmasq
> (I know odhcpd at one time used 0 for INFINITE_VALID in the statefile
> but that that was changed, and I don't know why). From a LuCI point of
> view I'm not sure if there some caveat with the 0 value (I seem to
> recall odhcpd uses 0 to represent something other than infinite, but I
> could be wrong). Before hacking on LuCI for the dnsmasq case I want to
> make sure I understand what values are going to be found in the odhcpd
> User's findings (last comment only) reproduced below.
> Begin forwarded message:
> Date: Thu, 19 Jan 2017 22:38:34 -0800
> From: NvrBst <notifications at github.com>
> To: openwrt/luci <luci at noreply.github.com>
> <mention at noreply.github.com> Subject: Re: [openwrt/luci] BUG: DHCP
> Leases "infinite" time shows as "expired" not as "unlimited" in IPv4
> I see! Upon looking, _dnsmasq_ stores infinite leases as "0" in the
> _/tmp/dhcp.leases_ file. This corresponds to the _01/01/1970 00:00:00
> GMT_, in Unix EPOCH time. Since today's date is "1484889355". But the
> expires property is (EXPIRY DATE - TODAYS DATE). So it's 0-1484889355.
> So any value below -1484889355 works.
> So if someone wanted to do a dnsmasq infinite check properly you could:
> 1. Check the _/tmp/dhcp.leases_ file and see if it has a 0 as the time.
> 2. Since the DHCP Lease Table is pulling its information from:
> 3. `XHR.poll(5, '<%=url('admin/network/dhcplease_status')%>'`
> 4. Going to the URL:
> _http://192.168.0.1/cgi-bin/luci/admin/network/dhcplease_status_ shows
> that it only gives the expiry conversion, and not the original expiry
> date. So someone would have to alter the structs and put the expiry
> time, and original EXPIRY DATE. Then you can use that and check to see
> if it's 0 for an infinite lease --- More work. 5. The leases[i].expires
> property is just EXPIRY DATE - CURRENT DATE. So you could reverse this
> calculation and check to see if it's 0. Of course, playing with time
> can be smudgy with rounding.
> Option 2 is probably the cleanest, Option 3 is the easiest. So if we
> were doing 3, we can just do the check in these two files as:
> if (info.leases[i].expires ===
> false || Math.trunc((new Date().getTime()/1000 +
> info.leases[i].expires)/10) == 0) timestr = '<em><%:unlimited%></em>';
> else if (info.leases[i].expires <= 0) timestr = '<em><%:expired%></em>';
> You are receiving this because you were mentioned.
> Reply to this email directly or view it on GitHub:
More information about the Lede-dev