udhcpd server lease expiration issue

Mahavir Jain mahavir.coep at gmail.com
Fri Jan 2 04:29:46 UTC 2009


Hi,

Thanks for making sure that i am not wrong.(Reply)

This is my udhcpd.conf file,

start 192.168.1.100
end 192.168.1.200
interface br0
opt      lease  86400
opt     router  192.168.1.1
opt     subnet  255.255.255.0
opt     dns     192.168.1.1
opt     domain     localdomain
max_leases     101
lease_file     /var/lib/udhcpd.leases


In busybox 1.5.0 , i was able to fix it as


 printf(" %-15s ", inet_ntoa(addr));
 expires = ntohl(lease.expires);
 +  expires -= time(0);

 if (mode == REMAINING) {
                        if (!expires)
                                printf("expired\n");



Adding same thing to get amount of time remaining in busybox 1.12.0
gives me some decrementing count in

$ dumpleases -f /var/lib/udhcpd.lease

as 4015678 & then it keeps in decrementing . I think its due to format
of unix time , i am not able to convert it to actual seconds.


Any help regarding this....? As i want to upgrade to latest busybox.

Regards

Mahavir


On Thu, Jan 1, 2009 at 11:23 PM, Denys Vlasenko
<vda.linux at googlemail.com> wrote:
> On Thursday 01 January 2009 08:57, Mahavir Jain wrote:
>> Hi,
>>
>> I was working with busybox 1.12.0 . I found that dhcp server never
>> shows amount time remaining in lease to expire with,
>>
>> $ dumpleases -f /var/lib/udhcpd.lease
>>
>> It just shows amount of lease allocated.
>
> You need to set auto_time in udhcpd config file to something
> smaller than default 7200 seconds (2 hours) in order to make udhcpd
> write out lease file more often. Or "killall -USR1 udhcpd"
> to force it to do that.
>
> Unfortunately current leasefile format is stupid, it does not
> allow to figure out how old (stale) is it, and lease times
> are encoded as offsets from "current time" (which is not in the file!)
> Thus, "watch dumpleases -f /var/lib/udhcpd.lease" will never
> show you how lease times tick down to zero,
> they will be unchanged until udhcpd rewrites the file.
>
>> I also tried -r option but it
>> didn't work either.
>
> -r option is the default, it won't change anything. -a option
> is supposed to show "absolute" expiration time, but is broken.
> Add these lines in networking/udhcp/dumpleases.c:
>
>               } else /* -a */
> +{
> +                      expires += time(NULL);
>                       fputs(ctime(&expires), stdout);
> +}
>
> to fix it.
>
>> Please let me know whether it's issue or something
>> wrong with my settings....?   Because we should know when lease is
>> expired for specific client...
>
> You need to report your udhcpd problems so that I can fix them.
> You are doing that just right. Thanks.
> --
> vda
>


More information about the busybox mailing list