Re: Re: Selecting a "better" offer from two DHCP servers
Shahid Mahmood
Mon Jun 20 15:26:39 2016
On Fri, Jun 17, 2016 at 1:11 PM, Shahid Mahmood <shahid.avaya@xxxxxxxxx>
wrote:
>
> On Fri, Jun 17, 2016 at 12:51 PM, Roy Marples <roy@xxxxxxxxxxxx> wrote:
>
>> Hi
>>
>> On 16/06/2016 21:27, Shahid Mahmood wrote:
>> > Back to this question again ...
>> >
>> > Recap: Two dhcp servers, one sending offer with preferred option, other
>> > without.
>> >
>> > If within 1 second of sending discover, two leases were received, then
>> > pick the one with preferred option.
>> > If 1 second has elapsed and no lease with preferred option seen, then
>> > just pick the other one without the preferred option.
>> >
>> > (1 sec can be changed to upto 5)
>> >
>> > Here is my idea how to implement this:
>> >
>> > 1. Start dhcpcd with -Q vendor_option -t10
>> > (Hook scripts dump option and variables in a file, say
>> > /tmp/dhcp/dhcpcd_data)
>> > 2. Monitor /tmp/dhcp/ for activity (using inotify)
>> > 3. *Somehow detect* 2 lease situation, e.g a lease was offered but
>> > rejected, or timeout has occurred, and if so, restart dhcpcd without -Q
>> > and -t (settle on non-preferred lease)
>> > 4. Of course, if a lease with vendor_option was received, accept it and
>> > continue normal life.
>> >
>> > Q:
>> > Is this good approach?
>> > If so, how can I do step 3? ie detect events such as timeout, reject or
>> > offer received?
>> > If not, is there a better way to do this? e.g is -T worth considering?
>>
>> I don't think that's a good approach because you're signallng dhcpcd
>> from outside about what is good and what is bad.
>>
>>
> Correct, because dhcpcd does not know how to decide with lease to select.
>
>
>> Right now, dhcpcd internally has a state machine per protocol that is
>> desinged to handle only one offer. These should be refactored to handle
>> N offers, with a mechanisn to handle preference.
>>
>> We need only one offer per protocol. Just need to prefer the one with
> site_specif option.
>
>
>> Another interesting question is this: do we want to only have one
>> primary lease or take the IPv6 autoconf approach and merge active offers?
>>
>> Just one lease for now. Merged offer option will also do the job, if/when
> it is available :)
>
>> Roy
>>
>>
> Trying to implement the flow as outlined above.
dhcpcd starts correctly with '-Q site_specific' and rejects the lease when
it comes from a server not providing this option.
HOWEVER I am not able to detect this condition programatically.
Is there a variable I can check in the hook script? I can't find one.
I tried redirecting stdout and stderr in a log file ( 2>&1 >
/tmp/logfile.txt) but the file is always empty.
If I run dhcpcd with command line, e.g
# dhcpcd -Q site_specific
The console shows some usable output, e.g
#eth0: sending DISCOVER (xid 0xd265890a), next in 4.2 seconds
#eth0: reject DHCP 192.168.20.20 from 192.168.20.4 `DC16010051'
How can my application detect if an offer was rejected?
Alternately, is there a better way to save/read logs? (I have 'debug'
enabled too).
Thanks
-shahid
Archive administrator: postmaster@marples.name