detecting whether a reserved lease is being issued for the first time

Afif Elghraoui afif at ghraoui.name
Sun Nov 20 07:46:38 UTC 2016



على السبت 19 تشرين الثاني 2016 ‫01:18، كتب Simon Hobson:
> Afif Elghraoui <afif at ghraoui.name> wrote:
> 
>> I have an action that I'd like to run the first time the IP address is
>> issued. I used an "on commit" statement, but I see that it gets run
>> every time the client boots and rebinds its address. Is there a good way
>> for the server to detect whether the IP address is issued for the first
>> time?
> 
> Is this an action that needs to be run exactly once, or can it be run multiple times without causing problems ?
> 
> But my main suggestion is to keep track of the action outside of DHCP. So when your on commit handler is called, check to see if you've already run the task and if so, then skip it.
> 

Thanks, that's a great idea! I don't know why it never occurred to me.
I've made the commit handler idempotent and it seems to be working fine now.

> Be aware that, unless it's changed, ISTR that the "on <action>" hooks need to run fast or they will block the server. So ideally your handler should do as little as possible (perhaps write some data to a signalling file ?) and then return - leaving any time consuming tasks to another process.
> 

Of course.

Many thanks and regards
Afif

-- 
Afif Elghraoui | عفيف الغراوي
http://afif.ghraoui.name


More information about the dhcp-users mailing list