]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/patches/dhcp-4.2.2-improved-xid.patch
udev: remove /var/run mount from initskript.
[people/teissler/ipfire-2.x.git] / src / patches / dhcp-4.2.2-improved-xid.patch
CommitLineData
78ab9b04
MT
1diff -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) {
5 }
6 }
7
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
15+ */
16+ unsigned backup_seed = 0;
17+ for (ip = interfaces; ip; ip = ip -> next) {
18+ int junk;
19+ if ( ip -> hw_address.hlen <= sizeof seed )
20+ continue;
21+ memcpy (&junk,
22+ &ip -> hw_address.hbuf [ip -> hw_address.hlen -
23+ sizeof seed], sizeof seed);
24+ backup_seed = junk;
25+ }
26+
27+
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. */
34 seed = 0;
35+ int seed_flag = 0;
36 for (ip = interfaces; ip; ip = ip->next) {
37 int junk;
38+ if ( ip -> hw_address.hlen <= sizeof seed )
39+ continue;
40 memcpy(&junk,
41 &ip->hw_address.hbuf[ip->hw_address.hlen -
42 sizeof seed], sizeof seed);
43 seed += junk;
44+ seed_flag = 1;
45 }
46- srandom(seed + cur_time + (unsigned)getpid());
47+ if ( seed_flag == 0 ) {
48+ if ( backup_seed != 0 ) {
49+ seed = backup_seed;
50+ log_info ("xid: rand init seed (0x%x) built using all"
51+ " available interfaces",seed);
52+ }
53+ else {
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",
58+ seed);
59+ }
60+ /* we only use seed and no current time as a broadcast reply */
61+ /* will certainly be used by the hwaddrless interface */
62+ srandom(seed);
63+ }
64+ else
65+ srandom(seed + cur_time + (unsigned)getpid());
66
67 /* Setup specific Infiniband options */
68 for (ip = interfaces; ip; ip = ip->next) {
69@@ -1457,7 +1499,7 @@ void dhcpack (packet)
70 return;
71 }
72
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);
75
76 lease = packet_to_lease (packet, client);
77 if (!lease) {
78@@ -2174,7 +2216,7 @@ void dhcpnak (packet)
79 return;
80 }
81
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);
84
85 if (!client -> active) {
86 #if defined (DEBUG)
87@@ -2300,10 +2342,10 @@ void send_discover (cpp)
88 client -> packet.secs = htons (65535);
89 client -> secs = client -> packet.secs;
90
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);
97
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);
102 }
103
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);
110
111 if (destination.sin_addr.s_addr != INADDR_BROADCAST &&
112 fallback_interface)
113@@ -2618,10 +2660,10 @@ void send_decline (cpp)
114
115 int result;
116
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);
123
124 /* Send out a packet. */
125 result = send_packet (client -> interface, (struct packet *)0,
126@@ -2661,10 +2703,10 @@ void send_release (cpp)
127 return;
128 }
129
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);
136
137 if (fallback_interface)
138 result = send_packet (fallback_interface,