Patch to prevent multiple dhclients starting on an interface

LaMont Jones lamont at ubuntu.com
Wed Jun 15 17:57:50 UTC 2005


On Wed, Jun 15, 2005 at 10:30:13AM -0700, Ted Lemon wrote:
> On Jun 15, 2005, at 9:48 AM, LaMont Jones wrote:
> > Interesting that the bind works, though...
> It works because we have to set SO_REUSEADDR.   Even on the first  
> socket open.   No idea why.   Which is a bummer, because it makes  
> this a lot harder.

Some (old??) Unixes would have the port remain busy so long as there was
any association with it, including some time beyond the final close.
Hence SO_REUSEADDR - which does suck for this case.

> Looking in /proc/pid/exe is a chancy solution,  
> both because it's linux-specific and because it assumes that the  
> program will be named dhclient.  This latter assumption isn't a bad  
> one, but you never know.

It could check against basename(argv[0]), which would then just require
that the client be the same name as ours.  Likewise, it could parse
netstat -an output, which is probably even more OS-specific in format.

In the more-complete department, one could add a unix socket to the
daemon, which the new one could try issuing commands through, and
determine live/dead status that way....  Actually, long term, that's
far better than talking to it with signals, although it's more code to
deal with.

lamont


More information about the dhcp-hackers mailing list