|
|
26a25c |
diff -up dhcp-4.3.4/client/dhclient.c.improved-xid dhcp-4.3.4/client/dhclient.c
|
|
|
26a25c |
--- dhcp-4.3.4/client/dhclient.c.improved-xid 2016-04-29 12:54:55.997102182 +0200
|
|
|
26a25c |
+++ dhcp-4.3.4/client/dhclient.c 2016-04-29 12:57:25.123139587 +0200
|
|
|
26a25c |
@@ -1045,6 +1045,26 @@ main(int argc, char **argv) {
|
|
|
26a25c |
}
|
|
|
26a25c |
}
|
|
|
26a25c |
|
|
|
26a25c |
+ /* We create a backup seed before rediscovering interfaces in order to
|
|
|
26a25c |
+ have a seed built using all of the available interfaces
|
|
|
26a25c |
+ It's interesting if required interfaces doesn't let us defined
|
|
|
26a25c |
+ a really unique seed due to a lack of valid HW addr later
|
|
|
26a25c |
+ (this is the case with DHCP over IB)
|
|
|
26a25c |
+ We only use the last device as using a sum could broke the
|
|
|
26a25c |
+ uniqueness of the seed among multiple nodes
|
|
|
26a25c |
+ */
|
|
|
26a25c |
+ unsigned backup_seed = 0;
|
|
|
26a25c |
+ for (ip = interfaces; ip; ip = ip -> next) {
|
|
|
26a25c |
+ int junk;
|
|
|
26a25c |
+ if ( ip -> hw_address.hlen <= sizeof seed )
|
|
|
26a25c |
+ continue;
|
|
|
26a25c |
+ memcpy (&junk,
|
|
|
26a25c |
+ &ip -> hw_address.hbuf [ip -> hw_address.hlen -
|
|
|
26a25c |
+ sizeof seed], sizeof seed);
|
|
|
26a25c |
+ backup_seed = junk;
|
|
|
26a25c |
+ }
|
|
|
26a25c |
+
|
|
|
26a25c |
+
|
|
|
26a25c |
/* At this point, all the interfaces that the script thinks
|
|
|
26a25c |
are relevant should be running, so now we once again call
|
|
|
26a25c |
discover_interfaces(), and this time ask it to actually set
|
|
|
26a25c |
@@ -1059,14 +1079,36 @@ main(int argc, char **argv) {
|
|
|
26a25c |
Not much entropy, but we're booting, so we're not likely to
|
|
|
26a25c |
find anything better. */
|
|
|
26a25c |
seed = 0;
|
|
|
26a25c |
+ int seed_flag = 0;
|
|
|
26a25c |
for (ip = interfaces; ip; ip = ip->next) {
|
|
|
26a25c |
int junk;
|
|
|
26a25c |
+ if ( ip -> hw_address.hlen <= sizeof seed )
|
|
|
26a25c |
+ continue;
|
|
|
26a25c |
memcpy(&junk,
|
|
|
26a25c |
&ip->hw_address.hbuf[ip->hw_address.hlen -
|
|
|
26a25c |
sizeof seed], sizeof seed);
|
|
|
26a25c |
seed += junk;
|
|
|
26a25c |
+ seed_flag = 1;
|
|
|
26a25c |
}
|
|
|
26a25c |
- srandom(seed + cur_time + (unsigned)getpid());
|
|
|
26a25c |
+ if ( seed_flag == 0 ) {
|
|
|
26a25c |
+ if ( backup_seed != 0 ) {
|
|
|
26a25c |
+ seed = backup_seed;
|
|
|
26a25c |
+ log_info ("xid: rand init seed (0x%x) built using all"
|
|
|
26a25c |
+ " available interfaces",seed);
|
|
|
26a25c |
+ }
|
|
|
26a25c |
+ else {
|
|
|
26a25c |
+ seed = cur_time^((unsigned) gethostid()) ;
|
|
|
26a25c |
+ log_info ("xid: warning: no netdev with useable HWADDR found"
|
|
|
26a25c |
+ " for seed's uniqueness enforcement");
|
|
|
26a25c |
+ log_info ("xid: rand init seed (0x%x) built using gethostid",
|
|
|
26a25c |
+ seed);
|
|
|
26a25c |
+ }
|
|
|
26a25c |
+ /* we only use seed and no current time as a broadcast reply */
|
|
|
26a25c |
+ /* will certainly be used by the hwaddrless interface */
|
|
|
26a25c |
+ srandom(seed + ((unsigned)(cur_tv.tv_usec * 1000000)) + (unsigned)getpid());
|
|
|
26a25c |
+ }
|
|
|
26a25c |
+ else
|
|
|
26a25c |
+ srandom(seed + ((unsigned)(cur_tv.tv_usec * 1000000)) + (unsigned)getpid());
|
|
|
26a25c |
|
|
|
26a25c |
/* Setup specific Infiniband options */
|
|
|
26a25c |
for (ip = interfaces; ip; ip = ip->next) {
|
|
|
26a25c |
@@ -1633,7 +1675,7 @@ void dhcpack (packet)
|
|
|
26a25c |
return;
|
|
|
26a25c |
}
|
|
|
26a25c |
|
|
|
26a25c |
- log_info ("DHCPACK from %s", piaddr (packet -> client_addr));
|
|
|
26a25c |
+ log_info ("DHCPACK from %s (xid=0x%x)", piaddr (packet -> client_addr), ntohl(client -> xid));
|
|
|
26a25c |
|
|
|
26a25c |
lease = packet_to_lease (packet, client);
|
|
|
26a25c |
if (!lease) {
|
|
|
26a25c |
@@ -2541,7 +2583,7 @@ void dhcpnak (packet)
|
|
|
26a25c |
return;
|
|
|
26a25c |
}
|
|
|
26a25c |
|
|
|
26a25c |
- log_info ("DHCPNAK from %s", piaddr (packet -> client_addr));
|
|
|
26a25c |
+ log_info ("DHCPNAK from %s (xid=0x%x)", piaddr (packet -> client_addr), ntohl(client -> xid));
|
|
|
26a25c |
|
|
|
26a25c |
if (!client -> active) {
|
|
|
26a25c |
#if defined (DEBUG)
|
|
|
26a25c |
@@ -2674,10 +2716,10 @@ void send_discover (cpp)
|
|
|
26a25c |
(long)(client -> interval));
|
|
|
26a25c |
} else
|
|
|
26a25c |
#endif
|
|
|
26a25c |
- log_info ("DHCPDISCOVER on %s to %s port %d interval %ld",
|
|
|
26a25c |
+ log_info ("DHCPDISCOVER on %s to %s port %d interval %ld (xid=0x%x)",
|
|
|
26a25c |
client -> name ? client -> name : client -> interface -> name,
|
|
|
26a25c |
inet_ntoa (sockaddr_broadcast.sin_addr),
|
|
|
26a25c |
- ntohs (sockaddr_broadcast.sin_port), (long)(client -> interval));
|
|
|
26a25c |
+ ntohs (sockaddr_broadcast.sin_port), (long)(client -> interval), ntohl(client -> xid));
|
|
|
26a25c |
|
|
|
26a25c |
/* Send out a packet. */
|
|
|
26a25c |
#if defined(DHCPv6) && defined(DHCP4o6)
|
|
|
26a25c |
@@ -2962,10 +3004,10 @@ void send_request (cpp)
|
|
|
26a25c |
log_info ("DHCPREQUEST");
|
|
|
26a25c |
} else
|
|
|
26a25c |
#endif
|
|
|
26a25c |
- log_info ("DHCPREQUEST on %s to %s port %d",
|
|
|
26a25c |
+ log_info ("DHCPREQUEST on %s to %s port %d (xid=0x%x)",
|
|
|
26a25c |
client -> name ? client -> name : client -> interface -> name,
|
|
|
26a25c |
inet_ntoa (destination.sin_addr),
|
|
|
26a25c |
- ntohs (destination.sin_port));
|
|
|
26a25c |
+ ntohs (destination.sin_port), ntohl(client -> xid));
|
|
|
26a25c |
|
|
|
26a25c |
#if defined(DHCPv6) && defined(DHCP4o6)
|
|
|
26a25c |
if (dhcpv4_over_dhcpv6) {
|
|
|
26a25c |
@@ -3022,10 +3064,10 @@ void send_decline (cpp)
|
|
|
26a25c |
log_info ("DHCPDECLINE");
|
|
|
26a25c |
} else
|
|
|
26a25c |
#endif
|
|
|
26a25c |
- log_info ("DHCPDECLINE on %s to %s port %d",
|
|
|
26a25c |
+ log_info ("DHCPDECLINE on %s to %s port %d (xid=0x%x)",
|
|
|
26a25c |
client->name ? client->name : client->interface->name,
|
|
|
26a25c |
inet_ntoa(sockaddr_broadcast.sin_addr),
|
|
|
26a25c |
- ntohs(sockaddr_broadcast.sin_port));
|
|
|
26a25c |
+ ntohs(sockaddr_broadcast.sin_port), ntohl(client -> xid));
|
|
|
26a25c |
|
|
|
26a25c |
/* Send out a packet. */
|
|
|
26a25c |
#if defined(DHCPv6) && defined(DHCP4o6)
|
|
|
26a25c |
@@ -3084,10 +3126,10 @@ void send_release (cpp)
|
|
|
26a25c |
log_info ("DHCPRELEASE");
|
|
|
26a25c |
} else
|
|
|
26a25c |
#endif
|
|
|
26a25c |
- log_info ("DHCPRELEASE on %s to %s port %d",
|
|
|
26a25c |
+ log_info ("DHCPRELEASE on %s to %s port %d (xid=0x%x)",
|
|
|
26a25c |
client -> name ? client -> name : client -> interface -> name,
|
|
|
26a25c |
inet_ntoa (destination.sin_addr),
|
|
|
26a25c |
- ntohs (destination.sin_port));
|
|
|
26a25c |
+ ntohs (destination.sin_port), ntohl(client -> xid));
|
|
|
26a25c |
|
|
|
26a25c |
#if defined(DHCPv6) && defined(DHCP4o6)
|
|
|
26a25c |
if (dhcpv4_over_dhcpv6) {
|