Problems running multiple dhclients at the same time

Jeremiah Jinno jeremiah.jinno at gmail.com
Wed Jun 9 21:25:47 UTC 2010


Working with Bob, we have confirmed that the patch at the end of this
message does in fact fix the "multiple dhclients running at the same
time will receive the same IP address" problem. (Thanks to Jeff for
the suggestion!) However there is still a synchronization issue
between the base-interface IP address (primary) and the alias
addresses (secondary).

For lack of a better word, I will be using "base" in reference to any
address (passed to dhclient-script) that defines an "$interface" but
does not define a "$client".
      Example: "eth0"

Likewise, I will be using "alias" in reference to any address (passed
to dhclient-script) that defines both "$interface" and "$client".
      Example: "eth0:v0"




Synchronization Issue 1:

It would appear that when running with dhclient base & alias instances
in parallel, there is no synchronization to force the alias address
assignment to wait for the base address assignment.

For example, (best case) if the dhclient instances assign addresses in
the following order we get the base + all aliases:
      eth0, eth0:v0, eth0:v2, eth0:v1

However if the base-interface dhclient (average case) is not scheduled
first by the CPU, we get a different order like:
      eth0:v1, eth0:v0, eth0, eth0:v2

The problem is that with (re)assignment of 'eth0', the aliases are
destroyed, leaving us with 4 instances of dhclient, but only the
following actual interfaces:
      eth0, eth0:v2

Of course, you can force the addresses to come up correctly by making
sure the base assignment never occurs in parallel with any of its
aliases.  However this prevents us from having multiple RC scripts
each fork off different dhclient instances.




Synchronization Issue 2:

I am also noticing that if the base & alias interfaces are up, the
dhclient instances responsible for the alias IPs do not pay attention
to the base interface.  Therefore, when you kill, remove lease, and
restart the base-interface dhclient, the aliases go away until
lease-renewal, seemingly because they have no knowledge of the fact
that their IPs have disappeared.




Patch for bad transaction IDs (based on Jeff's input)
** Should this be filed as a bug?? **
---------------------------------------------------------------------------

diff -rupN original/client/dhclient.c new/client/dhclient.c
--- original/client/dhclient.c  2010-01-07 13:53:52.000000000 -0800
+++ new/client/dhclient.c       2010-06-09 12:43:07.000000000 -0700
@@ -522,7 +522,7 @@ main(int argc, char **argv) {
                                            sizeof seed], sizeof seed);
                seed += junk;
        }
-       srandom(seed + cur_time);
+       srandom(seed + (unsigned)cur_time + (unsigned)getpid());

        /* Start a configuration state machine for each interface. */
 #ifdef DHCPv6



More information about the dhcp-users mailing list