bd3a57b
diff -up dhcp-4.2.2/client/dhclient.c.improved-xid dhcp-4.2.2/client/dhclient.c
bd3a57b
--- dhcp-4.2.2/client/dhclient.c.improved-xid	2011-09-16 18:18:00.649730661 +0200
bd3a57b
+++ dhcp-4.2.2/client/dhclient.c	2011-09-16 18:22:36.815035513 +0200
bd3a57b
@@ -898,6 +898,26 @@ main(int argc, char **argv) {
bd3a57b
 		}
bd3a57b
 	}
bd3a57b
 
bd3a57b
+	/* We create a backup seed before rediscovering interfaces in order to
bd3a57b
+	   have a seed built using all of the available interfaces
bd3a57b
+	   It's interesting if required interfaces doesn't let us defined
bd3a57b
+	   a really unique seed due to a lack of valid HW addr later
bd3a57b
+	   (this is the case with DHCP over IB)
bd3a57b
+	   We only use the last device as using a sum could broke the
bd3a57b
+	   uniqueness of the seed among multiple nodes
bd3a57b
+	 */
bd3a57b
+	unsigned backup_seed = 0;
bd3a57b
+	for (ip = interfaces; ip; ip = ip -> next) {
bd3a57b
+		int junk;
bd3a57b
+		if ( ip -> hw_address.hlen <= sizeof seed )
bd3a57b
+		  continue;
bd3a57b
+		memcpy (&junk,
bd3a57b
+			&ip -> hw_address.hbuf [ip -> hw_address.hlen -
bd3a57b
+						sizeof seed], sizeof seed);
bd3a57b
+		backup_seed = junk;
bd3a57b
+	}
bd3a57b
+
bd3a57b
+
bd3a57b
 	/* At this point, all the interfaces that the script thinks
bd3a57b
 	   are relevant should be running, so now we once again call
bd3a57b
 	   discover_interfaces(), and this time ask it to actually set
bd3a57b
@@ -912,14 +932,36 @@ main(int argc, char **argv) {
bd3a57b
 	   Not much entropy, but we're booting, so we're not likely to
bd3a57b
 	   find anything better. */
bd3a57b
 	seed = 0;
bd3a57b
+	int seed_flag = 0;
bd3a57b
 	for (ip = interfaces; ip; ip = ip->next) {
bd3a57b
 		int junk;
bd3a57b
+		if ( ip -> hw_address.hlen <= sizeof seed )
bd3a57b
+		  continue;
bd3a57b
 		memcpy(&junk,
bd3a57b
 		       &ip->hw_address.hbuf[ip->hw_address.hlen -
bd3a57b
 					    sizeof seed], sizeof seed);
bd3a57b
 		seed += junk;
bd3a57b
+		seed_flag = 1;
bd3a57b
 	}
bd3a57b
-	srandom(seed + cur_time + (unsigned)getpid());
bd3a57b
+	if ( seed_flag == 0 ) {
bd3a57b
+		if ( backup_seed != 0 ) {
bd3a57b
+		  seed = backup_seed;
bd3a57b
+		  log_info ("xid: rand init seed (0x%x) built using all"
bd3a57b
+			    " available interfaces",seed);
bd3a57b
+		}
bd3a57b
+		else {
bd3a57b
+		  seed = cur_time^((unsigned) gethostid()) ;
bd3a57b
+		  log_info ("xid: warning: no netdev with useable HWADDR found"
bd3a57b
+			    " for seed's uniqueness enforcement");
bd3a57b
+		  log_info ("xid: rand init seed (0x%x) built using gethostid",
bd3a57b
+			    seed);
bd3a57b
+		}
bd3a57b
+		/* we only use seed and no current time as a broadcast reply */
bd3a57b
+		/* will certainly be used by the hwaddrless interface */
bd3a57b
+		srandom(seed);
bd3a57b
+	}
bd3a57b
+	else
bd3a57b
+	        srandom(seed + cur_time + (unsigned)getpid());
bd3a57b
 
bd3a57b
 	/* Setup specific Infiniband options */
bd3a57b
 	for (ip = interfaces; ip; ip = ip->next) {
bd3a57b
@@ -1457,7 +1499,7 @@ void dhcpack (packet)
bd3a57b
 		return;
bd3a57b
 	}
bd3a57b
 
bd3a57b
-	log_info ("DHCPACK from %s", piaddr (packet -> client_addr));
bd3a57b
+	log_info ("DHCPACK from %s (xid=0x%x)", piaddr (packet -> client_addr), client -> xid);
bd3a57b
 
bd3a57b
 	lease = packet_to_lease (packet, client);
bd3a57b
 	if (!lease) {
bd3a57b
@@ -2174,7 +2216,7 @@ void dhcpnak (packet)
bd3a57b
 		return;
bd3a57b
 	}
bd3a57b
 
bd3a57b
-	log_info ("DHCPNAK from %s", piaddr (packet -> client_addr));
bd3a57b
+	log_info ("DHCPNAK from %s (xid=0x%x)", piaddr (packet -> client_addr), client -> xid);
bd3a57b
 
bd3a57b
 	if (!client -> active) {
bd3a57b
 #if defined (DEBUG)
bd3a57b
@@ -2300,10 +2342,10 @@ void send_discover (cpp)
bd3a57b
 		client -> packet.secs = htons (65535);
bd3a57b
 	client -> secs = client -> packet.secs;
bd3a57b
 
bd3a57b
-	log_info ("DHCPDISCOVER on %s to %s port %d interval %ld",
bd3a57b
+	log_info ("DHCPDISCOVER on %s to %s port %d interval %ld (xid=0x%x)",
bd3a57b
 	      client -> name ? client -> name : client -> interface -> name,
bd3a57b
 	      inet_ntoa (sockaddr_broadcast.sin_addr),
bd3a57b
-	      ntohs (sockaddr_broadcast.sin_port), (long)(client -> interval));
bd3a57b
+	      ntohs (sockaddr_broadcast.sin_port), (long)(client -> interval), client -> xid);
bd3a57b
 
bd3a57b
 	/* Send out a packet. */
bd3a57b
 	result = send_packet (client -> interface, (struct packet *)0,
bd3a57b
@@ -2584,10 +2626,10 @@ void send_request (cpp)
bd3a57b
 			client -> packet.secs = htons (65535);
bd3a57b
 	}
bd3a57b
 
bd3a57b
-	log_info ("DHCPREQUEST on %s to %s port %d",
bd3a57b
+	log_info ("DHCPREQUEST on %s to %s port %d (xid=0x%x)",
bd3a57b
 	      client -> name ? client -> name : client -> interface -> name,
bd3a57b
 	      inet_ntoa (destination.sin_addr),
bd3a57b
-	      ntohs (destination.sin_port));
bd3a57b
+	      ntohs (destination.sin_port), client -> xid);
bd3a57b
 
bd3a57b
 	if (destination.sin_addr.s_addr != INADDR_BROADCAST &&
bd3a57b
 	    fallback_interface)
bd3a57b
@@ -2618,10 +2660,10 @@ void send_decline (cpp)
bd3a57b
 
bd3a57b
 	int result;
bd3a57b
 
bd3a57b
-	log_info ("DHCPDECLINE on %s to %s port %d",
bd3a57b
+	log_info ("DHCPDECLINE on %s to %s port %d (xid=0x%x)",
bd3a57b
 	      client -> name ? client -> name : client -> interface -> name,
bd3a57b
 	      inet_ntoa (sockaddr_broadcast.sin_addr),
bd3a57b
-	      ntohs (sockaddr_broadcast.sin_port));
bd3a57b
+	      ntohs (sockaddr_broadcast.sin_port), client -> xid);
bd3a57b
 
bd3a57b
 	/* Send out a packet. */
bd3a57b
 	result = send_packet (client -> interface, (struct packet *)0,
bd3a57b
@@ -2661,10 +2703,10 @@ void send_release (cpp)
bd3a57b
 		return;
bd3a57b
 	}
bd3a57b
 
bd3a57b
-	log_info ("DHCPRELEASE on %s to %s port %d",
bd3a57b
+	log_info ("DHCPRELEASE on %s to %s port %d (xid=0x%x)",
bd3a57b
 	      client -> name ? client -> name : client -> interface -> name,
bd3a57b
 	      inet_ntoa (destination.sin_addr),
bd3a57b
-	      ntohs (destination.sin_port));
bd3a57b
+	      ntohs (destination.sin_port), client -> xid);
bd3a57b
 
bd3a57b
 	if (fallback_interface)
bd3a57b
 		result = send_packet (fallback_interface,