OMAPI: Retrieve lease object given hardware-address and state

Robin Breathe robin-dhcp at isometry.net
Wed Aug 24 10:03:02 UTC 2005


Richard Hirst wrote:
> On Wed, Aug 24, 2005 at 08:42:51AM +0100, Robin Breathe wrote:
>> Robin Breathe wrote:
>>> The real problem comes when I start trying to lookup leases given just 
>>> hardware-address/-type. If I specify only hardware-address, 
>>> hardware-type and state, it more often than not reports that "more than 
>>> one object matches key". Manual inspection of the leases file makes it 
>>> apparent that in these cases there are indeed multiple leases with the 
>>> same hardware-address (for example in different subnets), but that only 
>>> one is active (I have "one-lease-per-client on" set). Thus ignoring 
>>> 'state' has become a real problem, since I can't retrieve *any* lease 
>>> object.
>> I've now had the opportunity to clear out the leases file, and currently
>> with 430 distinct MAC addresses this seems to be working (i.e. I can
>> search leases by hardware-address).
>>
>> As nobody replied to my initial query, could anyone more knowledgeable
>> than I tell me whether I can expect for this to continue working? It is
>> possible there were some stale leases following global configuration
>> changes in the old leases file.
> 
> I think you'll find it breaks once some lease expires and a machine gets
> given a different address.  If all your systems tend to maintain their
> current leases then you may be lucky.  Presumably if one of your
> machines pops up on a different subnet you'll have to give it a
> different ip address and that will trigger the problem too.  Part of the
> problem is that OMAPI doesn't provide a way of returning multiple
> results, and so any time there is more than one hit on a search you get
> the "more than one object matches key" error.  I guess fixing OMAPI to
> check the state is the right thing to do, provided dhcpd does update the
> state of leases on other subnets when a machine moves.  I've never
> messed with dhcpd managing more than one subnet though.

Thank you for the advice. It's as I feared.

Any tips on where I need to start looking in order to patch in the
state-filtering functionality to OMAPI? I've become lost after the call
to omapi_protocol_send_message() from dhcpctl_object_update() in
dhcpctl.c... Some of the code's a little convoluted, but the additional
functionality would be exceptionally handy. Of course if anyone else is
interested, understands the code and has the time to fix this... words
could barely express how grateful I'd be.

Regards,
Robin
-- 
Robin Breathe, Computer Services, Oxford Brookes University, Oxford, UK
rbreathe at brookes.ac.uk       Tel: +44 1865 483685  Fax: +44 1865 483073


More information about the dhcp-hackers mailing list