Update of /cvsroot/dhcp-agent/dhcp-agent
In directory usw-pr-cvs1:/tmp/cvs-serv20722
Modified Files:
dhcp-icmp-discovery.c dhcp-sysconf.c
Log Message:
Modify usage of icmp_rtt_discovery().
Index: dhcp-icmp-discovery.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-icmp-discovery.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** dhcp-icmp-discovery.c 6 Jun 2002 23:59:00 -0000 1.11
--- dhcp-icmp-discovery.c 15 Jun 2002 21:53:46 -0000 1.12
***************
*** 126,131 ****
* Here we're interested in how long it takes to
* get a response from a list of addresses.
! * We return a list of unsigned integers giving
! * us the average rtt time for each address.
*
*/
--- 126,132 ----
* Here we're interested in how long it takes to
* get a response from a list of addresses.
! * We return a list of alternating unsigned integers
! * and IP addresses, the uint giving the rtt for the
! * following address.
*
*/
***************
*** 158,170 ****
if(route_find(net, *host_addr, &dest_mac)) {
! error_message("icmp rtt discovery: could not find route for address for %s -- skipping", network_address_to_string_static(*host_addr));
continue;
}
- /* We have the MAC address here. Run
- * icmp_get_echo_latency to get latency. This also tells
- * us if the host is up. */
-
-
/* allocate latency array. */
latency = xmalloc(sizeof(int) * *(sends));
--- 159,166 ----
if(route_find(net, *host_addr, &dest_mac)) {
! error_message("icmp_rtt_discovery: could not find route for address for %s -- skipping", network_address_to_string_static(*host_addr));
continue;
}
/* allocate latency array. */
latency = xmalloc(sizeof(int) * *(sends));
***************
*** 176,180 ****
/* This part is a little tricky. We want to make sure
! * the host is actually up first. So if we got al -1's
* we know it wasn't. Then if it is up we set the -1
* latencies (indicating we never got an answer) to the
--- 172,176 ----
/* This part is a little tricky. We want to make sure
! * the host is actually up first. So if we got all -1's
* we know it wasn't. Then if it is up we set the -1
* latencies (indicating we never got an answer) to the
***************
*** 229,232 ****
--- 225,229 ----
xfree(latency); /* free our latency array. */
rtts = add_to_list(rtts, average_latency);
+ rtts = add_to_list(rtts, *host_addr);
}
Index: dhcp-sysconf.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-sysconf.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** dhcp-sysconf.c 12 Jun 2002 01:47:09 -0000 1.15
--- dhcp-sysconf.c 15 Jun 2002 21:53:46 -0000 1.16
***************
*** 107,111 ****
list_t *routers;
list_t *average_latencies, *list_ptr;
! int lowest_latency = -1;
int *latency;
--- 107,111 ----
list_t *routers;
list_t *average_latencies, *list_ptr;
! int lowest_latency;
int *latency;
***************
*** 116,119 ****
--- 116,125 ----
average_latencies = icmp_rtt_discovery(dc->rawnet, routers);
+ /* Even if all routers fail to respond to the ICMP echo query,
+ * we still want to use one of them.
+ * (See RFC 1812, section 4.3.3.6.) */
+ addr_val = average_latencies->next->data;
+ lowest_latency = average_latencies->data;
+
/* Now pick best router and use it as default. */
for(list_ptr = average_latencies;
***************
*** 122,137 ****
latency = list_ptr->data;
! if(lowest_latency < *latency) {
lowest_latency = *latency;
! addr_val = routers->data;
}
}
purge_list(average_latencies, NULL);
-
- if(addr_val == NULL) {
- error_message("sysconf_routers: could not add router as default route since none are responding!");
- return -1;
- }
r_entry.route_dst.addr_type = ADDR_TYPE_IP;
--- 128,138 ----
latency = list_ptr->data;
! if(*latency != -1 && *latency < lowest_latency) {
lowest_latency = *latency;
! addr_val = list_ptr->next->data;
}
}
purge_list(average_latencies, NULL);
r_entry.route_dst.addr_type = ADDR_TYPE_IP;
|