Subject: Re: dhclient
To: John Nemeth <jnemeth@victoria.tc.ca>
From: Douglas Wade Needham <cinnion@ka8zrt.com>
List: current-users
Date: 11/07/2004 07:47:15
	version=3.0.0
Sender: current-users-owner@NetBSD.org

Quoting John Nemeth (jnemeth@victoria.tc.ca):
> On Mar 21,  6:57pm, Lennart Augustsson wrote:
> }
> } Is there some way to make dhclient work like you want
> } in this century?  Or is there a replacement?
> 
>      I've used a couple of different DHCP clients in the L* world, and
> to be blunt, they sucked big time.  dhclient is by far the best I've
> seen.
  
I agree.  I have used DHCP clients on HP/UX, OSF, Solaris, M$, and
dozens of other operating systems, and "sucked big time" was putting
it mildly.  I ported the ISC DHCP to several of them, back in the 1.x
days, and since then, the only real thing I have had to do it is to
add code in to manage ntp.conf.  I did not contribute them at the time
due to being under contraints by a previous employer who wanted a hand
in everything I did, even on my own machines and time.  Ted, you
interested in these simple diffs?  If so, send them to you via ISC,
NetBSD or PR them??

> } Some wishes:
> } * I have interfaces that come and go.  dhclient
> }    should notice this.
> 
>      How?  By scanning the list of interfaces every second?  That
> wouldn't be very efficient.  It may be able to do something with
> kevent.  But, that isn't very portable.  Remember that dhclient isn't
> an inherit part of NetBSD, but rather part of the ISC's DHCP package
> which runs on just about every version of UNIX.  Whether or not the
> developers would use something that isn't universally available
> (although it is probably available on all the BSDs), I don't know.  You
> could always ask.  The primary developer is Ted Lemon, who is also a
> NetBSD developer, mellon@netbsd.org.  When I had some problems, I found
> him to be quite reasonable.  He took one of my patches verbatim and
> implemented my other patch in a portable way.  As somebody else in this
> thread mentioned, you could do something using ifwatchd.  If you check
> the manpage, you will see that there is a method of informing dhclient
> of new interfaces.

Ted is about as reasonable as they come, but having worked with him
for awhile on the project, I still have to wonder if he would pick up
something which would not be very portable which would fall outside of
the dhclient-script.  I would definitely have to recommend just going
with ifwatchd.

Oh, and as for the shell script info talking about killing and
restarting dhclient directly, I would actually recommend having
/etc/rc.conf call another script which sets stuff releated to dhclient
and other stuff which may change due to your mobility, and then using
the rc.d scripts.  This way, you do not need to worry about all sorts
of other things associated with restarting dhclient or other programs.
And you do not have to worry about munging /etc/rc.conf either.

> } * With multiple interface it should only configure
> }    one of them for use, and you should be able to specify
> }    priority.  If you don't say anything prefer wires over
> }    wireless.
> 
>      This is something that is completely personal and system based.
> There is no way to satisfy everybody on this issue.  However, there is
> an easy way to tell it to just use one interface.

No way to even begin on this one.  You are much better off playing
around with wrapper scripts which say "I have interfaces a, b, and c,
we prefer b so I will set it up for that and restart dhclient."  I did
something like this years ago, and even put in hooks so that
/etc/rc.conf and other paths would pick up the right info.  But as for
the single interface, if you want to have it listen just to port wi0, you
just add 'wi0' as an argument to the command line.

> } * dhclient should not use programs from /usr.  It might not
> }    be mounted when dhclient runs.
> 
>      Which programs does it use?  Should these programs be moved to /,
> or is there some other way to do the same thing.  External programs are
> called from a script, which is specific to NetBSD, so there shouldn't
> be a problem with feeding these kinds of changes back to Ted.
> 
> }-- End of excerpt from Lennart Augustsson

I know he mentioned arp and sed as such programs.  Look at where it is
being called... delete_old_routes().  The only time this would get
called is when you have been up for some time and you get a new lease,
or perhaps if you get leases for multiple interfaces (I would have to
check the code much closer on this).  But in this latter case, if you
are doing DHCP to configure multiply connected hosts, you are
generally asking for trouble anyways, as this is the way to problems
such as routing loops.  Hence, I would say that this is not likely to
be a real biggie, while having an old route still hanging around would
be an even bigger problem.

- Doug

-- 
Douglas Wade Needham - KA8ZRT        UN*X Consultant & UW/BSD kernel programmer
Email:  cinnion @ ka8zrt . com       http://cinnion.ka8zrt.com
Disclaimer: My opinions are my own.  Since I don't want them, why
            should my employer, or anybody else for that matter!