2013-12-20 15:13:52 +00:00
|
|
|
diff -up dhcp-4.3.0a1/client/dhclient.c.improved-xid dhcp-4.3.0a1/client/dhclient.c
|
|
|
|
--- dhcp-4.3.0a1/client/dhclient.c.improved-xid 2013-12-20 13:29:41.836260810 +0100
|
|
|
|
+++ dhcp-4.3.0a1/client/dhclient.c 2013-12-20 13:29:41.843260713 +0100
|
|
|
|
@@ -894,6 +894,26 @@ main(int argc, char **argv) {
|
2011-09-19 10:27:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ /* We create a backup seed before rediscovering interfaces in order to
|
|
|
|
+ have a seed built using all of the available interfaces
|
|
|
|
+ It's interesting if required interfaces doesn't let us defined
|
|
|
|
+ a really unique seed due to a lack of valid HW addr later
|
|
|
|
+ (this is the case with DHCP over IB)
|
|
|
|
+ We only use the last device as using a sum could broke the
|
|
|
|
+ uniqueness of the seed among multiple nodes
|
|
|
|
+ */
|
|
|
|
+ unsigned backup_seed = 0;
|
|
|
|
+ for (ip = interfaces; ip; ip = ip -> next) {
|
|
|
|
+ int junk;
|
|
|
|
+ if ( ip -> hw_address.hlen <= sizeof seed )
|
|
|
|
+ continue;
|
|
|
|
+ memcpy (&junk,
|
|
|
|
+ &ip -> hw_address.hbuf [ip -> hw_address.hlen -
|
|
|
|
+ sizeof seed], sizeof seed);
|
|
|
|
+ backup_seed = junk;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
/* At this point, all the interfaces that the script thinks
|
|
|
|
are relevant should be running, so now we once again call
|
|
|
|
discover_interfaces(), and this time ask it to actually set
|
2013-12-20 15:13:52 +00:00
|
|
|
@@ -908,14 +928,36 @@ main(int argc, char **argv) {
|
2011-09-19 10:27:55 +00:00
|
|
|
Not much entropy, but we're booting, so we're not likely to
|
|
|
|
find anything better. */
|
|
|
|
seed = 0;
|
|
|
|
+ int seed_flag = 0;
|
|
|
|
for (ip = interfaces; ip; ip = ip->next) {
|
|
|
|
int junk;
|
|
|
|
+ if ( ip -> hw_address.hlen <= sizeof seed )
|
|
|
|
+ continue;
|
|
|
|
memcpy(&junk,
|
|
|
|
&ip->hw_address.hbuf[ip->hw_address.hlen -
|
|
|
|
sizeof seed], sizeof seed);
|
|
|
|
seed += junk;
|
|
|
|
+ seed_flag = 1;
|
|
|
|
}
|
|
|
|
- srandom(seed + cur_time + (unsigned)getpid());
|
|
|
|
+ if ( seed_flag == 0 ) {
|
|
|
|
+ if ( backup_seed != 0 ) {
|
|
|
|
+ seed = backup_seed;
|
|
|
|
+ log_info ("xid: rand init seed (0x%x) built using all"
|
|
|
|
+ " available interfaces",seed);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ seed = cur_time^((unsigned) gethostid()) ;
|
|
|
|
+ log_info ("xid: warning: no netdev with useable HWADDR found"
|
|
|
|
+ " for seed's uniqueness enforcement");
|
|
|
|
+ log_info ("xid: rand init seed (0x%x) built using gethostid",
|
|
|
|
+ seed);
|
|
|
|
+ }
|
|
|
|
+ /* we only use seed and no current time as a broadcast reply */
|
|
|
|
+ /* will certainly be used by the hwaddrless interface */
|
|
|
|
+ srandom(seed);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ srandom(seed + cur_time + (unsigned)getpid());
|
|
|
|
|
|
|
|
/* Setup specific Infiniband options */
|
|
|
|
for (ip = interfaces; ip; ip = ip->next) {
|
2013-12-20 15:13:52 +00:00
|
|
|
@@ -1460,7 +1502,7 @@ void dhcpack (packet)
|
2011-09-19 10:27:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
- log_info ("DHCPACK from %s", piaddr (packet -> client_addr));
|
2015-01-30 16:07:29 +00:00
|
|
|
+ log_info ("DHCPACK from %s (xid=0x%x)", piaddr (packet -> client_addr), ntohl(client -> xid));
|
2011-09-19 10:27:55 +00:00
|
|
|
|
|
|
|
lease = packet_to_lease (packet, client);
|
|
|
|
if (!lease) {
|
2013-12-20 15:13:52 +00:00
|
|
|
@@ -2171,7 +2213,7 @@ void dhcpnak (packet)
|
2011-09-19 10:27:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
- log_info ("DHCPNAK from %s", piaddr (packet -> client_addr));
|
2015-01-30 16:07:29 +00:00
|
|
|
+ log_info ("DHCPNAK from %s (xid=0x%x)", piaddr (packet -> client_addr), ntohl(client -> xid));
|
2011-09-19 10:27:55 +00:00
|
|
|
|
|
|
|
if (!client -> active) {
|
|
|
|
#if defined (DEBUG)
|
2013-12-20 15:13:52 +00:00
|
|
|
@@ -2298,10 +2340,10 @@ void send_discover (cpp)
|
2011-09-19 10:27:55 +00:00
|
|
|
client -> packet.secs = htons (65535);
|
|
|
|
client -> secs = client -> packet.secs;
|
|
|
|
|
|
|
|
- log_info ("DHCPDISCOVER on %s to %s port %d interval %ld",
|
|
|
|
+ log_info ("DHCPDISCOVER on %s to %s port %d interval %ld (xid=0x%x)",
|
|
|
|
client -> name ? client -> name : client -> interface -> name,
|
|
|
|
inet_ntoa (sockaddr_broadcast.sin_addr),
|
|
|
|
- ntohs (sockaddr_broadcast.sin_port), (long)(client -> interval));
|
2015-01-30 16:07:29 +00:00
|
|
|
+ ntohs (sockaddr_broadcast.sin_port), (long)(client -> interval), ntohl(client -> xid));
|
2011-09-19 10:27:55 +00:00
|
|
|
|
|
|
|
/* Send out a packet. */
|
2012-04-17 09:46:32 +00:00
|
|
|
result = send_packet(client->interface, NULL, &client->packet,
|
2013-12-20 15:13:52 +00:00
|
|
|
@@ -2570,10 +2612,10 @@ void send_request (cpp)
|
2011-09-19 10:27:55 +00:00
|
|
|
client -> packet.secs = htons (65535);
|
|
|
|
}
|
|
|
|
|
|
|
|
- log_info ("DHCPREQUEST on %s to %s port %d",
|
|
|
|
+ log_info ("DHCPREQUEST on %s to %s port %d (xid=0x%x)",
|
|
|
|
client -> name ? client -> name : client -> interface -> name,
|
|
|
|
inet_ntoa (destination.sin_addr),
|
|
|
|
- ntohs (destination.sin_port));
|
2015-01-30 16:07:29 +00:00
|
|
|
+ ntohs (destination.sin_port), ntohl(client -> xid));
|
2011-09-19 10:27:55 +00:00
|
|
|
|
|
|
|
if (destination.sin_addr.s_addr != INADDR_BROADCAST &&
|
2012-04-17 09:46:32 +00:00
|
|
|
fallback_interface) {
|
2013-12-20 15:13:52 +00:00
|
|
|
@@ -2613,10 +2655,10 @@ void send_decline (cpp)
|
2011-09-19 10:27:55 +00:00
|
|
|
|
|
|
|
int result;
|
|
|
|
|
|
|
|
- log_info ("DHCPDECLINE on %s to %s port %d",
|
|
|
|
+ log_info ("DHCPDECLINE on %s to %s port %d (xid=0x%x)",
|
2012-04-17 09:46:32 +00:00
|
|
|
client->name ? client->name : client->interface->name,
|
|
|
|
inet_ntoa(sockaddr_broadcast.sin_addr),
|
|
|
|
- ntohs(sockaddr_broadcast.sin_port));
|
2015-01-30 16:07:29 +00:00
|
|
|
+ ntohs(sockaddr_broadcast.sin_port), ntohl(client -> xid));
|
2011-09-19 10:27:55 +00:00
|
|
|
|
|
|
|
/* Send out a packet. */
|
2012-04-17 09:46:32 +00:00
|
|
|
result = send_packet(client->interface, NULL, &client->packet,
|
2013-12-20 15:13:52 +00:00
|
|
|
@@ -2659,10 +2701,10 @@ void send_release (cpp)
|
2011-09-19 10:27:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
- log_info ("DHCPRELEASE on %s to %s port %d",
|
|
|
|
+ log_info ("DHCPRELEASE on %s to %s port %d (xid=0x%x)",
|
|
|
|
client -> name ? client -> name : client -> interface -> name,
|
|
|
|
inet_ntoa (destination.sin_addr),
|
|
|
|
- ntohs (destination.sin_port));
|
2015-01-30 16:07:29 +00:00
|
|
|
+ ntohs (destination.sin_port), ntohl(client -> xid));
|
2011-09-19 10:27:55 +00:00
|
|
|
|
2012-04-17 09:46:32 +00:00
|
|
|
if (fallback_interface) {
|
|
|
|
result = send_packet(fallback_interface, NULL, &client->packet,
|