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