Freeing leases with OMSHELL

Greg Rabil greg.rabil at ins.com
Fri Nov 3 20:52:50 UTC 2006


Yes, I noticed the behavior that the server waited until the expiration of
the lease.  I also tried setting the "ends" time equal to the "starts" time,
but it never would take.  That is, after an "update", I'd do a "refresh",
and the original "ends" time would come back.

Thank you for the patch.

Regards,
Greg

-----Original Message-----
From: dhcp-users-bounce at isc.org [mailto:dhcp-users-bounce at isc.org] On Behalf
Of Christof Chen
Sent: Friday, November 03, 2006 3:27 PM
To: dhcp-users at isc.org
Subject: Re: Freeing leases with OMSHELL

> set the state to one (1=free), and then
> update the lease.  This causes the lease to be updated in the dhcpd.leases
> file, showing that the state is indeed free.  However, if the 11th client
> again attempts to get a lease, the server still complains that there are
> "no free leases".

The server still waits until the "ends" time before it hands out a new
lease.
You have to reset the "ends" time as well. 3.0.4 does not allow this out of 
the box, but you may try this patch (no guarantees, of course):


Modified: trunk/current/server/omapi.c
===================================================================
--- trunk/current/server/omapi.c        2006-07-27 11:28:37 UTC (rev 28)
+++ trunk/current/server/omapi.c        2006-10-27 15:40:36 UTC (rev 29)
@@ -261,7 +261,20 @@
        } else if (!omapi_ds_strcmp (name, "starts")) {
            return ISC_R_NOPERM;
        } else if (!omapi_ds_strcmp (name, "ends")) {
-           return ISC_R_NOPERM;
+           unsigned long bar,ole;
+           status = omapi_get_int_value (&bar, value);
+           if (status != ISC_R_SUCCESS)
+               return status;
+           ole = lease -> ends;
+           lease -> ends = bar;   /* CC test */
+           if (supersede_lease (lease, 0, 1, 1, 1)) {
+                       log_info ("lease %s end changed from %lu to %lu",
+                                 piaddr(lease->ip_addr), ole, bar);
+                       return ISC_R_SUCCESS;
+           }
+           log_info ("lease %s end changed from %lu to %lu failed",
+                                 piaddr(lease->ip_addr), ole, bar);
+           return ISC_R_IOERROR;
        } else if (!omapi_ds_strcmp (name, "billing-class")) {
            return ISC_R_UNCHANGED;     /* XXX carefully allow change. */
        } else if (!omapi_ds_strcmp (name, "hardware-address")) {


This makes "ends" writable for a lease via OMAPI. I have not tried anything 
beyond ends = starts, but this made the lease immediately available for a
new 
client.

-- 
Christof Chen



More information about the dhcp-users mailing list