1 diff -up dhcp-4.2.2/client/dhclient.c.improved-xid dhcp-4.2.2/client/dhclient.c
2 --- dhcp-4.2.2/client/dhclient.c.improved-xid 2011-09-16 18:18:00.649730661 +0200
3 +++ dhcp-4.2.2/client/dhclient.c 2011-09-16 18:22:36.815035513 +0200
4 @@ -898,6 +898,26 @@ main(int argc, char **argv) {
8 + /* We create a backup seed before rediscovering interfaces in order to
9 + have a seed built using all of the available interfaces
10 + It's interesting if required interfaces doesn't let us defined
11 + a really unique seed due to a lack of valid HW addr later
12 + (this is the case with DHCP over IB)
13 + We only use the last device as using a sum could broke the
14 + uniqueness of the seed among multiple nodes
16 + unsigned backup_seed = 0;
17 + for (ip = interfaces; ip; ip = ip -> next) {
19 + if ( ip -> hw_address.hlen <= sizeof seed )
22 + &ip -> hw_address.hbuf [ip -> hw_address.hlen -
23 + sizeof seed], sizeof seed);
28 /* At this point, all the interfaces that the script thinks
29 are relevant should be running, so now we once again call
30 discover_interfaces(), and this time ask it to actually set
31 @@ -912,14 +932,36 @@ main(int argc, char **argv) {
32 Not much entropy, but we're booting, so we're not likely to
33 find anything better. */
36 for (ip = interfaces; ip; ip = ip->next) {
38 + if ( ip -> hw_address.hlen <= sizeof seed )
41 &ip->hw_address.hbuf[ip->hw_address.hlen -
42 sizeof seed], sizeof seed);
46 - srandom(seed + cur_time + (unsigned)getpid());
47 + if ( seed_flag == 0 ) {
48 + if ( backup_seed != 0 ) {
50 + log_info ("xid: rand init seed (0x%x) built using all"
51 + " available interfaces",seed);
54 + seed = cur_time^((unsigned) gethostid()) ;
55 + log_info ("xid: warning: no netdev with useable HWADDR found"
56 + " for seed's uniqueness enforcement");
57 + log_info ("xid: rand init seed (0x%x) built using gethostid",
60 + /* we only use seed and no current time as a broadcast reply */
61 + /* will certainly be used by the hwaddrless interface */
65 + srandom(seed + cur_time + (unsigned)getpid());
67 /* Setup specific Infiniband options */
68 for (ip = interfaces; ip; ip = ip->next) {
69 @@ -1457,7 +1499,7 @@ void dhcpack (packet)
73 - log_info ("DHCPACK from %s", piaddr (packet -> client_addr));
74 + log_info ("DHCPACK from %s (xid=0x%x)", piaddr (packet -> client_addr), client -> xid);
76 lease = packet_to_lease (packet, client);
78 @@ -2174,7 +2216,7 @@ void dhcpnak (packet)
82 - log_info ("DHCPNAK from %s", piaddr (packet -> client_addr));
83 + log_info ("DHCPNAK from %s (xid=0x%x)", piaddr (packet -> client_addr), client -> xid);
85 if (!client -> active) {
87 @@ -2300,10 +2342,10 @@ void send_discover (cpp)
88 client -> packet.secs = htons (65535);
89 client -> secs = client -> packet.secs;
91 - log_info ("DHCPDISCOVER on %s to %s port %d interval %ld",
92 + log_info ("DHCPDISCOVER on %s to %s port %d interval %ld (xid=0x%x)",
93 client -> name ? client -> name : client -> interface -> name,
94 inet_ntoa (sockaddr_broadcast.sin_addr),
95 - ntohs (sockaddr_broadcast.sin_port), (long)(client -> interval));
96 + ntohs (sockaddr_broadcast.sin_port), (long)(client -> interval), client -> xid);
98 /* Send out a packet. */
99 result = send_packet (client -> interface, (struct packet *)0,
100 @@ -2584,10 +2626,10 @@ void send_request (cpp)
101 client -> packet.secs = htons (65535);
104 - log_info ("DHCPREQUEST on %s to %s port %d",
105 + log_info ("DHCPREQUEST on %s to %s port %d (xid=0x%x)",
106 client -> name ? client -> name : client -> interface -> name,
107 inet_ntoa (destination.sin_addr),
108 - ntohs (destination.sin_port));
109 + ntohs (destination.sin_port), client -> xid);
111 if (destination.sin_addr.s_addr != INADDR_BROADCAST &&
113 @@ -2618,10 +2660,10 @@ void send_decline (cpp)
117 - log_info ("DHCPDECLINE on %s to %s port %d",
118 + log_info ("DHCPDECLINE on %s to %s port %d (xid=0x%x)",
119 client -> name ? client -> name : client -> interface -> name,
120 inet_ntoa (sockaddr_broadcast.sin_addr),
121 - ntohs (sockaddr_broadcast.sin_port));
122 + ntohs (sockaddr_broadcast.sin_port), client -> xid);
124 /* Send out a packet. */
125 result = send_packet (client -> interface, (struct packet *)0,
126 @@ -2661,10 +2703,10 @@ void send_release (cpp)
130 - log_info ("DHCPRELEASE on %s to %s port %d",
131 + log_info ("DHCPRELEASE on %s to %s port %d (xid=0x%x)",
132 client -> name ? client -> name : client -> interface -> name,
133 inet_ntoa (destination.sin_addr),
134 - ntohs (destination.sin_port));
135 + ntohs (destination.sin_port), client -> xid);
137 if (fallback_interface)
138 result = send_packet (fallback_interface,